diff options
author | John Hawthorn <[email protected]> | 2023-02-06 09:41:36 -0800 |
---|---|---|
committer | John Hawthorn <[email protected]> | 2023-02-07 11:16:50 -0800 |
commit | 91b18dc88cd1d7737ceff13d3b2d250f63230177 () | |
tree | 71bb75fea2a70ef63a13d153c1a714da9bd22bc3 /vm_backtrace.c | |
parent | 0ee4fec98831a515a3e0765445905f79d7873d38 (diff) |
Use write barriers for Backtrace objects
Backtrace objects hold references to: * iseqs - via the captured locations * strary - a lazily allocated array of strings * locary - a lazily allocated array of backtrace locations Co-authored-by: Adam Hess <[email protected]>
Notes: Merged: https://.com/ruby/ruby/pull/7253
-rw-r--r-- | vm_backtrace.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -518,7 +518,7 @@ backtrace_memsize(const void *ptr) static const rb_data_type_t backtrace_data_type = { "backtrace", {backtrace_mark, backtrace_free, backtrace_memsize, backtrace_update}, - 0, 0, RUBY_TYPED_FREE_IMMEDIATELY }; int @@ -640,7 +640,7 @@ rb_ec_partial_backtrace_object(const rb_execution_context_t *ec, long start_fram const VALUE *pc = cfp->pc; loc = &bt->backtrace[bt->backtrace_size++]; loc->type = LOCATION_TYPE_ISEQ; - loc->iseq = iseq; loc->pc = pc; bt_update_cfunc_loc(cfunc_counter, loc-1, iseq, pc); if (do_yield) { @@ -670,6 +670,7 @@ rb_ec_partial_backtrace_object(const rb_execution_context_t *ec, long start_fram for (; cfp != end_cfp; cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)) { if (cfp->iseq && cfp->pc && (!skip_internal || !is_internal_location(cfp))) { bt_update_cfunc_loc(cfunc_counter, loc, cfp->iseq, cfp->pc); if (do_yield) { bt_yield_loc(loc - cfunc_counter, cfunc_counter, btobj); } @@ -728,7 +729,7 @@ rb_backtrace_to_str_ary(VALUE self) GetCoreDataFromValue(self, rb_backtrace_t, bt); if (!bt->strary) { - bt->strary = backtrace_to_str_ary(self); } return bt->strary; } @@ -780,7 +781,7 @@ rb_backtrace_to_location_ary(VALUE self) GetCoreDataFromValue(self, rb_backtrace_t, bt); if (!bt->locary) { - bt->locary = backtrace_to_location_ary(self); } return bt->locary; } @@ -797,7 +798,7 @@ backtrace_load_data(VALUE self, VALUE str) { rb_backtrace_t *bt; GetCoreDataFromValue(self, rb_backtrace_t, bt); - bt->strary = str; return self; } |