summaryrefslogtreecommitdiff
path: root/src/template
Commit message (Collapse)AuthorAgeFilesLines
* wasm2c: harmonize bulk mem ops re: i32/i64 (#2506) + parametrize memchecks ↵HEADmainKeith Winstein2024-12-173-128/+183
| | | | | | | | | | | | | | | | | per-memory (#2507) The PR updates the bulk memory operations (memory.fill, memory.copy, table.fill, etc.) to support 64-bit addresses and counts. Previously these functions only took u32's, even with memory64 enabled. (#2506) This PR also allows "software-bounds-checked" memories and "guard-page-checked" memories to coexist in the same module. It creates two versions of every memory operation: an unrestricted version (that works with any memory) and a _default32 version (for memories with default page size and i32 indexing). (#2507) #2506 and #2507 have been squashed together to avoid a performance regression. This is a stepping stone to supporting custom-page-sizes (which will need to be software-bounds-checked) (#2508).
* wasm2c: Cleanup of handling of WASM_RT_USE_SEGUE macroShravan Narayan2024-10-141-27/+7
|
* wasm2c: Add segue option to make exclusive use of the segment registerShravan Narayan2024-09-181-0/+8
|
* wasm2c: Segue support for CPUs without wrgsbase instructionsShravan Narayan2024-09-061-6/+22
|
* wasm2c: Segue optimization for modules with a single unshared memory (#2395)Shravan Narayan2024-06-261-16/+64
|
* Add macOS arm64 support and CI testing (#2406)Soni L2024-03-261-0/+2
|
* wasm2c: Implement big-endian SIMD (#2340)Soni L2024-02-061-2/+220
|
* Remove unnecessary restriction (#2378)Soni L2024-01-311-21/+18
| | | | Thanks to MEM_ADDR we don't need to think about big-endian vs little-endian for any scalar(!) operations.
* wasm2c: atomic and shared mem operations using c11Shravan Narayan2024-01-301-200/+196
|
* wasm2c: Cleanup/separate code for heap and stack signal handlersShravan Narayan2023-12-141-1/+1
|
* wasm2c: Improve address abstraction for BE support (#2328)Soni L2023-11-143-83/+77
|
* wasm2c: implement the tail-call proposal (#2272)Keith Winstein2023-10-241-4/+28
|
* [wasm2c] Use wasm_rt_memcpy everywhere in generated code (#2292)Sam Clegg2023-09-091-15/+15
|
* Share reading/validation code between elem exprs & other const exprs (#2288)Keith Winstein2023-09-061-5/+18
| | | | | | This continues the work from #1783 and reduces special handling of elem exprs, by treating them the same as other const expressions (init expressions).
* wasm2c: add link to clang bug on mips force read constraintShravan Narayan2023-07-301-0/+1
|
* wasm2c: ensure force read constraints compile for clang on mipsShravan Narayan2023-07-303-31/+39
|
* wasm2c: fix bug in windows atomic load macroShravan Narayan2023-06-191-4/+4
|
* wasm2c: partial support for atomic memory opsShravan Narayan2023-05-171-0/+238
|
* wasm2c: include simd128.h and wasm-rt-exceptions.h where necessary (#2236)Keith Winstein2023-05-123-137/+117
| | | Co-authored-by: Shravan Narayan <shravanrn@gmail.com>
* wasm2c: Enable exceptions and simd according to command line flagsShravan Narayan2023-05-021-0/+4
|
* alloca() lives in <stdlib.h> on OpenBSD too (fixes #2216) (#2217)Landry Breuil2023-04-261-1/+1
| | | per http://man.openbsd.org/alloca.3
* wasm2c: Use malloc.h instead of alloca.h for mingwShravan Narayan2023-04-241-1/+3
|
* wasm2c.includes.c: replace alloca.h with stdlib.h on FreeBSD (#2212)Petr Penzin2023-04-221-0/+2
|
* wasm2c: Separate the macros for allocation and bounds checks strategiesShravan Narayan2023-04-121-1/+1
|
* wasm2c: multiple .c outputs (#2146)Yuhan Deng2023-04-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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: cap blank lines between sections (NFC) (#2148)Keith Winstein2023-02-251-1/+0
|
* wasm2c: add SIMD support (#2119)Willy R. Vasquez2023-01-292-0/+130
| | | 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.
* Make wasm2c output UBSAN-clean (and run w2c CI w/ UBSAN) (#2080)Keith Winstein2023-01-281-2/+8
| | | | | | 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.
* wasm2c: serialize types at wasm2c-time (#2120)Keith Winstein2023-01-252-11/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+11
| | | | | | | 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: allow externref initialization when externref type is not void* (#2062)Keith Winstein2022-11-151-4/+2
|
* Update testsuite (#2054)Sam Clegg2022-11-131-0/+17
| | | | | | | | | | | | | | | As well as the testsuite update there are two notable changes that come with it here. These can both be split out an landed first if it makes sense. 1. wasm2c now supports element sections containing externref. Currently only the null reference is supported. 2. element segments no longer use funcref as the default element type but instead, unless explicitly included in the binary, the element type defaults to the type of the table in which the segment is active. Fixes: #1612 #2022
* wasm2c: Avoid unnecessary heap allocation in wasm_rt_register_func_type. NFC ↵Sam Clegg2022-11-082-2/+1
| | | | (#2047)
* wasm2c: Fix 8gb model, signals, memory reserve/commits, stack depth on windowsShravan Narayan2022-11-051-5/+5
| | | | | | | | 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
* wasm2c: implement the reference-types proposal (#1887)Keith Winstein2022-10-031-24/+62
| | | | Restores current versions of all non-SIMD tests in the core testsuite and multi-memory and exception-handling proposals.
* wasm2c templated code: simplify table_copy to use memmove (#2012)Keith Winstein2022-10-021-17/+2
|
* wasm2c: implement the bulk memory operations proposal (#1877)Keith Winstein2022-09-212-0/+82
| | | Co-authored-by: Yuhan Deng <yhdeng@stanford.edu>
* wasm2c: support for module instancing (#1814)Yuhan Deng2022-09-162-0/+3
| | | Co-authored-by: Angela Montemayor <amontema@cs.stanford.edu>
* wasm2c: implement the exception-handling proposal (#1930)Keith Winstein2022-07-142-1/+7
| | | | | (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-0/+130
| | | | | | | | | 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: simplify handling of templated code (#1940)Keith Winstein2022-07-114-0/+343
Store templated wasm2c code as .h/.c; build templates on demand