Changeset 39796 in webkit for trunk/JavaScriptCore/interpreter


Ignore:
Timestamp:
Jan 11, 2009, 8:48:39 AM (16 years ago)
Author:
[email protected]
Message:

Bug 23128: get/put_by_val need to respecialise in the face of ByteArray
<https://bugs.webkit.org/show_bug.cgi?id=23128>

Reviewed by Anders Carlsson.

Fairly simple patch, add specialised versions of cti_op_get/put_by_val
that assume ByteArray, thus avoiding a few branches in the case of bytearray
manipulation.

No effect on SunSpider. 15% win on the original testcase.

Location:
trunk/JavaScriptCore/interpreter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r39752 r39796  
    51185118        } else if (interpreter->isJSString(baseValue) && asString(baseValue)->canGetIndex(i))
    51195119            return JSValuePtr::encode(asString(baseValue)->getIndex(ARG_globalData, i));
    5120         else if (interpreter->isJSByteArray(baseValue) && asByteArray(baseValue)->canAccessIndex(i))
     5120        else if (interpreter->isJSByteArray(baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
     5121            ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val_byte_array));
    51215122            return JSValuePtr::encode(asByteArray(baseValue)->getIndex(i));
    5122         else
     5123        } else
    51235124            result = baseValue->get(callFrame, i);
    51245125    } else {
     
    51275128    }
    51285129
     5130    CHECK_FOR_EXCEPTION_AT_END();
     5131    return JSValuePtr::encode(result);
     5132}
     5133
     5134JSValueEncodedAsPointer* Interpreter::cti_op_get_by_val_byte_array(STUB_ARGS)
     5135{
     5136    BEGIN_STUB_FUNCTION();
     5137   
     5138    CallFrame* callFrame = ARG_callFrame;
     5139    Interpreter* interpreter = ARG_globalData->interpreter;
     5140   
     5141    JSValuePtr baseValue = ARG_src1;
     5142    JSValuePtr subscript = ARG_src2;
     5143   
     5144    JSValuePtr result;
     5145    unsigned i;
     5146   
     5147    bool isUInt32 = JSImmediate::getUInt32(subscript, i);
     5148    if (LIKELY(isUInt32)) {
     5149        if (interpreter->isJSByteArray(baseValue) && asByteArray(baseValue)->canAccessIndex(i))
     5150            return JSValuePtr::encode(asByteArray(baseValue)->getIndex(i));
     5151        else {
     5152            result = baseValue->get(callFrame, i);
     5153            if (!interpreter->isJSByteArray(baseValue))
     5154                ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val));
     5155        }
     5156    } else {
     5157        Identifier property(callFrame, subscript->toString(callFrame));
     5158        result = baseValue->get(callFrame, property);
     5159    }
     5160   
    51295161    CHECK_FOR_EXCEPTION_AT_END();
    51305162    return JSValuePtr::encode(result);
     
    52155247            JSByteArray* jsByteArray = asByteArray(baseValue);
    52165248            double dValue = 0;
     5249            ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_put_by_val_byte_array));
    52175250            if (JSImmediate::isNumber(value)) {
    52185251                jsByteArray->setIndex(i, JSImmediate::getTruncatedInt32(value));
     
    52625295}
    52635296
     5297void Interpreter::cti_op_put_by_val_byte_array(STUB_ARGS)
     5298{
     5299    BEGIN_STUB_FUNCTION();
     5300   
     5301    CallFrame* callFrame = ARG_callFrame;
     5302    Interpreter* interpreter = ARG_globalData->interpreter;
     5303   
     5304    JSValuePtr baseValue = ARG_src1;
     5305    JSValuePtr subscript = ARG_src2;
     5306    JSValuePtr value = ARG_src3;
     5307   
     5308    unsigned i;
     5309   
     5310    bool isUInt32 = JSImmediate::getUInt32(subscript, i);
     5311    if (LIKELY(isUInt32)) {
     5312        if (interpreter->isJSByteArray(baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
     5313            JSByteArray* jsByteArray = asByteArray(baseValue);
     5314            double dValue = 0;
     5315            if (JSImmediate::isNumber(value)) {
     5316                jsByteArray->setIndex(i, JSImmediate::getTruncatedInt32(value));
     5317                return;
     5318            } else if (fastIsNumber(value, dValue)) {
     5319                jsByteArray->setIndex(i, dValue);
     5320                return;
     5321            } else
     5322                baseValue->put(callFrame, i, value);
     5323        } else {
     5324            if (!interpreter->isJSByteArray(baseValue))
     5325                ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_put_by_val));
     5326            baseValue->put(callFrame, i, value);
     5327        }
     5328    } else {
     5329        Identifier property(callFrame, subscript->toString(callFrame));
     5330        if (!ARG_globalData->exception) { // Don't put to an object if toString threw an exception.
     5331            PutPropertySlot slot;
     5332            baseValue->put(callFrame, property, value, slot);
     5333        }
     5334    }
     5335   
     5336    CHECK_FOR_EXCEPTION_AT_END();
     5337}
     5338
    52645339JSValueEncodedAsPointer* Interpreter::cti_op_lesseq(STUB_ARGS)
    52655340{
  • trunk/JavaScriptCore/interpreter/Interpreter.h

    r39670 r39796  
    222222        static JSValueEncodedAsPointer* JIT_STUB cti_op_construct_NotJSConstruct(STUB_ARGS);
    223223        static JSValueEncodedAsPointer* JIT_STUB cti_op_get_by_val(STUB_ARGS);
     224        static JSValueEncodedAsPointer* JIT_STUB cti_op_get_by_val_byte_array(STUB_ARGS);
    224225        static VoidPtrPair JIT_STUB cti_op_resolve_func(STUB_ARGS);
    225226        static JSValueEncodedAsPointer* JIT_STUB cti_op_sub(STUB_ARGS);
    226227        static void JIT_STUB cti_op_put_by_val(STUB_ARGS);
    227228        static void JIT_STUB cti_op_put_by_val_array(STUB_ARGS);
     229        static void JIT_STUB cti_op_put_by_val_byte_array(STUB_ARGS);
    228230        static JSValueEncodedAsPointer* JIT_STUB cti_op_lesseq(STUB_ARGS);
    229231        static int JIT_STUB cti_op_loop_if_true(STUB_ARGS);
Note: See TracChangeset for help on using the changeset viewer.