11use std:: ffi:: c_void;
22
33use crate :: backend:: lir:: { self , Assembler , EC , Opnd , Target , asm_comment} ;
4- use crate :: codegen:: JITState ;
54use crate :: cruby:: {
65 RB_GC_ZJIT_FASTPATH_DEFAULT , RB_GC_ZJIT_FASTPATH_MMTK ,
76 RUBY_OFFSET_EC_THREAD_PTR , RUBY_OFFSET_RBASIC_FLAGS , RUBY_OFFSET_RBASIC_KLASS ,
87 RUBY_OFFSET_THREAD_RACTOR , VALUE , VALUE_BITS , rb_zjit_offset_ractor_newobj_cache,
98} ;
9+ use super :: JITState ;
1010
1111#[ repr( C ) ]
1212#[ derive( Clone , Copy ) ]
13- pub ( crate ) struct RbGcZjitDefaultNewObjFastpath {
13+ struct RbGcZjitDefaultNewObjFastpath {
1414 cursor_offset : usize ,
1515 jit_cursor_end_offset : usize ,
1616 slot_size : usize ,
@@ -20,7 +20,7 @@ pub(crate) struct RbGcZjitDefaultNewObjFastpath {
2020
2121#[ repr( C ) ]
2222#[ derive( Clone , Copy ) ]
23- pub ( crate ) struct RbGcZjitMmtkNewObjFastpath {
23+ struct RbGcZjitMmtkNewObjFastpath {
2424 objspace : * const c_void ,
2525 objspace_total_allocated_objects_offset : usize ,
2626 ractor_cache_mutator_offset : usize ,
@@ -63,12 +63,12 @@ unsafe extern "C" {
6363 ) -> bool ;
6464}
6565
66- pub ( crate ) enum PreparedNewObjFastpath {
66+ enum PreparedNewObjFastpath {
6767 Default ( RbGcZjitDefaultNewObjFastpath ) ,
6868 Mmtk ( RbGcZjitMmtkNewObjFastpath ) ,
6969}
7070
71- pub ( crate ) fn gc_fast_path_new_obj (
71+ pub ( super ) fn gc_fast_path_new_obj (
7272 jit : & mut JITState ,
7373 asm : & mut Assembler ,
7474 alloc_size : usize ,
@@ -141,7 +141,7 @@ fn prepare_new_obj_fastpath(alloc_size: usize, flags: u64, klass: VALUE) -> Opti
141141 }
142142}
143143
144- pub ( crate ) fn emit_new_obj_fastpath (
144+ fn emit_new_obj_fastpath (
145145 jit : & mut JITState ,
146146 asm : & mut Assembler ,
147147 prepared : & PreparedNewObjFastpath ,
@@ -162,6 +162,10 @@ pub(crate) fn emit_new_obj_fastpath(
162162 }
163163}
164164
165+ /* This function implements the GC fast path for the default GC. It implements
166+ * the fast path defined in function ractor_cache_allocate_slot (but not the
167+ * medium path in ractor_cache_advance_region). It also implements newobj_init
168+ * to write the flags and klass in the object. */
165169fn emit_default_new_obj_fastpath (
166170 jit : & mut JITState ,
167171 asm : & mut Assembler ,
@@ -199,6 +203,9 @@ fn emit_default_new_obj_fastpath(
199203 Some ( cursor)
200204}
201205
206+ /* This function implements the GC fast path for MMTk. It implements the fast
207+ * path defined in function rb_mmtk_alloc_fast_path, as well as writing the
208+ * flags and klass into the object. */
202209fn emit_mmtk_new_obj_fastpath (
203210 jit : & mut JITState ,
204211 asm : & mut Assembler ,
0 commit comments