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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 11362210: Restrict immediate operands to smi where only smis are supported. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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/flow_graph_optimizer.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_ia32.cc
===================================================================
--- runtime/vm/intermediate_language_ia32.cc (revision 14796)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -284,7 +284,11 @@
LocationSummary* locs =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
locs->set_in(0, Location::RegisterOrConstant(left()));
- locs->set_in(1, Location::RegisterOrConstant(right()));
+ // Only one input can be a constant operand. The case of two constant
+ // operands should be handled by constant propagation.
+ locs->set_in(1, locs->in(0).IsConstant()
+ ? Location::RequiresRegister()
+ : Location::RegisterOrConstant(right()));
locs->set_out(Location::RequiresRegister());
return locs;
}
@@ -608,36 +612,10 @@
BranchInstr* branch) {
Location left = locs.in(0);
Location right = locs.in(1);
+ ASSERT(!left.IsConstant() || !right.IsConstant());
Condition true_condition = TokenKindToSmiCondition(kind);
- if (left.IsConstant() && right.IsConstant()) {
- bool result = false;
- // One of them could be NULL (for equality only).
- if (left.constant().IsNull() || right.constant().IsNull()) {
- ASSERT((kind == Token::kEQ) || (kind == Token::kNE));
- result = left.constant().IsNull() && right.constant().IsNull();
- if (kind == Token::kNE) {
- result = !result;
- }
- } else {
- // TODO(vegorov): should be eliminated earlier by constant propagation.
- result = FlowGraphCompiler::EvaluateCondition(
- true_condition,
- Smi::Cast(left.constant()).Value(),
- Smi::Cast(right.constant()).Value());
- }
-
- if (branch != NULL) {
- branch->EmitBranchOnValue(compiler, result);
- } else {
- __ LoadObject(locs.out().reg(), result ? compiler->bool_true()
- : compiler->bool_false());
- }
-
- return;
- }
-
if (left.IsConstant()) {
__ CompareObject(right.reg(), left.constant());
true_condition = FlowGraphCompiler::FlipCondition(true_condition);
@@ -919,7 +897,11 @@
LocationSummary* summary =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
summary->set_in(0, Location::RegisterOrConstant(left()));
- summary->set_in(1, Location::RegisterOrConstant(right()));
+ // Only one input can be a constant operand. The case of two constant
+ // operands should be handled by constant propagation.
+ summary->set_in(1, summary->in(0).IsConstant()
+ ? Location::RequiresRegister()
+ : Location::RegisterOrConstant(right()));
summary->set_out(Location::RequiresRegister());
return summary;
}
@@ -1717,7 +1699,7 @@
LocationSummary* summary =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
summary->set_in(0, Location::RequiresRegister());
- summary->set_in(1, Location::FixedRegisterOrConstant(right(), ECX));
+ summary->set_in(1, Location::FixedRegisterOrSmiConstant(right(), ECX));
summary->set_out(Location::SameAsFirstInput());
return summary;
} else if (op_kind() == Token::kSHL) {
@@ -1725,7 +1707,7 @@
LocationSummary* summary =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
summary->set_in(0, Location::RequiresRegister());
- summary->set_in(1, Location::FixedRegisterOrConstant(right(), ECX));
+ summary->set_in(1, Location::FixedRegisterOrSmiConstant(right(), ECX));
summary->set_temp(0, Location::RequiresRegister());
summary->set_out(Location::SameAsFirstInput());
return summary;
@@ -1734,7 +1716,7 @@
LocationSummary* summary =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
summary->set_in(0, Location::RequiresRegister());
- summary->set_in(1, Location::RegisterOrConstant(right()));
+ summary->set_in(1, Location::RegisterOrSmiConstant(right()));
summary->set_out(Location::SameAsFirstInput());
return summary;
}
@@ -2369,8 +2351,8 @@
const intptr_t kNumTemps = 0;
LocationSummary* locs =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
- locs->set_in(0, Location::RegisterOrConstant(array()));
- locs->set_in(1, Location::RegisterOrConstant(index()));
+ locs->set_in(0, Location::RegisterOrSmiConstant(array()));
+ locs->set_in(1, Location::RegisterOrSmiConstant(index()));
return locs;
}
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698