Title: [151355] branches/dfgFourthTier
Revision
151355
Author
[email protected]
Date
2013-06-09 12:19:11 -0700 (Sun, 09 Jun 2013)

Log Message

fourthTier: DFG GetById patching shouldn't distinguish between self lists and proto lists
https://bugs.webkit.org/show_bug.cgi?id=117377

Source/_javascript_Core: 

Reviewed by Geoffrey Garen.
        
Previously if you did self accesses and then wanted to do a prototype access, you'd
have a bad time: the prototype accesses would be forced to take slow path because
the self list wouldn't allow prototype accesses. Likewise if you did prototype (or
chain) accesses and then wanted to do a self access, similar stupidity would ensue.
        
This fixes the stupidity.

I believe that this was introduced way back in the days of the old interpreter,
where distinguishing between self lists, proto lists, and chain lists was meaningful
for interpreter performance: it meant fewer branches to evaluate those lists. Then
it got mostly carried over to the old JIT since the old JIT was just initially an
optimized version of the old interpreter, and then later it got carried over to the
DFG because I didn't know any better at the time. Now I do know better and I'm
fixing it.

* bytecode/PolymorphicAccessStructureList.h:
(JSC::PolymorphicAccessStructureList::PolymorphicStubInfo::set):
* bytecode/StructureStubInfo.h:
(JSC::StructureStubInfo::initGetByIdSelfList):
* dfg/DFGOperations.cpp:
* dfg/DFGOperations.h:
* dfg/DFGRepatch.cpp:
(JSC::DFG::tryCacheGetByID):
(JSC::DFG::getPolymorphicStructureList):
(DFG):
(JSC::DFG::patchJumpToGetByIdStub):
(JSC::DFG::tryBuildGetByIDList):
(JSC::DFG::dfgBuildGetByIDList):

LayoutTests: 

Reviewed by Geoffrey Garen.
        
Add tests that show why this is important. These tests speed up by more than 3x.

* fast/js/regress/get-by-id-proto-or-self-expected.txt: Added.
* fast/js/regress/get-by-id-proto-or-self.html: Added.
* fast/js/regress/get-by-id-self-or-proto-expected.txt: Added.
* fast/js/regress/get-by-id-self-or-proto.html: Added.
* fast/js/regress/script-tests/get-by-id-proto-or-self.js: Added.
(foo):
(bar):
(Foo):
* fast/js/regress/script-tests/get-by-id-self-or-proto.js: Added.
(foo):
(bar):
(Foo):

Modified Paths

Added Paths

Diff

Modified: branches/dfgFourthTier/LayoutTests/ChangeLog (151354 => 151355)


--- branches/dfgFourthTier/LayoutTests/ChangeLog	2013-06-09 19:04:22 UTC (rev 151354)
+++ branches/dfgFourthTier/LayoutTests/ChangeLog	2013-06-09 19:19:11 UTC (rev 151355)
@@ -1,3 +1,25 @@
+2013-06-09  Filip Pizlo  <[email protected]>
+
+        fourthTier: DFG GetById patching shouldn't distinguish between self lists and proto lists
+        https://bugs.webkit.org/show_bug.cgi?id=117377
+
+        Reviewed by Geoffrey Garen.
+        
+        Add tests that show why this is important. These tests speed up by more than 3x.
+
+        * fast/js/regress/get-by-id-proto-or-self-expected.txt: Added.
+        * fast/js/regress/get-by-id-proto-or-self.html: Added.
+        * fast/js/regress/get-by-id-self-or-proto-expected.txt: Added.
+        * fast/js/regress/get-by-id-self-or-proto.html: Added.
+        * fast/js/regress/script-tests/get-by-id-proto-or-self.js: Added.
+        (foo):
+        (bar):
+        (Foo):
+        * fast/js/regress/script-tests/get-by-id-self-or-proto.js: Added.
+        (foo):
+        (bar):
+        (Foo):
+
 2013-06-07  Filip Pizlo  <[email protected]>
 
         fourthTier: don't insert ForceOSRExits except for inadequate coverage

Added: branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-proto-or-self-expected.txt (0 => 151355)


--- branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-proto-or-self-expected.txt	                        (rev 0)
+++ branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-proto-or-self-expected.txt	2013-06-09 19:19:11 UTC (rev 151355)
@@ -0,0 +1,10 @@
+JSRegress/get-by-id-proto-or-self
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-proto-or-self.html (0 => 151355)


--- branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-proto-or-self.html	                        (rev 0)
+++ branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-proto-or-self.html	2013-06-09 19:19:11 UTC (rev 151355)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>

Added: branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-self-or-proto-expected.txt (0 => 151355)


--- branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-self-or-proto-expected.txt	                        (rev 0)
+++ branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-self-or-proto-expected.txt	2013-06-09 19:19:11 UTC (rev 151355)
@@ -0,0 +1,10 @@
+JSRegress/get-by-id-self-or-proto
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-self-or-proto.html (0 => 151355)


--- branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-self-or-proto.html	                        (rev 0)
+++ branches/dfgFourthTier/LayoutTests/fast/js/regress/get-by-id-self-or-proto.html	2013-06-09 19:19:11 UTC (rev 151355)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>

Added: branches/dfgFourthTier/LayoutTests/fast/js/regress/script-tests/get-by-id-proto-or-self.js (0 => 151355)


--- branches/dfgFourthTier/LayoutTests/fast/js/regress/script-tests/get-by-id-proto-or-self.js	                        (rev 0)
+++ branches/dfgFourthTier/LayoutTests/fast/js/regress/script-tests/get-by-id-proto-or-self.js	2013-06-09 19:19:11 UTC (rev 151355)
@@ -0,0 +1,22 @@
+function foo(o) {
+    return o.f;
+}
+
+function bar(a) {
+    var result = 0;
+    for (var i = 0; i < 2000000; ++i) {
+        for (var j = 0; j < a.length; ++j)
+            result += foo(a[j]);
+    }
+    return result;
+}
+
+function Foo() {
+}
+
+Foo.prototype.f = 42;
+
+var result = bar([new Foo(), {f:24}]);
+
+if (result != 132000000)
+    throw "Error bad result: " + result;

Added: branches/dfgFourthTier/LayoutTests/fast/js/regress/script-tests/get-by-id-self-or-proto.js (0 => 151355)


--- branches/dfgFourthTier/LayoutTests/fast/js/regress/script-tests/get-by-id-self-or-proto.js	                        (rev 0)
+++ branches/dfgFourthTier/LayoutTests/fast/js/regress/script-tests/get-by-id-self-or-proto.js	2013-06-09 19:19:11 UTC (rev 151355)
@@ -0,0 +1,22 @@
+function foo(o) {
+    return o.f;
+}
+
+function bar(a) {
+    var result = 0;
+    for (var i = 0; i < 2000000; ++i) {
+        for (var j = 0; j < a.length; ++j)
+            result += foo(a[j]);
+    }
+    return result;
+}
+
+function Foo() {
+}
+
+Foo.prototype.f = 42;
+
+var result = bar([{f:24}, new Foo()]);
+
+if (result != 132000000)
+    throw "Error bad result: " + result;

Modified: branches/dfgFourthTier/Source/_javascript_Core/ChangeLog (151354 => 151355)


--- branches/dfgFourthTier/Source/_javascript_Core/ChangeLog	2013-06-09 19:04:22 UTC (rev 151354)
+++ branches/dfgFourthTier/Source/_javascript_Core/ChangeLog	2013-06-09 19:19:11 UTC (rev 151355)
@@ -1,3 +1,39 @@
+2013-06-09  Filip Pizlo  <[email protected]>
+
+        fourthTier: DFG GetById patching shouldn't distinguish between self lists and proto lists
+        https://bugs.webkit.org/show_bug.cgi?id=117377
+
+        Reviewed by Geoffrey Garen.
+        
+        Previously if you did self accesses and then wanted to do a prototype access, you'd
+        have a bad time: the prototype accesses would be forced to take slow path because
+        the self list wouldn't allow prototype accesses. Likewise if you did prototype (or
+        chain) accesses and then wanted to do a self access, similar stupidity would ensue.
+        
+        This fixes the stupidity.
+
+        I believe that this was introduced way back in the days of the old interpreter,
+        where distinguishing between self lists, proto lists, and chain lists was meaningful
+        for interpreter performance: it meant fewer branches to evaluate those lists. Then
+        it got mostly carried over to the old JIT since the old JIT was just initially an
+        optimized version of the old interpreter, and then later it got carried over to the
+        DFG because I didn't know any better at the time. Now I do know better and I'm
+        fixing it.
+
+        * bytecode/PolymorphicAccessStructureList.h:
+        (JSC::PolymorphicAccessStructureList::PolymorphicStubInfo::set):
+        * bytecode/StructureStubInfo.h:
+        (JSC::StructureStubInfo::initGetByIdSelfList):
+        * dfg/DFGOperations.cpp:
+        * dfg/DFGOperations.h:
+        * dfg/DFGRepatch.cpp:
+        (JSC::DFG::tryCacheGetByID):
+        (JSC::DFG::getPolymorphicStructureList):
+        (DFG):
+        (JSC::DFG::patchJumpToGetByIdStub):
+        (JSC::DFG::tryBuildGetByIDList):
+        (JSC::DFG::dfgBuildGetByIDList):
+
 2013-06-09  Mark Lam  <[email protected]>
 
         Fix broken no-DFG build.

Modified: branches/dfgFourthTier/Source/_javascript_Core/bytecode/PolymorphicAccessStructureList.h (151354 => 151355)


--- branches/dfgFourthTier/Source/_javascript_Core/bytecode/PolymorphicAccessStructureList.h	2013-06-09 19:04:22 UTC (rev 151354)
+++ branches/dfgFourthTier/Source/_javascript_Core/bytecode/PolymorphicAccessStructureList.h	2013-06-09 19:19:11 UTC (rev 151355)
@@ -60,31 +60,31 @@
             u.proto.clear();
         }
 
-        void set(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> _stubRoutine, Structure* _base, bool isDirect)
+        void set(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> _stubRoutine, Structure* _base, bool _isDirect)
         {
             stubRoutine = _stubRoutine;
             base.set(vm, owner, _base);
             u.proto.clear();
             isChain = false;
-            this->isDirect = isDirect;
+            isDirect = _isDirect;
         }
             
-        void set(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> _stubRoutine, Structure* _base, Structure* _proto, bool isDirect)
+        void set(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> _stubRoutine, Structure* _base, Structure* _proto, bool _isDirect)
         {
             stubRoutine = _stubRoutine;
             base.set(vm, owner, _base);
             u.proto.set(vm, owner, _proto);
             isChain = false;
-            this->isDirect = isDirect;
+            isDirect = _isDirect;
         }
             
-        void set(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> _stubRoutine, Structure* _base, StructureChain* _chain, bool isDirect)
+        void set(VM& vm, JSCell* owner, PassRefPtr<JITStubRoutine> _stubRoutine, Structure* _base, StructureChain* _chain, bool _isDirect)
         {
             stubRoutine = _stubRoutine;
             base.set(vm, owner, _base);
             u.chain.set(vm, owner, _chain);
             isChain = true;
-            this->isDirect = isDirect;
+            isDirect = _isDirect;
         }
     } list[POLYMORPHIC_LIST_CACHE_SIZE];
         

Modified: branches/dfgFourthTier/Source/_javascript_Core/bytecode/StructureStubInfo.h (151354 => 151355)


--- branches/dfgFourthTier/Source/_javascript_Core/bytecode/StructureStubInfo.h	2013-06-09 19:04:22 UTC (rev 151354)
+++ branches/dfgFourthTier/Source/_javascript_Core/bytecode/StructureStubInfo.h	2013-06-09 19:19:11 UTC (rev 151355)
@@ -127,12 +127,13 @@
         u.getByIdChain.isDirect = isDirect;
     }
 
-    void initGetByIdSelfList(PolymorphicAccessStructureList* structureList, int listSize)
+    void initGetByIdSelfList(PolymorphicAccessStructureList* structureList, int listSize, bool didSelfPatching = false)
     {
         accessType = access_get_by_id_self_list;
 
         u.getByIdSelfList.structureList = structureList;
         u.getByIdSelfList.listSize = listSize;
+        u.getByIdSelfList.didSelfPatching = didSelfPatching;
     }
 
     void initGetByIdProtoList(PolymorphicAccessStructureList* structureList, int listSize)
@@ -277,7 +278,8 @@
         } getByIdChain;
         struct {
             PolymorphicAccessStructureList* structureList;
-            int listSize;
+            int listSize : 31;
+            bool didSelfPatching : 1;
         } getByIdSelfList;
         struct {
             PolymorphicAccessStructureList* structureList;

Modified: branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOperations.cpp (151354 => 151355)


--- branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOperations.cpp	2013-06-09 19:04:22 UTC (rev 151354)
+++ branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOperations.cpp	2013-06-09 19:19:11 UTC (rev 151355)
@@ -515,26 +515,6 @@
     return JSValue::encode(result);
 }
 
-J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(operationGetByIdProtoBuildList);
-EncodedJSValue DFG_OPERATION operationGetByIdProtoBuildListWithReturnAddress(ExecState* exec, EncodedJSValue base, StringImpl* uid, ReturnAddressPtr returnAddress)
-{
-    VM* vm = &exec->vm();
-    NativeCallFrameTracer tracer(vm, exec);
-    
-    Identifier ident(vm, uid);
-    StructureStubInfo& stubInfo = exec->codeBlock()->getStubInfo(returnAddress);
-    AccessType accessType = static_cast<AccessType>(stubInfo.accessType);
-
-    JSValue baseValue = JSValue::decode(base);
-    PropertySlot slot(baseValue);
-    JSValue result = baseValue.get(exec, ident, slot);
-    
-    if (accessType == static_cast<AccessType>(stubInfo.accessType))
-        dfgBuildGetByIDProtoList(exec, baseValue, ident, slot, stubInfo);
-
-    return JSValue::encode(result);
-}
-
 J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(operationGetByIdOptimize);
 EncodedJSValue DFG_OPERATION operationGetByIdOptimizeWithReturnAddress(ExecState* exec, EncodedJSValue base, StringImpl* uid, ReturnAddressPtr returnAddress)
 {

Modified: branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOperations.h (151354 => 151355)


--- branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOperations.h	2013-06-09 19:04:22 UTC (rev 151354)
+++ branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOperations.h	2013-06-09 19:19:11 UTC (rev 151355)
@@ -136,7 +136,6 @@
 EncodedJSValue DFG_OPERATION operationGetByValArrayInt(ExecState*, JSArray*, int32_t) WTF_INTERNAL;
 EncodedJSValue DFG_OPERATION operationGetById(ExecState*, EncodedJSValue, StringImpl*) WTF_INTERNAL;
 EncodedJSValue DFG_OPERATION operationGetByIdBuildList(ExecState*, EncodedJSValue, StringImpl*) WTF_INTERNAL;
-EncodedJSValue DFG_OPERATION operationGetByIdProtoBuildList(ExecState*, EncodedJSValue, StringImpl*) WTF_INTERNAL;
 EncodedJSValue DFG_OPERATION operationGetByIdOptimize(ExecState*, EncodedJSValue, StringImpl*) WTF_INTERNAL;
 EncodedJSValue DFG_OPERATION operationCallCustomGetter(ExecState*, JSCell*, PropertySlot::GetValueFunc, StringImpl*) WTF_INTERNAL;
 EncodedJSValue DFG_OPERATION operationCallGetter(ExecState*, JSCell*, JSCell*) WTF_INTERNAL;

Modified: branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGRepatch.cpp (151354 => 151355)


--- branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGRepatch.cpp	2013-06-09 19:04:22 UTC (rev 151354)
+++ branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGRepatch.cpp	2013-06-09 19:19:11 UTC (rev 151355)
@@ -355,7 +355,7 @@
     
     RepatchBuffer repatchBuffer(codeBlock);
     replaceWithJump(repatchBuffer, stubInfo, stubInfo.stubRoutine->code().code());
-    repatchBuffer.relink(stubInfo.callReturnLocation, operationGetByIdProtoBuildList);
+    repatchBuffer.relink(stubInfo.callReturnLocation, operationGetByIdBuildList);
     
     stubInfo.initGetByIdChain(*vm, codeBlock->ownerExecutable(), structure, prototypeChain, count, true);
     return true;
@@ -368,48 +368,83 @@
         dfgRepatchCall(exec->codeBlock(), stubInfo.callReturnLocation, operationGetById);
 }
 
-static bool tryBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identifier& ident, const PropertySlot& slot, StructureStubInfo& stubInfo)
+static bool getPolymorphicStructureList(
+    VM* vm, CodeBlock* codeBlock, StructureStubInfo& stubInfo,
+    PolymorphicAccessStructureList*& polymorphicStructureList, int& listIndex)
 {
-    if (!baseValue.isCell()
-        || !slot.isCacheable()
-        || baseValue.asCell()->structure()->isUncacheableDictionary()
-        || slot.slotBase() != baseValue)
-        return false;
-    
-    if (!stubInfo.patch.dfg.registersFlushed) {
-        // We cannot do as much inline caching if the registers were not flushed prior to this GetById. In particular,
-        // non-Value cached properties require planting calls, which requires registers to have been flushed. Thus,
-        // if registers were not flushed, don't do non-Value caching.
-        if (slot.cachedPropertyType() != PropertySlot::Value)
-            return false;
-    }
-    
-    CodeBlock* codeBlock = exec->codeBlock();
-    JSCell* baseCell = baseValue.asCell();
-    Structure* structure = baseCell->structure();
-    VM* vm = &exec->vm();
-    
-    ASSERT(slot.slotBase().isObject());
-    
-    PolymorphicAccessStructureList* polymorphicStructureList;
-    int listIndex;
-    
     if (stubInfo.accessType == access_unset) {
-        ASSERT(!stubInfo.stubRoutine);
+        RELEASE_ASSERT(!stubInfo.stubRoutine);
         polymorphicStructureList = new PolymorphicAccessStructureList();
-        stubInfo.initGetByIdSelfList(polymorphicStructureList, 0);
+        stubInfo.initGetByIdSelfList(polymorphicStructureList, 0, false);
         listIndex = 0;
     } else if (stubInfo.accessType == access_get_by_id_self) {
-        ASSERT(!stubInfo.stubRoutine);
+        RELEASE_ASSERT(!stubInfo.stubRoutine);
         polymorphicStructureList = new PolymorphicAccessStructureList(*vm, codeBlock->ownerExecutable(), JITStubRoutine::createSelfManagedRoutine(stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.dfg.deltaCallToSlowCase)), stubInfo.u.getByIdSelf.baseObjectStructure.get(), true);
-        stubInfo.initGetByIdSelfList(polymorphicStructureList, 1);
+        stubInfo.initGetByIdSelfList(polymorphicStructureList, 1, true);
         listIndex = 1;
+    } else if (stubInfo.accessType == access_get_by_id_chain) {
+        RELEASE_ASSERT(!!stubInfo.stubRoutine);
+        polymorphicStructureList = new PolymorphicAccessStructureList(*vm, codeBlock->ownerExecutable(), stubInfo.stubRoutine, stubInfo.u.getByIdChain.baseObjectStructure.get(), stubInfo.u.getByIdChain.chain.get(), true);
+        stubInfo.stubRoutine.clear();
+        stubInfo.initGetByIdSelfList(polymorphicStructureList, 1, false);
+        listIndex = 1;
     } else {
+        RELEASE_ASSERT(stubInfo.accessType == access_get_by_id_self_list);
         polymorphicStructureList = stubInfo.u.getByIdSelfList.structureList;
         listIndex = stubInfo.u.getByIdSelfList.listSize;
     }
     
-    if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) {
+    if (listIndex == POLYMORPHIC_LIST_CACHE_SIZE)
+        return false;
+    
+    RELEASE_ASSERT(listIndex < POLYMORPHIC_LIST_CACHE_SIZE);
+    return true;
+}
+
+static void patchJumpToGetByIdStub(CodeBlock* codeBlock, StructureStubInfo& stubInfo, JITStubRoutine* stubRoutine)
+{
+    RELEASE_ASSERT(stubInfo.accessType == access_get_by_id_self_list);
+    RepatchBuffer repatchBuffer(codeBlock);
+    if (stubInfo.u.getByIdSelfList.didSelfPatching) {
+        repatchBuffer.relink(
+            stubInfo.callReturnLocation.jumpAtOffset(
+                stubInfo.patch.dfg.deltaCallToStructCheck),
+            CodeLocationLabel(stubRoutine->code().code()));
+        return;
+    }
+    
+    replaceWithJump(repatchBuffer, stubInfo, stubRoutine->code().code());
+}
+
+static bool tryBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identifier& ident, const PropertySlot& slot, StructureStubInfo& stubInfo)
+{
+    if (!baseValue.isCell()
+        || !slot.isCacheable()
+        || !baseValue.asCell()->structure()->propertyAccessesAreCacheable())
+        return false;
+
+    CodeBlock* codeBlock = exec->codeBlock();
+    VM* vm = &exec->vm();
+    JSCell* baseCell = baseValue.asCell();
+    Structure* structure = baseCell->structure();
+    
+    if (slot.slotBase() == baseValue) {
+        if (!stubInfo.patch.dfg.registersFlushed) {
+            // We cannot do as much inline caching if the registers were not flushed prior to this GetById. In particular,
+            // non-Value cached properties require planting calls, which requires registers to have been flushed. Thus,
+            // if registers were not flushed, don't do non-Value caching.
+            if (slot.cachedPropertyType() != PropertySlot::Value)
+                return false;
+        }
+    
+        ASSERT(slot.slotBase().isObject());
+    
+        PolymorphicAccessStructureList* polymorphicStructureList;
+        int listIndex;
+
+        if (!getPolymorphicStructureList(vm, codeBlock, stubInfo, polymorphicStructureList, listIndex))
+            return false;
+        
         stubInfo.u.getByIdSelfList.listSize++;
         
         GPRReg baseGPR = static_cast<GPRReg>(stubInfo.patch.dfg.baseGPR);
@@ -529,8 +564,8 @@
                 FINALIZE_DFG_CODE(
                     patchBuffer,
                     ("DFG GetById polymorphic list access for %s, return point %p",
-                        toCString(*exec->codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset(
-                            stubInfo.patch.dfg.deltaCallToDone).executableAddress())),
+                     toCString(*exec->codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset(
+                         stubInfo.patch.dfg.deltaCallToDone).executableAddress())),
                 *vm,
                 codeBlock->ownerExecutable(),
                 slot.cachedPropertyType() == PropertySlot::Getter
@@ -538,87 +573,47 @@
         
         polymorphicStructureList->list[listIndex].set(*vm, codeBlock->ownerExecutable(), stubRoutine, structure, isDirect);
         
-        RepatchBuffer repatchBuffer(codeBlock);
-        repatchBuffer.relink(
-            stubInfo.callReturnLocation.jumpAtOffset(
-                stubInfo.patch.dfg.deltaCallToStructCheck),
-            CodeLocationLabel(stubRoutine->code().code()));
-        
-        if (listIndex < (POLYMORPHIC_LIST_CACHE_SIZE - 1))
-            return true;
+        patchJumpToGetByIdStub(codeBlock, stubInfo, stubRoutine.get());
+        return listIndex < (POLYMORPHIC_LIST_CACHE_SIZE - 1);
     }
     
-    return false;
-}
-
-void dfgBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot, StructureStubInfo& stubInfo)
-{
-    bool dontChangeCall = tryBuildGetByIDList(exec, baseValue, propertyName, slot, stubInfo);
-    if (!dontChangeCall)
-        dfgRepatchCall(exec->codeBlock(), stubInfo.callReturnLocation, operationGetById);
-}
-
-static bool tryBuildGetByIDProtoList(ExecState* exec, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot, StructureStubInfo& stubInfo)
-{
-    if (!baseValue.isCell()
-        || !slot.isCacheable()
-        || baseValue.asCell()->structure()->isDictionary()
-        || baseValue.asCell()->structure()->typeInfo().prohibitsPropertyCaching()
-        || slot.slotBase() == baseValue
+    if (baseValue.asCell()->structure()->typeInfo().prohibitsPropertyCaching()
         || slot.cachedPropertyType() != PropertySlot::Value)
         return false;
-    
+
     ASSERT(slot.slotBase().isObject());
     
     PropertyOffset offset = slot.cachedOffset();
-    size_t count = normalizePrototypeChainForChainAccess(exec, baseValue, slot.slotBase(), propertyName, offset);
+    size_t count = normalizePrototypeChainForChainAccess(exec, baseValue, slot.slotBase(), ident, offset);
     if (count == InvalidPrototypeChain)
         return false;
 
-    Structure* structure = baseValue.asCell()->structure();
     StructureChain* prototypeChain = structure->prototypeChain(exec);
-    CodeBlock* codeBlock = exec->codeBlock();
-    VM* vm = &exec->vm();
     
     PolymorphicAccessStructureList* polymorphicStructureList;
-    int listIndex = 1;
+    int listIndex;
+    if (!getPolymorphicStructureList(vm, codeBlock, stubInfo, polymorphicStructureList, listIndex))
+        return false;
     
-    if (stubInfo.accessType == access_get_by_id_chain) {
-        ASSERT(!!stubInfo.stubRoutine);
-        polymorphicStructureList = new PolymorphicAccessStructureList(*vm, codeBlock->ownerExecutable(), stubInfo.stubRoutine, stubInfo.u.getByIdChain.baseObjectStructure.get(), stubInfo.u.getByIdChain.chain.get(), true);
-        stubInfo.stubRoutine.clear();
-        stubInfo.initGetByIdProtoList(polymorphicStructureList, 1);
-    } else {
-        ASSERT(stubInfo.accessType == access_get_by_id_proto_list);
-        polymorphicStructureList = stubInfo.u.getByIdProtoList.structureList;
-        listIndex = stubInfo.u.getByIdProtoList.listSize;
-    }
+    stubInfo.u.getByIdProtoList.listSize++;
     
-    if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) {
-        stubInfo.u.getByIdProtoList.listSize++;
-        
-        CodeLocationLabel lastProtoBegin = CodeLocationLabel(polymorphicStructureList->list[listIndex - 1].stubRoutine->code().code());
-        ASSERT(!!lastProtoBegin);
-
-        RefPtr<JITStubRoutine> stubRoutine;
-        
-        generateProtoChainAccessStub(exec, stubInfo, prototypeChain, count, offset, structure, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.dfg.deltaCallToDone), lastProtoBegin, stubRoutine);
-        
-        polymorphicStructureList->list[listIndex].set(*vm, codeBlock->ownerExecutable(), stubRoutine, structure, true);
-        
-        RepatchBuffer repatchBuffer(codeBlock);
-        replaceWithJump(repatchBuffer, stubInfo, stubRoutine->code().code());
-        
-        if (listIndex < (POLYMORPHIC_LIST_CACHE_SIZE - 1))
-            return true;
-    }
+    CodeLocationLabel lastProtoBegin = CodeLocationLabel(polymorphicStructureList->list[listIndex - 1].stubRoutine->code().code());
+    ASSERT(!!lastProtoBegin);
     
-    return false;
+    RefPtr<JITStubRoutine> stubRoutine;
+    
+    generateProtoChainAccessStub(exec, stubInfo, prototypeChain, count, offset, structure, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.dfg.deltaCallToDone), lastProtoBegin, stubRoutine);
+    
+    polymorphicStructureList->list[listIndex].set(*vm, codeBlock->ownerExecutable(), stubRoutine, structure, true);
+    
+    patchJumpToGetByIdStub(codeBlock, stubInfo, stubRoutine.get());
+    
+    return listIndex < (POLYMORPHIC_LIST_CACHE_SIZE - 1);
 }
 
-void dfgBuildGetByIDProtoList(ExecState* exec, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot, StructureStubInfo& stubInfo)
+void dfgBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot, StructureStubInfo& stubInfo)
 {
-    bool dontChangeCall = tryBuildGetByIDProtoList(exec, baseValue, propertyName, slot, stubInfo);
+    bool dontChangeCall = tryBuildGetByIDList(exec, baseValue, propertyName, slot, stubInfo);
     if (!dontChangeCall)
         dfgRepatchCall(exec->codeBlock(), stubInfo.callReturnLocation, operationGetById);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to