@@ -544,7 +544,7 @@ pub struct Block {
544544
545545 // FIXME: should these be code pointers instead?
546546 // Offsets for GC managed objects in the mainline code block
547- gc_obj_offsets : Vec < u32 > ,
547+ gc_obj_offsets : Box < [ u32 ] > ,
548548
549549 // CME dependencies of this block, to help to remove all pointers to this
550550 // block in the system.
@@ -796,7 +796,7 @@ pub extern "C" fn rb_yjit_iseq_mark(payload: *mut c_void) {
796796 }
797797
798798 // Walk over references to objects in generated code.
799- for offset in & block. gc_obj_offsets {
799+ for offset in block. gc_obj_offsets . iter ( ) {
800800 let value_address: * const u8 = cb. get_ptr ( offset. as_usize ( ) ) . raw_ptr ( ) ;
801801 // Creating an unaligned pointer is well defined unlike in C.
802802 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) {
843843 }
844844
845845 // Walk over references to objects in generated code.
846- for offset in & block. gc_obj_offsets {
846+ for offset in block. gc_obj_offsets . iter ( ) {
847847 let offset_to_value = offset. as_usize ( ) ;
848848 let value_code_ptr = cb. get_ptr ( offset_to_value) ;
849849 let value_ptr: * const u8 = value_code_ptr. raw_ptr ( ) ;
@@ -1043,7 +1043,7 @@ fn add_block_version(blockref: &BlockRef, cb: &CodeBlock) {
10431043 }
10441044
10451045 // Run write barriers for all objects in generated code.
1046- for offset in & block. gc_obj_offsets {
1046+ for offset in block. gc_obj_offsets . iter ( ) {
10471047 let value_address: * const u8 = cb. get_ptr ( offset. as_usize ( ) ) . raw_ptr ( ) ;
10481048 // Creating an unaligned pointer is well defined unlike in C.
10491049 let value_address: * const VALUE = value_address. cast ( ) ;
@@ -1088,7 +1088,7 @@ impl Block {
10881088 end_addr : None ,
10891089 incoming : Vec :: new ( ) ,
10901090 outgoing : Vec :: new ( ) ,
1091- gc_obj_offsets : Vec :: new ( ) ,
1091+ gc_obj_offsets : Box :: new ( [ ] ) ,
10921092 cme_dependencies : Vec :: new ( ) ,
10931093 entry_exit : None ,
10941094 } ;
@@ -1147,12 +1147,12 @@ impl Block {
11471147 self . end_idx = end_idx;
11481148 }
11491149
1150- pub fn add_gc_obj_offsets ( self : & mut Block , gc_offsets : Vec < u32 > ) {
1151- for offset in gc_offsets {
1152- self . gc_obj_offsets . push ( offset) ;
1153- incr_counter ! ( num_gc_obj_refs) ;
1150+ pub fn set_gc_obj_offsets ( self : & mut Block , gc_offsets : Vec < u32 > ) {
1151+ assert_eq ! ( self . gc_obj_offsets. len( ) , 0 ) ;
1152+ if !gc_offsets. is_empty ( ) {
1153+ incr_counter_by ! ( num_gc_obj_refs, gc_offsets. len( ) ) ;
1154+ self . gc_obj_offsets = gc_offsets. into_boxed_slice ( ) ;
11541155 }
1155- self . gc_obj_offsets . shrink_to_fit ( ) ;
11561156 }
11571157
11581158 /// Instantiate a new CmeDependency struct and add it to the list of
0 commit comments