Changeset 39799 in webkit for trunk/JavaScriptCore/interpreter


Ignore:
Timestamp:
Jan 11, 2009, 11:12:47 AM (16 years ago)
Author:
[email protected]
Message:

Bug 23128: get/put_by_val need to respecialise in the face of ByteArray

Reviewed by Darin Adler and Anders Carlsson

Restructure the code slightly, and add comments per Darin's suggestions

File:
1 edited

Legend:

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

    r39798 r39799  
    51195119            result = JSValuePtr::encode(asString(baseValue)->getIndex(ARG_globalData, i));
    51205120        else if (interpreter->isJSByteArray(baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
     5121            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    51215122            ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val_byte_array));
    51225123            return JSValuePtr::encode(asByteArray(baseValue)->getIndex(i));
     
    51475148    bool isUInt32 = JSImmediate::getUInt32(subscript, i);
    51485149    if (LIKELY(isUInt32)) {
    5149         if (interpreter->isJSByteArray(baseValue) && asByteArray(baseValue)->canAccessIndex(i))
     5150        if (interpreter->isJSByteArray(baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
     5151            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    51505152            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         }
     5153        }
     5154
     5155        result = baseValue->get(callFrame, i);
     5156        if (!interpreter->isJSByteArray(baseValue))
     5157            ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val));
    51565158    } else {
    51575159        Identifier property(callFrame, subscript->toString(callFrame));
     
    52465248        } else if (interpreter->isJSByteArray(baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
    52475249            JSByteArray* jsByteArray = asByteArray(baseValue);
    5248             double dValue = 0;
    52495250            ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_put_by_val_byte_array));
     5251            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    52505252            if (JSImmediate::isNumber(value)) {
    52515253                jsByteArray->setIndex(i, JSImmediate::getTruncatedInt32(value));
    52525254                return;
    5253             } else if (fastIsNumber(value, dValue)) {
    5254                 jsByteArray->setIndex(i, dValue);
    5255                 return;
    5256             } else
    5257                 baseValue->put(callFrame, i, value);
     5255            } else {
     5256                double dValue = 0;
     5257                if (fastIsNumber(value, dValue)) {
     5258                    jsByteArray->setIndex(i, dValue);
     5259                    return;
     5260                }
     5261            }
     5262
     5263            baseValue->put(callFrame, i, value);
    52585264        } else
    52595265            baseValue->put(callFrame, i, value);
     
    53125318        if (interpreter->isJSByteArray(baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
    53135319            JSByteArray* jsByteArray = asByteArray(baseValue);
    5314             double dValue = 0;
     5320           
     5321            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    53155322            if (JSImmediate::isNumber(value)) {
    53165323                jsByteArray->setIndex(i, JSImmediate::getTruncatedInt32(value));
    53175324                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         }
     5325            } else {
     5326                double dValue = 0;               
     5327                if (fastIsNumber(value, dValue)) {
     5328                    jsByteArray->setIndex(i, dValue);
     5329                    return;
     5330                }
     5331            }
     5332        }
     5333
     5334        if (!interpreter->isJSByteArray(baseValue))
     5335            ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_put_by_val));
     5336        baseValue->put(callFrame, i, value);
    53285337    } else {
    53295338        Identifier property(callFrame, subscript->toString(callFrame));
Note: See TracChangeset for help on using the changeset viewer.