+2008-08-05 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Cameron.
+
+ - add fast path for immediates to % operator, as we have for many other math ops
+
+ This fixes handling for a 0 divisor relative to the last patch. Only an 0.2% speedup on SunSpider but
+ still a 1.4x win on Oliver's prime test.
+
+ * VM/Machine.cpp:
+ (KJS::Machine::privateExecute):
+
2008-08-05 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Darin.
int dst = (++vPC)->u.operand;
int dividend = (++vPC)->u.operand;
int divisor = (++vPC)->u.operand;
- double d = r[dividend].jsValue(exec)->toNumber(exec);
- JSValue* result = jsNumber(exec, fmod(d, r[divisor].jsValue(exec)->toNumber(exec)));
+
+ JSValue* dividendValue = r[dividend].jsValue(exec);
+ JSValue* divisorValue = r[divisor].jsValue(exec);
+
+ if (JSImmediate::areBothImmediateNumbers(dividendValue, divisorValue) && divisorValue != JSImmediate::from(0)) {
+ r[dst] = JSImmediate::from(JSImmediate::getTruncatedInt32(dividendValue) % JSImmediate::getTruncatedInt32(divisorValue));
+ ++vPC;
+ NEXT_OPCODE;
+ }
+
+ double d = dividendValue->toNumber(exec);
+ JSValue* result = jsNumber(exec, fmod(d, divisorValue->toNumber(exec)));
VM_CHECK_EXCEPTION();
r[dst] = result;
++vPC;