Index: runtime/vm/intermediate_language_x64.cc |
=================================================================== |
--- runtime/vm/intermediate_language_x64.cc (revision 25732) |
+++ runtime/vm/intermediate_language_x64.cc (working copy) |
@@ -2151,20 +2151,15 @@ |
} |
-static void Emit54BitOverflowCheck(FlowGraphCompiler* compiler, |
- Label* overflow, |
- Register result) { |
+static void EmitJavascriptOverflowCheck(FlowGraphCompiler* compiler, |
+ Label* overflow, |
+ Register result) { |
if (FLAG_throw_on_javascript_int_overflow) { |
ASSERT(overflow != NULL); |
- __ movq(TMP, result); // result is a tagged Smi. |
- // Bits 55...64 must be all 0 or all 1. (It would be bit 54, but result |
- // is tagged.) |
- __ shlq(result, Immediate(64 - 55)); |
- __ sarq(result, Immediate(64 - 55)); |
- __ cmpq(result, TMP); |
- __ j(NOT_EQUAL, overflow); // 54-bit overflow. |
- __ cmpq(result, Immediate(-0x1FFFFFFFFFFFFFLL - 1)); |
- __ j(EQUAL, overflow); // The most negative 54-bit int is also disallowed. |
+ __ cmpq(result, Immediate(-0x20000000000000)); |
+ __ j(LESS, overflow); |
+ __ cmpq(result, Immediate(0x20000000000000)); |
+ __ j(GREATER, overflow); |
} |
} |
@@ -2208,7 +2203,7 @@ |
// Shift for result now we know there is no overflow. |
__ shlq(left, Immediate(value)); |
} |
- Emit54BitOverflowCheck(compiler, deopt, result); |
+ EmitJavascriptOverflowCheck(compiler, deopt, result); |
return; |
} |
@@ -2238,7 +2233,7 @@ |
__ SmiUntag(right); |
__ shlq(left, right); |
} |
- Emit54BitOverflowCheck(compiler, deopt, result); |
+ EmitJavascriptOverflowCheck(compiler, deopt, result); |
return; |
} |
@@ -2289,7 +2284,7 @@ |
// Shift for result now we know there is no overflow. |
__ shlq(left, right); |
} |
- Emit54BitOverflowCheck(compiler, deopt, result); |
+ EmitJavascriptOverflowCheck(compiler, deopt, result); |
} |
@@ -2488,7 +2483,7 @@ |
UNREACHABLE(); |
break; |
} |
- Emit54BitOverflowCheck(compiler, deopt, result); |
+ EmitJavascriptOverflowCheck(compiler, deopt, result); |
return; |
} // locs()->in(1).IsConstant(). |
@@ -2531,7 +2526,7 @@ |
UNREACHABLE(); |
break; |
} |
- Emit54BitOverflowCheck(compiler, deopt, result); |
+ EmitJavascriptOverflowCheck(compiler, deopt, result); |
return; |
} // locs()->in(1).IsStackSlot(). |
@@ -2661,7 +2656,7 @@ |
UNREACHABLE(); |
break; |
} |
- Emit54BitOverflowCheck(compiler, deopt, result); |
+ EmitJavascriptOverflowCheck(compiler, deopt, result); |
} |
@@ -3839,7 +3834,7 @@ |
kDeoptUnaryOp); |
__ negq(value); |
__ j(OVERFLOW, deopt); |
- Emit54BitOverflowCheck(compiler, deopt, value); |
+ EmitJavascriptOverflowCheck(compiler, deopt, value); |
break; |
} |
case Token::kBIT_NOT: |
@@ -3900,7 +3895,7 @@ |
__ shlq(temp, Immediate(1)); |
__ j(OVERFLOW, &do_call, Assembler::kNearJump); |
__ SmiTag(result); |
- Emit54BitOverflowCheck(compiler, &do_call, result); |
+ EmitJavascriptOverflowCheck(compiler, &do_call, result); |
__ jmp(&done); |
__ Bind(&do_call); |
ASSERT(instance_call()->HasICData()); |
@@ -3946,7 +3941,7 @@ |
__ shlq(temp, Immediate(1)); |
__ j(OVERFLOW, deopt); |
__ SmiTag(result); |
- Emit54BitOverflowCheck(compiler, deopt, result); |
+ EmitJavascriptOverflowCheck(compiler, deopt, result); |
} |