diff options
author | Takashi Kokubun <[email protected]> | 2022-11-16 15:30:29 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2022-11-16 15:30:29 -0800 |
commit | 6de4032e407b5e4bcf837332b9980a5892282df8 (patch) | |
tree | c29bfdfbbd3b7109d55da90062cf2172f8df2d9f /yjit/src | |
parent | 3eb7a6521ce08eb3758e63575a90b66a3ea10717 (diff) |
YJIT: Stop wrapping CmePtr with CmeDependency (#6747)
* YJIT: Stop wrapping CmePtr with CmeDependency
* YJIT: Fix an outdated comment [ci skip]
Notes
Notes:
Merged-By: k0kubun <[email protected]>
Diffstat (limited to 'yjit/src')
-rw-r--r-- | yjit/src/core.rs | 26 | ||||
-rw-r--r-- | yjit/src/invariants.rs | 2 |
2 files changed, 12 insertions, 16 deletions
diff --git a/yjit/src/core.rs b/yjit/src/core.rs index adce0f51de..d07f8e0c8c 100644 --- a/yjit/src/core.rs +++ b/yjit/src/core.rs @@ -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(); } diff --git a/yjit/src/invariants.rs b/yjit/src/invariants.rs index e2db8f36b5..b911ff2c92 100644 --- a/yjit/src/invariants.rs +++ b/yjit/src/invariants.rs @@ -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); } } |