mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
gc.c: Use dedicated APIs for conservative GC in Emscripten
Emscripten provides "emscripten_scan_stack" to get the beginning and end pointers of the stack for conservative GC. Also, "emscripten_scan_registers" allows the GC to mark local variables in WASM.
This commit is contained in:
parent
e79b42c9b2
commit
c576e63ee7
1 changed files with 26 additions and 0 deletions
26
gc.c
26
gc.c
|
@ -71,6 +71,10 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#include "constant.h"
|
||||
#include "debug_counter.h"
|
||||
#include "eval_intern.h"
|
||||
|
@ -5895,6 +5899,7 @@ mark_const_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl)
|
|||
static void mark_stack_locations(rb_objspace_t *objspace, const rb_execution_context_t *ec,
|
||||
const VALUE *stack_start, const VALUE *stack_end);
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
static void
|
||||
mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec)
|
||||
{
|
||||
|
@ -5919,6 +5924,27 @@ mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec
|
|||
|
||||
mark_stack_locations(objspace, ec, stack_start, stack_end);
|
||||
}
|
||||
#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);
|
||||
mark_stack_locations(objspace, ec, rb_emscripten_stack_range_tmp[0], rb_emscripten_stack_range_tmp[1]);
|
||||
|
||||
emscripten_scan_registers(rb_emscripten_mark_locations);
|
||||
mark_stack_locations(objspace, ec, rb_emscripten_stack_range_tmp[0], rb_emscripten_stack_range_tmp[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
rb_gc_mark_machine_stack(const rb_execution_context_t *ec)
|
||||
|
|
Loading…
Add table
Reference in a new issue