diff options
author | Yuta Saito <[email protected]> | 2022-01-15 23:59:37 +0900 |
---|---|---|
committer | Yuta Saito <[email protected]> | 2022-01-19 11:19:06 +0900 |
commit | bf1c4d254beb0e01fac1d9e6cb805de8ec6260eb () | |
tree | 5669f945f0f3780c2dde64b13182cb40e3ee146e | |
parent | e7fb1fa0414a0c6e43796052c877f317e8e09846 (diff) |
[wasm] gc.c: scan wasm locals and c stack to mark living objects
WebAssembly has function local infinite registers and stack values, but there is no way to scan the values in a call stack for now. This implementation uses Asyncify to spilling out wasm locals into linear memory.
Notes: Merged: https://.com/ruby/ruby/pull/5407
-rw-r--r-- | gc.c | 61 |
1 files changed, 40 insertions, 21 deletions
@@ -30,6 +30,7 @@ #if defined(__wasm__) && !defined(__EMSCRIPTEN__) # include "wasm/setjmp.h" #else # include <setjmp.h> #endif @@ -6504,7 +6505,45 @@ mark_const_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl) static void each_stack_location(rb_objspace_t *objspace, const rb_execution_context_t *ec, const VALUE *stack_start, const VALUE *stack_end, void (*cb)(rb_objspace_t *, VALUE)); -#ifndef __EMSCRIPTEN__ static void mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec) { @@ -6529,26 +6568,6 @@ mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec each_stack_location(objspace, ec, stack_start, stack_end, gc_mark_maybe); } -#else - -static VALUE *rb_emscripten_stack_range_tmp[2]; - -static void -rb_emscripten_mark_locations(void *begin, void *end) -{ - rb_emscripten_stack_range_tmp[0] = begin; - rb_emscripten_stack_range_tmp[1] = end; -} - -static void -mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec) -{ - emscripten_scan_stack(rb_emscripten_mark_locations); - each_stack_location(objspace, ec, rb_emscripten_stack_range_tmp[0], rb_emscripten_stack_range_tmp[1], gc_mark_maybe); - - emscripten_scan_registers(rb_emscripten_mark_locations); - each_stack_location(objspace, ec, rb_emscripten_stack_range_tmp[0], rb_emscripten_stack_range_tmp[1], gc_mark_maybe); -} #endif static void |