@@ -625,6 +625,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
625625 Insn :: ArrayLength { array } => gen_array_length ( asm, opnd ! ( array) ) ,
626626 Insn :: ObjectAlloc { val, state } => gen_object_alloc ( jit, asm, opnd ! ( val) , & function. frame_state ( * state) ) ,
627627 & Insn :: ObjectAllocClass { class, state } => gen_object_alloc_class ( asm, class, & function. frame_state ( state) ) ,
628+ & Insn :: StringNew { capa, cfunc, state } => gen_string_new ( asm, opnd ! ( capa) , cfunc, & function. frame_state ( state) ) ,
628629 Insn :: StringCopy { val, chilled, state } => gen_string_copy ( asm, opnd ! ( val) , * chilled, & function. frame_state ( * state) ) ,
629630 Insn :: StringConcat { strings, state } => gen_string_concat ( jit, asm, opnds ! ( strings) , & function. frame_state ( * state) ) ,
630631 & Insn :: StringGetbyte { string, index } => gen_string_getbyte ( asm, opnd ! ( string) , opnd ! ( index) ) ,
@@ -2311,6 +2312,12 @@ fn gen_object_alloc(jit: &JITState, asm: &mut Assembler, val: lir::Opnd, state:
23112312 asm_ccall ! ( asm, rb_obj_alloc, val)
23122313}
23132314
2315+ fn gen_string_new ( asm : & mut Assembler , capa : lir:: Opnd , cfunc : * const u8 , state : & FrameState ) -> lir:: Opnd {
2316+ // rb_str_buf_new / rb_str_new_capa_for_init are leaf allocators that may trigger GC.
2317+ gen_prepare_leaf_call_with_gc ( asm, state) ;
2318+ asm. ccall ( cfunc, vec ! [ capa] )
2319+ }
2320+
23142321fn gen_object_alloc_class ( asm : & mut Assembler , class : VALUE , state : & FrameState ) -> lir:: Opnd {
23152322 // Allocating an object for a known class with default allocator is leaf; see doc for
23162323 // `ObjectAllocClass`.
0 commit comments