@@ -850,7 +850,7 @@ pub enum Insn {
850850 /// Get the block parameter as a Proc.
851851 GetBlockParam { level : u32 , ep_offset : u32 , state : InsnId } ,
852852 /// Set a local variable in a higher scope or the heap
853- SetLocal { level : u32 , ep_offset : u32 , val : InsnId , state : InsnId } ,
853+ SetLocal { level : u32 , ep_offset : u32 , val : InsnId } ,
854854 GetSpecialSymbol { symbol_type : SpecialBackrefSymbol , state : InsnId } ,
855855 GetSpecialNumber { nth : u64 , state : InsnId } ,
856856
@@ -2404,7 +2404,7 @@ impl Function {
24042404 & SetIvar { self_val, id, ic, val, state } => SetIvar { self_val : find ! ( self_val) , id, ic, val : find ! ( val) , state } ,
24052405 & GetClassVar { id, ic, state } => GetClassVar { id, ic, state } ,
24062406 & SetClassVar { id, val, ic, state } => SetClassVar { id, val : find ! ( val) , ic, state } ,
2407- & SetLocal { val, ep_offset, level, state } => SetLocal { val : find ! ( val) , ep_offset, level, state } ,
2407+ & SetLocal { val, ep_offset, level } => SetLocal { val : find ! ( val) , ep_offset, level } ,
24082408 & GetSpecialSymbol { symbol_type, state } => GetSpecialSymbol { symbol_type, state } ,
24092409 & GetSpecialNumber { nth, state } => GetSpecialNumber { nth, state } ,
24102410 & ToArray { val, state } => ToArray { val : find ! ( val) , state } ,
@@ -6723,11 +6723,12 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
67236723 }
67246724 }
67256725 YARVINSN_setlocal_WC_0 => {
6726+ // TODO(Jacob): Modify this to use guards
67266727 let ep_offset = get_arg ( pc, 0 ) . as_u32 ( ) ;
67276728 let val = state. stack_pop ( ) ?;
67286729 if ep_escaped || has_blockiseq { // TODO: figure out how to drop has_blockiseq here
67296730 // Write the local using EP
6730- fun. push_insn ( block, Insn :: SetLocal { val, ep_offset, level : 0 , state : exit_id } ) ;
6731+ fun. push_insn ( block, Insn :: SetLocal { val, ep_offset, level : 0 } ) ;
67316732 } else if local_inval {
67326733 // If there has been any non-leaf call since JIT entry or the last patch point,
67336734 // add a patch point to make sure locals have not been escaped.
@@ -6743,20 +6744,24 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
67436744 state. stack_push ( fun. push_insn ( block, Insn :: GetLocal { ep_offset, level : 1 , use_sp : false , rest_param : false } ) ) ;
67446745 }
67456746 YARVINSN_setlocal_WC_1 => {
6747+ // TODO(Jacob): Modify this to use guards
67466748 let ep_offset = get_arg ( pc, 0 ) . as_u32 ( ) ;
6747- fun. push_insn ( block, Insn :: SetLocal { val : state. stack_pop ( ) ?, ep_offset, level : 1 , state : exit_id } ) ;
6749+ fun. push_insn ( block, Insn :: SetLocal { val : state. stack_pop ( ) ?, ep_offset, level : 1 } ) ;
67486750 }
67496751 YARVINSN_getlocal => {
67506752 let ep_offset = get_arg ( pc, 0 ) . as_u32 ( ) ;
67516753 let level = get_arg ( pc, 1 ) . as_u32 ( ) ;
67526754 state. stack_push ( fun. push_insn ( block, Insn :: GetLocal { ep_offset, level, use_sp : false , rest_param : false } ) ) ;
67536755 }
67546756 YARVINSN_setlocal => {
6757+ // TODO(Jacob): Make sure this works
6758+ // TODO(Jacob): Clean up the offset, levels, ep chasing, etc
67556759 let ep_offset = get_arg ( pc, 0 ) . as_u32 ( ) ;
67566760 let level = get_arg ( pc, 1 ) . as_u32 ( ) ;
6757- // TODO(Jacob): Add guard here
6758- // TODO(Jacob): Figure out if we should change ALL of the setlocals and what the differences are
6759- fun. push_insn ( block, Insn :: SetLocal { val : state. stack_pop ( ) ?, ep_offset, level, state : exit_id } ) ;
6761+ let ep = fun. push_insn ( block, Insn :: GetEP { level } ) ;
6762+ let flags = fun. push_insn ( block, Insn :: LoadField { recv : ep, id : ID ! ( _env_data_index_flags) , offset : SIZEOF_VALUE_I32 * ( VM_ENV_DATA_INDEX_FLAGS as i32 ) , return_type : types:: CInt64 } ) ;
6763+ fun. push_insn ( block, Insn :: GuardNoBitsSet { val : flags, mask : Const :: CUInt64 ( VM_ENV_FLAG_WB_REQUIRED . into ( ) ) , reason : SideExitReason :: WriteBarrierRequired , state : exit_id } ) ;
6764+ fun. push_insn ( block, Insn :: SetLocal { val : state. stack_pop ( ) ?, ep_offset, level } ) ;
67606765 }
67616766 YARVINSN_getblockparamproxy => {
67626767 let level = get_arg ( pc, 1 ) . as_u32 ( ) ;
0 commit comments