Changeset 51976 in webkit


Ignore:
Timestamp:
Dec 10, 2009 6:22:07 PM (14 years ago)
Author:
oliver@apple.com
Message:

Incorrect caching of prototype lookup with dictionary base
https://bugs.webkit.org/show_bug.cgi?id=32402

Reviewed by Gavin Barraclough

Make sure we don't add cached prototype lookup to the proto_list
lookup chain if the top level object is a dictionary.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r51975 r51976  
     12009-12-10  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Incorrect caching of prototype lookup with dictionary base
     6        https://bugs.webkit.org/show_bug.cgi?id=32402
     7
     8        Make sure we don't add cached prototype lookup to the proto_list
     9        lookup chain if the top level object is a dictionary.
     10
     11        * jit/JITStubs.cpp:
     12        (JSC::JITThunks::tryCacheGetByID):
     13
    1142009-12-10  Gavin Barraclough  <barraclough@apple.com>
    215
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r51975 r51976  
    848848        stubInfo->initGetByIdProto(structure, slotBaseObject->structure());
    849849
     850        ASSERT(!structure->isDictionary());
     851        ASSERT(!slotBaseObject->structure()->isDictionary());
    850852        JIT::compileGetByIdProto(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, structure, slotBaseObject->structure(), slot.cachedOffset(), returnAddress);
    851853        return;
     
    13661368    CHECK_FOR_EXCEPTION();
    13671369
    1368     if (!baseValue.isCell() || !slot.isCacheable() || asCell(baseValue)->structure()->isUncacheableDictionary()) {
     1370    if (!baseValue.isCell() || !slot.isCacheable() || asCell(baseValue)->structure()->isDictionary()) {
    13691371        ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_fail));
    13701372        return JSValue::encode(result);
     
    13811383        ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_fail));
    13821384    else if (slot.slotBase() == asCell(baseValue)->structure()->prototypeForLookup(callFrame)) {
     1385        ASSERT(!asCell(baseValue)->structure()->isDictionary());
    13831386        // Since we're accessing a prototype in a loop, it's a good bet that it
    13841387        // should not be treated as a dictionary.
     
    13941397            ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_list_full));
    13951398    } else if (size_t count = normalizePrototypeChain(callFrame, baseValue, slot.slotBase())) {
     1399        ASSERT(!asCell(baseValue)->structure()->isDictionary());
    13961400        int listIndex;
    13971401        PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(stubInfo, listIndex);
  • trunk/LayoutTests/ChangeLog

    r51973 r51976  
     12009-12-10  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Gavin Barraclough.
     4
     5        Incorrect caching of prototype lookup with dictionary base
     6        https://bugs.webkit.org/show_bug.cgi?id=32402
     7
     8        Adding test for prototype caching through a dictionary
     9
     10        * fast/js/dictionary-prototype-caching-expected.txt:
     11        * fast/js/script-tests/dictionary-prototype-caching.js:
     12        (testFunction):
     13
    1142009-12-10  Alexey Proskuryakov  <ap@apple.com>
    215
  • trunk/LayoutTests/fast/js/dictionary-prototype-caching-expected.txt

    r50707 r51976  
    88PASS protoKeys is [1,2,3]
    99PASS protoKeys is [1,2,3]
     10PASS testFunction(subclass1) is true
     11PASS testFunction(subclass2) is true
     12PASS testFunction(subclass2) is true
    1013PASS successfullyParsed is true
    1114
  • trunk/LayoutTests/fast/js/script-tests/dictionary-prototype-caching.js

    r50704 r51976  
    5555shouldBe("protoKeys", "[1,2,3]");
    5656
     57function testFunction(o) {
     58    return o.test;
     59}
     60
     61var proto = { test: true };
     62var subclass1 = { __proto__: proto };
     63var subclass2 = { __proto__: proto };
     64for (var i = 0; i < 500; i++)
     65    subclass2["a"+i]="a"+i;
     66
     67testFunction(subclass1);
     68shouldBeTrue("testFunction(subclass1)");
     69shouldBeTrue("testFunction(subclass2)");
     70proto.test = false
     71subclass2.test = true;
     72shouldBeTrue("testFunction(subclass2)");
     73
    5774successfullyParsed = true;
Note: See TracChangeset for help on using the changeset viewer.