extensions
Steven Massey 4 years ago
commit f3c078fa94

@ -1,4 +1,4 @@
<img align="right" width="30%" src="/extra/screenshot-android.png">
<img align="right" width="30%" src="/extra/screenshot-ios.png">
# <img src="/extra/wasm-symbol.svg" width="32" height="32" /> Wasm3
@ -65,10 +65,11 @@ Wasm3 started as a research project and remains so by many means. Evaluating the
## Further Resources
[Demos](./docs/Demos.md)
[Build and Development instructions](./docs/Development.md)
[Testing & Fuzzing](./docs/Testing.md)
[Performance](./docs/Performance.md)
[Interpreter Architecture](./docs/Interpreter.md)
[Interpreter Architecture](./docs/Interpreter.md)
### License
This project is released under The MIT License (MIT)

@ -0,0 +1,4 @@
# Wasm3 demos
- **Basic WiFi/Gpio access, updating `wasm` file over-the-air.** [demo](https://twitter.com/alvaroviebrantz/status/1221618910803513344), [github](https://github.com/alvarowolfx/wasm-arduino-wifi) [ESP32 / Web]
- **RGB lamp animation using WebAssembly.** [demo](https://twitter.com/wasm3_engine/status/1222835097289752576), [github](https://github.com/vshymanskyy/Wasm3_RGB_Lamp) [nRF51 / nRF52 / ESP8266 / ESP32]

@ -27,7 +27,7 @@ Native (GCC 7.4.0, 64-bit) 19144.862795 11.8x
```log
fib(40)
----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
# Intel i5-8250U x64 (1.6-3.4GHz)
Native C implementation 0.23s
Linux 3.83s
@ -54,48 +54,31 @@ OpenWRT 3m 20s
## Wasm3 on MCUs
```log
fib32(24) fib64(24) comments
----------------------------------------------------------------------------------------------------
Maix (K210) rv64imafc @ 400MHz 77ms 77ms
ESP8266 LX106 @ 160MHz 308ms 321ms TCO failed, stack used: 9024
ESP32 LX6 @ 240MHz 297ms 314ms TCO failed, stack used: 10600
ESP32-s2 (beta) LX6 @ 240MHz 297ms 314ms TCO failed
Particle Photon Arm M3 @ 120MHz 536ms 562ms
MXChip AZ3166 Arm M4 @ 100MHz ms ms
WM W600 Arm M3 @ 80MHz 698ms 782ms TCO enabled, stack used: 1325
WM W600 Arm M3 @ 80MHz 826ms 914ms TCO disabled, stack used: 8109
Arduino DUE (SAM3X8E) Arm M3 @ 84MHz 754ms 813ms
BleNano2 (nRF52) Arm M4 @ 64MHz 1.19s 1.29s
Arduino MKR1000 Arm M0+ @ 48MHz 1.93s 2.06s TCO failed
TinyBLE (nRF51) Arm M0 @ 16MHz 5.69s 5.93s TCO failed
BluePill Arm M3 @ 72MHz 7.62s 8.20s
HiFive1 (FE310) rv32imac @ 320MHz 9.10s 9.82s <- something wrong here?
ATmega1284 avr @ 16MHz 12.99s --- TCO failed
Fomu rv32i @ 12MHz 25.20s 26.10s
```
## Wasm3 vs other WebAssembly engines
This is how different engines run the same function on Intel i5-8250U (1.6-3.4GHz):
```log
fib(40)
----------------------------------------------------------------------------------------------------
WAVM jit 0.62s
wasmer jit 0.70s
V8 (Node.js) jit 0.74s
SpiderMonkey jit 0.93s ▲ faster
Wasm3 interp 3.83s
iwasm interp 25.70s ▼ slower
wac interp 37.11s
fib(24) comments
-----------------------------------------------------------------------------------------
Maix (K210) rv64imafc @ 400MHz 77ms
ESP8266 LX106 @ 160MHz 308ms TCO failed, stack used: 9024
ESP32 LX6 @ 240MHz 297ms TCO failed, stack used: 10600
ESP32-s2 (beta) LX6 @ 240MHz 297ms TCO failed
Particle Photon Arm M3 @ 120MHz 536ms
MXChip AZ3166 Arm M4 @ 100MHz ms
WM W600 Arm M3 @ 80MHz 698ms TCO enabled, stack used: 1325
WM W600 Arm M3 @ 80MHz 826ms TCO disabled, stack used: 8109
Arduino DUE (SAM3X8E) Arm M3 @ 84MHz 754ms
BleNano2 (nRF52) Arm M4 @ 64MHz 1.19s
Arduino MKR1000 Arm M0+ @ 48MHz 1.93s TCO failed
TinyBLE (nRF51) Arm M0 @ 16MHz 5.69s TCO failed
BluePill Arm M3 @ 72MHz 7.62s
HiFive1 (FE310) rv32imac @ 320MHz 9.10s <- something wrong here?
ATmega1284 avr @ 16MHz 12.99s TCO failed
Fomu rv32i @ 12MHz 25.20s
```
## Wasm3 vs other languages
```log
fib(40)
----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
LuaJIT jit 1.15s
Node v10.15 jit 2.97s ▲ faster
Wasm3 interp 3.83s

@ -1,5 +1,7 @@
## Build for ESP-IDF, with minimal WASI support
**Note:** Currently, to run this example you need a PSRAM-enabled ESP32 module (this might be improved in future).
Download and install ESP-IDF v4.0
```sh

@ -165,7 +165,7 @@ static const char * const c_waCompactTypes [] = { "0", "i", "I", "f", "F", "v"
#define m3Alloc(OPTR, STRUCT, NUM) m3Malloc ((void **) OPTR, sizeof (STRUCT) * (NUM))
#define m3RellocArray(PTR, STRUCT, NEW, OLD) m3Realloc ((PTR), sizeof (STRUCT) * (NEW), sizeof (STRUCT) * (OLD))
#define m3ReallocArray(PTR, STRUCT, NEW, OLD) m3Realloc ((PTR), sizeof (STRUCT) * (NEW), sizeof (STRUCT) * (OLD))
#define m3Free(P) { m3Free_impl((void*)(P)); P = NULL; }
# if d_m3VerboseLogs

@ -175,6 +175,8 @@ void ReleaseRuntime (IM3Runtime i_runtime)
FreeCompilationPatches (& i_runtime->compilation);
m3Free (i_runtime->stack);
m3Free (i_runtime->memory.mallocated);
}
@ -422,7 +424,7 @@ _ (ReadLEB_u32 (& numElements, & bytes, end));
if (endElement > offset) // TODO: check this, endElement depends on offset
{
io_module->table0 = (IM3Function*)m3RellocArray (io_module->table0, IM3Function, endElement, io_module->table0Size);
io_module->table0 = (IM3Function*)m3ReallocArray (io_module->table0, IM3Function, endElement, io_module->table0Size);
if (io_module->table0)
{

@ -8,6 +8,8 @@
#include "m3_env.h"
static void Module_FreeFunctions(IM3Module i_module);
void m3_FreeModule (IM3Module i_module)
{
if (i_module)
@ -15,10 +17,13 @@ void m3_FreeModule (IM3Module i_module)
m3log (module, "freeing module: %s (funcs: %d; segments: %d)",
i_module->name, i_module->numFunctions, i_module->numDataSegments);
Module_FreeFunctions (i_module);
m3Free (i_module->functions);
m3Free (i_module->imports);
m3Free (i_module->funcTypes);
m3Free (i_module->dataSegments);
m3Free (i_module->table0);
// TODO: free importinfo
m3Free (i_module->globals);
@ -27,13 +32,27 @@ void m3_FreeModule (IM3Module i_module)
}
}
static void Module_FreeFunctions(IM3Module i_module)
{
for (u32 i = 0; i < i_module->numFunctions; ++i)
{
IM3Function func = &i_module->functions[i];
m3Free (func->constants);
if (func->name != func->import.fieldUtf8)
{
m3Free (func->name);
}
FreeImportInfo (&func->import);
}
}
M3Result Module_AddGlobal (IM3Module io_module, IM3Global * o_global, u8 i_type, bool i_mutable, bool i_isImported)
{
M3Result result = m3Err_none;
u32 index = io_module->numGlobals++;
io_module->globals = (M3Global *) m3RellocArray (io_module->globals, M3Global, io_module->numGlobals, index);
io_module->globals = (M3Global *) m3ReallocArray (io_module->globals, M3Global, io_module->numGlobals, index);
if (io_module->globals)
{
@ -57,7 +76,7 @@ M3Result Module_AddFunction (IM3Module io_module, u32 i_typeIndex, IM3ImportIn
M3Result result = m3Err_none;
u32 index = io_module->numFunctions++;
io_module->functions = (M3Function*)m3RellocArray (io_module->functions, M3Function, io_module->numFunctions, index);
io_module->functions = (M3Function*)m3ReallocArray (io_module->functions, M3Function, io_module->numFunctions, index);
if (io_module->functions)
{

Loading…
Cancel
Save