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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.