summaryrefslogtreecommitdiff
path: root/test/run-spec-wasm2c.py
Commit message (Collapse)AuthorAgeFilesLines
* Suppress pass-failed warnings (#2404)Soni L2024-03-251-0/+3
|
* wasm2c: Implement big-endian SIMD (#2340)Soni L2024-02-061-1/+1
|
* wasm2c: atomic and shared mem operations using c11Shravan Narayan2024-01-301-12/+21
|
* Make run-spec-wasm2c platform-consistent (#2335)Soni L2023-11-281-6/+3
|
* wasm2c: Fix f64 harness (#2331)Soni L2023-11-201-1/+1
|
* wasm2c: Fix test harness UB with SIMD (#2327)Soni L2023-11-121-2/+5
|
* wasm2c: implement the tail-call proposal (#2272)Keith Winstein2023-10-241-0/+3
|
* [wasm2c] Add '-Wno-array-bounds' when building wasm2c output (#2293)Sam Clegg2023-09-081-0/+1
| | | | | | We are seeing some (spurious?) warning from gcc 12.2. I've been seeing them locally, but they started to show up in CI as part of #2292.
* wasm2c: partial support for atomic memory opsShravan Narayan2023-05-171-0/+3
|
* wasm2c: Fix typo in testing harness (#2234)Shravan Narayan2023-05-111-1/+1
|
* wasm2c: Enable exceptions and simd according to command line flagsShravan Narayan2023-05-021-3/+5
|
* wasm2c: multiple .c outputs (#2146)Yuhan Deng2023-04-051-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * wasm2c: multiple .c outputs This enables wasm2c to have multiple .c outputs, which allows parallel compilation of the wasm2c outputs. This is useful when the input WASM module is big. wasm2c takes the number of .c outputs as an argument to `--num-outputs` (defaulting to 1). If the number is equal to 1, the .c output does not change except for two new macro declarations and the ordering of declarations and definitions. If greater than 1, wasm2c outputs change in the following ways: 1) wasm2c outputs a [module-name]-impl.h that includes any module-wide declarations, including: * content of `WriteSourceTop()` * function type declarations * tag types * tag declarations * function declarations * data segments and elem segments declarations Any static declaration become extern in this header. 2) wasm2c outputs [module-name]_i.c for i = [0, ..., number of .c outputs - 1). Any module-wide material is written to [module-name]_0.c, including: * function types, tags, data segments, elem segments * imports and exports * module initialization, instantiation and free 3) For each function implementation, wasm2c assigns it to one output .c file by sorting the function names and partitioning into roughly equal buckets. Alternately, the caller can supply its own assignment function (helpful if it wants the assignments to be more stable in the face of function insertion or deletion).
* wasm2c: implement the extended const expressions proposal (#2162)Keith Winstein2023-03-081-0/+3
|
* wasm2c: prettify/change name mangling (#2142)Keith Winstein2023-02-231-11/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * wasm2c: prettify/change name-mangling This refactors the wasm2c name-mangling in two big ways: 1) Removing the `Z_` prefix and trying to make the names somewhat ergonomic/pretty. Previously the `factorial` export from a `fac` module looked like this: ``` u32 Z_facZ_factorial(Z_fac_instance_t*, u32); ``` After this commit, it looks like this: ``` u32 w2c_fac_factorial(w2c_fac*, u32); ``` Symbols defined by wasm2c itself (including instantiate, free, get_func_type and the imported memory limits) are now prefixed with `wasm2c_` to avoid conflicting with names defined by the module. 2) Using globally unique (module-prefixed) names for functions, types, segments, and tags, even though they are currently static (internal-linkage) symbols in the .c output. This is preparation for a future "multiple .c output" option where these symbols will need to have external linkage.
* wasm2c: add SIMD support (#2119)Willy R. Vasquez2023-01-291-8/+56
| | | This change incorporates [simd-everywhere](https://github.com/simd-everywhere/simde) into the wasm2c output, which maps wasm SIMD C intrinsics to any supported target architecture.
* Rename before_args to after_argsKeith Winstein2023-01-251-1/+1
|
* wasm2c: move WASM2C_CFLAGS to end of compiler command lineKeith Winstein2023-01-251-2/+2
| | | | This allows overriding flags like -O2 by appending -O0 from the env var.
* wasm2c: serialize types at wasm2c-time (#2120)Keith Winstein2023-01-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | This makes wasm2c serialize each function type, rather than registering function types at module-initialization time. The serialized function type is the SHA-256 of the mangled param and result types (with a space between params and results). At runtime in call_indirect, a known (immediate) function type is compared against the function type stored in a funcref structure. For call_indirects to functions local to the module, or for any call_indirect when the toolchain merges string constants across compilation units (generally, GCC and clang), this can be done by comparing the pointers to each function type. Otherwise, the actual 32-byte values are compared. The function type IDs can be looked up at runtime with `Z_[modname]_get_func_type`, which matches the API from `wasm_rt_register_func_type`. A new `callback` example demos this. wasm2c does the SHA-256 either by linking against libcrypto or, if not available or if requested via `cmake -DUSE_INTERNAL_SHA256=ON`, by using a vendored (header-only) PicoSHA2. There is no runtime dependency on SHA-256 in the wasm2c runtime or generated modules. This eliminates the last of the per-module state, so this commit also removes the [modname]_init_module() function and the s_module_initialized bool.
* Fix wasm2c test runner (#2131)Sam Clegg2023-01-181-1/+1
| | | | I mistakenly broke the wasm2c test runner in #2086. I guess we need tests for our test runner..
* wasm2c: Initial implementation of memory64 (#2086)Sam Clegg2023-01-121-6/+15
| | | | | | | Note, there are still some issues here that needs to be resolved, mostly about memory sandboxing (bounds checking). Since this is still experimental I've also added a `--experimental` flag to wasm2c that is required in addition to passing `--enable-memory64`.
* run-spec-wasm2c.py: split `run_spec_tests` function if it's too long (#2077)Keith Winstein2022-11-281-6/+21
| | | | | | This is intended to improve GCC's long compile times for some of the extremely long SIMD tests. On a recent laptop running Ubuntu 22.04 and GCC 11.3, this change reduces the time for the simd_f32x4_pmin_pmax.wast test from 16 minutes to about 70 seconds.
* Honor CC environment variable in test/run-spec-wasm2c.py (#2052)Sam Clegg2022-11-111-0/+1
| | | | | I've been having some issues with the recent version of gcc on my system and being able to run `CC=/usr/bin/clang ./test/run-tests.py` has proved useful.
* BinaryReaderIR: fix mis-binding of tags with debug name (#2040)Keith Winstein2022-11-041-1/+3
| | | Fixes #2039
* wasm2c: implement the reference-types proposal (#1887)Keith Winstein2022-10-031-3/+9
| | | | Restores current versions of all non-SIMD tests in the core testsuite and multi-memory and exception-handling proposals.
* wasm2c: implement the bulk memory operations proposal (#1877)Keith Winstein2022-09-211-0/+4
| | | Co-authored-by: Yuhan Deng <yhdeng@stanford.edu>
* wasm2c: support for module instancing (#1814)Yuhan Deng2022-09-161-12/+47
| | | Co-authored-by: Angela Montemayor <amontema@cs.stanford.edu>
* wasm2c: implement the exception-handling proposal (#1930)Keith Winstein2022-07-141-0/+5
| | | | | (The imports.txt and exports.txt tests require multi-table and are disabled until reference types is supported.)
* wasm2c: run tests with -O2 on non-Windows (#1939)Keith Winstein2022-07-111-1/+8
| | | | | | | | | Enable optimization when compiling the wasm2c output on non-Windows platforms (effectively GCC and clang). This required: - Preventing load instructions from being optimized away if their value is unused (using inline assembly with an input operand and empty code). This is necessary to force an OOB trap on platforms that use mprotect and the signal handler to detect OOB. - Disabling tail-call optimization in the compiler, to make sure that infinite recursion traps. (This required bumping the version of macOS in GitHub Actions to get a new-enough AppleClang. We should revert this back to 'macos-latest' as soon as that becomes the default.) - Using NaN-quieting versions of a bunch of FP ops that were previously only used on Windows, and adding floor/ceil and promotion/demotion. - Using the '-frounding-math' and '-fsignaling-nans' compiler flags to tell GCC and clang not to fold certain FP ops (e.g. subtracting zero, multiplying by 1). Fixes #1925.
* run-spec-wasm2c.py: fix failure to free module #0 (NFC) (#1904)Keith Winstein2022-04-201-1/+1
|
* wasm2c: export free() function to free module state (#1901)Keith Winstein2022-04-141-0/+5
| | | | | | This will be required by module instancing and bulk memory ops to avoid a memory leak detected by asan. Update README.md to reflect changes, including the `fac` walkthrough.
* wasm2c: Always use a module prefix and set one by default (#1897)Sam Clegg2022-04-141-14/+16
| | | | | | | | | | | | The module prefix is no longer optional and is now set by default to the name of the module as given in the name section, or taken from the name of the input file. A new `-n/--module-name` command line flag can also be used to override. The prefix used by the generated code is now fixed at wasm2c time which makes the output code easier to read and also avoid the symbol pasting in the C pre-processor which makes the source hard to understand. For example, it makes symbols hard to `grep` for.
* Remove signature mangling from wasm2c output (#1896)Sam Clegg2022-04-141-14/+1
| | | | | | | | | | | This effectively means that we no longer support imports that are overloaded by signature only. This is not something that we need to support in order to support the core wasm spec. This feature is available in the JS embedding but there is no good reason (AFAICT) to support it in wasm2c, and this simplifies the generated code. Fixes #1858
* wasm2c: use signal handler to detect stack exhaustion (#1875)Keith Winstein2022-04-041-0/+1
| | | | | | On MacOS, merge OOB and exhaustion traps. (Linux distinguishes these as SEGV_ACCERR vs. SEGV_MAPERR in the si_code, but MacOS seems to deliver a SEGV_ACCERR for both.) Add wasm_rt_init() and wasm_rt_free() functions to wasm-rt.h that the embedder must call to set up and clean up the runtime state. (If the embedder doesn't call these, OOB and exhaustion will result in an uncaught segfault.)
* Add windows implementation of wasm2c runtime (#1843)Sam Clegg2022-03-091-14/+48
| | | | | | | All tests are now passing with cl.exe under x64. With x86 there are some test failure that I believe relate the use of the x87 registers to pass floating point numbers. I suggest we look into fixing those as a followup. Split out from #1833
* wasm2c: run older versions of some spec tests (#1853)Keith Winstein2022-03-081-1/+5
| | | | | | Test wasm2c against versions of the spec tests from before bulk-memory and reference-types were merged (as of commit a8bcbaf in the testsuite repo). These should be replaced with the current versions once wasm2c supports bulk-memory and reference-types.
* Build and run wasm2c-generated code under sanitizers in CI. NFC (#1856)Sam Clegg2022-03-081-0/+2
| | | Split out from #1843
* Avoid passing signed char to islpha family of function on windows (#1847)Sam Clegg2022-03-031-7/+9
| | | | | | | | | | | | | On windows these functions assert when passed negative numbers. This change is the first step in getting wasm2c running on windows. For now the C code can be generated on windows but the generated code cannot is not yet MSVC compatible. Also, update run-spec-wasm2c.py so that it run on windows, although we are still skipping all the wasm2c tests by default on windows (for now). Also, honor the --no-compile options which is how I managed to test this change locally.
* Fix compiler warnings in wasm2c output (#1844)Sam Clegg2022-03-021-3/+8
| | | | | Use stricter compiler settings and fix the resulting warnings. This is precursor to landing windows compiler support for wasm2c. See #1843.
* wasm2c: run multi-memory tests (#1834)Keith Winstein2022-02-171-1/+6
| | | | | | | | | | | This runs and passes 5 of the 9 multi-memory tests (although one of them, binary.wast, is a nop for wasm2c itself). The other 4 tests would require reference types or bulk memory: imports.wast load.wast memory-multi.wast store.wast
* Update testsuite (#1738)Sam Clegg2021-10-181-3/+8
| | | | | | | | | | | bulk-memory-operations and reference-types were completely removed from the upstream testsuite becuase there were merged into the upstream spec: https://github.com/WebAssembly/testsuite/pull/44 In order to land this I had to disable several spec tests under wasm2c because it lacks support for mutli-table and reference types. I filed #1737 to track this.
* Avoid race between tests introduced in #1731 (#1733)Sam Clegg2021-10-141-5/+5
| | | | | | | | The `wasm-rt-impl.o` in particular needs to be compiled with a different input and output directory. Without this change each test tries to build this object in (the same) place. I'm not sure how this passed the tests as it fails pretty reliably on my machine.
* Avoid changing directory in run-spec-wasm2c.py and honor --print-cmd. NFC ↵Sam Clegg2021-10-141-15/+16
| | | | | | | (#1731) With this change once can run `test/run-spec-wasm2c.py -p` and any failing commands can be re-run directly from the root without needing to figure out in which directory to run the command.
* Enable reference types by default (#1729)Sam Clegg2021-10-131-0/+1
| | | | | | | | | This features was finished earlier this year: https://github.com/WebAssembly/proposals/blob/master/finished-proposals.md One thing to note is that the version of the spec tests we currently have in third_party/testsuite doesn't have ref types merged yet so this change disables ref types when running some of those tests. This can be removed in a followup when we update the testsuite.
* Enable bulk memory by default (#1728)Sam Clegg2021-10-131-0/+1
| | | | | | | | | | | This features was finished earlier this year: https://github.com/WebAssembly/proposals/blob/master/finished-proposals.md One thing to note is that the version of the spec tests we currently have in third_party/testsuite doesn't have bulk memory merged yet so this change disables bulk memory when running some of those tests. This will be removed in a followup when we update the testsuite. Fixes: #1717
* wasm2c: Support multi-value (#1686)Soni L2021-07-141-1/+23
|
* Remove support for python2 (#1321)Sam Clegg2020-01-311-17/+4
|
* Update testsuite (#1275)Sam Clegg2020-01-091-33/+35
| | | | | | | | | | | | | | | | | The two primary changes involved are: 1. Removal of `assert_return_canonical_nan`/`arithetic nan` in favor of special `nan:canonical`/`nan:arithmetic` constants that can only be used in test expectations. See: https://github.com/WebAssembly/spec/pull/1104 2. New trapping behaviour for bulk memory operations. Range checks are now performed up front for opterations such as memory.fill and memory.copy. See: https://github.com/webassembly/bulk-memory-operations/issues/111 And: https://github.com/webassembly/bulk-memory-operations/pull/123 The old behaviour is still kept around to support table.fill which is defined in reference-types proposal and has yet to be updated.
* run-tests.py works properly with python3 (#1285)Ben Smith2020-01-081-7/+8
| | | Fixes #1180 and #1181.
* Switch python indentation from 2-space to 4-space (#1145)Sam Clegg2019-08-151-349/+349
| | | | | | | | pep8 specifies 4 space indentation. The use of 2 spaces is, I believe, a historical anomaly where certain large organizations such as google chose 2 over 4 and have yet to make the switch. For a project like wabt with little python code I think the cost of switching is small enough to justify the churn.
* Run flake8 on the whole repository (#1144)Guanzhong Chen2019-08-151-4/+5
|