@@ -3331,26 +3331,25 @@ fn yjit_reg_method(klass: VALUE, mid_str: &str, gen_fn: MethodGenFn)
3331
3331
CodegenGlobals :: register_codegen_method ( method_serial, gen_fn) ;
3332
3332
}
3333
3333
3334
- /*
3335
3334
// Codegen for rb_obj_not().
3336
3335
// Note, caller is responsible for generating all the right guards, including
3337
3336
// arity guards.
3338
3337
fn jit_rb_obj_not ( jit : & mut JITState , ctx : & mut Context , cb : & mut CodeBlock , ocb : & mut OutlinedCb , ci : * const rb_callinfo , cme : * const rb_callable_method_entry_t , block : Option < IseqPtr > , argc : i32 , known_recv_class : * const VALUE ) -> bool
3339
3338
{
3340
- const val_type_t recv_opnd = ctx.get_opnd_type(StackOpnd(0));
3339
+ let recv_opnd = ctx. get_opnd_type ( StackOpnd ( 0 ) ) ;
3341
3340
3342
- if ( recv_opnd == Type::Nil || recv_opnd == Type::False) {
3341
+ if recv_opnd == Type :: Nil || recv_opnd == Type :: False {
3343
3342
add_comment ( cb, "rb_obj_not(nil_or_false)" ) ;
3344
3343
ctx. stack_pop ( 1 ) ;
3345
3344
let out_opnd = ctx. stack_push ( Type :: True ) ;
3346
- mov(cb, out_opnd, imm_opnd (Qtrue));
3345
+ mov ( cb, out_opnd, uimm_opnd ( Qtrue . into ( ) ) ) ;
3347
3346
}
3348
- else if ( recv_opnd.is_heap || recv_opnd != Type::Unknown) {
3347
+ else if recv_opnd. is_heap ( ) || recv_opnd != Type :: Unknown {
3349
3348
// Note: recv_opnd != Type::Nil && recv_opnd != Type::False.
3350
3349
add_comment ( cb, "rb_obj_not(truthy)" ) ;
3351
3350
ctx. stack_pop ( 1 ) ;
3352
3351
let out_opnd = ctx. stack_push ( Type :: False ) ;
3353
- mov(cb, out_opnd, imm_opnd (Qfalse));
3352
+ mov ( cb, out_opnd, uimm_opnd ( Qfalse . into ( ) ) ) ;
3354
3353
}
3355
3354
else {
3356
3355
// jit_guard_known_klass() already ran on the receiver which should
@@ -3360,7 +3359,6 @@ fn jit_rb_obj_not(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb
3360
3359
}
3361
3360
true
3362
3361
}
3363
- */
3364
3362
3365
3363
// Codegen for rb_true()
3366
3364
fn jit_rb_true ( jit : & mut JITState , ctx : & mut Context , cb : & mut CodeBlock , ocb : & mut OutlinedCb , ci : * const rb_callinfo , cme : * const rb_callable_method_entry_t , block : Option < IseqPtr > , argc : i32 , known_recv_class : * const VALUE ) -> bool
@@ -3401,20 +3399,13 @@ fn jit_rb_obj_equal(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, o
3401
3399
true
3402
3400
}
3403
3401
3404
- /*
3405
- static VALUE
3406
- yjit_str_bytesize(VALUE str)
3407
- {
3408
- return LONG2NUM(RSTRING_LEN(str));
3409
- }
3410
-
3411
3402
fn jit_rb_str_bytesize ( jit : & mut JITState , ctx : & mut Context , cb : & mut CodeBlock , ocb : & mut OutlinedCb , ci : * const rb_callinfo , cme : * const rb_callable_method_entry_t , block : Option < IseqPtr > , argc : i32 , known_recv_class : * const VALUE ) -> bool
3412
3403
{
3413
3404
add_comment ( cb, "String#bytesize" ) ;
3414
3405
3415
3406
let recv = ctx. stack_pop ( 1 ) ;
3416
3407
mov ( cb, C_ARG_REGS [ 0 ] , recv) ;
3417
- call_ptr(cb, REG0, (void *)&yjit_str_bytesize );
3408
+ call_ptr ( cb, REG0 , rb_str_bytesize as * const u8 ) ;
3418
3409
3419
3410
let out_opnd = ctx. stack_push ( Type :: Fixnum ) ;
3420
3411
mov ( cb, out_opnd, RAX ) ;
@@ -3428,7 +3419,7 @@ fn jit_rb_str_bytesize(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock
3428
3419
// this situation happens a lot in some workloads.
3429
3420
fn jit_rb_str_to_s ( jit : & mut JITState , ctx : & mut Context , cb : & mut CodeBlock , ocb : & mut OutlinedCb , ci : * const rb_callinfo , cme : * const rb_callable_method_entry_t , block : Option < IseqPtr > , argc : i32 , known_recv_class : * const VALUE ) -> bool
3430
3421
{
3431
- if (recv_known_klass && *recv_known_klass == rb_cString) {
3422
+ if !known_recv_class . is_null ( ) && unsafe { * known_recv_class == rb_cString } {
3432
3423
add_comment ( cb, "to_s on plain string" ) ;
3433
3424
// The method returns the receiver, which is already on the stack.
3434
3425
// No stack movement.
@@ -3443,16 +3434,18 @@ fn jit_thread_s_current(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBloc
3443
3434
ctx. stack_pop ( 1 ) ;
3444
3435
3445
3436
// ec->thread_ptr
3446
- mov(cb, REG0, member_opnd(REG_EC, rb_execution_context_t, thread_ptr));
3437
+ let ec_thread_ptr = mem_opnd ( 64 , REG_EC , RUBY_OFFSET_EC_THREAD_PTR ) ;
3438
+ mov ( cb, REG0 , ec_thread_ptr) ;
3447
3439
3448
3440
// thread->self
3449
- mov(cb, REG0, member_opnd(REG0, rb_thread_t, self));
3441
+ let thread_self = mem_opnd ( 64 , REG0 , RUBY_OFFSET_THREAD_SELF ) ;
3442
+ mov ( cb, REG0 , thread_self) ;
3450
3443
3451
3444
let stack_ret = ctx. stack_push ( Type :: UnknownHeap ) ;
3452
3445
mov ( cb, stack_ret, REG0 ) ;
3453
3446
true
3454
3447
}
3455
- */
3448
+
3456
3449
// Check if we know how to codegen for a particular cfunc method
3457
3450
fn lookup_cfunc_codegen ( def : * const rb_method_definition_t ) -> Option < MethodGenFn >
3458
3451
{
@@ -5172,7 +5165,7 @@ fn get_method_gen_fn()
5172
5165
// All these class constants are mutable statics.
5173
5166
unsafe {
5174
5167
// Specialization for C methods. See yjit_reg_method() for details.
5175
- // yjit_reg_method(rb_cBasicObject, "!", jit_rb_obj_not);
5168
+ yjit_reg_method ( rb_cBasicObject, "!" , jit_rb_obj_not) ;
5176
5169
5177
5170
yjit_reg_method ( rb_cNilClass, "nil?" , jit_rb_true) ;
5178
5171
yjit_reg_method ( rb_mKernel, "nil?" , jit_rb_false) ;
@@ -5183,15 +5176,14 @@ fn get_method_gen_fn()
5183
5176
yjit_reg_method ( rb_cModule, "==" , jit_rb_obj_equal) ;
5184
5177
yjit_reg_method ( rb_cSymbol, "==" , jit_rb_obj_equal) ;
5185
5178
yjit_reg_method ( rb_cSymbol, "===" , jit_rb_obj_equal) ;
5186
- /*
5179
+
5187
5180
// rb_str_to_s() methods in string.c
5188
5181
yjit_reg_method ( rb_cString, "to_s" , jit_rb_str_to_s) ;
5189
5182
yjit_reg_method ( rb_cString, "to_str" , jit_rb_str_to_s) ;
5190
5183
yjit_reg_method ( rb_cString, "bytesize" , jit_rb_str_bytesize) ;
5191
5184
5192
5185
// Thread.current
5193
5186
yjit_reg_method ( rb_singleton_class ( rb_cThread) , "current" , jit_thread_s_current) ;
5194
- */
5195
5187
}
5196
5188
}
5197
5189
0 commit comments