Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Unified Diff: runtime/vm/intermediate_language.cc

Issue 2094613003: Canonicalize CheckedSmiOp if compile type turns out to be smi. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc
index 85bae296698dc527504a9513dc504f10bef454db..cc5e51f9a91bec5a4dcc6b578d255df57b05aa9d 100644
--- a/runtime/vm/intermediate_language.cc
+++ b/runtime/vm/intermediate_language.cc
@@ -1762,6 +1762,48 @@ Definition* BinaryIntegerOpInstr::CreateConstantResult(FlowGraph* flow_graph,
}
+Definition* CheckedSmiOpInstr::Canonicalize(FlowGraph* flow_graph) {
+ if ((left()->Type()->ToCid() == kSmiCid) &&
+ (right()->Type()->ToCid() == kSmiCid)) {
+ Definition* replacement = NULL;
+ // Operations that can't deoptimize are specialized here: These include
+ // bit-wise operators and comparisons. Other arithmetic operations can
+ // overflow or divide by 0 and can't be specialized unless we have extra
+ // range information.
+ switch (op_kind()) {
+ case Token::kBIT_AND:
+ case Token::kBIT_OR:
+ case Token::kBIT_XOR:
+ replacement =
+ new BinarySmiOpInstr(op_kind(),
+ new Value(left()->definition()),
+ new Value(right()->definition()),
+ Thread::kNoDeoptId);
+ default:
+ break;
+ }
+ if (Token::IsRelationalOperator(op_kind())) {
+ replacement = new RelationalOpInstr(token_pos(), op_kind(),
+ new Value(left()->definition()),
+ new Value(right()->definition()),
+ kSmiCid,
+ Thread::kNoDeoptId);
+ } else if (Token::IsEqualityOperator(op_kind())) {
+ replacement = new EqualityCompareInstr(token_pos(), op_kind(),
+ new Value(left()->definition()),
+ new Value(right()->definition()),
+ kSmiCid,
+ Thread::kNoDeoptId);
+ }
+ if (replacement != NULL) {
+ flow_graph->InsertBefore(this, replacement, env(), FlowGraph::kValue);
+ return replacement;
+ }
+ }
+ return this;
+}
+
+
Definition* BinaryIntegerOpInstr::Canonicalize(FlowGraph* flow_graph) {
// If both operands are constants evaluate this expression. Might
// occur due to load forwarding after constant propagation pass
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698