diff options
Diffstat (limited to 'src/prebuilt/wasm2c_source_declarations.cc')
-rw-r--r-- | src/prebuilt/wasm2c_source_declarations.cc | 54 |
1 files changed, 7 insertions, 47 deletions
diff --git a/src/prebuilt/wasm2c_source_declarations.cc b/src/prebuilt/wasm2c_source_declarations.cc index 86c07ded..87529c40 100644 --- a/src/prebuilt/wasm2c_source_declarations.cc +++ b/src/prebuilt/wasm2c_source_declarations.cc @@ -40,62 +40,22 @@ R"w2c_template(#define MEM_ADDR(mem, addr, n) &(mem)->data[addr] R"w2c_template(#endif )w2c_template" R"w2c_template( -#ifndef WASM_RT_USE_SEGUE +// We can only use Segue for this module if it uses a single unshared imported )w2c_template" -R"w2c_template(// Memory functions can use the segue optimization if allowed. The segue +R"w2c_template(// or exported memory )w2c_template" -R"w2c_template(// optimization uses x86 segments to point to a linear memory. We use this +R"w2c_template(#if WASM_RT_USE_SEGUE && IS_SINGLE_UNSHARED_MEMORY )w2c_template" -R"w2c_template(// optimization when: -)w2c_template" -R"w2c_template(// -)w2c_template" -R"w2c_template(// (1) Segue is allowed using WASM_RT_ALLOW_SEGUE -)w2c_template" -R"w2c_template(// (2) on x86_64 without WABT_BIG_ENDIAN enabled -)w2c_template" -R"w2c_template(// (3) the Wasm module uses a single unshared imported or exported memory -)w2c_template" -R"w2c_template(// (4) the compiler supports: intrinsics for (rd|wr)gsbase, "address namespaces" -)w2c_template" -R"w2c_template(// for accessing pointers, and supports memcpy on pointers with custom -)w2c_template" -R"w2c_template(// "address namespaces". GCC does not support the memcpy requirement, so -)w2c_template" -R"w2c_template(// this leaves only clang for now. -)w2c_template" -R"w2c_template(// (5) The OS provides a way to query if (rd|wr)gsbase is allowed by the kernel -)w2c_template" -R"w2c_template(// or the implementation has to use a syscall for this. -)w2c_template" -R"w2c_template(// (6) The OS doesn't replace the segment register on context switch which -)w2c_template" -R"w2c_template(// eliminates windows for now -)w2c_template" -R"w2c_template(// -)w2c_template" -R"w2c_template(// While more OS can be supported in the future, we only support linux for now -)w2c_template" -R"w2c_template(#if WASM_RT_ALLOW_SEGUE && !WABT_BIG_ENDIAN && \ -)w2c_template" -R"w2c_template( (defined(__x86_64__) || defined(_M_X64)) && IS_SINGLE_UNSHARED_MEMORY && \ -)w2c_template" -R"w2c_template( __clang__ && __has_builtin(__builtin_ia32_wrgsbase64) && \ -)w2c_template" -R"w2c_template( !defined(_WIN32) && defined(__linux__) -)w2c_template" -R"w2c_template(#define WASM_RT_USE_SEGUE 1 +R"w2c_template(#define WASM_RT_USE_SEGUE_FOR_THIS_MODULE 1 )w2c_template" R"w2c_template(#else )w2c_template" -R"w2c_template(#define WASM_RT_USE_SEGUE 0 -)w2c_template" -R"w2c_template(#endif +R"w2c_template(#define WASM_RT_USE_SEGUE_FOR_THIS_MODULE 0 )w2c_template" R"w2c_template(#endif )w2c_template" R"w2c_template( -#if WASM_RT_USE_SEGUE +#if WASM_RT_USE_SEGUE_FOR_THIS_MODULE )w2c_template" R"w2c_template(// POSIX uses FS for TLS, GS is free )w2c_template" @@ -234,7 +194,7 @@ R"w2c_template( TRAP(OOB); R"w2c_template(#endif )w2c_template" R"w2c_template( -#if WASM_RT_USE_SEGUE && WASM_RT_SANITY_CHECKS +#if WASM_RT_USE_SEGUE_FOR_THIS_MODULE && WASM_RT_SANITY_CHECKS )w2c_template" R"w2c_template(#include <stdio.h> )w2c_template" |