Ignore:
Timestamp:
Apr 28, 2009, 5:38:23 PM (16 years ago)
Author:
[email protected]
Message:

Improve performance of string indexing

Reviewed by Geoff Garen

Add a cti_get_by_val_string function to specialise indexing into a string object.
This gives us a slight performance win on a number of string tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r42337 r42976  
    11271127            else
    11281128                result = jsArray->JSArray::get(callFrame, i);
    1129         } else if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i))
     1129        } else if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i)) {
     1130            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
     1131            ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val_string));
    11301132            result = asString(baseValue)->getIndex(ARG_globalData, i);
    1131         else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
     1133        } else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
    11321134            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    11331135            ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val_byte_array));
     
    11431145    return JSValuePtr::encode(result);
    11441146}
     1147   
     1148    JSValueEncodedAsPointer* JITStubs::cti_op_get_by_val_string(STUB_ARGS)
     1149    {
     1150        BEGIN_STUB_FUNCTION();
     1151       
     1152        CallFrame* callFrame = ARG_callFrame;
     1153        JSGlobalData* globalData = ARG_globalData;
     1154       
     1155        JSValuePtr baseValue = ARG_src1;
     1156        JSValuePtr subscript = ARG_src2;
     1157       
     1158        JSValuePtr result;
     1159       
     1160        if (LIKELY(subscript.isUInt32Fast())) {
     1161            uint32_t i = subscript.getUInt32Fast();
     1162            if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i))
     1163                result = asString(baseValue)->getIndex(ARG_globalData, i);
     1164            else {
     1165                result = baseValue.get(callFrame, i);
     1166                if (!isJSString(globalData, baseValue))
     1167                    ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val));
     1168            }
     1169        } else {
     1170            Identifier property(callFrame, subscript.toString(callFrame));
     1171            result = baseValue.get(callFrame, property);
     1172        }
     1173       
     1174        CHECK_FOR_EXCEPTION_AT_END();
     1175        return JSValuePtr::encode(result);
     1176    }
     1177   
    11451178
    11461179JSValueEncodedAsPointer* JITStubs::cti_op_get_by_val_byte_array(STUB_ARGS)
Note: See TracChangeset for help on using the changeset viewer.