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

Unified Diff: runtime/vm/intermediate_language_x64.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_ia32.cc ('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_x64.cc
===================================================================
--- runtime/vm/intermediate_language_x64.cc (revision 11146)
+++ runtime/vm/intermediate_language_x64.cc (working copy)
@@ -1442,13 +1442,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(RCX));
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.
@@ -1462,13 +1461,12 @@
summary->set_temp(1, Location::RegisterLocation(RCX));
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;
}
}
@@ -1478,32 +1476,19 @@
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) {
- __ movq(temp, left);
- __ orq(temp, right);
- __ testq(temp, Immediate(kSmiTagMask));
- __ j(NOT_ZERO, deopt);
- }
switch (op_kind()) {
case Token::kADD: {
__ addq(left, right);
@@ -1537,6 +1522,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.
__ testq(right, right);
@@ -1577,6 +1563,7 @@
break;
}
case Token::kSHL: {
+ Register temp = locs()->temp(0).reg();
Label call_method, done;
// Check if count too large for handling it inlined.
__ movq(temp, left);
@@ -2205,6 +2192,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);
+ __ testq(value, Immediate(kSmiTagMask));
+ __ j(NOT_ZERO, deopt);
+}
+
+
} // namespace dart
#undef __
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698