summaryrefslogtreecommitdiff
path: root/eval_intern.h
diff options
context:
space:
mode:
authorYuta Saito <[email protected]>2023-11-12 07:18:01 +0900
committerYuta Saito <[email protected]>2023-11-13 19:17:16 +0900
commit50a5b76decf21f833da6c838e7acc7f991e47e00 ()
treea3c6aa29871902e44238ea244c7648a88f2ae2cb /eval_intern.h
parentf1b95095d6635567cc5820b3eb40d9618faa73ed (diff)
[wasm] allocate Asyncify setjmp buffer in heap
`rb_jmpbuf_t` type is considerably large due to inline-allocated Asyncify buffer, and it leads to stack overflow even with small number of C-method call frames. This commit allocates the Asyncify buffer used by `rb_wasm_setjmp` in heap to mitigate the issue. This introduces a new type `rb_vm_tag_jmpbuf_t` to abstract the representation of a jump buffer, and init/deinit hook points to manage lifetime of the buffer. These changes are effectively NFC for non-wasm platforms.
-rw-r--r--eval_intern.h6
1 files changed, 4 insertions, 2 deletions
@@ -110,9 +110,11 @@ extern int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval
_tag.tag = Qundef; \
_tag.prev = _ec->tag; \
_tag.lock_rec = rb_ec_vm_lock_rec(_ec); \
#define EC_POP_TAG() \
_ec->tag = _tag.prev; \
} while (0)
#define EC_TMPPOP_TAG() \
@@ -161,7 +163,7 @@ rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st)
{
RUBY_ASSERT(st != TAG_NONE);
ec->tag->state = st;
- ruby_longjmp(ec->tag->buf, 1);
}
/*
@@ -169,7 +171,7 @@ rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st)
[ISO/IEC 9899:1999] 7.13.1.1
*/
#define EC_EXEC_TAG() \
- (UNLIKELY(ruby_setjmp(_tag.buf)) ? rb_ec_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0))
#define EC_JUMP_TAG(ec, st) rb_ec_tag_jump(ec, st)