From 8b9002d572b38283d48138e879f2b341cbd30e8a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 27 Feb 2024 14:20:01 -0800 Subject: [PATCH 1/2] Add some comments regarding __c_longjmp. NFC --- system/lib/compiler-rt/emscripten_setjmp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/lib/compiler-rt/emscripten_setjmp.c b/system/lib/compiler-rt/emscripten_setjmp.c index 9c4afc3620d81..b13f34d20c4a6 100644 --- a/system/lib/compiler-rt/emscripten_setjmp.c +++ b/system/lib/compiler-rt/emscripten_setjmp.c @@ -81,13 +81,17 @@ struct __WasmLongjmpArgs { thread_local struct __WasmLongjmpArgs __wasm_longjmp_args; +// llvm uses `1` for the __c_longjmp tag. +// See llvm/CodeGen/WasmEHFuncInfo.h +#define C_LONGJMP 1 + // Wasm EH allows us to throw and catch multiple values, but that requires // multivalue support in the toolchain, whch is not reliable at the time. // TODO Consider switching to throwing two values at the same time later. void __wasm_longjmp(void *env, int val) { __wasm_longjmp_args.env = env; __wasm_longjmp_args.val = val; - __builtin_wasm_throw(1, &__wasm_longjmp_args); + __builtin_wasm_throw(C_LONGJMP, &__wasm_longjmp_args); } #endif From 422d7d4d69eedaa3aecde69352211c0fd03b89f5 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 27 Feb 2024 14:29:23 -0800 Subject: [PATCH 2/2] Update system/lib/compiler-rt/emscripten_setjmp.c Co-authored-by: Heejin Ahn --- system/lib/compiler-rt/emscripten_setjmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/lib/compiler-rt/emscripten_setjmp.c b/system/lib/compiler-rt/emscripten_setjmp.c index b13f34d20c4a6..8dd944b010b52 100644 --- a/system/lib/compiler-rt/emscripten_setjmp.c +++ b/system/lib/compiler-rt/emscripten_setjmp.c @@ -82,7 +82,7 @@ struct __WasmLongjmpArgs { thread_local struct __WasmLongjmpArgs __wasm_longjmp_args; // llvm uses `1` for the __c_longjmp tag. -// See llvm/CodeGen/WasmEHFuncInfo.h +// See https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h #define C_LONGJMP 1 // Wasm EH allows us to throw and catch multiple values, but that requires