Changeset 59055 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
May 9, 2010, 4:18:25 AM (15 years ago)
Author:
[email protected]
Message:

2010-05-09 Maciej Stachowiak <[email protected]>

Fixed version of: "Optimized o[s] where o is a cell and s is a string"
https://bugs.webkit.org/show_bug.cgi?id=38815


Fixed the previous patch for this from Geoff Garen.


The two problems were a missing exception check and a PropertySlot
initialized improperly, leading to crashes and failures in the case
of getters accessed with bracket syntax.

Previous patch:

Optimized o[s] where o is a cell and s is a string, removing some old
code that wasn't really tuned for the JIT.


SunSpider says 0.8% faster.

  • jit/JITStubs.cpp: (JSC::DEFINE_STUB_FUNCTION):
  • runtime/JSCell.h:
Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r59049 r59055  
     12010-05-09  Maciej Stachowiak  <[email protected]>
     2
     3        Fixed version of: "Optimized o[s] where o is a cell and s is a string"
     4        https://bugs.webkit.org/show_bug.cgi?id=38815
     5       
     6        Fixed the previous patch for this from Geoff Garen.
     7       
     8        The two problems were a missing exception check and a PropertySlot
     9        initialized improperly, leading to crashes and failures in the case
     10        of getters accessed with bracket syntax.
     11
     12    Previous patch:
     13
     14        Optimized o[s] where o is a cell and s is a string, removing some old
     15        code that wasn't really tuned for the JIT.
     16       
     17        SunSpider says 0.8% faster.
     18
     19        * jit/JITStubs.cpp:
     20        (JSC::DEFINE_STUB_FUNCTION):
     21        * runtime/JSCell.h:
     22
    1232010-05-08  Laszlo Gombos  <[email protected]>
    224
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r58995 r59055  
    20882088    JSValue subscript = stackFrame.args[1].jsValue();
    20892089
    2090     JSValue result;
    2091 
    2092     if (LIKELY(subscript.isUInt32())) {
     2090    if (LIKELY(baseValue.isCell() && subscript.isString())) {
     2091        Identifier propertyName(callFrame, asString(subscript)->value(callFrame));
     2092        PropertySlot slot(asCell(baseValue));
     2093        if (asCell(baseValue)->fastGetOwnPropertySlot(callFrame, propertyName, slot)) {
     2094            JSValue result = slot.getValue(callFrame, propertyName);
     2095            CHECK_FOR_EXCEPTION();
     2096            return JSValue::encode(result);
     2097        }
     2098    }
     2099
     2100    if (subscript.isUInt32()) {
    20932101        uint32_t i = subscript.asUInt32();
    2094         if (isJSArray(globalData, baseValue)) {
    2095             JSArray* jsArray = asArray(baseValue);
    2096             if (jsArray->canGetIndex(i))
    2097                 result = jsArray->getIndex(i);
    2098             else
    2099                 result = jsArray->JSArray::get(callFrame, i);
    2100         } else if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i)) {
    2101             // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
     2102        if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i)) {
    21022103            ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val_string));
    2103             result = asString(baseValue)->getIndex(callFrame, i);
    2104         } else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
     2104            JSValue result = asString(baseValue)->getIndex(callFrame, i);
     2105            CHECK_FOR_EXCEPTION();
     2106            return JSValue::encode(result);
     2107        }
     2108        if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
    21052109            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    21062110            ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val_byte_array));
    21072111            return JSValue::encode(asByteArray(baseValue)->getIndex(callFrame, i));
    2108         } else
    2109             result = baseValue.get(callFrame, i);
    2110     } else {
    2111         Identifier property(callFrame, subscript.toString(callFrame));
    2112         result = baseValue.get(callFrame, property);
    2113     }
    2114 
     2112        }
     2113        JSValue result = baseValue.get(callFrame, i);
     2114        CHECK_FOR_EXCEPTION();
     2115        return JSValue::encode(result);
     2116    }
     2117   
     2118    Identifier property(callFrame, subscript.toString(callFrame));
     2119    JSValue result = baseValue.get(callFrame, property);
    21152120    CHECK_FOR_EXCEPTION_AT_END();
    21162121    return JSValue::encode(result);
  • trunk/JavaScriptCore/runtime/JSCell.h

    r58995 r59055  
    112112        void setVPtr(void* vptr) { *reinterpret_cast<void**>(this) = vptr; }
    113113
     114        // FIXME: Rename getOwnPropertySlot to virtualGetOwnPropertySlot, and
     115        // fastGetOwnPropertySlot to getOwnPropertySlot. Callers should always
     116        // call this function, not its slower virtual counterpart. (For integer
     117        // property names, we want a similar interface with appropriate optimizations.)
     118        bool fastGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
     119
    114120    protected:
    115121        static const unsigned AnonymousSlotCount = 0;
     
    117123    private:
    118124        // Base implementation; for non-object classes implements getPropertySlot.
    119         bool fastGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    120125        virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    121126        virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
Note: See TracChangeset for help on using the changeset viewer.