summaryrefslogtreecommitdiff
path: root/wasm2c/wasm-rt-impl.c
Commit message (Collapse)AuthorAgeFilesLines
* [wasm2c] Fix alternate stack deallocation (#2466)Christian Nieves2024-09-201-0/+1
| | | | | | | | This makes `wasm_rt_init()` properly reentrant. By setting `g_alt_stack = NULL`, we allow execution to continue beyond [wasm-rt-impl.c L171 ](https://github.com/WebAssembly/wabt/blob/main/wasm2c/wasm-rt-impl.c#L171) in `os_allocate_and_install_altstack`. Applies to debug builds only due to `assert`.
* wasm2c: Add segue option to make exclusive use of the segment registerShravan Narayan2024-09-181-0/+4
|
* wasm2c: Segue support for CPUs without wrgsbase instructionsShravan Narayan2024-09-061-0/+39
|
* wasm2c: move table ops to an include fileShravan Narayan2024-01-311-37/+9
|
* wasm2c: atomic and shared mem operations using c11Shravan Narayan2024-01-301-176/+0
|
* Fix emscripten build warning and add missing export (#2367)Changqing Jing2024-01-191-0/+2
|
* wasm2c: Cleanup/separate code for heap and stack signal handlersShravan Narayan2023-12-141-53/+54
|
* wasm2c runtime: fix mis-nesting of def'n of os_has_altstack_installed (#2346)Keith Winstein2023-12-051-11/+14
| | | | | Also adds an RLBox-like CI test where the embedder takes responsibility for signal handling Co-authored-by: wrv <wrv@utexas.edu>
* wasm2c runtime: clean up some error messages (NFC) (#2345)Keith Winstein2023-12-031-7/+3
|
* w2c runtime: add per-thread init/free API (#2332)Keith Winstein2023-12-041-6/+14
|
* wasm2c runtime: refactor handling of alternate stack (NFC) (#2338)Keith Winstein2023-11-281-12/+81
| | | | | The runtime installs an alternate stack to handle SIGSEGV from stack exhaustion. Make this variable thread-local and refactor implementation that touches it.
* wasm2c: implement the tail-call proposal (#2272)Keith Winstein2023-10-241-1/+1
|
* wasm2c: partial support for atomic memory opsShravan Narayan2023-05-171-0/+2
|
* wasm2c: Enable exceptions and simd according to command line flagsShravan Narayan2023-05-021-52/+1
|
* wasm2c: reduce the max exceptions sizeShravan Narayan2023-05-011-1/+1
|
* wasm-rt-impl: reset g_signal_handler_installed in wasm_rt_free (#2209)Keith Winstein2023-04-211-0/+1
|
* wasm2c: Misc docs and inline comment fixesShravan Narayan2023-04-131-2/+1
|
* wasm2c: Add optional WASM_RT_GROW_FAILED_HANDLER to be notified of memory ↵Shravan Narayan2023-04-121-1/+15
| | | | growth failures
* wasm2c: Separate the macros for allocation and bounds checks strategiesShravan Narayan2023-04-121-23/+44
|
* wasm2c: add signature for the wasm2c trap handler if definedShravan Narayan2023-04-101-0/+4
|
* wasm2c: add SIMD support (#2119)Willy R. Vasquez2023-01-291-0/+2
| | | 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.
* wasm2c: serialize types at wasm2c-time (#2120)Keith Winstein2023-01-251-72/+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.
* wasm2c: Initial implementation of memory64 (#2086)Sam Clegg2023-01-121-12/+17
| | | | | | | 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`.
* wasm2c rt: mark temp storage for traps/exceptions as thread_local (#2126)Keith Winstein2023-01-121-7/+7
|
* wasm2c: eliminate wasm_rt_register_tag() (#2122)Keith Winstein2023-01-111-10/+5
| | | | This lets exception tags be pre-assigned, instead of making the runtime keep an incrementing counter.
* wasm2c: harden set/longjmp to check for uninit jmp_bufShravan Narayan2023-01-031-3/+3
|
* wasm2c: Avoid unnecessary heap allocation in wasm_rt_register_func_type. NFC ↵Sam Clegg2022-11-081-8/+20
| | | | (#2047)
* wasm2c: cleanup function type indexes when calling wasm_rt_freeShravan Narayan2022-11-071-0/+9
|
* wasm2c: add hook to allow a custom trap handlerShravan Narayan2022-11-071-0/+6
| | | | In production use cases, unwinding the stack before reporting an error throws away valuable information such as the stack trace. This hook allows the host to implement an alternate error recovery/reporting mechanism
* wasm2c: Uninstall sighandler in os_cleanup_signal_handler (#2043)Sam Clegg2022-11-071-0/+13
|
* wasm2c: Fix 8gb model, signals, memory reserve/commits, stack depth on windowsShravan Narayan2022-11-051-54/+100
| | | | | | | | Correct handling of Wasm's 8gb model on Windows - Uses the Windows ExceptionHandler to track access violations (segfaults) - Fix Windows memory to reserve, but not commit memory up front - Correct handling of return values in os_mmap functions - Decouple stack depth handling and heap bounds checking
* Allow use of guard pages without requiring a signal handlerShravan Narayan2022-11-021-6/+6
|
* wasm2c: implement the reference-types proposal (#1887)Keith Winstein2022-10-031-12/+39
| | | | Restores current versions of all non-SIMD tests in the core testsuite and multi-memory and exception-handling proposals.
* wasm2c: support for module instancing (#1814)Yuhan Deng2022-09-161-0/+8
| | | Co-authored-by: Angela Montemayor <amontema@cs.stanford.edu>
* Update declaration of wasm_rt_get/set_unwind_target. NFC (#1967)Sam Clegg2022-08-231-2/+2
| | | This matches how they are declared in the header file.
* wasm2c: implement the exception-handling proposal (#1930)Keith Winstein2022-07-141-0/+53
| | | | | (The imports.txt and exports.txt tests require multi-table and are disabled until reference types is supported.)
* wasm2c: Use static for wasm-rt globals. NFC (#1945)Sam Clegg2022-07-131-8/+9
| | | | | And use the `wasm_rt_` prefix for the one non-static global. While reviewing #1930 I noticed these globals could/should be static.
* wasm2c: run tests with -O2 on non-Windows (#1939)Keith Winstein2022-07-111-68/+0
| | | | | | | | | 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.
* wasm2c: export free() function to free module state (#1901)Keith Winstein2022-04-141-0/+21
| | | | | | 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: use signal handler to detect stack exhaustion (#1875)Keith Winstein2022-04-041-11/+49
| | | | | | 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-6/+134
| | | | | | | 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: Add wasm_rt_strerror to covert trap code to string (#1848)Sam Clegg2022-03-031-0/+22
|
* Port to big-endian platforms (s390x but others can be trivially added) (#1557)Soni L2020-12-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial attempt at s390x port * Second attempt at s390x port * Fix big-endian memory fill * Fix more memory location calculations * Improve SIMD * Implement big-endian memory grow * Fill relocation with 0x00, as per spec * Make wasm2c endianness work * Fix shuffle * Fix load endianness in wasm2c * Refactor into shared code * Clean up SwapBytesSized * Clean up MemcpyEndianAware * Clean up * "Fix" opcodecnt basic test
* Fix warning. NFC. (#1580)Sam Clegg2020-12-031-1/+1
| | | We really should enable Werror on CI..
* Fix warning on comparison of void* to integer. fixes #1472 (#1473)Alon Zakai2020-06-221-1/+1
|
* [wasm2c] Implement trap handler for linux/macos (#1442)Ben Smith2020-06-041-4/+56
| | | | | | | * Test whether this works for macOS * Use __builtin_memcpy (fixes bug on macOS) * Use #if instead of #ifdef (so 0 and 1 values work properly) * Add `WASM_RT_SETJMP` and `WASM_RT_LONGJMP` macros
* [wasm2c] Fix realloc check in wasm_rt_grow_memory (#1171)Ben Smith2019-09-251-1/+1
| | | See issue #1159.
* [wasm2c] Return -1 if wasm_rt_grow_memory fails (#1148)Ben Smith2019-08-291-2/+10
|
* Add missing string.h include to wasm-rt-impl.c (#1010)Matt McCormick2019-02-101-0/+1
| | | | | | | | | | | | | | | Addresses: gcc -I/tmp/wabt/wasm2c -O3 /tmp/wabt/wasm2c/wasm-rt-impl.c -o wasm-rt-impl.o /tmp/wabt/wasm2c/wasm-rt-impl.c: In function ‘wasm_rt_grow_memory’: /tmp/wabt/wasm2c/wasm-rt-impl.c:111:3: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration] memset(memory->data + old_pages * PAGE_SIZE, 0, delta * PAGE_SIZE); ^~~~~~ /tmp/wabt/wasm2c/wasm-rt-impl.c:111:3: warning: incompatible implicit declaration of built-in function ‘memset’ /tmp/wabt/wasm2c/wasm-rt-impl.c:111:3: note: include ‘<string.h>’ or provide a declaration of ‘memset’ /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start': (.text+0x20): undefined reference to `main' with gcc (Debian 6.3.0-18+deb9u1).
* Update testsuite (#942)Ben Smith2018-11-051-0/+2
| | | | Also fix bug when parsing elem/data segment; the table/memory index is stored as an LEB128, not a U8.