@@ -1735,6 +1735,19 @@ RawInteger* BinaryIntegerOpInstr::Evaluate(const Integer& left,
1735
1735
}
1736
1736
1737
1737
1738
+ Definition* BinaryIntegerOpInstr::CreateConstantResult (FlowGraph* flow_graph,
1739
+ const Integer& result) {
1740
+ Definition* result_defn = flow_graph->GetConstant (result);
1741
+ if (representation () != kTagged ) {
1742
+ result_defn = UnboxInstr::Create (representation (),
1743
+ new Value (result_defn),
1744
+ GetDeoptId ());
1745
+ flow_graph->InsertBefore (this , result_defn, env (), FlowGraph::kValue );
1746
+ }
1747
+ return result_defn;
1748
+ }
1749
+
1750
+
1738
1751
Definition* BinaryIntegerOpInstr::Canonicalize (FlowGraph* flow_graph) {
1739
1752
// If both operands are constants evaluate this expression. Might
1740
1753
// occur due to load forwarding after constant propagation pass
@@ -1747,7 +1760,7 @@ Definition* BinaryIntegerOpInstr::Canonicalize(FlowGraph* flow_graph) {
1747
1760
Evaluate (Integer::Cast (left ()->BoundConstant ()),
1748
1761
Integer::Cast (right ()->BoundConstant ())));
1749
1762
if (!result.IsNull ()) {
1750
- return flow_graph-> GetConstant ( result);
1763
+ return CreateConstantResult (flow_graph, result);
1751
1764
}
1752
1765
}
1753
1766
@@ -1872,7 +1885,7 @@ Definition* BinaryIntegerOpInstr::Canonicalize(FlowGraph* flow_graph) {
1872
1885
DeoptimizeInstr* deopt =
1873
1886
new DeoptimizeInstr (ICData::kDeoptBinarySmiOp , GetDeoptId ());
1874
1887
flow_graph->InsertBefore (this , deopt, env (), FlowGraph::kEffect );
1875
- return flow_graph-> GetConstant ( Smi ::Handle (Smi::New (0 )));
1888
+ return CreateConstantResult (flow_graph, Integer ::Handle (Smi::New (0 )));
1876
1889
}
1877
1890
break ;
1878
1891
@@ -1886,7 +1899,7 @@ Definition* BinaryIntegerOpInstr::Canonicalize(FlowGraph* flow_graph) {
1886
1899
new DeoptimizeInstr (ICData::kDeoptBinarySmiOp , GetDeoptId ());
1887
1900
flow_graph->InsertBefore (this , deopt, env (), FlowGraph::kEffect );
1888
1901
}
1889
- return flow_graph-> GetConstant ( Smi ::Handle (Smi::New (0 )));
1902
+ return CreateConstantResult (flow_graph, Integer ::Handle (Smi::New (0 )));
1890
1903
}
1891
1904
break ;
1892
1905
}
@@ -2202,11 +2215,13 @@ Definition* UnboxIntegerInstr::Canonicalize(FlowGraph* flow_graph) {
2202
2215
// Fold away UnboxInteger<rep_to>(BoxInteger<rep_from>(v)).
2203
2216
BoxIntegerInstr* box_defn = value ()->definition ()->AsBoxInteger ();
2204
2217
if (box_defn != NULL ) {
2205
- if (box_defn->value ()->definition ()->representation () == representation ()) {
2218
+ Representation from_representation =
2219
+ box_defn->value ()->definition ()->representation ();
2220
+ if (from_representation == representation ()) {
2206
2221
return box_defn->value ()->definition ();
2207
2222
} else {
2208
2223
UnboxedIntConverterInstr* converter = new UnboxedIntConverterInstr (
2209
- box_defn-> value ()-> definition ()-> representation () ,
2224
+ from_representation ,
2210
2225
representation (),
2211
2226
box_defn->value ()->CopyWithType (),
2212
2227
(representation () == kUnboxedInt32 ) ?
0 commit comments