@@ -7,7 +7,7 @@ use crate::state::ZJITState;
7
7
use crate :: { asm:: CodeBlock , cruby:: * , options:: debug, virtualmem:: CodePtr } ;
8
8
use crate :: invariants:: { iseq_escapes_ep, track_no_ep_escape_assumption} ;
9
9
use crate :: backend:: lir:: { self , asm_comment, Assembler , Opnd , Target , CFP , C_ARG_OPNDS , C_RET_OPND , EC , SP } ;
10
- use crate :: hir:: { iseq_to_hir, Block , BlockId , BranchEdge , CallInfo , RangeType } ;
10
+ use crate :: hir:: { iseq_to_hir, Block , BlockId , BranchEdge , CallInfo , RangeType , SELF_PARAM_IDX } ;
11
11
use crate :: hir:: { Const , FrameState , Function , Insn , InsnId } ;
12
12
use crate :: hir_type:: { types:: Fixnum , Type } ;
13
13
use crate :: options:: get_option;
@@ -248,7 +248,6 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
248
248
}
249
249
250
250
let out_opnd = match insn {
251
- Insn :: PutSelf => gen_putself ( ) ,
252
251
Insn :: Const { val : Const :: Value ( val) } => gen_const ( * val) ,
253
252
Insn :: NewArray { elements, state } => gen_new_array ( jit, asm, elements, & function. frame_state ( * state) ) ,
254
253
Insn :: NewRange { low, high, flag, state } => gen_new_range ( asm, opnd ! ( low) , opnd ! ( high) , * flag, & function. frame_state ( * state) ) ,
@@ -324,13 +323,16 @@ fn gen_entry_prologue(asm: &mut Assembler, iseq: IseqPtr) {
324
323
325
324
/// Assign method arguments to basic block arguments at JIT entry
326
325
fn gen_method_params ( asm : & mut Assembler , iseq : IseqPtr , entry_block : & Block ) {
326
+ let self_param = gen_param ( asm, SELF_PARAM_IDX ) ;
327
+ asm. mov ( self_param, Opnd :: mem ( VALUE_BITS , CFP , RUBY_OFFSET_CFP_SELF ) ) ;
328
+
327
329
let num_params = entry_block. params ( ) . len ( ) ;
328
330
if num_params > 0 {
329
331
asm_comment ! ( asm, "set method params: {num_params}" ) ;
330
332
331
333
// Allocate registers for basic block arguments
332
334
let params: Vec < Opnd > = ( 0 ..num_params) . map ( |idx|
333
- gen_param ( asm, idx)
335
+ gen_param ( asm, idx + 1 )
334
336
) . collect ( ) ;
335
337
336
338
// Assign local variables to the basic block arguments
@@ -374,11 +376,6 @@ fn gen_getlocal(asm: &mut Assembler, iseq: IseqPtr, local_idx: usize) -> lir::Op
374
376
}
375
377
}
376
378
377
- /// Compile self in the current frame
378
- fn gen_putself ( ) -> lir:: Opnd {
379
- Opnd :: mem ( VALUE_BITS , CFP , RUBY_OFFSET_CFP_SELF )
380
- }
381
-
382
379
/// Compile a constant
383
380
fn gen_const ( val : VALUE ) -> lir:: Opnd {
384
381
// Just propagate the constant value and generate nothing
@@ -482,16 +479,14 @@ fn gen_send_without_block_direct(
482
479
recv : Opnd ,
483
480
args : & Vec < InsnId > ,
484
481
) -> Option < lir:: Opnd > {
485
- // Set up the new frame
486
- gen_push_frame ( asm, recv) ;
487
-
488
482
asm_comment ! ( asm, "switch to new CFP" ) ;
489
483
let new_cfp = asm. sub ( CFP , RUBY_SIZEOF_CONTROL_FRAME . into ( ) ) ;
490
484
asm. mov ( CFP , new_cfp) ;
491
485
asm. store ( Opnd :: mem ( 64 , EC , RUBY_OFFSET_EC_CFP ) , CFP ) ;
492
486
493
487
// Set up arguments
494
488
let mut c_args: Vec < Opnd > = vec ! [ ] ;
489
+ c_args. push ( recv) ;
495
490
for & arg in args. iter ( ) {
496
491
c_args. push ( jit. get_opnd ( arg) ?) ;
497
492
}
@@ -714,18 +709,6 @@ fn gen_save_sp(asm: &mut Assembler, stack_size: usize) {
714
709
asm. mov ( cfp_sp, sp_addr) ;
715
710
}
716
711
717
- /// Compile an interpreter frame
718
- fn gen_push_frame ( asm : & mut Assembler , recv : Opnd ) {
719
- // Write to a callee CFP
720
- fn cfp_opnd ( offset : i32 ) -> Opnd {
721
- Opnd :: mem ( 64 , CFP , offset - ( RUBY_SIZEOF_CONTROL_FRAME as i32 ) )
722
- }
723
-
724
- asm_comment ! ( asm, "push callee control frame" ) ;
725
- asm. mov ( cfp_opnd ( RUBY_OFFSET_CFP_SELF ) , recv) ;
726
- // TODO: Write more fields as needed
727
- }
728
-
729
712
/// Return a register we use for the basic block argument at a given index
730
713
fn param_reg ( idx : usize ) -> Reg {
731
714
// To simplify the implementation, allocate a fixed register for each basic block argument for now.
0 commit comments