@@ -993,6 +993,14 @@ fn gen_putobject_int2fix(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlo
993993 KeepCompiling
994994}
995995
996+ fn gen_putobject ( jit : & mut JITState , ctx : & mut Context , cb : & mut CodeBlock , ocb : & mut CodeBlock ) -> CodegenStatus
997+ {
998+ let arg: VALUE = jit_get_arg ( jit, 0 ) ;
999+
1000+ jit_putobject ( jit, ctx, cb, arg) ;
1001+ KeepCompiling
1002+ }
1003+
9961004#[ cfg( test) ]
9971005mod tests {
9981006 use super :: * ;
@@ -1103,6 +1111,50 @@ mod tests {
11031111 assert ! ( cb. get_write_pos( ) > 0 ) ;
11041112 }
11051113
1114+ #[ test]
1115+ fn test_putobject_qtrue ( ) {
1116+ // Test gen_putobject with Qtrue
1117+ let mut context = Context :: new ( ) ;
1118+ let mut cb = CodeBlock :: new ( ) ;
1119+ let mut ocb = CodeBlock :: new ( ) ;
1120+
1121+ let VALUE ( qtrue_value) = Qtrue ;
1122+ let mut value_array: [ u64 ; 2 ] = [ 0 , qtrue_value as u64 ] ;
1123+ let pc: * mut VALUE = & mut value_array as * mut u64 as * mut VALUE ;
1124+ let mut jit = JITState :: new ( ) ;
1125+ jit. set_pc ( pc) ;
1126+
1127+ let status = gen_putobject ( & mut jit, & mut context, & mut cb, & mut ocb) ;
1128+
1129+ let ( _, tmp_type_top) = context. get_opnd_mapping ( StackOpnd ( 0 ) ) ;
1130+
1131+ assert ! ( matches!( KeepCompiling , status) ) ;
1132+ assert_eq ! ( tmp_type_top, Type :: True ) ;
1133+ assert ! ( cb. get_write_pos( ) > 0 ) ;
1134+ }
1135+
1136+ #[ test]
1137+ fn test_putobject_fixnum ( ) {
1138+ // Test gen_putobject with a Fixnum to test another conditional branch
1139+ let mut context = Context :: new ( ) ;
1140+ let mut cb = CodeBlock :: new ( ) ;
1141+ let mut ocb = CodeBlock :: new ( ) ;
1142+
1143+ // The Fixnum 7 is encoded as 7 * 2 + 1, or 15
1144+ let mut value_array: [ u64 ; 2 ] = [ 0 , 15 ] ;
1145+ let pc: * mut VALUE = & mut value_array as * mut u64 as * mut VALUE ;
1146+ let mut jit = JITState :: new ( ) ;
1147+ jit. set_pc ( pc) ;
1148+
1149+ let status = gen_putobject ( & mut jit, & mut context, & mut cb, & mut ocb) ;
1150+
1151+ let ( _, tmp_type_top) = context. get_opnd_mapping ( StackOpnd ( 0 ) ) ;
1152+
1153+ assert ! ( matches!( KeepCompiling , status) ) ;
1154+ assert_eq ! ( tmp_type_top, Type :: Fixnum ) ;
1155+ assert ! ( cb. get_write_pos( ) > 0 ) ;
1156+ }
1157+
11061158 #[ test]
11071159 fn test_int2fix ( ) {
11081160 let mut context = Context :: new ( ) ;
@@ -1426,15 +1478,6 @@ gen_newhash(jitstate_t *jit, ctx_t *ctx, codeblock_t *cb)
14261478 return YJIT_KEEP_COMPILING;
14271479}
14281480
1429- static codegen_status_t
1430- gen_putobject(jitstate_t *jit, ctx_t *ctx, codeblock_t *cb)
1431- {
1432- VALUE arg = jit_get_arg(jit, 0);
1433-
1434- jit_putobject(jit, ctx, arg);
1435- return YJIT_KEEP_COMPILING;
1436- }
1437-
14381481static codegen_status_t
14391482gen_putstring(jitstate_t *jit, ctx_t *ctx, codeblock_t *cb)
14401483{
@@ -5140,6 +5183,7 @@ fn get_gen_fn(opcode: VALUE) -> Option<CodeGenFn>
51405183 OP_DUPN => Some ( gen_dupn) ,
51415184 OP_SWAP => Some ( gen_swap) ,
51425185 OP_PUTNIL => Some ( gen_putnil) ,
5186+ OP_PUTOBJECT => Some ( gen_putobject) ,
51435187 OP_PUTOBJECT_INT2FIX_0_ => Some ( gen_putobject_int2fix) ,
51445188 OP_PUTOBJECT_INT2FIX_1_ => Some ( gen_putobject_int2fix) ,
51455189
0 commit comments