Ignore:
Timestamp:
May 28, 2008, 2:47:29 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

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

2% speedup overall, maximum 10% on controlflow-recursive and bitops-3bit-bits-in-byte,
but a 4% regression on bitops-bits-in-byte and bitops-bitwise-and.

  • kjs/JSImmediate.h: (KJS::JSImmediate::canDoFastAdditiveOperations): (KJS::JSImmediate::addImmediateNumbers): (KJS::JSImmediate::subImmediateNumbers): Added fast cases that work with positive values less than 230.
  • VM/Machine.cpp: (KJS::Machine::privateExecute): Use the above operations. Also updated SunSpider frequencies with my results (looks like tag values have changed, not sure what caused the minor variation in actual frequencies).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSImmediate.h

    r34149 r34170  
    119119    }
    120120
     121    static ALWAYS_INLINE bool canDoFastAdditiveOperations(const JSValue* v)
     122    {
     123        // Number is positive and an operation involving two of these can't overflow.
     124        // Checking for allowed negative numbers takes more time than it's worth on SunSpider.
     125        return (reinterpret_cast<uintptr_t>(v) & (NumberType + (3 << 30))) == NumberType;
     126    }
     127
     128    static ALWAYS_INLINE JSValue* addImmediateNumbers(const JSValue* v1, const JSValue* v2)
     129    {
     130        ASSERT(canDoFastAdditiveOperations(v1));
     131        ASSERT(canDoFastAdditiveOperations(v2));
     132        return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v1) + (reinterpret_cast<uintptr_t>(v2) & ~NumberType));
     133    }
     134
     135    static ALWAYS_INLINE JSValue* subImmediateNumbers(const JSValue* v1, const JSValue* v2)
     136    {
     137        ASSERT(canDoFastAdditiveOperations(v1));
     138        ASSERT(canDoFastAdditiveOperations(v2));
     139        return reinterpret_cast<JSValue*>(reinterpret_cast<uintptr_t>(v1) - (reinterpret_cast<uintptr_t>(v2) & ~NumberType));
     140    }
     141
    121142    static double toDouble(const JSValue*);
    122143    static bool toBoolean(const JSValue*);
Note: See TracChangeset for help on using the changeset viewer.