diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7c1d220..dacf5af 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -215,6 +215,22 @@ jobs: run: | cd platforms/android ./gradlew build + + build-cosmopolitan: + name: cosmopolitan + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v2 + - name: Build αcτµαlly pδrταblε εxεcµταblε + run: | + cd platforms/cosmopolitan + ./build.sh + - name: Test WebAssembly spec + run: | + cd test + python3 run-spec-test.py --exec "../platforms/cosmopolitan/wasm3.com --repl" build-cross-qemu: runs-on: ubuntu-latest diff --git a/platforms/cosmopolitan/.gitignore b/platforms/cosmopolitan/.gitignore index f920527..f250355 100644 --- a/platforms/cosmopolitan/.gitignore +++ b/platforms/cosmopolitan/.gitignore @@ -1 +1,2 @@ cosmopolitan/ +wasm3.com diff --git a/platforms/cosmopolitan/build.sh b/platforms/cosmopolitan/build.sh index 5933d0c..eebdc72 100755 --- a/platforms/cosmopolitan/build.sh +++ b/platforms/cosmopolitan/build.sh @@ -3,7 +3,7 @@ COSMOPOLITAN_URL=https://justine.lol/cosmopolitan/cosmopolitan.zip SOURCE_DIR=../../source -EXTRA_FLAGS= #-Dd_m3HasWASI +EXTRA_FLAGS="-Dd_m3PreferStaticAlloc" #-Dd_m3HasWASI STD=./cosmopolitan/std diff --git a/source/m3_env.c b/source/m3_env.c index 2251a82..34d4adb 100644 --- a/source/m3_env.c +++ b/source/m3_env.c @@ -376,7 +376,11 @@ M3Result EvaluateExpression (IM3Module i_module, void * o_expressed, u8 i_type M3Result result = m3Err_none; // create a temporary runtime context +#if defined(d_m3PreferStaticAlloc) + static M3Runtime runtime; +#else M3Runtime runtime; +#endif M3_INIT (runtime); runtime.environment = i_module->runtime->environment; diff --git a/source/m3_parse.c b/source/m3_parse.c index 79fb219..eceb18c 100644 --- a/source/m3_parse.c +++ b/source/m3_parse.c @@ -264,8 +264,13 @@ M3Result Parse_InitExpr (M3Module * io_module, bytes_t * io_bytes, cbytes_t i_ M3Result result = m3Err_none; // this doesn't generate code pages. just walks the wasm bytecode to find the end - IM3Runtime rt; - M3Compilation compilation = { rt= NULL, io_module, * io_bytes, i_end }; + +#if defined(d_m3PreferStaticAlloc) + static M3Compilation compilation; +#else + M3Compilation compilation; +#endif + compilation = (M3Compilation){ NULL, io_module, * io_bytes, i_end }; result = Compile_BlockStatements (& compilation);