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

Unified Diff: runtime/vm/intermediate_language_arm.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/ast.cc ('k') | runtime/vm/intermediate_language_arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_arm.cc
===================================================================
--- runtime/vm/intermediate_language_arm.cc (revision 36182)
+++ runtime/vm/intermediate_language_arm.cc (working copy)
@@ -2959,12 +2959,8 @@
if (locs()->in(1).IsConstant()) {
const Object& constant = locs()->in(1).constant();
ASSERT(constant.IsSmi());
- int32_t imm = reinterpret_cast<int32_t>(constant.raw());
+ const int32_t imm = reinterpret_cast<int32_t>(constant.raw());
switch (op_kind()) {
- case Token::kSUB: {
- imm = -imm; // TODO(regis): What if deopt != NULL && imm == 0x80000000?
- // Fall through.
- }
case Token::kADD: {
if (deopt == NULL) {
__ AddImmediate(result, left, imm);
@@ -2974,6 +2970,17 @@
}
break;
}
+ case Token::kSUB: {
+ if (deopt == NULL) {
+ __ AddImmediate(result, left, -imm);
+ } else {
+ // Negating imm and using AddImmediateSetFlags would not detect the
+ // overflow when imm == kMinInt32.
+ __ SubImmediateSetFlags(result, left, imm);
+ __ b(deopt, VS);
+ }
+ break;
+ }
case Token::kMUL: {
// Keep left value tagged and untag right value.
const intptr_t value = Smi::Cast(constant).Value();
@@ -3044,8 +3051,9 @@
ShifterOperand shifter_op;
if (ShifterOperand::CanHold(imm, &shifter_op)) {
__ and_(result, left, shifter_op);
+ } else if (ShifterOperand::CanHold(~imm, &shifter_op)) {
+ __ bic(result, left, shifter_op);
} else {
- // TODO(regis): Try to use bic.
__ LoadImmediate(IP, imm);
__ and_(result, left, ShifterOperand(IP));
}
@@ -3057,7 +3065,6 @@
if (ShifterOperand::CanHold(imm, &shifter_op)) {
__ orr(result, left, shifter_op);
} else {
- // TODO(regis): Try to use orn.
__ LoadImmediate(IP, imm);
__ orr(result, left, ShifterOperand(IP));
}
« no previous file with comments | « runtime/vm/ast.cc ('k') | runtime/vm/intermediate_language_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698