| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
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: 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: 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.
|
|
|
| |
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.
|
| |
|
|
|
|
| |
This allows overriding flags like -O2 by appending -O0 from the env var.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
I mistakenly broke the wasm2c test runner in #2086. I guess we need
tests for our test runner..
|
|
|
|
|
|
|
| |
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`.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
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.
|
|
|
| |
Fixes #2039
|
|
|
|
| |
Restores current versions of all non-SIMD tests in the core testsuite
and multi-memory and exception-handling proposals.
|
|
|
| |
Co-authored-by: Yuhan Deng <yhdeng@stanford.edu>
|
|
|
| |
Co-authored-by: Angela Montemayor <amontema@cs.stanford.edu>
|
|
|
|
|
| |
(The imports.txt and exports.txt tests require multi-table and
are disabled until reference types is supported.)
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
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.)
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
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.
|
|
|
| |
Split out from #1843
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Use stricter compiler settings and fix the resulting warnings.
This is precursor to landing windows compiler support for wasm2c.
See #1843.
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
(#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.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
| |
Fixes #1180 and #1181.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|