summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gc.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index 5ec317ddc7..f4c8a948c9 100644
--- a/gc.c
+++ b/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)