mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
YJIT: Use raw memory write to update pointers in code
Because we have set all code memory to writable before the reference updating phase, we can use raw memory writes directly.
This commit is contained in:
parent
fd492a45eb
commit
5ef20b3a27
1 changed files with 3 additions and 5 deletions
|
@ -2091,11 +2091,9 @@ pub extern "C" fn rb_yjit_iseq_update_references(iseq: IseqPtr) {
|
||||||
|
|
||||||
// Only write when the VALUE moves, to be copy-on-write friendly.
|
// Only write when the VALUE moves, to be copy-on-write friendly.
|
||||||
if new_addr != object {
|
if new_addr != object {
|
||||||
for (byte_idx, &byte) in new_addr.as_u64().to_le_bytes().iter().enumerate() {
|
// SAFETY: Since we already set code memory writable before the compacting phase,
|
||||||
let byte_code_ptr = value_code_ptr.add_bytes(byte_idx);
|
// we can use raw memory accesses directly.
|
||||||
cb.write_mem(byte_code_ptr, byte)
|
unsafe { value_ptr.write_unaligned(new_addr); }
|
||||||
.expect("patching existing code should be within bounds");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue