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

Unified Diff: runtime/vm/intermediate_language_x64.cc

Issue 281823002: Fix an undetected Smi overflow on ARM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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_mips.cc ('k') | runtime/vm/object.h » ('j') | 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 36182)
+++ runtime/vm/intermediate_language_x64.cc (working copy)
@@ -168,7 +168,7 @@
Utils::ShiftForPowerOfTwo(Utils::Maximum(true_value, false_value));
__ shlq(RDX, Immediate(shift + kSmiTagSize));
} else {
- __ AddImmediate(RDX, Immediate(-1), PP);
+ __ decq(RDX);
__ AndImmediate(RDX,
Immediate(Smi::RawValue(true_value) - Smi::RawValue(false_value)), PP);
if (false_value != 0) {
@@ -2739,17 +2739,22 @@
if (locs()->in(1).IsConstant()) {
const Object& constant = locs()->in(1).constant();
ASSERT(constant.IsSmi());
- const int64_t imm =
- reinterpret_cast<int64_t>(constant.raw());
+ const int64_t imm = reinterpret_cast<int64_t>(constant.raw());
switch (op_kind()) {
case Token::kADD: {
- __ AddImmediate(left, Immediate(imm), PP);
- if (deopt != NULL) __ j(OVERFLOW, deopt);
+ if (imm != 0) {
+ // Checking overflow without emitting an instruction would be wrong.
+ __ AddImmediate(left, Immediate(imm), PP);
+ if (deopt != NULL) __ j(OVERFLOW, deopt);
+ }
break;
}
case Token::kSUB: {
- __ AddImmediate(left, Immediate(-imm), PP);
- if (deopt != NULL) __ j(OVERFLOW, deopt);
+ if (imm != 0) {
+ // Checking overflow without emitting an instruction would be wrong.
+ __ SubImmediate(left, Immediate(imm), PP);
+ if (deopt != NULL) __ j(OVERFLOW, deopt);
+ }
break;
}
case Token::kMUL: {
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698