Diff
Modified: trunk/Source/_javascript_Core/CMakeLists.txt (216814 => 216815)
--- trunk/Source/_javascript_Core/CMakeLists.txt 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/CMakeLists.txt 2017-05-13 04:59:35 UTC (rev 216815)
@@ -358,7 +358,6 @@
dfg/DFGLazyJSValue.cpp
dfg/DFGLazyNode.cpp
dfg/DFGLivenessAnalysisPhase.cpp
- dfg/DFGLongLivedState.cpp
dfg/DFGLoopPreHeaderCreationPhase.cpp
dfg/DFGMaximalFlushInsertionPhase.cpp
dfg/DFGMayExit.cpp
Modified: trunk/Source/_javascript_Core/ChangeLog (216814 => 216815)
--- trunk/Source/_javascript_Core/ChangeLog 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-05-13 04:59:35 UTC (rev 216815)
@@ -1,3 +1,44 @@
+2017-05-12 Geoffrey Garen <gga...@apple.com>
+
+ [JSC] DFG::Node should not have its own allocator
+ https://bugs.webkit.org/show_bug.cgi?id=160098
+
+ Reviewed by Saam Barati.
+
+ I just rebased the patch from <http://trac.webkit.org/changeset/203808>.
+
+ I ran Octane and JetStream locally on a MacBook Air and I wasn't able to
+ reproduce a regression. Let's land this again and see what the bots say.
+
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * b3/B3SparseCollection.h:
+ (JSC::B3::SparseCollection::packIndices):
+ * dfg/DFGAllocator.h: Removed.
+ * dfg/DFGDriver.cpp:
+ (JSC::DFG::compileImpl):
+ * dfg/DFGGraph.cpp:
+ (JSC::DFG::Graph::Graph):
+ (JSC::DFG::Graph::~Graph):
+ (JSC::DFG::Graph::deleteNode):
+ (JSC::DFG::Graph::packNodeIndices):
+ (JSC::DFG::Graph::addNodeToMapByIndex): Deleted.
+ * dfg/DFGGraph.h:
+ (JSC::DFG::Graph::addNode):
+ (JSC::DFG::Graph::maxNodeCount):
+ (JSC::DFG::Graph::nodeAt):
+ * dfg/DFGLongLivedState.cpp: Removed.
+ * dfg/DFGLongLivedState.h: Removed.
+ * dfg/DFGNode.h:
+ * dfg/DFGNodeAllocator.h:
+ * dfg/DFGPlan.cpp:
+ (JSC::DFG::Plan::compileInThread):
+ (JSC::DFG::Plan::compileInThreadImpl):
+ * dfg/DFGPlan.h:
+ * dfg/DFGWorklist.cpp:
+ * runtime/VM.cpp:
+ (JSC::VM::VM):
+ * runtime/VM.h:
+
2017-05-12 Keith Miller <keith_mil...@apple.com>
Use Mach exceptions instead of signals where possible
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (216814 => 216815)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2017-05-13 04:59:35 UTC (rev 216815)
@@ -1003,8 +1003,6 @@
0FEFC9AB1681A3B600567F53 /* DFGOSRExitJumpPlaceholder.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FEFC9A81681A3B000567F53 /* DFGOSRExitJumpPlaceholder.h */; };
0FF054F91AC35B4400E5BE57 /* ExecutableAllocationFuzz.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FF054F71AC35B4400E5BE57 /* ExecutableAllocationFuzz.cpp */; };
0FF054FA1AC35B4400E5BE57 /* ExecutableAllocationFuzz.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF054F81AC35B4400E5BE57 /* ExecutableAllocationFuzz.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 0FF0F19916B729F6005DF95B /* DFGLongLivedState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB4B51C16B62772003F696B /* DFGLongLivedState.cpp */; };
- 0FF0F19B16B729FA005DF95B /* DFGLongLivedState.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB4B51D16B62772003F696B /* DFGLongLivedState.h */; };
0FF0F19C16B72A03005DF95B /* DFGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB4B51E16B62772003F696B /* DFGNode.cpp */; };
0FF0F19D16B72A08005DF95B /* DFGCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB4B51A16B62772003F696B /* DFGCommon.cpp */; };
0FF0F19E16B72A0B005DF95B /* DFGEdge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB4B51B16B62772003F696B /* DFGEdge.cpp */; };
@@ -1063,9 +1061,7 @@
0FFA549816B8835300B3A982 /* A64DOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 652A3A231651C69700A80AFE /* A64DOpcode.h */; settings = {ATTRIBUTES = (Private, ); }; };
0FFB6C381AF48DDC00DB1BF7 /* TypeofType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FFB6C361AF48DDC00DB1BF7 /* TypeofType.cpp */; };
0FFB6C391AF48DDC00DB1BF7 /* TypeofType.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FFB6C371AF48DDC00DB1BF7 /* TypeofType.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 0FFB921816D02EB20055A5DB /* DFGAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB4B51916B62772003F696B /* DFGAllocator.h */; };
0FFB921A16D02EC50055A5DB /* DFGBasicBlockInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD5652216AB780A00197653 /* DFGBasicBlockInlines.h */; };
- 0FFB921B16D02F010055A5DB /* DFGNodeAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB4B51F16B62772003F696B /* DFGNodeAllocator.h */; };
0FFB921C16D02F110055A5DB /* DFGOSRExitCompilationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 65987F2C167FE84B003C2F8D /* DFGOSRExitCompilationInfo.h */; };
0FFB921D16D02F300055A5DB /* DFGSlowPathGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F1E3A501537C2CB000F9456 /* DFGSlowPathGenerator.h */; };
0FFB922016D033B70055A5DB /* NodeConstructors.h in Headers */ = {isa = PBXBuildFile; fileRef = 930DAD030FB1EB1A0082D205 /* NodeConstructors.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3278,13 +3274,9 @@
0FB4767C1D99AEA7008EA6CB /* GCDeferralContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCDeferralContext.h; sourceTree = "<group>"; };
0FB4767D1D99AEA7008EA6CB /* GCDeferralContextInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCDeferralContextInlines.h; sourceTree = "<group>"; };
0FB4B51016B3A964003F696B /* DFGMinifiedID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGMinifiedID.h; path = dfg/DFGMinifiedID.h; sourceTree = "<group>"; };
- 0FB4B51916B62772003F696B /* DFGAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGAllocator.h; path = dfg/DFGAllocator.h; sourceTree = "<group>"; };
0FB4B51A16B62772003F696B /* DFGCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGCommon.cpp; path = dfg/DFGCommon.cpp; sourceTree = "<group>"; };
0FB4B51B16B62772003F696B /* DFGEdge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGEdge.cpp; path = dfg/DFGEdge.cpp; sourceTree = "<group>"; };
- 0FB4B51C16B62772003F696B /* DFGLongLivedState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGLongLivedState.cpp; path = dfg/DFGLongLivedState.cpp; sourceTree = "<group>"; };
- 0FB4B51D16B62772003F696B /* DFGLongLivedState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGLongLivedState.h; path = dfg/DFGLongLivedState.h; sourceTree = "<group>"; };
0FB4B51E16B62772003F696B /* DFGNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGNode.cpp; path = dfg/DFGNode.cpp; sourceTree = "<group>"; };
- 0FB4B51F16B62772003F696B /* DFGNodeAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGNodeAllocator.h; path = dfg/DFGNodeAllocator.h; sourceTree = "<group>"; };
0FB4B52116B6278D003F696B /* FunctionExecutableDump.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionExecutableDump.cpp; sourceTree = "<group>"; };
0FB4B52216B6278D003F696B /* FunctionExecutableDump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionExecutableDump.h; sourceTree = "<group>"; };
0FB4FB701BC843140025CA5A /* FTLLazySlowPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLLazySlowPath.cpp; path = ftl/FTLLazySlowPath.cpp; sourceTree = "<group>"; };
@@ -7221,7 +7213,6 @@
0F18D3CD1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.cpp */,
0F18D3CE1B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.h */,
0F66E16814DF3F1300B7B2E4 /* DFGAdjacencyList.h */,
- 0FB4B51916B62772003F696B /* DFGAllocator.h */,
0F1E3A431534CBAD000F9456 /* DFGArgumentPosition.h */,
0F2DD80C1AB3D8BE00BBB8E8 /* DFGArgumentsEliminationPhase.cpp */,
0F2DD80D1AB3D8BE00BBB8E8 /* DFGArgumentsEliminationPhase.h */,
@@ -7376,8 +7367,6 @@
79C4B15C1BA2158F00FD592E /* DFGLiveCatchVariablePreservationPhase.h */,
A7D89CEC17A0B8CC00773AD8 /* DFGLivenessAnalysisPhase.cpp */,
A7D89CED17A0B8CC00773AD8 /* DFGLivenessAnalysisPhase.h */,
- 0FB4B51C16B62772003F696B /* DFGLongLivedState.cpp */,
- 0FB4B51D16B62772003F696B /* DFGLongLivedState.h */,
A767B5B317A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.cpp */,
A767B5B417A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.h */,
79F8FC1C1B9FED0F00CA66AB /* DFGMaximalFlushInsertionPhase.cpp */,
@@ -7399,7 +7388,6 @@
86ECA3E9132DEF1C002B2AD7 /* DFGNode.h */,
0F2017871DCB942200EA5950 /* DFGNodeAbstractValuePair.cpp */,
0F2017881DCB942200EA5950 /* DFGNodeAbstractValuePair.h */,
- 0FB4B51F16B62772003F696B /* DFGNodeAllocator.h */,
0FA581B7150E952A00B9A2D9 /* DFGNodeFlags.cpp */,
0FA581B8150E952A00B9A2D9 /* DFGNodeFlags.h */,
0F2017831DCAE14700EA5950 /* DFGNodeFlowProjection.cpp */,
@@ -8535,7 +8523,6 @@
0FD3E4021B618AAF00C80E1E /* DFGAdaptiveInferredPropertyValueWatchpoint.h in Headers */,
0F18D3D01B55A6E0002C5C9F /* DFGAdaptiveStructureWatchpoint.h in Headers */,
0F66E16B14DF3F1600B7B2E4 /* DFGAdjacencyList.h in Headers */,
- 0FFB921816D02EB20055A5DB /* DFGAllocator.h in Headers */,
0F1E3A461534CBAF000F9456 /* DFGArgumentPosition.h in Headers */,
0F2DD8121AB3D8BE00BBB8E8 /* DFGArgumentsEliminationPhase.h in Headers */,
0F2DD8141AB3D8BE00BBB8E8 /* DFGArgumentsUtilities.h in Headers */,
@@ -8633,7 +8620,6 @@
A7D9A29817A0BC7400EE2618 /* DFGLICMPhase.h in Headers */,
79C4B15E1BA2158F00FD592E /* DFGLiveCatchVariablePreservationPhase.h in Headers */,
A7D89CFC17A0B8CC00773AD8 /* DFGLivenessAnalysisPhase.h in Headers */,
- 0FF0F19B16B729FA005DF95B /* DFGLongLivedState.h in Headers */,
A767B5B617A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.h in Headers */,
79F8FC1F1B9FED0F00CA66AB /* DFGMaximalFlushInsertionPhase.h in Headers */,
0F5874EE194FEB1200AAB2C1 /* DFGMayExit.h in Headers */,
@@ -8645,7 +8631,6 @@
A737810E1799EA2E00817533 /* DFGNaturalLoops.h in Headers */,
86ECA3EA132DEF1C002B2AD7 /* DFGNode.h in Headers */,
0F2017891DCB942400EA5950 /* DFGNodeAbstractValuePair.h in Headers */,
- 0FFB921B16D02F010055A5DB /* DFGNodeAllocator.h in Headers */,
0FA581BB150E953000B9A2D9 /* DFGNodeFlags.h in Headers */,
0F2017851DCAE14900EA5950 /* DFGNodeFlowProjection.h in Headers */,
0F300B7818AB051100A6D72E /* DFGNodeOrigin.h in Headers */,
@@ -10406,7 +10391,6 @@
A7D9A29717A0BC7400EE2618 /* DFGLICMPhase.cpp in Sources */,
79C4B15D1BA2158F00FD592E /* DFGLiveCatchVariablePreservationPhase.cpp in Sources */,
A7D89CFB17A0B8CC00773AD8 /* DFGLivenessAnalysisPhase.cpp in Sources */,
- 0FF0F19916B729F6005DF95B /* DFGLongLivedState.cpp in Sources */,
A767B5B517A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.cpp in Sources */,
79F8FC1E1B9FED0F00CA66AB /* DFGMaximalFlushInsertionPhase.cpp in Sources */,
0F5874ED194FEB1200AAB2C1 /* DFGMayExit.cpp in Sources */,
Modified: trunk/Source/_javascript_Core/b3/B3SparseCollection.h (216814 => 216815)
--- trunk/Source/_javascript_Core/b3/B3SparseCollection.h 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/b3/B3SparseCollection.h 2017-05-13 04:59:35 UTC (rev 216815)
@@ -25,7 +25,7 @@
#pragma once
-#if ENABLE(B3_JIT)
+#if ENABLE(DFG_JIT)
#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
@@ -75,6 +75,42 @@
m_vector[value->m_index] = nullptr;
}
+ void packIndices()
+ {
+ if (m_indexFreeList.isEmpty())
+ return;
+
+ unsigned holeIndex = 0;
+ unsigned endIndex = m_vector.size();
+
+ while (true) {
+ while (holeIndex < endIndex && m_vector[holeIndex])
+ ++holeIndex;
+
+ if (holeIndex == endIndex)
+ break;
+ ASSERT(holeIndex < m_vector.size());
+ ASSERT(!m_vector[holeIndex]);
+
+ do {
+ --endIndex;
+ } while (!m_vector[endIndex] && endIndex > holeIndex);
+
+ if (holeIndex == endIndex)
+ break;
+ ASSERT(endIndex > holeIndex);
+ ASSERT(m_vector[endIndex]);
+
+ auto& value = m_vector[endIndex];
+ value->m_index = holeIndex;
+ m_vector[holeIndex] = WTFMove(value);
+ ++holeIndex;
+ }
+
+ m_indexFreeList.resize(0);
+ m_vector.resize(endIndex);
+ }
+
unsigned size() const { return m_vector.size(); }
bool isEmpty() const { return m_vector.isEmpty(); }
@@ -139,4 +175,4 @@
} } // namespace JSC::B3
-#endif // ENABLE(B3_JIT)
+#endif // ENABLE(DFG_JIT)
Deleted: trunk/Source/_javascript_Core/dfg/DFGAllocator.h (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGAllocator.h 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGAllocator.h 2017-05-13 04:59:35 UTC (rev 216815)
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(DFG_JIT)
-
-#include "DFGCommon.h"
-#include <wtf/StdLibExtras.h>
-
-namespace JSC { namespace DFG {
-
-// Custom pool allocator for exactly one type (type T). It has fast (O(1), only a few
-// instructions) allocator, and a similarly fast free(). Recycling works if either of
-// the following is true:
-// - T has a trivial destructor. In that case you don't have to ever call free() on
-// anything. You can just call freeAll() instead.
-// - You call free() on all T's that you allocated, and never use freeAll().
-
-template<typename T>
-class Allocator {
-public:
- Allocator();
- ~Allocator();
-
- void* allocate(); // Use placement new to allocate, and avoid using this method.
- void free(T*); // Call this method to delete; never use 'delete' directly.
-
- void freeAll(); // Only call this if you've either freed everything or if T has a trivial destructor.
- void reset(); // Like freeAll(), but also returns all memory to the OS.
-
- unsigned indexOf(const T*);
-
- static Allocator* allocatorOf(const T*);
-
-private:
- void* bumpAllocate();
- void* freeListAllocate();
- void* allocateSlow();
-
- struct Region {
- static size_t size() { return 64 * KB; }
- static size_t headerSize() { return std::max(sizeof(Region), sizeof(T)); }
- static unsigned numberOfThingsPerRegion() { return (size() - headerSize()) / sizeof(T); }
- T* data() { return bitwise_cast<T*>(bitwise_cast<char*>(this) + headerSize()); }
- bool isInThisRegion(const T* pointer) { return static_cast<unsigned>(pointer - data()) < numberOfThingsPerRegion(); }
- static Region* regionFor(const T* pointer) { return bitwise_cast<Region*>(bitwise_cast<uintptr_t>(pointer) & ~(size() - 1)); }
-
- void* m_allocation;
- Allocator* m_allocator;
- Region* m_next;
- };
-
- void freeRegionsStartingAt(Region*);
- void startBumpingIn(Region*);
-
- Region* m_regionHead;
- void** m_freeListHead;
- T* m_bumpEnd;
- unsigned m_bumpRemaining;
-};
-
-template<typename T>
-inline Allocator<T>::Allocator()
- : m_regionHead(0)
- , m_freeListHead(0)
- , m_bumpRemaining(0)
-{
-}
-
-template<typename T>
-inline Allocator<T>::~Allocator()
-{
- reset();
-}
-
-template<typename T>
-ALWAYS_INLINE void* Allocator<T>::allocate()
-{
- void* result = bumpAllocate();
- if (LIKELY(!!result))
- return result;
- return freeListAllocate();
-}
-
-template<typename T>
-void Allocator<T>::free(T* object)
-{
- object->~T();
-
- void** cell = bitwise_cast<void**>(object);
- *cell = m_freeListHead;
- m_freeListHead = cell;
-}
-
-template<typename T>
-void Allocator<T>::freeAll()
-{
- if (!m_regionHead) {
- ASSERT(!m_bumpRemaining);
- ASSERT(!m_freeListHead);
- return;
- }
-
- // Since the caller is opting out of calling the destructor for any allocated thing,
- // we have two choices, plus a continuum between: we can either just delete all regions
- // (i.e. call reset()), or we can make all regions available for reuse. We do something
- // that optimizes for (a) speed of freeAll(), (b) the assumption that if the user calls
- // freeAll() then they will probably be calling allocate() in the near future. Namely,
- // we free all but one region, and make the remaining region a bump allocation region.
-
- freeRegionsStartingAt(m_regionHead->m_next);
-
- m_regionHead->m_next = 0;
- m_freeListHead = 0;
- startBumpingIn(m_regionHead);
-}
-
-template<typename T>
-void Allocator<T>::reset()
-{
- freeRegionsStartingAt(m_regionHead);
-
- m_regionHead = 0;
- m_freeListHead = 0;
- m_bumpRemaining = 0;
-}
-
-template<typename T>
-unsigned Allocator<T>::indexOf(const T* object)
-{
- unsigned numRegions = 0;
- for (Region* region = m_regionHead; region; region = region->m_next)
- numRegions++;
- unsigned regionIndex = 0;
- for (Region* region = m_regionHead; region; region = region->m_next) {
- if (region->isInThisRegion(object))
- return (numRegions - 1 - regionIndex) * Region::numberOfThingsPerRegion() + (object - region->data());
- regionIndex++;
- }
- CRASH();
- return 0;
-}
-
-template<typename T>
-Allocator<T>* Allocator<T>::allocatorOf(const T* object)
-{
- return Region::regionFor(object)->m_allocator;
-}
-
-template<typename T>
-ALWAYS_INLINE void* Allocator<T>::bumpAllocate()
-{
- if (unsigned remaining = m_bumpRemaining) {
- remaining--;
- m_bumpRemaining = remaining;
- return m_bumpEnd - (remaining + 1);
- }
- return 0;
-}
-
-template<typename T>
-void* Allocator<T>::freeListAllocate()
-{
- void** result = m_freeListHead;
- if (UNLIKELY(!result))
- return allocateSlow();
- m_freeListHead = bitwise_cast<void**>(*result);
- return result;
-}
-
-template<typename T>
-void* Allocator<T>::allocateSlow()
-{
- ASSERT(!m_freeListHead);
- ASSERT(!m_bumpRemaining);
-
- if (logCompilationChanges())
- dataLog("Allocating another allocator region.\n");
-
- void* allocation = fastAlignedMalloc(Region::size(), Region::size());
- Region* region = static_cast<Region*>(allocation);
- region->m_allocation = allocation;
- region->m_allocator = this;
- startBumpingIn(region);
- region->m_next = m_regionHead;
- m_regionHead = region;
-
- void* result = bumpAllocate();
- ASSERT(result);
- return result;
-}
-
-template<typename T>
-void Allocator<T>::freeRegionsStartingAt(typename Allocator<T>::Region* region)
-{
- while (region) {
- Region* nextRegion = region->m_next;
- fastAlignedFree(region->m_allocation);
- region = nextRegion;
- }
-}
-
-template<typename T>
-void Allocator<T>::startBumpingIn(typename Allocator<T>::Region* region)
-{
- m_bumpEnd = region->data() + Region::numberOfThingsPerRegion();
- m_bumpRemaining = Region::numberOfThingsPerRegion();
-}
-
-} } // namespace JSC::DFG
-
-#endif // ENABLE(DFG_JIT)
Modified: trunk/Source/_javascript_Core/dfg/DFGDriver.cpp (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGDriver.cpp 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGDriver.cpp 2017-05-13 04:59:35 UTC (rev 216815)
@@ -108,7 +108,7 @@
return CompilationDeferred;
}
- plan->compileInThread(*vm.dfgState, 0);
+ plan->compileInThread(nullptr);
return plan->finalizeWithoutNotifyingCallback();
}
#else // ENABLE(DFG_JIT)
Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.cpp (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGGraph.cpp 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.cpp 2017-05-13 04:59:35 UTC (rev 216815)
@@ -68,12 +68,11 @@
#undef STRINGIZE_DFG_OP_ENUM
};
-Graph::Graph(VM& vm, Plan& plan, LongLivedState& longLivedState)
+Graph::Graph(VM& vm, Plan& plan)
: m_vm(vm)
, m_plan(plan)
, m_codeBlock(m_plan.codeBlock)
, m_profiledBlock(m_codeBlock->alternative())
- , m_allocator(longLivedState.m_allocator)
, m_cfg(std::make_unique<CFG>(*this))
, m_nextMachineLocal(0)
, m_fixpointState(BeforeFixpoint)
@@ -96,17 +95,6 @@
Graph::~Graph()
{
- for (BlockIndex blockIndex = numBlocks(); blockIndex--;) {
- BasicBlock* block = this->block(blockIndex);
- if (!block)
- continue;
-
- for (unsigned phiIndex = block->phis.size(); phiIndex--;)
- m_allocator.free(block->phis[phiIndex]);
- for (unsigned nodeIndex = block->size(); nodeIndex--;)
- m_allocator.free(block->at(nodeIndex));
- }
- m_allocator.freeAll();
}
const char *Graph::opName(NodeType op)
@@ -599,19 +587,6 @@
}
}
-void Graph::addNodeToMapByIndex(Node* node)
-{
- if (m_nodeIndexFreeList.isEmpty()) {
- node->m_index = m_nodesByIndex.size();
- m_nodesByIndex.append(node);
- return;
- }
- unsigned index = m_nodeIndexFreeList.takeLast();
- node->m_index = index;
- ASSERT(!m_nodesByIndex[index]);
- m_nodesByIndex[index] = node;
-}
-
void Graph::deleteNode(Node* node)
{
if (validationEnabled() && m_form == SSA) {
@@ -621,48 +596,12 @@
}
}
- RELEASE_ASSERT(m_nodesByIndex[node->m_index] == node);
- unsigned nodeIndex = node->m_index;
- m_nodesByIndex[nodeIndex] = nullptr;
- m_nodeIndexFreeList.append(nodeIndex);
-
- m_allocator.free(node);
+ m_nodes.remove(node);
}
void Graph::packNodeIndices()
{
- if (m_nodeIndexFreeList.isEmpty())
- return;
-
- unsigned holeIndex = 0;
- unsigned endIndex = m_nodesByIndex.size();
-
- while (true) {
- while (holeIndex < endIndex && m_nodesByIndex[holeIndex])
- ++holeIndex;
-
- if (holeIndex == endIndex)
- break;
- ASSERT(holeIndex < m_nodesByIndex.size());
- ASSERT(!m_nodesByIndex[holeIndex]);
-
- do {
- --endIndex;
- } while (!m_nodesByIndex[endIndex] && endIndex > holeIndex);
-
- if (holeIndex == endIndex)
- break;
- ASSERT(endIndex > holeIndex);
- ASSERT(m_nodesByIndex[endIndex]);
-
- auto& value = m_nodesByIndex[endIndex];
- value->m_index = holeIndex;
- m_nodesByIndex[holeIndex] = WTFMove(value);
- ++holeIndex;
- }
-
- m_nodeIndexFreeList.resize(0);
- m_nodesByIndex.resize(endIndex);
+ m_nodes.packIndices();
}
void Graph::dethread()
Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.h (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGGraph.h 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.h 2017-05-13 04:59:35 UTC (rev 216815)
@@ -33,9 +33,7 @@
#include "DFGArgumentPosition.h"
#include "DFGBasicBlock.h"
#include "DFGFrozenValue.h"
-#include "DFGLongLivedState.h"
#include "DFGNode.h"
-#include "DFGNodeAllocator.h"
#include "DFGPlan.h"
#include "DFGPropertyTypeKey.h"
#include "DFGScannable.h"
@@ -126,7 +124,7 @@
// Nodes that are 'dead' remain in the vector with refCount 0.
class Graph : public virtual Scannable {
public:
- Graph(VM&, Plan&, LongLivedState&);
+ Graph(VM&, Plan&);
~Graph();
void changeChild(Edge& edge, Node* newNode)
@@ -186,22 +184,20 @@
template<typename... Params>
Node* addNode(Params... params)
{
- Node* node = new (m_allocator) Node(params...);
- addNodeToMapByIndex(node);
- return node;
+ return m_nodes.addNew(params...);
}
+
template<typename... Params>
Node* addNode(SpeculatedType type, Params... params)
{
- Node* node = new (m_allocator) Node(params...);
+ Node* node = m_nodes.addNew(params...);
node->predict(type);
- addNodeToMapByIndex(node);
return node;
}
void deleteNode(Node*);
- unsigned maxNodeCount() const { return m_nodesByIndex.size(); }
- Node* nodeAt(unsigned index) const { return m_nodesByIndex[index]; }
+ unsigned maxNodeCount() const { return m_nodes.size(); }
+ Node* nodeAt(unsigned index) const { return m_nodes[index]; }
void packNodeIndices();
void dethread();
@@ -923,8 +919,6 @@
CodeBlock* m_codeBlock;
CodeBlock* m_profiledBlock;
- NodeAllocator& m_allocator;
-
Vector< RefPtr<BasicBlock> , 8> m_blocks;
Vector<Edge, 16> m_varArgChildren;
@@ -1020,8 +1014,6 @@
RegisteredStructure symbolStructure;
private:
- void addNodeToMapByIndex(Node*);
-
bool isStringPrototypeMethodSane(JSGlobalObject*, UniquedStringImpl*);
void handleSuccessor(Vector<BasicBlock*, 16>& worklist, BasicBlock*, BasicBlock* successor);
@@ -1054,8 +1046,7 @@
return bytecodeCanTruncateInteger(add->arithNodeFlags()) ? SpeculateInt32AndTruncateConstants : DontSpeculateInt32;
}
- Vector<Node*, 0, UnsafeVectorOverflow> m_nodesByIndex;
- Vector<unsigned, 0, UnsafeVectorOverflow> m_nodeIndexFreeList;
+ B3::SparseCollection<Node> m_nodes;
SegmentedVector<RegisteredStructureSet, 16> m_structureSets;
};
Deleted: trunk/Source/_javascript_Core/dfg/DFGLongLivedState.cpp (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGLongLivedState.cpp 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGLongLivedState.cpp 2017-05-13 04:59:35 UTC (rev 216815)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DFGLongLivedState.h"
-
-#if ENABLE(DFG_JIT)
-
-#include "JSCInlines.h"
-
-namespace JSC { namespace DFG {
-
-LongLivedState::LongLivedState()
-{
-}
-
-LongLivedState::~LongLivedState()
-{
-}
-
-void LongLivedState::shrinkToFit()
-{
- m_allocator.reset();
-}
-
-} } // namespace JSC::DFG
-
-#endif // ENABLE(DFG_JIT)
-
Deleted: trunk/Source/_javascript_Core/dfg/DFGLongLivedState.h (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGLongLivedState.h 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGLongLivedState.h 2017-05-13 04:59:35 UTC (rev 216815)
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(DFG_JIT)
-
-#include "DFGNodeAllocator.h"
-#include <wtf/FastMalloc.h>
-#include <wtf/Noncopyable.h>
-
-namespace JSC { namespace DFG {
-
-class LongLivedState {
- WTF_MAKE_FAST_ALLOCATED; WTF_MAKE_NONCOPYABLE(LongLivedState);
-public:
- LongLivedState();
- ~LongLivedState();
-
- void shrinkToFit();
-
- NodeAllocator m_allocator;
-};
-
-} } // namespace JSC::DFG
-
-#endif // ENABLE(DFG_JIT)
Modified: trunk/Source/_javascript_Core/dfg/DFGNode.h (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGNode.h 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGNode.h 2017-05-13 04:59:35 UTC (rev 216815)
@@ -27,6 +27,7 @@
#if ENABLE(DFG_JIT)
+#include "B3SparseCollection.h"
#include "BasicBlockLocation.h"
#include "CodeBlock.h"
#include "DFGAbstractValue.h"
@@ -246,6 +247,7 @@
//
// Node represents a single operation in the data flow graph.
struct Node {
+ WTF_MAKE_FAST_ALLOCATED;
public:
static const char HashSetTemplateInstantiationString[];
@@ -2533,7 +2535,7 @@
AdjacencyList children;
private:
- friend class Graph;
+ friend class B3::SparseCollection<Node>;
unsigned m_index { std::numeric_limits<unsigned>::max() };
unsigned m_op : 10; // real type is NodeType
Modified: trunk/Source/_javascript_Core/dfg/DFGNodeAllocator.h (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGNodeAllocator.h 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGNodeAllocator.h 2017-05-13 04:59:35 UTC (rev 216815)
@@ -27,7 +27,6 @@
#if ENABLE(DFG_JIT)
-#include "DFGAllocator.h"
#include "DFGNode.h"
namespace JSC { namespace DFG {
Modified: trunk/Source/_javascript_Core/dfg/DFGPlan.cpp (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGPlan.cpp 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGPlan.cpp 2017-05-13 04:59:35 UTC (rev 216815)
@@ -169,7 +169,7 @@
|| (Options::reportFTLCompileTimes() && isFTL(mode));
}
-void Plan::compileInThread(LongLivedState& longLivedState, ThreadData* threadData)
+void Plan::compileInThread(ThreadData* threadData)
{
this->threadData = threadData;
@@ -185,7 +185,7 @@
if (logCompilationChanges(mode) || Options::reportDFGPhaseTimes())
dataLog("DFG(Plan) compiling ", *codeBlock, " with ", mode, ", number of instructions = ", codeBlock->instructionCount(), "\n");
- CompilationPath path = compileInThreadImpl(longLivedState);
+ CompilationPath path = compileInThreadImpl();
RELEASE_ASSERT(path == CancelPath || finalizer);
RELEASE_ASSERT((path == CancelPath) == (stage == Cancelled));
@@ -235,7 +235,7 @@
}
}
-Plan::CompilationPath Plan::compileInThreadImpl(LongLivedState& longLivedState)
+Plan::CompilationPath Plan::compileInThreadImpl()
{
cleanMustHandleValuesIfNecessary();
@@ -245,7 +245,7 @@
dataLog("\n");
}
- Graph dfg(*vm, *this, longLivedState);
+ Graph dfg(*vm, *this);
if (!parse(dfg)) {
finalizer = std::make_unique<FailedFinalizer>(*this);
Modified: trunk/Source/_javascript_Core/dfg/DFGPlan.h (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGPlan.h 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGPlan.h 2017-05-13 04:59:35 UTC (rev 216815)
@@ -47,7 +47,6 @@
namespace DFG {
-class LongLivedState;
class ThreadData;
#if ENABLE(DFG_JIT)
@@ -59,7 +58,7 @@
const Operands<JSValue>& mustHandleValues);
~Plan();
- void compileInThread(LongLivedState&, ThreadData*);
+ void compileInThread(ThreadData*);
CompilationResult finalizeWithoutNotifyingCallback();
void finalizeAndNotifyCallback();
@@ -122,7 +121,7 @@
bool reportCompileTimes() const;
enum CompilationPath { FailPath, DFGPath, FTLPath, CancelPath };
- CompilationPath compileInThreadImpl(LongLivedState&);
+ CompilationPath compileInThreadImpl();
bool isStillValid();
void reallyAdd(CommonData*);
Modified: trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp (216814 => 216815)
--- trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp 2017-05-13 04:59:35 UTC (rev 216815)
@@ -27,7 +27,6 @@
#include "DFGWorklist.h"
#include "CodeBlock.h"
-#include "DFGLongLivedState.h"
#include "DFGSafepoint.h"
#include "DeferGC.h"
#include "JSCInlines.h"
@@ -109,7 +108,7 @@
dataLog("Heap is stoped but here we are! (1)\n");
RELEASE_ASSERT_NOT_REACHED();
}
- m_plan->compileInThread(*m_longLivedState, &m_data);
+ m_plan->compileInThread(&m_data);
if (m_plan->stage != Plan::Cancelled) {
if (m_plan->vm->heap.collectorBelievesThatTheWorldIsStopped()) {
dataLog("Heap is stopped but here we are! (2)\n");
@@ -147,7 +146,6 @@
Thread::current().changePriority(m_relativePriority);
m_compilationScope = std::make_unique<CompilationScope>();
- m_longLivedState = std::make_unique<LongLivedState>();
}
void threadIsStopping(const AbstractLocker&) override
@@ -160,7 +158,6 @@
ASSERT(!m_plan);
m_compilationScope = nullptr;
- m_longLivedState = nullptr;
m_plan = nullptr;
}
@@ -169,7 +166,6 @@
ThreadData& m_data;
int m_relativePriority;
std::unique_ptr<CompilationScope> m_compilationScope;
- std::unique_ptr<LongLivedState> m_longLivedState;
RefPtr<Plan> m_plan;
};
Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (216814 => 216815)
--- trunk/Source/_javascript_Core/runtime/VM.cpp 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp 2017-05-13 04:59:35 UTC (rev 216815)
@@ -38,7 +38,6 @@
#include "CommonIdentifiers.h"
#include "CommonSlowPaths.h"
#include "CustomGetterSetter.h"
-#include "DFGLongLivedState.h"
#include "DFGWorklist.h"
#include "Disassembler.h"
#include "ErrorInstance.h"
@@ -315,11 +314,6 @@
callFrameForCatch = nullptr;
-#if ENABLE(DFG_JIT)
- if (canUseJIT())
- dfgState = std::make_unique<DFG::LongLivedState>();
-#endif
-
// Initialize this last, as a free way of asserting that VM initialization itself
// won't use this.
m_typedArrayController = adoptRef(new SimpleTypedArrayController());
Modified: trunk/Source/_javascript_Core/runtime/VM.h (216814 => 216815)
--- trunk/Source/_javascript_Core/runtime/VM.h 2017-05-13 03:09:57 UTC (rev 216814)
+++ trunk/Source/_javascript_Core/runtime/VM.h 2017-05-13 04:59:35 UTC (rev 216815)
@@ -141,11 +141,6 @@
class Watchpoint;
class WatchpointSet;
-#if ENABLE(DFG_JIT)
-namespace DFG {
-class LongLivedState;
-}
-#endif // ENABLE(DFG_JIT)
#if ENABLE(FTL_JIT)
namespace FTL {
class Thunks;
@@ -300,10 +295,6 @@
JSWebAssemblyCodeBlockSubspace webAssemblyCodeBlockSpace;
#endif
-#if ENABLE(DFG_JIT)
- std::unique_ptr<DFG::LongLivedState> dfgState;
-#endif // ENABLE(DFG_JIT)
-
VMType vmType;
ClientData* clientData;
VMEntryFrame* topVMEntryFrame;