diff options
author | KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au> | 2024-01-12 17:32:16 +1100 |
---|---|---|
committer | KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au> | 2024-01-12 17:58:54 +1100 |
commit | ac0ba3c07ee3f700b0b45176a7bdd322d8773e27 (patch) | |
tree | 10722d43569d31e8fcd41ff5b5e2e4ededd41a61 /gc.c | |
parent | 33a03cb236057b1dc044fc76bf51b263d6cbda81 (diff) |
Revert "Allow each_stack_location to accept context for the callback"
This reverts commit 179228cd83a926efcd79ca5d0c6ed6af0c2389c0.
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 46 |
1 files changed, 19 insertions, 27 deletions
@@ -6548,38 +6548,32 @@ ruby_stack_check(void) return stack_check(GET_EC(), STACKFRAME_FOR_CALL_CFUNC); } -ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(static void each_location(rb_objspace_t *objspace, register const VALUE *x, register long n, void *ctx, void (*cb)(rb_objspace_t *, void *, VALUE))); +ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(static void each_location(rb_objspace_t *objspace, register const VALUE *x, register long n, void (*cb)(rb_objspace_t *, VALUE))); static void -each_location(rb_objspace_t *objspace, register const VALUE *x, register long n, void *ctx, void (*cb)(rb_objspace_t *, void *, VALUE)) +each_location(rb_objspace_t *objspace, register const VALUE *x, register long n, void (*cb)(rb_objspace_t *, VALUE)) { VALUE v; while (n--) { v = *x; - cb(objspace, ctx, v); + cb(objspace, v); x++; } } static void -gc_mark_locations(rb_objspace_t *objspace, const VALUE *start, const VALUE *end, void *ctx, void (*cb)(rb_objspace_t *, void *, VALUE)) +gc_mark_locations(rb_objspace_t *objspace, const VALUE *start, const VALUE *end, void (*cb)(rb_objspace_t *, VALUE)) { long n; if (end <= start) return; n = end - start; - each_location(objspace, start, n, ctx, cb); -} - -static void -gc_mark_maybe_cb(rb_objspace_t *objspace, void *ctx, VALUE obj) -{ - gc_mark_maybe(objspace, obj); + each_location(objspace, start, n, cb); } void rb_gc_mark_locations(const VALUE *start, const VALUE *end) { - gc_mark_locations(&rb_objspace, start, end, NULL, gc_mark_maybe_cb); + gc_mark_locations(&rb_objspace, start, end, gc_mark_maybe); } void @@ -6825,8 +6819,7 @@ mark_const_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl) #endif static void each_stack_location(rb_objspace_t *objspace, const rb_execution_context_t *ec, - const VALUE *stack_start, const VALUE *stack_end, void *ctx, - void (*cb)(rb_objspace_t *, void *, VALUE)); + const VALUE *stack_start, const VALUE *stack_end, void (*cb)(rb_objspace_t *, VALUE)); #if defined(__wasm__) @@ -6846,10 +6839,10 @@ static void mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec) { emscripten_scan_stack(rb_mark_locations); - each_stack_location(objspace, ec, rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe_cb); + each_stack_location(objspace, ec, rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe); emscripten_scan_registers(rb_mark_locations); - each_stack_location(objspace, ec, rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe_cb); + each_stack_location(objspace, ec, rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe); } # else // use Asyncify version @@ -6859,10 +6852,10 @@ mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec VALUE *stack_start, *stack_end; SET_STACK_END; GET_STACK_BOUNDS(stack_start, stack_end, 1); - each_stack_location(objspace, ec, stack_start, stack_end, gc_mark_maybe_cb); + each_stack_location(objspace, ec, stack_start, stack_end, gc_mark_maybe); rb_wasm_scan_locals(rb_mark_locations); - each_stack_location(objspace, ec, rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe_cb); + each_stack_location(objspace, ec, rb_stack_range_tmp[0], rb_stack_range_tmp[1], gc_mark_maybe); } # endif @@ -6889,41 +6882,40 @@ mark_current_machine_context(rb_objspace_t *objspace, rb_execution_context_t *ec SET_STACK_END; GET_STACK_BOUNDS(stack_start, stack_end, 1); - each_location(objspace, save_regs_gc_mark.v, numberof(save_regs_gc_mark.v), NULL, gc_mark_maybe_cb); + each_location(objspace, save_regs_gc_mark.v, numberof(save_regs_gc_mark.v), gc_mark_maybe); - each_stack_location(objspace, ec, stack_start, stack_end, NULL, gc_mark_maybe_cb); + each_stack_location(objspace, ec, stack_start, stack_end, gc_mark_maybe); } #endif static void -each_machine_stack_value(const rb_execution_context_t *ec, void *ctx, void (*cb)(rb_objspace_t *, void *, VALUE)) +each_machine_stack_value(const rb_execution_context_t *ec, void (*cb)(rb_objspace_t *, VALUE)) { rb_objspace_t *objspace = &rb_objspace; VALUE *stack_start, *stack_end; GET_STACK_BOUNDS(stack_start, stack_end, 0); RUBY_DEBUG_LOG("ec->th:%u stack_start:%p stack_end:%p", rb_ec_thread_ptr(ec)->serial, stack_start, stack_end); - each_stack_location(objspace, ec, stack_start, stack_end, ctx, cb); + each_stack_location(objspace, ec, stack_start, stack_end, cb); } void rb_gc_mark_machine_stack(const rb_execution_context_t *ec) { - each_machine_stack_value(ec, NULL, gc_mark_maybe_cb); + each_machine_stack_value(ec, gc_mark_maybe); } static void each_stack_location(rb_objspace_t *objspace, const rb_execution_context_t *ec, - const VALUE *stack_start, const VALUE *stack_end, void *ctx, - void (*cb)(rb_objspace_t *, void *, VALUE)) + const VALUE *stack_start, const VALUE *stack_end, void (*cb)(rb_objspace_t *, VALUE)) { - gc_mark_locations(objspace, stack_start, stack_end, ctx, cb); + gc_mark_locations(objspace, stack_start, stack_end, cb); #if defined(__mc68000__) gc_mark_locations(objspace, (VALUE*)((char*)stack_start + 2), - (VALUE*)((char*)stack_end - 2), ctx, cb); + (VALUE*)((char*)stack_end - 2), cb); #endif } |