YJIT: Stop wrapping CmePtr with CmeDependency (#6747)

* YJIT: Stop wrapping CmePtr with CmeDependency

* YJIT: Fix an outdated comment [ci skip]
This commit is contained in:
Takashi Kokubun 2022-11-16 15:30:29 -08:00 коммит произвёл GitHub
Родитель 3eb7a6521c
Коммит 6de4032e40
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 12 добавлений и 16 удалений

Просмотреть файл

@ -369,12 +369,8 @@ impl Branch {
}
}
// In case this block is invalidated, these two pieces of info
// help to remove all pointers to this block in the system.
#[derive(Debug)]
pub struct CmeDependency {
pub callee_cme: *const rb_callable_method_entry_t,
}
// In case a block is invalidated, this helps to remove all pointers to the block.
pub type CmePtr = *const rb_callable_method_entry_t;
/// Basic block version
/// Represents a portion of an iseq compiled with a given context
@ -411,7 +407,7 @@ pub struct Block {
// CME dependencies of this block, to help to remove all pointers to this
// block in the system.
cme_dependencies: Vec<CmeDependency>,
cme_dependencies: Vec<CmePtr>,
// Code address of an exit for `ctx` and `blockid`.
// Used for block invalidation.
@ -634,8 +630,8 @@ pub extern "C" fn rb_yjit_iseq_mark(payload: *mut c_void) {
unsafe { rb_gc_mark_movable(block.blockid.iseq.into()) };
// Mark method entry dependencies
for cme_dep in &block.cme_dependencies {
unsafe { rb_gc_mark_movable(cme_dep.callee_cme.into()) };
for &cme_dep in &block.cme_dependencies {
unsafe { rb_gc_mark_movable(cme_dep.into()) };
}
// Mark outgoing branch entries
@ -690,7 +686,7 @@ pub extern "C" fn rb_yjit_iseq_update_references(payload: *mut c_void) {
// Update method entry dependencies
for cme_dep in &mut block.cme_dependencies {
cme_dep.callee_cme = unsafe { rb_gc_location(cme_dep.callee_cme.into()) }.as_cme();
*cme_dep = unsafe { rb_gc_location((*cme_dep).into()) }.as_cme();
}
// Update outgoing branch entries
@ -885,8 +881,8 @@ fn add_block_version(blockref: &BlockRef, cb: &CodeBlock) {
// By writing the new block to the iseq, the iseq now
// contains new references to Ruby objects. Run write barriers.
let iseq: VALUE = block.blockid.iseq.into();
for dep in block.iter_cme_deps() {
obj_written!(iseq, dep.callee_cme.into());
for &dep in block.iter_cme_deps() {
obj_written!(iseq, dep.into());
}
// Run write barriers for all objects in generated code.
@ -968,7 +964,7 @@ impl Block {
}
/// Get an immutable iterator over cme dependencies
pub fn iter_cme_deps(&self) -> std::slice::Iter<'_, CmeDependency> {
pub fn iter_cme_deps(&self) -> std::slice::Iter<'_, CmePtr> {
self.cme_dependencies.iter()
}
@ -1006,8 +1002,8 @@ impl Block {
/// Instantiate a new CmeDependency struct and add it to the list of
/// dependencies for this block.
pub fn add_cme_dependency(&mut self, callee_cme: *const rb_callable_method_entry_t) {
self.cme_dependencies.push(CmeDependency { callee_cme });
pub fn add_cme_dependency(&mut self, callee_cme: CmePtr) {
self.cme_dependencies.push(callee_cme);
self.cme_dependencies.shrink_to_fit();
}

Просмотреть файл

@ -355,7 +355,7 @@ pub fn block_assumptions_free(blockref: &BlockRef) {
// For each method lookup dependency
for dep in block.iter_cme_deps() {
// Remove tracking for cme validity
if let Some(blockset) = invariants.cme_validity.get_mut(&dep.callee_cme) {
if let Some(blockset) = invariants.cme_validity.get_mut(dep) {
blockset.remove(blockref);
}
}