@@ -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 } ,
@@ -1040,6 +1042,15 @@ impl<'a> std::fmt::Display for InsnPrinter<'a> {
10401042 }
10411043 Ok ( ( ) )
10421044 }
1045+ Insn :: ArrayHash { elements, .. } => {
1046+ write ! ( f, "ArrayHash" ) ?;
1047+ let mut prefix = " " ;
1048+ for element in elements {
1049+ write ! ( f, "{prefix}{element}" ) ?;
1050+ prefix = ", " ;
1051+ }
1052+ Ok ( ( ) )
1053+ }
10431054 Insn :: ArrayInclude { elements, target, .. } => {
10441055 write ! ( f, "ArrayInclude" ) ?;
10451056 let mut prefix = " " ;
@@ -1887,6 +1898,7 @@ impl Function {
18871898 & ArrayMax { ref elements, state } => ArrayMax { elements : find_vec ! ( elements) , state : find ! ( state) } ,
18881899 & ArrayInclude { ref elements, target, state } => ArrayInclude { elements : find_vec ! ( elements) , target : find ! ( target) , state : find ! ( state) } ,
18891900 & DupArrayInclude { ary, target, state } => DupArrayInclude { ary, target : find ! ( target) , state : find ! ( state) } ,
1901+ & ArrayHash { ref elements, state } => ArrayHash { elements : find_vec ! ( elements) , state } ,
18901902 & SetGlobal { id, val, state } => SetGlobal { id, val : find ! ( val) , state } ,
18911903 & GetIvar { self_val, id, ic, state } => GetIvar { self_val : find ! ( self_val) , id, ic, state } ,
18921904 & LoadField { recv, id, offset, return_type } => LoadField { recv : find ! ( recv) , id, offset, return_type } ,
@@ -2032,6 +2044,7 @@ impl Function {
20322044 Insn :: ArrayMax { .. } => types:: BasicObject ,
20332045 Insn :: ArrayInclude { .. } => types:: BoolExact ,
20342046 Insn :: DupArrayInclude { .. } => types:: BoolExact ,
2047+ Insn :: ArrayHash { .. } => types:: Fixnum ,
20352048 Insn :: GetGlobal { .. } => types:: BasicObject ,
20362049 Insn :: GetIvar { .. } => types:: BasicObject ,
20372050 Insn :: LoadPC => types:: CPtr ,
@@ -3346,6 +3359,7 @@ impl Function {
33463359 worklist. push_back ( val)
33473360 }
33483361 & Insn :: ArrayMax { ref elements, state }
3362+ | & Insn :: ArrayHash { ref elements, state }
33493363 | & Insn :: NewHash { ref elements, state }
33503364 | & Insn :: NewArray { ref elements, state } => {
33513365 worklist. extend ( elements) ;
@@ -4102,6 +4116,7 @@ impl Function {
41024116 | Insn :: InvokeBuiltin { ref args, .. }
41034117 | Insn :: InvokeBlock { ref args, .. }
41044118 | Insn :: NewArray { elements : ref args, .. }
4119+ | Insn :: ArrayHash { elements : ref args, .. }
41054120 | Insn :: ArrayMax { elements : ref args, .. } => {
41064121 for & arg in args {
41074122 self . assert_subtype ( insn_id, arg, types:: BasicObject ) ?;
@@ -4908,6 +4923,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
49084923 let elements = state. stack_pop_n ( count) ?;
49094924 let ( bop, insn) = match method {
49104925 VM_OPT_NEWARRAY_SEND_MAX => ( BOP_MAX , Insn :: ArrayMax { elements, state : exit_id } ) ,
4926+ VM_OPT_NEWARRAY_SEND_HASH => ( BOP_HASH , Insn :: ArrayHash { elements, state : exit_id } ) ,
49114927 VM_OPT_NEWARRAY_SEND_INCLUDE_P => {
49124928 let target = elements[ elements. len ( ) - 1 ] ;
49134929 let array_elements = elements[ ..elements. len ( ) - 1 ] . to_vec ( ) ;
0 commit comments