ruby-changes:61293
From: Aaron <ko1@a...>
Date: Tue, 19 May 2020 08:57:38 +0900 (JST)
Subject: [ruby-changes:61293] 6efb9fe042 (master): Allow references stored in the VM stack to move
https://git.ruby-lang.org/ruby.git/commit/?id=6efb9fe042 From 6efb9fe04229c9e96205025bfd8b6cfec1b9a30f Mon Sep 17 00:00:00 2001 From: Aaron Patterson <tenderlove@r...> Date: Tue, 12 May 2020 12:00:35 -0700 Subject: Allow references stored in the VM stack to move We can update these references too, so lets allow them to move. diff --git a/gc.c b/gc.c index 76d112c..6353a7b 100644 --- a/gc.c +++ b/gc.c @@ -4800,14 +4800,13 @@ rb_gc_mark_values(long n, const VALUE *values) https://github.com/ruby/ruby/blob/trunk/gc.c#L4800 } static void -gc_mark_and_pin_stack_values(rb_objspace_t *objspace, long n, const VALUE *values) +gc_mark_stack_values(rb_objspace_t *objspace, long n, const VALUE *values) { long i; for (i=0; i<n; i++) { - /* skip MOVED objects that are on the stack */ - if (is_markable_object(objspace, values[i]) && T_MOVED != BUILTIN_TYPE(values[i])) { - gc_mark_and_pin(objspace, values[i]); + if (is_markable_object(objspace, values[i])) { + gc_mark(objspace, values[i]); } } } @@ -4816,7 +4815,7 @@ void https://github.com/ruby/ruby/blob/trunk/gc.c#L4815 rb_gc_mark_vm_stack_values(long n, const VALUE *values) { rb_objspace_t *objspace = &rb_objspace; - gc_mark_and_pin_stack_values(objspace, n, values); + gc_mark_stack_values(objspace, n, values); } static int diff --git a/vm.c b/vm.c index d286bc7..e627148 100644 --- a/vm.c +++ b/vm.c @@ -2488,11 +2488,21 @@ rb_execution_context_update(const rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/vm.c#L2488 { /* update VM stack */ if (ec->vm_stack) { + long i; VM_ASSERT(ec->cfp); - + VALUE *p = ec->vm_stack; + VALUE *sp = ec->cfp->sp; rb_control_frame_t *cfp = ec->cfp; rb_control_frame_t *limit_cfp = (void *)(ec->vm_stack + ec->vm_stack_size); + for (i = 0; i < (long)(sp - p); i++) { + VALUE ref = p[i]; + VALUE update = rb_gc_location(ref); + if (ref != update) { + p[i] = update; + } + } + while (cfp != limit_cfp) { const VALUE *ep = cfp->ep; cfp->self = rb_gc_location(cfp->self); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/