summaryrefslogtreecommitdiff
path: root/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'wasm')
-rw-r--r--wasm/setjmp.c8
-rw-r--r--wasm/setjmp.h3
2 files changed, 10 insertions, 1 deletions
diff --git a/wasm/setjmp.c b/wasm/setjmp.c
index ebbf8949c1..32ede68c09 100644
--- a/wasm/setjmp.c
+++ b/wasm/setjmp.c
@@ -143,9 +143,11 @@ rb_wasm_try_catch_init(struct rb_wasm_try_catch *try_catch,
try_catch->try_f = try_f;
try_catch->catch_f = catch_f;
try_catch->context = context;
+ try_catch->stack_pointer = NULL;
}
// NOTE: This function is not processed by Asyncify due to a call of asyncify_stop_rewind
+__attribute__((noinline))
void
rb_wasm_try_catch_loop_run(struct rb_wasm_try_catch *try_catch, rb_wasm_jmp_buf *target)
{
@@ -154,6 +156,10 @@ rb_wasm_try_catch_loop_run(struct rb_wasm_try_catch *try_catch, rb_wasm_jmp_buf
target->state = JMP_BUF_STATE_CAPTURED;
+ if (try_catch->stack_pointer == NULL) {
+ try_catch->stack_pointer = rb_wasm_get_stack_pointer();
+ }
+
switch ((enum try_catch_phase)try_catch->state) {
case TRY_CATCH_PHASE_MAIN:
// may unwind
@@ -175,6 +181,8 @@ rb_wasm_try_catch_loop_run(struct rb_wasm_try_catch *try_catch, rb_wasm_jmp_buf
// stop unwinding
// (but call stop_rewind to update the asyncify state to "normal" from "unwind")
asyncify_stop_rewind();
+ // reset the stack pointer to what it was before the most recent call to try_f or catch_f
+ rb_wasm_set_stack_pointer(try_catch->stack_pointer);
// clear the active jmpbuf because it's already stopped
_rb_wasm_active_jmpbuf = NULL;
// reset jmpbuf state to be able to unwind again
diff --git a/wasm/setjmp.h b/wasm/setjmp.h
index cc14df33be..82cfff1d00 100644
--- a/wasm/setjmp.h
+++ b/wasm/setjmp.h
@@ -5,7 +5,7 @@
#include <stdbool.h>
#ifndef WASM_SETJMP_STACK_BUFFER_SIZE
-# define WASM_SETJMP_STACK_BUFFER_SIZE 6144
+# define WASM_SETJMP_STACK_BUFFER_SIZE 8192
#endif
struct __rb_wasm_asyncify_jmp_buf {
@@ -65,6 +65,7 @@ struct rb_wasm_try_catch {
rb_wasm_try_catch_func_t try_f;
rb_wasm_try_catch_func_t catch_f;
void *context;
+ void *stack_pointer;
int state;
};