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

Unified Diff: vm/opt_code_generator_ia32.cc

Issue 8931016: Fix truncate divide bug (reported by sra) when dividing MIN_SMI by -1. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 9 years 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 | « vm/intrinsifier_ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/opt_code_generator_ia32.cc
===================================================================
--- vm/opt_code_generator_ia32.cc (revision 2397)
+++ vm/opt_code_generator_ia32.cc (working copy)
@@ -860,16 +860,25 @@
break;
}
case Token::kTRUNCDIV: {
- // Handle Divide by zero in runtime.
+ // Handle divide by zero in runtime.
__ cmpl(EDX, Immediate(0));
__ j(EQUAL, overflow_label);
+ // Preserve left & right in case of 'overflow'.
+ __ pushl(EDX);
+ __ pushl(ECX);
// Move right to ECX, left is in EAX.
__ movl(ECX, EDX);
__ SmiUntag(ECX);
__ SmiUntag(EAX);
// Sign extend EAX -> EDX:EAX.
__ cdq();
- __ idivl(ECX);
+ __ idivl(ECX); // Result in EAX.
+ __ popl(ECX);
+ __ popl(EDX);
+ // Check the corner case of dividing the 'MIN_SMI' with -1, in which
+ // case we cannot tag the result.
+ __ cmpl(EAX, Immediate(0x40000000));
+ __ j(EQUAL, overflow_label);
__ SmiTag(EAX);
break;
}
« no previous file with comments | « vm/intrinsifier_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698