Ignore:
Timestamp:
Dec 18, 2008, 9:45:44 AM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-12-17 Geoffrey Garen <[email protected]>

Reviewed by Gavin Barraclough.


Fixed https://bugs.webkit.org/show_bug.cgi?id=22393
Segfault when caching property accesses to primitive cells.


Changed some asObject casts to asCell casts in cases where a primitive
value may be a cell and not an object.


Re-enabled property caching for primitives in cases where it had been
disabled because of this bug.


Updated a comment to better explain something Darin thought needed
explaining in an old patch review.

  • interpreter/Interpreter.cpp: (JSC::countPrototypeChainEntriesAndCheckForProxies): (JSC::Interpreter::tryCacheGetByID): (JSC::Interpreter::tryCTICacheGetByID): (JSC::Interpreter::cti_op_get_by_id_self_fail): (JSC::Interpreter::cti_op_get_by_id_proto_list):

LayoutTests:

2008-12-17 Geoffrey Garen <[email protected]>

Reviewed by Gavin Barraclough.


Added a test for https://bugs.webkit.org/show_bug.cgi?id=22393
Segfault when caching property accesses to primitive cells.

  • fast/js/primitive-property-access-edge-cases-expected.txt: Added.
  • fast/js/primitive-property-access-edge-cases.html: Added.
  • fast/js/resources/primitive-property-access-edge-cases.js: Added. ():
File:
1 edited

Legend:

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

    r39370 r39374  
    13151315static size_t countPrototypeChainEntriesAndCheckForProxies(CallFrame* callFrame, JSValue* baseValue, const PropertySlot& slot)
    13161316{
    1317     JSObject* o = asObject(baseValue);
     1317    JSCell* cell = asCell(baseValue);
    13181318    size_t count = 0;
    13191319
    1320     while (slot.slotBase() != o) {
    1321         JSValue* v = o->structure()->prototypeForLookup(callFrame);
     1320    while (slot.slotBase() != cell) {
     1321        JSValue* v = cell->structure()->prototypeForLookup(callFrame);
    13221322
    13231323        // If we didn't find slotBase in baseValue's prototype chain, then baseValue
     
    13271327            return 0;
    13281328
    1329         o = asObject(v);
    1330 
    1331         // Heavy access to a prototype is a good indication that it's not being
    1332         // used as a dictionary.
    1333         if (o->structure()->isDictionary()) {
    1334             RefPtr<Structure> transition = Structure::fromDictionaryTransition(o->structure());
    1335             o->setStructure(transition.release());
    1336             asObject(baseValue)->structure()->setCachedPrototypeChain(0);
     1329        cell = asCell(v);
     1330
     1331        // Since we're accessing a prototype in a loop, it's a good bet that it
     1332        // should not be treated as a dictionary.
     1333        if (cell->structure()->isDictionary()) {
     1334            RefPtr<Structure> transition = Structure::fromDictionaryTransition(cell->structure());
     1335            asObject(cell)->setStructure(transition.release());
     1336            cell->structure()->setCachedPrototypeChain(0);
    13371337        }
    13381338
     
    14081408        JSObject* baseObject = asObject(slot.slotBase());
    14091409
    1410         // Heavy access to a prototype is a good indication that it's not being
    1411         // used as a dictionary.
     1410        // Since we're accessing a prototype in a loop, it's a good bet that it
     1411        // should not be treated as a dictionary.
    14121412        if (baseObject->structure()->isDictionary()) {
    14131413            RefPtr<Structure> transition = Structure::fromDictionaryTransition(baseObject->structure());
     
    41794179        JSObject* slotBaseObject = asObject(slot.slotBase());
    41804180
    4181         // Heavy access to a prototype is a good indication that it's not being
    4182         // used as a dictionary.
     4181        // Since we're accessing a prototype in a loop, it's a good bet that it
     4182        // should not be treated as a dictionary.
    41834183        if (slotBaseObject->structure()->isDictionary()) {
    41844184            RefPtr<Structure> transition = Structure::fromDictionaryTransition(slotBaseObject->structure());
    41854185            slotBaseObject->setStructure(transition.release());
    4186             asObject(baseValue)->structure()->setCachedPrototypeChain(0);
     4186            asCell(baseValue)->structure()->setCachedPrototypeChain(0);
    41874187        }
    41884188       
     
    45554555    CHECK_FOR_EXCEPTION();
    45564556
    4557     if (baseValue->isObject()
     4557    if (!JSImmediate::isImmediate(baseValue)
    45584558        && slot.isCacheable()
    45594559        && !asCell(baseValue)->structure()->isDictionary()
     
    46294629    CHECK_FOR_EXCEPTION();
    46304630
    4631     if (!baseValue->isObject() || !slot.isCacheable() || asCell(baseValue)->structure()->isDictionary()) {
     4631    if (JSImmediate::isImmediate(baseValue) || !slot.isCacheable() || asCell(baseValue)->structure()->isDictionary()) {
    46324632        ctiRepatchCallByReturnAddress(CTI_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_id_proto_fail));
    46334633        return result;
     
    46444644        ctiRepatchCallByReturnAddress(CTI_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_id_proto_fail));
    46454645    else if (slot.slotBase() == asCell(baseValue)->structure()->prototypeForLookup(callFrame)) {
    4646         // Heavy access to a prototype is a good indication that it's not being
    4647         // used as a dictionary.
     4646        // Since we're accessing a prototype in a loop, it's a good bet that it
     4647        // should not be treated as a dictionary.
    46484648        if (slotBaseObject->structure()->isDictionary()) {
    46494649            RefPtr<Structure> transition = Structure::fromDictionaryTransition(slotBaseObject->structure());
    46504650            slotBaseObject->setStructure(transition.release());
    4651             asObject(baseValue)->structure()->setCachedPrototypeChain(0);
     4651            asCell(baseValue)->structure()->setCachedPrototypeChain(0);
    46524652        }
    46534653
Note: See TracChangeset for help on using the changeset viewer.