| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
|
|
| |
- Passing "-lm" into the prereq isn't the correct way add the flag. This correctly adds it to the command.
- The "rot13" example incorrectly assumed that the "rot13.h" file would be generated by the time that "main.c"
was being compiled, however there is no rule supporting this and it would fail.
I've also added "rot13.h" to the clean rule.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Also adds an RLBox-like CI test where the embedder takes responsibility for signal handling
Co-authored-by: wrv <wrv@utexas.edu>
|
| |
|
| |
|
|
|
|
|
| |
The runtime installs an alternate stack to handle SIGSEGV
from stack exhaustion. Make this variable thread-local
and refactor implementation that touches it.
|
|
|
|
| |
wasm_rt_funcref_null_value and wasm_rt_externref_null_value are changed
to preprocessor macros for C and C++ compatibility
|
| |
|
| |
|
|
|
|
|
|
| |
This continues the work from #1783 and reduces special handling of elem
exprs, by treating them the same as other const expressions (init
expressions).
|
| |
|
| |
|
| |
|
| |
|
|
|
| |
Co-authored-by: Shravan Narayan <shravanrn@gmail.com>
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
growth failures
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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).
|
| |
|
|
|
|
|
|
| |
Add kLocalSymbolPrefix which is used for names of params, locals and
stack vars. This allows c-writer to not assign global_sym_map_ to
local_sym_map_ for writing each individual function, since local names
can't duplicate global names.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
| |
We had been running the GitHub UBSAN wasm2c tests with -fsanitize=undefined
but without -fno-sanitize-recover, meaning some of the spec tests
were printing UBSAN error messages but still returning 0, so we
weren't seeing the test failures.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
(#2133)
|
| |
|
|
|
|
|
|
|
| |
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 lets exception tags be pre-assigned, instead of
making the runtime keep an incrementing counter.
|
| |
|
| |
|