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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 755383002: Fix overflow check when shifting unboxed mints on 32-bit platforms, except on (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 1 month 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_arm.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 42002)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -6068,7 +6068,6 @@
__ movl(temp1, left_hi); // Preserve high 32 bits.
if (shift > 31) {
__ movl(left_hi, left_lo); // Shift by 32.
- __ xorl(left_lo, left_lo); // Zero left_lo.
if (shift > 32) {
__ shll(left_hi, Immediate(shift - 32));
}
@@ -6078,6 +6077,15 @@
__ sarl(temp2, Immediate(31));
__ cmpl(temp1, temp2);
__ j(NOT_EQUAL, deopt);
+ if (shift > 32) {
+ // Also compare low word from input with high word from
+ // output shifted back shift - 32.
+ __ movl(temp2, left_hi);
+ __ sarl(temp2, Immediate(shift - 32));
+ __ cmpl(left_lo, temp2);
+ __ j(NOT_EQUAL, deopt);
+ }
+ __ xorl(left_lo, left_lo); // Zero left_lo.
} else {
__ shldl(left_hi, left_lo, Immediate(shift));
__ shll(left_lo, Immediate(shift));
@@ -6153,7 +6161,6 @@
__ Bind(&large_shift);
// No need to subtract 32 from CL, only 5 bits used by shll.
__ movl(left_hi, left_lo); // Shift by 32.
- __ xorl(left_lo, left_lo); // Zero left_lo.
__ shll(left_hi, ECX); // Shift count: CL % 32.
// Check for overflow by sign extending the high 32 bits
// and comparing with the input.
@@ -6161,6 +6168,13 @@
__ sarl(temp2, Immediate(31));
__ cmpl(temp1, temp2);
__ j(NOT_EQUAL, deopt);
+ // Also compare low word from input with high word from
+ // output shifted back shift - 32.
+ __ movl(temp2, left_hi);
+ __ sarl(temp2, ECX); // Shift count: CL % 32.
+ __ cmpl(left_lo, temp2);
+ __ j(NOT_EQUAL, deopt);
+ __ xorl(left_lo, left_lo); // Zero left_lo.
} else {
__ cmpl(ECX, Immediate(31));
__ j(ABOVE, &large_shift);
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698