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

Unified Diff: dart/runtime/vm/intermediate_language.cc

Issue 754763003: Version 1.8.3 (Closed) Base URL: http://dart.googlecode.com/svn/branches/1.8/
Patch Set: Created 6 years 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 | « dart/runtime/vm/intermediate_language.h ('k') | dart/runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/runtime/vm/intermediate_language.cc
===================================================================
--- dart/runtime/vm/intermediate_language.cc (revision 42037)
+++ dart/runtime/vm/intermediate_language.cc (working copy)
@@ -789,6 +789,18 @@
}
+bool Instruction::HasUnmatchedInputRepresentations() const {
+ for (intptr_t i = 0; i < InputCount(); i++) {
+ Definition* input = InputAt(i)->definition();
+ if (RequiredInputRepresentation(i) != input->representation()) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
void Definition::ReplaceWith(Definition* other,
ForwardInstructionIterator* iterator) {
// Record other's input uses.
@@ -1205,7 +1217,8 @@
return false;
case Token::kSHL:
- return true;
+ return can_overflow() ||
+ !RangeUtils::IsPositive(right()->definition()->range());
case Token::kMOD: {
UNREACHABLE();
@@ -1228,19 +1241,14 @@
case Token::kBIT_OR:
case Token::kBIT_XOR:
return false;
- case Token::kSHR: {
- // Can't deopt if shift-count is known positive.
- Range* right_range = this->right()->definition()->range();
- return (right_range == NULL) || !right_range->IsPositive();
- }
- case Token::kSHL: {
- Range* right_range = this->right()->definition()->range();
- if ((right_range != NULL) && !can_overflow()) {
- // Can deoptimize if right can be negative.
- return !right_range->IsPositive();
- }
- return true;
- }
+
+ case Token::kSHR:
+ return !RangeUtils::IsPositive(right()->definition()->range());
+
+ case Token::kSHL:
+ return can_overflow() ||
+ !RangeUtils::IsPositive(right()->definition()->range());
+
case Token::kMOD: {
Range* right_range = this->right()->definition()->range();
return (right_range == NULL) || right_range->Overlaps(0, 0);
@@ -1994,7 +2002,7 @@
Definition* UnboxInstr::Canonicalize(FlowGraph* flow_graph) {
- if (!HasUses()) return NULL;
+ if (!HasUses() && !CanDeoptimize()) return NULL;
// Fold away Unbox<rep>(Box<rep>(v)).
BoxInstr* box_defn = value()->definition()->AsBox();
@@ -2026,7 +2034,7 @@
Definition* UnboxIntegerInstr::Canonicalize(FlowGraph* flow_graph) {
- if (!HasUses()) return NULL;
+ if (!HasUses() && !CanDeoptimize()) return NULL;
// Fold away UnboxInteger<rep_to>(BoxInteger<rep_from>(v)).
BoxIntegerInstr* box_defn = value()->definition()->AsBoxInteger();
@@ -2040,7 +2048,7 @@
box_defn->value()->CopyWithType(),
(representation() == kUnboxedInt32) ?
GetDeoptId() : Isolate::kNoDeoptId);
- if ((representation() == kUnboxedInt32) && is_truncating()) {
+ if ((representation() == kUnboxedInt32) && !CanDeoptimize()) {
converter->mark_truncating();
}
flow_graph->InsertBefore(this, converter, env(), FlowGraph::kValue);
@@ -2071,6 +2079,9 @@
UnboxedConstantInstr* uc =
new UnboxedConstantInstr(c->value(), kUnboxedInt32);
+ if (c->range() != NULL) {
+ uc->set_range(*c->range());
+ }
flow_graph->InsertBefore(this, uc, NULL, FlowGraph::kValue);
return uc;
}
@@ -2250,19 +2261,12 @@
return this;
}
ComparisonInstr* comp = replacement->AsComparison();
- if ((comp == NULL) || comp->CanDeoptimize()) {
+ if ((comp == NULL) ||
+ comp->CanDeoptimize() ||
+ comp->HasUnmatchedInputRepresentations()) {
return this;
}
- // Assert that the comparison is not serving as a pending deoptimization
- // target for conversions.
- for (intptr_t i = 0; i < comp->InputCount(); i++) {
- if (comp->RequiredInputRepresentation(i) !=
- comp->InputAt(i)->definition()->representation()) {
- return this;
- }
- }
-
// Replace the comparison if the replacement is used at this branch,
// and has exactly one use.
Value* use = comp->input_use_list();
« no previous file with comments | « dart/runtime/vm/intermediate_language.h ('k') | dart/runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698