Commit c55da2be authored by darin@apple.com's avatar darin@apple.com

2008-05-27 Darin Adler <darin@apple.com>

        Reviewed by Tim Hatcher.

        - https://bugs.webkit.org/show_bug.cgi?id=19180
          speed up SunSpider by optimizing immediate number cases

        Add immediate number cases for the &, |, and ^ operators.
        Makes standalone SunSpider 1.010x faster.

        * VM/Machine.cpp:
        (KJS::Machine::privateExecute): Add areBothImmediateNumbers special cases
        for the &, |, and ^ operators.

        * kjs/JSImmediate.h:
        (KJS::JSImmediate::xorImmediateNumbers): Added.
        (KJS::JSImmediate::orImmediateNumbers): Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34149 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 15b6da7a
2008-05-27 Darin Adler <darin@apple.com>
Reviewed by Tim Hatcher.
- https://bugs.webkit.org/show_bug.cgi?id=19180
speed up SunSpider by optimizing immediate number cases
Add immediate number cases for the &, |, and ^ operators.
Makes standalone SunSpider 1.010x faster.
* VM/Machine.cpp:
(KJS::Machine::privateExecute): Add areBothImmediateNumbers special cases
for the &, |, and ^ operators.
* kjs/JSImmediate.h:
(KJS::JSImmediate::xorImmediateNumbers): Added.
(KJS::JSImmediate::orImmediateNumbers): Added.
2008-05-26 Stephanie Lewis <slewis@apple.com>
Windows build fix.
......
......@@ -1308,8 +1308,15 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
int dst = (++vPC)->u.operand;
int src1 = (++vPC)->u.operand;
int src2 = (++vPC)->u.operand;
JSValue* result = jsNumber((r[src1].u.jsValue->toInt32(exec)) & (r[src2].u.jsValue->toInt32(exec)));
VM_CHECK_EXCEPTION();
JSValue* v1 = r[src1].u.jsValue;
JSValue* v2 = r[src2].u.jsValue;
JSValue* result;
if (JSImmediate::areBothImmediateNumbers(v1, v2))
result = JSImmediate::andImmediateNumbers(v1, v2);
else {
result = jsNumber(v1->toInt32(exec) & v2->toInt32(exec));
VM_CHECK_EXCEPTION();
}
r[dst].u.jsValue = result;
++vPC;
......@@ -1325,8 +1332,15 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
int dst = (++vPC)->u.operand;
int src1 = (++vPC)->u.operand;
int src2 = (++vPC)->u.operand;
JSValue* result = jsNumber((r[src1].u.jsValue->toInt32(exec)) ^ (r[src2].u.jsValue->toInt32(exec)));
VM_CHECK_EXCEPTION();
JSValue* v1 = r[src1].u.jsValue;
JSValue* v2 = r[src2].u.jsValue;
JSValue* result;
if (JSImmediate::areBothImmediateNumbers(v1, v2))
result = JSImmediate::xorImmediateNumbers(v1, v2);
else {
result = jsNumber(v1->toInt32(exec) ^ v2->toInt32(exec));
VM_CHECK_EXCEPTION();
}
r[dst].u.jsValue = result;
++vPC;
......@@ -1342,8 +1356,15 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
int dst = (++vPC)->u.operand;
int src1 = (++vPC)->u.operand;
int src2 = (++vPC)->u.operand;
JSValue* result = jsNumber((r[src1].u.jsValue->toInt32(exec)) | (r[src2].u.jsValue->toInt32(exec)));
VM_CHECK_EXCEPTION();
JSValue* v1 = r[src1].u.jsValue;
JSValue* v2 = r[src2].u.jsValue;
JSValue* result;
if (JSImmediate::areBothImmediateNumbers(v1, v2))
result = JSImmediate::orImmediateNumbers(v1, v2);
else {
result = jsNumber(v1->toInt32(exec) | v2->toInt32(exec));
VM_CHECK_EXCEPTION();
}
r[dst].u.jsValue = result;
++vPC;
......
......@@ -106,6 +106,18 @@ public:
return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v1) & reinterpret_cast<uintptr_t>(v2));
}
static ALWAYS_INLINE JSValue* xorImmediateNumbers(const JSValue* v1, const JSValue* v2)
{
ASSERT(areBothImmediateNumbers(v1, v2));
return tag(reinterpret_cast<uintptr_t>(v1) ^ reinterpret_cast<uintptr_t>(v2), NumberType);
}
static ALWAYS_INLINE JSValue* orImmediateNumbers(const JSValue* v1, const JSValue* v2)
{
ASSERT(areBothImmediateNumbers(v1, v2));
return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v1) | reinterpret_cast<uintptr_t>(v2));
}
static double toDouble(const JSValue*);
static bool toBoolean(const JSValue*);
static JSObject* toObject(const JSValue*, ExecState*);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment