[wasm] Allocate asyncify buffer on heap to save stack usage
This commit is contained in:
parent
ab7bb38aca
commit
8945143464
Notes:
git
2023-05-15 18:53:27 +00:00
@ -84,6 +84,7 @@ _rb_wasm_setjmp_internal(rb_wasm_jmp_buf *env)
|
||||
RB_WASM_DEBUG_LOG(" JMP_BUF_STATE_INITIALIZED");
|
||||
env->state = JMP_BUF_STATE_CAPTURING;
|
||||
env->payload = 0;
|
||||
env->longjmp_buf_ptr = NULL;
|
||||
_rb_wasm_active_jmpbuf = env;
|
||||
async_buf_init(&env->setjmp_buf);
|
||||
asyncify_start_unwind(&env->setjmp_buf);
|
||||
@ -100,6 +101,7 @@ _rb_wasm_setjmp_internal(rb_wasm_jmp_buf *env)
|
||||
asyncify_stop_rewind();
|
||||
RB_WASM_DEBUG_LOG(" JMP_BUF_STATE_RETURNING");
|
||||
env->state = JMP_BUF_STATE_CAPTURED;
|
||||
free(env->longjmp_buf_ptr);
|
||||
_rb_wasm_active_jmpbuf = NULL;
|
||||
return env->payload;
|
||||
}
|
||||
@ -117,9 +119,10 @@ _rb_wasm_longjmp(rb_wasm_jmp_buf* env, int value)
|
||||
assert(value != 0);
|
||||
env->state = JMP_BUF_STATE_RETURNING;
|
||||
env->payload = value;
|
||||
env->longjmp_buf_ptr = malloc(sizeof(struct __rb_wasm_asyncify_jmp_buf));
|
||||
_rb_wasm_active_jmpbuf = env;
|
||||
async_buf_init(&env->longjmp_buf);
|
||||
asyncify_start_unwind(&env->longjmp_buf);
|
||||
async_buf_init(env->longjmp_buf_ptr);
|
||||
asyncify_start_unwind(env->longjmp_buf_ptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ typedef struct {
|
||||
struct __rb_wasm_asyncify_jmp_buf setjmp_buf;
|
||||
// Internal Asyncify buffer space used while unwinding from longjmp
|
||||
// but never used for rewinding.
|
||||
struct __rb_wasm_asyncify_jmp_buf longjmp_buf;
|
||||
struct __rb_wasm_asyncify_jmp_buf *longjmp_buf_ptr;
|
||||
// Used to save top address of Asyncify stack `setjmp_buf`, which is
|
||||
// overwritten during first rewind.
|
||||
void *dst_buf_top;
|
||||
|
Loading…
x
Reference in New Issue
Block a user