@@ -231,6 +231,7 @@ impl<'a> std::fmt::Display for InvariantPrinter<'a> {
231231 BOP_FREEZE => write ! ( f, "BOP_FREEZE" ) ?,
232232 BOP_UMINUS => write ! ( f, "BOP_UMINUS" ) ?,
233233 BOP_MAX => write ! ( f, "BOP_MAX" ) ?,
234+ BOP_HASH => write ! ( f, "BOP_HASH" ) ?,
234235 BOP_AREF => write ! ( f, "BOP_AREF" ) ?,
235236 _ => write ! ( f, "{bop}" ) ?,
236237 }
@@ -650,6 +651,7 @@ pub enum Insn {
650651 NewRange { low : InsnId , high : InsnId , flag : RangeType , state : InsnId } ,
651652 NewRangeFixnum { low : InsnId , high : InsnId , flag : RangeType , state : InsnId } ,
652653 ArrayDup { val : InsnId , state : InsnId } ,
654+ ArrayHash { elements : Vec < InsnId > , state : InsnId } ,
653655 ArrayMax { elements : Vec < InsnId > , state : InsnId } ,
654656 ArrayInclude { elements : Vec < InsnId > , target : InsnId , state : InsnId } ,
655657 DupArrayInclude { ary : VALUE , target : InsnId , state : InsnId } ,
@@ -1042,6 +1044,15 @@ impl<'a> std::fmt::Display for InsnPrinter<'a> {
10421044 }
10431045 Ok ( ( ) )
10441046 }
1047+ Insn :: ArrayHash { elements, .. } => {
1048+ write ! ( f, "ArrayHash" ) ?;
1049+ let mut prefix = " " ;
1050+ for element in elements {
1051+ write ! ( f, "{prefix}{element}" ) ?;
1052+ prefix = ", " ;
1053+ }
1054+ Ok ( ( ) )
1055+ }
10451056 Insn :: ArrayInclude { elements, target, .. } => {
10461057 write ! ( f, "ArrayInclude" ) ?;
10471058 let mut prefix = " " ;
@@ -1890,6 +1901,7 @@ impl Function {
18901901 & ArrayMax { ref elements, state } => ArrayMax { elements : find_vec ! ( elements) , state : find ! ( state) } ,
18911902 & ArrayInclude { ref elements, target, state } => ArrayInclude { elements : find_vec ! ( elements) , target : find ! ( target) , state : find ! ( state) } ,
18921903 & DupArrayInclude { ary, target, state } => DupArrayInclude { ary, target : find ! ( target) , state : find ! ( state) } ,
1904+ & ArrayHash { ref elements, state } => ArrayHash { elements : find_vec ! ( elements) , state } ,
18931905 & SetGlobal { id, val, state } => SetGlobal { id, val : find ! ( val) , state } ,
18941906 & GetIvar { self_val, id, state } => GetIvar { self_val : find ! ( self_val) , id, state } ,
18951907 & LoadField { recv, id, offset, return_type } => LoadField { recv : find ! ( recv) , id, offset, return_type } ,
@@ -2036,6 +2048,7 @@ impl Function {
20362048 Insn :: ArrayMax { .. } => types:: BasicObject ,
20372049 Insn :: ArrayInclude { .. } => types:: BoolExact ,
20382050 Insn :: DupArrayInclude { .. } => types:: BoolExact ,
2051+ Insn :: ArrayHash { .. } => types:: Fixnum ,
20392052 Insn :: GetGlobal { .. } => types:: BasicObject ,
20402053 Insn :: GetIvar { .. } => types:: BasicObject ,
20412054 Insn :: LoadPC => types:: CPtr ,
@@ -3350,6 +3363,7 @@ impl Function {
33503363 worklist. push_back ( val)
33513364 }
33523365 & Insn :: ArrayMax { ref elements, state }
3366+ | & Insn :: ArrayHash { ref elements, state }
33533367 | & Insn :: NewHash { ref elements, state }
33543368 | & Insn :: NewArray { ref elements, state } => {
33553369 worklist. extend ( elements) ;
@@ -4108,6 +4122,7 @@ impl Function {
41084122 | Insn :: InvokeBuiltin { ref args, .. }
41094123 | Insn :: InvokeBlock { ref args, .. }
41104124 | Insn :: NewArray { elements : ref args, .. }
4125+ | Insn :: ArrayHash { elements : ref args, .. }
41114126 | Insn :: ArrayMax { elements : ref args, .. } => {
41124127 for & arg in args {
41134128 self . assert_subtype ( insn_id, arg, types:: BasicObject ) ?;
@@ -4914,6 +4929,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
49144929 let elements = state. stack_pop_n ( count) ?;
49154930 let ( bop, insn) = match method {
49164931 VM_OPT_NEWARRAY_SEND_MAX => ( BOP_MAX , Insn :: ArrayMax { elements, state : exit_id } ) ,
4932+ VM_OPT_NEWARRAY_SEND_HASH => ( BOP_HASH , Insn :: ArrayHash { elements, state : exit_id } ) ,
49174933 VM_OPT_NEWARRAY_SEND_INCLUDE_P => {
49184934 let target = elements[ elements. len ( ) - 1 ] ;
49194935 let array_elements = elements[ ..elements. len ( ) - 1 ] . to_vec ( ) ;
0 commit comments