diff options
Diffstat (limited to 'yjit/src/core.rs')
-rw-r--r-- | yjit/src/core.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/yjit/src/core.rs b/yjit/src/core.rs index e296afc4da..cd10bd0f04 100644 --- a/yjit/src/core.rs +++ b/yjit/src/core.rs @@ -544,7 +544,7 @@ pub struct Block { // FIXME: should these be code pointers instead? // Offsets for GC managed objects in the mainline code block - gc_obj_offsets: Vec<u32>, + gc_obj_offsets: Box<[u32]>, // CME dependencies of this block, to help to remove all pointers to this // block in the system. @@ -796,7 +796,7 @@ pub extern "C" fn rb_yjit_iseq_mark(payload: *mut c_void) { } // Walk over references to objects in generated code. - for offset in &block.gc_obj_offsets { + for offset in block.gc_obj_offsets.iter() { let value_address: *const u8 = cb.get_ptr(offset.as_usize()).raw_ptr(); // Creating an unaligned pointer is well defined unlike in C. let value_address = value_address as *const VALUE; @@ -843,7 +843,7 @@ pub extern "C" fn rb_yjit_iseq_update_references(payload: *mut c_void) { } // Walk over references to objects in generated code. - for offset in &block.gc_obj_offsets { + for offset in block.gc_obj_offsets.iter() { let offset_to_value = offset.as_usize(); let value_code_ptr = cb.get_ptr(offset_to_value); let value_ptr: *const u8 = value_code_ptr.raw_ptr(); @@ -1043,7 +1043,7 @@ fn add_block_version(blockref: &BlockRef, cb: &CodeBlock) { } // Run write barriers for all objects in generated code. - for offset in &block.gc_obj_offsets { + for offset in block.gc_obj_offsets.iter() { let value_address: *const u8 = cb.get_ptr(offset.as_usize()).raw_ptr(); // Creating an unaligned pointer is well defined unlike in C. let value_address: *const VALUE = value_address.cast(); @@ -1088,7 +1088,7 @@ impl Block { end_addr: None, incoming: Vec::new(), outgoing: Vec::new(), - gc_obj_offsets: Vec::new(), + gc_obj_offsets: Box::new([]), cme_dependencies: Vec::new(), entry_exit: None, }; @@ -1147,12 +1147,12 @@ impl Block { self.end_idx = end_idx; } - pub fn add_gc_obj_offsets(self: &mut Block, gc_offsets: Vec<u32>) { - for offset in gc_offsets { - self.gc_obj_offsets.push(offset); - incr_counter!(num_gc_obj_refs); + pub fn set_gc_obj_offsets(self: &mut Block, gc_offsets: Vec<u32>) { + assert_eq!(self.gc_obj_offsets.len(), 0); + if !gc_offsets.is_empty() { + incr_counter_by!(num_gc_obj_refs, gc_offsets.len()); + self.gc_obj_offsets = gc_offsets.into_boxed_slice(); } - self.gc_obj_offsets.shrink_to_fit(); } /// Instantiate a new CmeDependency struct and add it to the list of |