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
2 changes: 1 addition & 1 deletion .gdbinit
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ define rp
printf "%sT_OBJECT%s: ", $color_type, $color_end
print ((struct RObject *)($arg0))->basic
if ($flags & ROBJECT_EMBED)
print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (rb_shape_get_shape($arg0)->capacity)
print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (RSHAPE_CAPACITY(rb_obj_shape_id($arg0)))
else
print (((struct RObject *)($arg0))->as.heap)
if (((struct RObject*)($arg0))->as.heap.numiv) > 0
Expand Down
27 changes: 27 additions & 0 deletions bootstraptest/test_ractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,33 @@ class C8; def self.foo = 17; end
rs.map{|r| r.value} == Array.new(RN){n}
}

# check method cache invalidation
assert_equal 'true', %q{
class Foo
def hello = nil
end

r1 = Ractor.new do
1000.times do
class Foo
def hello = nil
end
end
end

r2 = Ractor.new do
1000.times do
o = Foo.new
o.hello
end
end

r1.value
r2.value

true
}

# check experimental warning
assert_match /\Atest_ractor\.rb:1:\s+warning:\s+Ractor is experimental/, %q{
Warning[:experimental] = $VERBOSE = true
Expand Down
2 changes: 1 addition & 1 deletion vm_callinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ static inline bool
vm_cc_check_cme(const struct rb_callcache *cc, const rb_callable_method_entry_t *cme)
{
bool valid;
RB_VM_LOCKING() {
RB_VM_LOCKING_NO_BARRIER() {
valid = vm_cc_cme(cc) == cme ||
(cme->def->iseq_overload && vm_cc_cme(cc) == rb_vm_lookup_overloaded_cme(cme));
}
Expand Down
4 changes: 4 additions & 0 deletions vm_method.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ clear_method_cache_by_id_in_class(VALUE klass, ID mid)
if (rb_objspace_garbage_object_p(klass)) return;

RB_VM_LOCKING() {
rb_vm_barrier();

if (LIKELY(RCLASS_SUBCLASSES_FIRST(klass) == NULL)) {
// no subclasses
// check only current class
Expand Down Expand Up @@ -1752,6 +1754,8 @@ cached_callable_method_entry(VALUE klass, ID mid)
return ccs->cme;
}
else {
rb_vm_barrier();

rb_managed_id_table_delete(cc_tbl, mid);
rb_vm_ccs_invalidate_and_free(ccs);
}
Expand Down
8 changes: 4 additions & 4 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4315,11 +4315,11 @@ fn gen_opt_ary_freeze(
return None;
}

let str = jit.get_arg(0);
let ary = jit.get_arg(0);

// Push the return value onto the stack
let stack_ret = asm.stack_push(Type::CArray);
asm.mov(stack_ret, str.into());
asm.mov(stack_ret, ary.into());

Some(KeepCompiling)
}
Expand All @@ -4332,11 +4332,11 @@ fn gen_opt_hash_freeze(
return None;
}

let str = jit.get_arg(0);
let hash = jit.get_arg(0);

// Push the return value onto the stack
let stack_ret = asm.stack_push(Type::CHash);
asm.mov(stack_ret, str.into());
asm.mov(stack_ret, hash.into());

Some(KeepCompiling)
}
Expand Down
33 changes: 17 additions & 16 deletions zjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,25 +737,26 @@ fn gen_entry_params(asm: &mut Assembler, iseq: IseqPtr, entry_block: &Block) {
}

/// Set branch params to basic block arguments
fn gen_branch_params(jit: &mut JITState, asm: &mut Assembler, branch: &BranchEdge) -> Option<()> {
if !branch.args.is_empty() {
asm_comment!(asm, "set branch params: {}", branch.args.len());
let mut moves: Vec<(Reg, Opnd)> = vec![];
for (idx, &arg) in branch.args.iter().enumerate() {
match param_opnd(idx) {
Opnd::Reg(reg) => {
// If a parameter is a register, we need to parallel-move it
moves.push((reg, jit.get_opnd(arg)));
},
param => {
// If a parameter is memory, we set it beforehand
asm.mov(param, jit.get_opnd(arg));
}
fn gen_branch_params(jit: &mut JITState, asm: &mut Assembler, branch: &BranchEdge) {
if branch.args.is_empty() {
return;
}

asm_comment!(asm, "set branch params: {}", branch.args.len());
let mut moves: Vec<(Reg, Opnd)> = vec![];
for (idx, &arg) in branch.args.iter().enumerate() {
match param_opnd(idx) {
Opnd::Reg(reg) => {
// If a parameter is a register, we need to parallel-move it
moves.push((reg, jit.get_opnd(arg)));
},
param => {
// If a parameter is memory, we set it beforehand
asm.mov(param, jit.get_opnd(arg));
}
}
asm.parallel_mov(moves);
}
Some(())
asm.parallel_mov(moves);
}

/// Get a method parameter on JIT entry. As of entry, whether EP is escaped or not solely
Expand Down