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

Unified Diff: runtime/vm/intrinsifier_ia32.cc

Issue 10663006: Expand ia32 intrinsic for integer modulo, implement it for x64. Next step will be to emit it direct… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 | « no previous file | runtime/vm/intrinsifier_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intrinsifier_ia32.cc
===================================================================
--- runtime/vm/intrinsifier_ia32.cc (revision 9046)
+++ runtime/vm/intrinsifier_ia32.cc (working copy)
@@ -586,10 +586,8 @@
}
-// Simple implementation: for positive dividend values greater than divisor,
-// return dividend.
bool Intrinsifier::Integer_modulo(Assembler* assembler) {
- Label fall_through, return_zero;
+ Label fall_through, return_zero, try_modulo;
TestBothArgumentsSmis(assembler, &fall_through);
// EAX: right argument (divisor)
// Check if modulo by zero -> exception thrown in main function.
@@ -600,12 +598,23 @@
__ j(LESS, &fall_through, Assembler::kNearJump);
__ cmpl(EBX, EAX);
__ j(EQUAL, &return_zero, Assembler::kNearJump);
- __ j(GREATER, &fall_through, Assembler::kNearJump);
- __ movl(EAX, EBX); // Return dividend.
+ __ j(GREATER, &try_modulo, Assembler::kNearJump);
+ __ movl(EAX, EBX); // Return dividend as it is smaller than divisor.
__ ret();
__ Bind(&return_zero);
__ xorl(EAX, EAX); // Return zero.
__ ret();
+ __ Bind(&try_modulo);
+ // EAX: right (non-null divisor).
+ __ movl(EBX, EAX);
+ __ SmiUntag(EBX);
+ __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Left argument (dividend).
+ __ SmiUntag(EAX);
+ __ cdq();
+ __ idivl(EBX);
+ __ movl(EAX, EDX);
+ __ SmiTag(EAX);
+ __ ret();
__ Bind(&fall_through);
return false;
}
« no previous file with comments | « no previous file | runtime/vm/intrinsifier_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698