diff options
author | Keith Winstein <keithw@cs.stanford.edu> | 2023-01-12 11:47:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-12 11:47:19 -0800 |
commit | ce775b0b55a29665956b021074d9eec9d2fa870a (patch) | |
tree | 799e369b16e2449d10e53acfeee2b9b8670174e5 /wasm2c | |
parent | 72a94375ff06126fd33e8cd44ec2527a9e84c923 (diff) | |
download | wabt-ce775b0b55a29665956b021074d9eec9d2fa870a.tar.gz wabt-ce775b0b55a29665956b021074d9eec9d2fa870a.tar.bz2 wabt-ce775b0b55a29665956b021074d9eec9d2fa870a.zip |
wasm2c rt: mark temp storage for traps/exceptions as thread_local (#2126)
Diffstat (limited to 'wasm2c')
-rw-r--r-- | wasm2c/wasm-rt-impl.c | 14 | ||||
-rw-r--r-- | wasm2c/wasm-rt-impl.h | 4 | ||||
-rw-r--r-- | wasm2c/wasm-rt.h | 8 |
3 files changed, 16 insertions, 10 deletions
diff --git a/wasm2c/wasm-rt-impl.c b/wasm2c/wasm-rt-impl.c index 2581f144..9349be68 100644 --- a/wasm2c/wasm-rt-impl.c +++ b/wasm2c/wasm-rt-impl.c @@ -62,20 +62,20 @@ static char* g_alt_stack = 0; #endif #if WASM_RT_USE_STACK_DEPTH_COUNT -uint32_t wasm_rt_call_stack_depth; -uint32_t wasm_rt_saved_call_stack_depth; +WASM_RT_THREAD_LOCAL uint32_t wasm_rt_call_stack_depth; +WASM_RT_THREAD_LOCAL uint32_t wasm_rt_saved_call_stack_depth; #endif static FuncType* g_func_types; static uint32_t g_func_type_count; -wasm_rt_jmp_buf g_wasm_rt_jmp_buf; +WASM_RT_THREAD_LOCAL wasm_rt_jmp_buf g_wasm_rt_jmp_buf; -static wasm_rt_tag_t g_active_exception_tag; -static uint8_t g_active_exception[MAX_EXCEPTION_SIZE]; -static uint32_t g_active_exception_size; +static WASM_RT_THREAD_LOCAL wasm_rt_tag_t g_active_exception_tag; +static WASM_RT_THREAD_LOCAL uint8_t g_active_exception[MAX_EXCEPTION_SIZE]; +static WASM_RT_THREAD_LOCAL uint32_t g_active_exception_size; -static wasm_rt_jmp_buf* g_unwind_target; +static WASM_RT_THREAD_LOCAL wasm_rt_jmp_buf* g_unwind_target; void wasm_rt_trap(wasm_rt_trap_t code) { assert(code != WASM_RT_TRAP_NONE); diff --git a/wasm2c/wasm-rt-impl.h b/wasm2c/wasm-rt-impl.h index 5e6b55a0..a05a9f8c 100644 --- a/wasm2c/wasm-rt-impl.h +++ b/wasm2c/wasm-rt-impl.h @@ -28,7 +28,7 @@ extern "C" { #endif /** A setjmp buffer used for handling traps. */ -extern wasm_rt_jmp_buf g_wasm_rt_jmp_buf; +extern WASM_RT_THREAD_LOCAL wasm_rt_jmp_buf g_wasm_rt_jmp_buf; #if WASM_RT_MEMCHECK_SIGNAL_HANDLER && !defined(_WIN32) #define WASM_RT_LONGJMP_UNCHECKED(buf, val) siglongjmp(buf, val) @@ -45,7 +45,7 @@ extern wasm_rt_jmp_buf g_wasm_rt_jmp_buf; #if WASM_RT_USE_STACK_DEPTH_COUNT /** Saved call stack depth that will be restored in case a trap occurs. */ -extern uint32_t wasm_rt_saved_call_stack_depth; +extern WASM_RT_THREAD_LOCAL uint32_t wasm_rt_saved_call_stack_depth; #define WASM_RT_SAVE_STACK_DEPTH() \ wasm_rt_saved_call_stack_depth = wasm_rt_call_stack_depth #else diff --git a/wasm2c/wasm-rt.h b/wasm2c/wasm-rt.h index 852e3872..07c8fd5f 100644 --- a/wasm2c/wasm-rt.h +++ b/wasm2c/wasm-rt.h @@ -51,6 +51,12 @@ extern "C" { #define wasm_rt_unreachable abort #endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) +#define WASM_RT_THREAD_LOCAL _Thread_local +#else +#define WASM_RT_THREAD_LOCAL +#endif + /** * Enable memory checking via a signal handler via the following definition: * @@ -116,7 +122,7 @@ extern "C" { #endif /** Current call stack depth. */ -extern uint32_t wasm_rt_call_stack_depth; +extern WASM_RT_THREAD_LOCAL uint32_t wasm_rt_call_stack_depth; #endif |