Index: src/arm/lithium-codegen-arm.cc |
=================================================================== |
--- src/arm/lithium-codegen-arm.cc (revision 12559) |
+++ src/arm/lithium-codegen-arm.cc (working copy) |
@@ -979,7 +979,28 @@ |
Register left = ToRegister(instr->left()); |
Register right = ToRegister(instr->right()); |
Register result = ToRegister(instr->result()); |
+#if CAN_USE_INTEGER_DIVISION |
danno
2012/09/27 15:28:09
Need to be a runtime check rather than a compile-t
|
+ // Check for x % 0. |
+ if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { |
+ __ cmp(right, Operand(0)); |
+ DeoptimizeIf(eq, instr->environment()); |
+ } |
+ Label done; |
+ // For r3 = r1 % r2; we can have the following ARM code |
+ // sdiv r3, r1, r2 |
+ // mls r3, r3, r2, r1 |
+ |
+ __ sdiv(result, left, right); |
+ __ mls(result, result, right, left); |
+ __ cmp(result, Operand(0)); |
+ __ b(ne, &done); |
+ |
+ if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
+ __ cmp(left, Operand(0)); |
+ DeoptimizeIf(lt, instr->environment()); |
+ } |
+#else |
Register scratch = scratch0(); |
Register scratch2 = ToRegister(instr->temp()); |
DwVfpRegister dividend = ToDoubleRegister(instr->temp2()); |
@@ -1081,7 +1102,7 @@ |
// Load the result and we are done. |
__ mov(result, scratch2); |
} |
- |
+#endif |
__ bind(&done); |
} |