Ignore:
Timestamp:
May 7, 2010, 7:18:45 PM (15 years ago)
Author:
[email protected]
Message:

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.

Reviewed by Darin Adler.

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

    r58286 r58990  
    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;
     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)) {
     2102        if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i)) {
    21012103            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    21022104            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)) {
     2105            JSValue result = asString(baseValue)->getIndex(callFrame, i);
     2106            CHECK_FOR_EXCEPTION();
     2107            return JSValue::encode(result);
     2108        }
     2109        if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
    21052110            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    21062111            ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val_byte_array));
    21072112            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 
     2113        }
     2114        return JSValue::encode(baseValue.get(callFrame, i));
     2115    }
     2116   
     2117    Identifier property(callFrame, subscript.toString(callFrame));
     2118    JSValue result = baseValue.get(callFrame, property);
    21152119    CHECK_FOR_EXCEPTION_AT_END();
    21162120    return JSValue::encode(result);
Note: See TracChangeset for help on using the changeset viewer.