summaryrefslogtreecommitdiff
path: root/wasm2c/wasm-rt-impl.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* [wasm2c] Add spec tests; fix update-spec-tests.py (#891)Ben Smith2018-08-141-0/+1
| | | | `update-spec-tests.py` now will update the tests in the `test/wasm2c/spec` directory.
* [wasm2c] Fix bad realloc in wasm-rt-impl (#869)Ben Smith2018-06-251-1/+1
| | | Fixes issue #868.
* Separate out wasm-rt.h and wasm-rt-impl.{c,h} (#813)Ben Smith2018-03-201-0/+118
This makes it easier to use outside of running wasm2c spec tests.