Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions gc/mmtk/src/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::upcalls;
use crate::utils::ChunkedVecCollector;
use crate::Ruby;
use crate::RubySlot;
use mmtk::memory_manager;
use mmtk::scheduler::GCWork;
use mmtk::scheduler::GCWorker;
use mmtk::scheduler::WorkBucketStage;
Expand Down Expand Up @@ -53,6 +54,19 @@ impl Scanning<Ruby> for VMScanning {
mmtk::memory_manager::is_mmtk_object(target_object.to_raw_address()).is_some(),
"Destination is not an MMTk object. Src: {object} dst: {target_object}"
);

debug_assert!(
// If we are in a moving GC, all objects should be pinned by PinningRegistry.
// If it is requested that target_object be pinned but it is not pinned, then
// it is a bug because it could be moved.
if crate::mmtk().get_plan().current_gc_may_move_object() && pin {
memory_manager::is_pinned(target_object)
} else {
true
},
"Object {object} is trying to pin {target_object}"
);

let forwarded_target = object_tracer.trace_object(target_object);
if forwarded_target != target_object {
trace!(" Forwarded target {target_object} -> {forwarded_target}");
Expand Down
4 changes: 4 additions & 0 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,10 @@ rb_hash_new_capa(long capa)
static VALUE
hash_copy(VALUE ret, VALUE hash)
{
if (rb_hash_compare_by_id_p(hash)) {
rb_gc_register_pinning_obj(ret);
}

if (RHASH_AR_TABLE_P(hash)) {
if (RHASH_AR_TABLE_P(ret)) {
ar_copy(ret, hash);
Expand Down
19 changes: 19 additions & 0 deletions test/ruby/test_call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ def self.f(*a); a end
assert_equal([1, 2, {kw: 3}], f(*a, kw: 3))
end

def test_forward_argument_init
o = Object.new
def o.simple_forward_argument_init(a=eval('b'), b=1)
[a, b]
end

def o.complex_forward_argument_init(a=eval('b'), b=eval('kw'), kw: eval('kw2'), kw2: 3)
[a, b, kw, kw2]
end

def o.keyword_forward_argument_init(a: eval('b'), b: eval('kw'), kw: eval('kw2'), kw2: 3)
[a, b, kw, kw2]
end

assert_equal [nil, 1], o.simple_forward_argument_init
assert_equal [nil, nil, 3, 3], o.complex_forward_argument_init
assert_equal [nil, nil, 3, 3], o.keyword_forward_argument_init
end

def test_call_bmethod_proc
pr = proc{|sym| sym}
define_singleton_method(:a, &pr)
Expand Down
8 changes: 2 additions & 6 deletions thread_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,12 +1043,8 @@ rb_queue_initialize(int argc, VALUE *argv, VALUE self)
initial_capa *= 2;
}
ring_buffer_init(q, initial_capa);

const VALUE *initial_ptr = RARRAY_CONST_PTR(initial);

for (long index = 0; index < len; index++) {
ring_buffer_push(self, q, initial_ptr[index]);
}
MEMCPY(q->buffer, RARRAY_CONST_PTR(initial), VALUE, len);
q->len = len;
}
else {
ring_buffer_init(q, QUEUE_INITIAL_CAPA);
Expand Down
6 changes: 0 additions & 6 deletions vm_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ args_setup_opt_parameters(struct args_info *args, int opt_max, VALUE *locals)
i = opt_max;
}
else {
int j;
i = args->argc;
args->argc = 0;

Expand All @@ -257,11 +256,6 @@ args_setup_opt_parameters(struct args_info *args, int opt_max, VALUE *locals)
locals[i] = argv[args->rest_index];
}
}

/* initialize by nil */
for (j=i; j<opt_max; j++) {
locals[j] = Qnil;
}
}

return i;
Expand Down