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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 10867012: Add a smi-check instruction for arithmetic smi operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 8 years, 4 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.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 11146)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -1426,13 +1426,12 @@
summary->set_temp(2, Location::RequiresRegister());
return summary;
} else if (op_kind() == Token::kSHR) {
- const intptr_t kNumTemps = 1;
+ const intptr_t kNumTemps = 0;
LocationSummary* summary =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
summary->set_in(0, Location::RequiresRegister());
summary->set_in(1, Location::RegisterLocation(ECX));
summary->set_out(Location::SameAsFirstInput());
- summary->set_temp(0, Location::RequiresRegister());
return summary;
} else if (op_kind() == Token::kSHL) {
// Two Smi operands can easily overflow into Mint.
@@ -1446,13 +1445,12 @@
summary->set_out(Location::RegisterLocation(EAX));
return summary;
} else {
- const intptr_t kNumTemps = 1;
+ const intptr_t kNumTemps = 0;
LocationSummary* summary =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
summary->set_in(0, Location::RequiresRegister());
summary->set_in(1, Location::RequiresRegister());
summary->set_out(Location::SameAsFirstInput());
- summary->set_temp(0, Location::RequiresRegister());
return summary;
}
}
@@ -1462,32 +1460,20 @@
Register left = locs()->in(0).reg();
Register right = locs()->in(1).reg();
Register result = locs()->out().reg();
- Register temp = locs()->temp(0).reg();
ASSERT(left == result);
- const bool left_is_smi = this->left()->ResultCid() == kSmiCid;
- const bool right_is_smi = this->right()->ResultCid() == kSmiCid;
- bool can_deopt;
+ Label* deopt = NULL;
switch (op_kind()) {
case Token::kBIT_AND:
case Token::kBIT_OR:
case Token::kBIT_XOR:
- can_deopt = !(right_is_smi && left_is_smi);
+ // Can't deoptimize. Arguments are already checked for smi.
break;
default:
- can_deopt = true;
+ deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
+ instance_call()->try_index(),
+ kDeoptBinarySmiOp);
}
- Label* deopt = NULL;
- if (can_deopt) {
- deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
- instance_call()->try_index(),
- kDeoptBinarySmiOp);
- }
- if (!left_is_smi || !right_is_smi) {
- __ movl(temp, left);
- __ orl(temp, right);
- __ testl(temp, Immediate(kSmiTagMask));
- __ j(NOT_ZERO, deopt);
- }
+
switch (op_kind()) {
case Token::kADD: {
__ addl(left, right);
@@ -1521,6 +1507,7 @@
break;
}
case Token::kTRUNCDIV: {
+ Register temp = locs()->temp(0).reg();
// Handle divide by zero in runtime.
// Deoptimization requires that temp and right are preserved.
__ testl(right, right);
@@ -1561,6 +1548,7 @@
break;
}
case Token::kSHL: {
+ Register temp = locs()->temp(0).reg();
Label call_method, done;
// Check if count too large for handling it inlined.
__ movl(temp, left);
@@ -2192,6 +2180,27 @@
__ Bind(&is_ok);
}
+
+LocationSummary* CheckSmiComp::MakeLocationSummary() const {
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* summary =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ summary->set_in(0, Location::RequiresRegister());
+ return summary;
+}
+
+
+void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) {
+ Register value = locs()->in(0).reg();
+ Label* deopt = compiler->AddDeoptStub(deopt_id(),
+ try_index(),
+ kDeoptCheckSmi);
+ __ testl(value, Immediate(kSmiTagMask));
+ __ j(NOT_ZERO, deopt);
+}
+
+
} // namespace dart
#undef __
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698