WebKit Bugzilla
Attachment 369261 Details for
Bug 186740
: CodeBlockSet wastes 190KB of HashTable capacity on nytimes.com
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186740-20190507022526.patch (text/plain), 62.33 KB, created by
Yusuke Suzuki
on 2019-05-07 02:25:27 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2019-05-07 02:25:27 PDT
Size:
62.33 KB
patch
obsolete
>Subversion Revision: 244955 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 7d960395584de6aa830c033c9f0c21d4162c62f6..6f5997e142d54ab36934d602fd4bca74d3cb2e52 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,89 @@ >+2019-05-07 Yusuke Suzuki <ysuzuki@apple.com> >+ >+ CodeBlockSet wastes 190KB of HashTable capacity on nytimes.com >+ https://bugs.webkit.org/show_bug.cgi?id=186740 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * CMakeLists.txt: >+ * JavaScriptCore.xcodeproj/project.pbxproj: >+ * Sources.txt: >+ * bytecode/CodeBlock.cpp: >+ (JSC::CodeBlock::CodeBlock): >+ (JSC::CodeBlock::~CodeBlock): >+ (JSC::CodeBlock::visitChildren): >+ (JSC::CodeBlock::finalizeUnconditionally): >+ * bytecode/EvalCodeBlock.h: >+ * bytecode/FunctionCodeBlock.h: >+ * bytecode/ModuleProgramCodeBlock.h: >+ * bytecode/ProgramCodeBlock.h: >+ * dfg/DFGCompilationKey.cpp: >+ * heap/CodeBlockSet.cpp: Removed. >+ * heap/CodeBlockSetInlines.h: Removed. >+ * heap/ConservativeRoots.cpp: >+ (JSC::CompositeMarkHook::CompositeMarkHook): >+ (JSC::CompositeMarkHook::markKnownJSCell): >+ (JSC::ConservativeRoots::add): >+ * heap/ConservativeRoots.h: >+ * heap/Heap.cpp: >+ (JSC::Heap::Heap): >+ (JSC::Heap::dumpHeapStatisticsAtVMDestruction): >+ (JSC::Heap::finalizeUnconditionalFinalizers): >+ (JSC::Heap::iterateExecutingAndCompilingCodeBlocks): >+ (JSC::Heap::gatherStackRoots): >+ (JSC::Heap::gatherJSStackRoots): >+ (JSC::Heap::deleteUnmarkedCompiledCode): >+ (JSC::Heap::runEndPhase): >+ (JSC::Heap::forEachCodeBlockImpl): >+ (JSC::Heap::forEachCodeBlockIgnoringJITPlansImpl): >+ * heap/Heap.h: >+ (JSC::Heap::codeBlockSet): Deleted. >+ * heap/IsoCellSet.cpp: >+ (JSC::IsoCellSet::addSlow): >+ * heap/IsoCellSet.h: >+ * heap/IsoCellSetInlines.h: >+ (JSC::IsoCellSet::add): >+ (JSC::IsoCellSet::remove): >+ (JSC::IsoCellSet::containsConservative const): >+ (JSC::IsoCellSet::forEachLiveCell): >+ (JSC::IsoCellSet::forEachCell): >+ * heap/IsoSubspace.h: >+ * heap/MachineStackMarker.cpp: >+ (JSC::MachineThreads::gatherFromCurrentThread): >+ (JSC::MachineThreads::gatherConservativeRoots): >+ * heap/MachineStackMarker.h: >+ * heap/MarkedBlock.cpp: >+ (JSC::MarkedBlock::Handle::stopAllocating): >+ * heap/MarkedBlock.h: >+ (JSC::MarkedBlock::Handle::forEachCell): >+ * interpreter/CLoopStack.cpp: >+ (JSC::CLoopStack::gatherConservativeRoots): >+ * interpreter/CLoopStack.h: >+ * runtime/CodeBlockSubspace.h: Renamed from Source/JavaScriptCore/heap/CodeBlockSet.h. >+ (JSC::CodeBlockSubspace::CodeBlockSubspace): >+ (JSC::CodeBlockSubspace::getLock): >+ * runtime/CodeBlockSubspaceInlines.h: Added. >+ (JSC::CodeBlockSubspace::add): >+ (JSC::CodeBlockSubspace::remove): >+ (JSC::CodeBlockSubspace::contains): >+ (JSC::CodeBlockSubspace::iterate): >+ (JSC::CodeBlockSubspace::addCurrentlyExecutingInGC): >+ (JSC::CodeBlockSubspace::removeCurrentlyExecutingInGC): >+ (JSC::CodeBlockSubspace::iterateCurrentlyExecutingInGC): >+ * runtime/JSGlobalObject.cpp: >+ (JSC::JSGlobalObject::bumpGlobalLexicalBindingEpoch): >+ * runtime/SamplingProfiler.cpp: >+ (JSC::FrameWalker::isValidCodeBlock): >+ (JSC::SamplingProfiler::takeSample): >+ * runtime/VM.h: >+ (JSC::VM::forEachCodeBlockSpace): Deleted. >+ * runtime/VMTraps.cpp: >+ (JSC::VMTraps::tryInstallTrapBreakpoints): >+ (JSC::VMTraps::invalidateCodeBlocksOnStack): >+ (JSC::VMTraps::handleTraps): >+ * tools/VMInspector.cpp: >+ (JSC::VMInspector::codeBlockForMachinePC): >+ > 2019-05-04 Tadeu Zagallo <tzagallo@apple.com> > > TypedArrays should not store properties that are canonical numeric indices >diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt >index fb6210c3f7275e70440fe41fdbc898c6be64574d..e04e68d5932818d49b089d36e009cffb2e058d94 100644 >--- a/Source/JavaScriptCore/CMakeLists.txt >+++ b/Source/JavaScriptCore/CMakeLists.txt >@@ -764,6 +764,8 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS > runtime/CallData.h > runtime/CatchScope.h > runtime/ClassInfo.h >+ runtime/CodeBlockSubspace.h >+ runtime/CodeBlockSubspaceInlines.h > runtime/CodeSpecializationKind.h > runtime/CommonIdentifiers.h > runtime/CompilationResult.h >diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >index e7dc887b9aaf815bb3b80a7d42e8a07f894fdd03..57bab9761d88afaf1499c68f855e8e3e184cff1f 100644 >--- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >+++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >@@ -397,7 +397,6 @@ > 0F6585E11EE0805A0095176D /* FreeListInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F6585E01EE080570095176D /* FreeListInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0F660E381E0517BB0031462C /* MarkingConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F660E341E0517B70031462C /* MarkingConstraint.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0F660E3A1E0517C10031462C /* MarkingConstraintSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F660E361E0517B80031462C /* MarkingConstraintSet.h */; }; >- 0F664CE81DA304EF00B00A11 /* CodeBlockSetInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F664CE71DA304ED00B00A11 /* CodeBlockSetInlines.h */; }; > 0F666EC0183566F900D017F1 /* BytecodeLivenessAnalysisInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F666EBE183566F900D017F1 /* BytecodeLivenessAnalysisInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0F666EC1183566F900D017F1 /* FullBytecodeLiveness.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F666EBF183566F900D017F1 /* FullBytecodeLiveness.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0F666EC71835672B00D017F1 /* DFGAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F666EC31835672B00D017F1 /* DFGAvailability.h */; }; >@@ -579,7 +578,6 @@ > 0FD81AD3154FB4F000983E72 /* DFGDominators.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD81AD0154FB4EB00983E72 /* DFGDominators.h */; }; > 0FD82E54141DAEEE00179C94 /* SpeculatedType.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82E4F141DAEA100179C94 /* SpeculatedType.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82E53141DAEDE00179C94 /* DFGOSREntry.h */; }; >- 0FD8A31417D4326C00CA2C40 /* CodeBlockSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD8A31217D4326C00CA2C40 /* CodeBlockSet.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0FD8A31A17D51F2200CA2C40 /* FTLForOSREntryJITCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD8A31617D51F2200CA2C40 /* FTLForOSREntryJITCode.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0FD8A31C17D51F2200CA2C40 /* FTLOSREntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD8A31817D51F2200CA2C40 /* FTLOSREntry.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0FD8A32617D51F5700CA2C40 /* DFGOSREntrypointCreationPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD8A31E17D51F5700CA2C40 /* DFGOSREntrypointCreationPhase.h */; }; >@@ -2549,7 +2547,6 @@ > 0F660E341E0517B70031462C /* MarkingConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkingConstraint.h; sourceTree = "<group>"; }; > 0F660E351E0517B70031462C /* MarkingConstraintSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkingConstraintSet.cpp; sourceTree = "<group>"; }; > 0F660E361E0517B80031462C /* MarkingConstraintSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkingConstraintSet.h; sourceTree = "<group>"; }; >- 0F664CE71DA304ED00B00A11 /* CodeBlockSetInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeBlockSetInlines.h; sourceTree = "<group>"; }; > 0F666EBE183566F900D017F1 /* BytecodeLivenessAnalysisInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BytecodeLivenessAnalysisInlines.h; sourceTree = "<group>"; }; > 0F666EBF183566F900D017F1 /* FullBytecodeLiveness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullBytecodeLiveness.h; sourceTree = "<group>"; }; > 0F666EC21835672B00D017F1 /* DFGAvailability.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGAvailability.cpp; path = dfg/DFGAvailability.cpp; sourceTree = "<group>"; }; >@@ -2866,8 +2863,6 @@ > 0FD82E52141DAEDE00179C94 /* DFGOSREntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGOSREntry.cpp; path = dfg/DFGOSREntry.cpp; sourceTree = "<group>"; }; > 0FD82E53141DAEDE00179C94 /* DFGOSREntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGOSREntry.h; path = dfg/DFGOSREntry.h; sourceTree = "<group>"; }; > 0FD82E84141F3FDA00179C94 /* SpeculatedType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpeculatedType.cpp; sourceTree = "<group>"; }; >- 0FD8A31117D4326C00CA2C40 /* CodeBlockSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeBlockSet.cpp; sourceTree = "<group>"; }; >- 0FD8A31217D4326C00CA2C40 /* CodeBlockSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeBlockSet.h; sourceTree = "<group>"; }; > 0FD8A31517D51F2200CA2C40 /* FTLForOSREntryJITCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLForOSREntryJITCode.cpp; path = ftl/FTLForOSREntryJITCode.cpp; sourceTree = "<group>"; }; > 0FD8A31617D51F2200CA2C40 /* FTLForOSREntryJITCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLForOSREntryJITCode.h; path = ftl/FTLForOSREntryJITCode.h; sourceTree = "<group>"; }; > 0FD8A31717D51F2200CA2C40 /* FTLOSREntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLOSREntry.cpp; path = ftl/FTLOSREntry.cpp; sourceTree = "<group>"; }; >@@ -5903,9 +5898,6 @@ > 0F070A421D543A89006E7232 /* CellContainer.h */, > 0F070A431D543A89006E7232 /* CellContainerInlines.h */, > 0F1C3DD91BBCE09E00E523E4 /* CellState.h */, >- 0FD8A31117D4326C00CA2C40 /* CodeBlockSet.cpp */, >- 0FD8A31217D4326C00CA2C40 /* CodeBlockSet.h */, >- 0F664CE71DA304ED00B00A11 /* CodeBlockSetInlines.h */, > 0FD0E5F11E46C8AD0006AB08 /* CollectingScope.h */, > 0FA762001DB9242300B7A2FD /* CollectionScope.cpp */, > 0FA762011DB9242300B7A2FD /* CollectionScope.h */, >@@ -8806,8 +8798,6 @@ > 969A07970ED1D3AE00F1F681 /* CodeBlock.h in Headers */, > 0F8F94411667633200D61971 /* CodeBlockHash.h in Headers */, > 0FC97F34182020D7002C9B26 /* CodeBlockJettisoningWatchpoint.h in Headers */, >- 0FD8A31417D4326C00CA2C40 /* CodeBlockSet.h in Headers */, >- 0F664CE81DA304EF00B00A11 /* CodeBlockSetInlines.h in Headers */, > 0F96EBB316676EF6008BADE3 /* CodeBlockWithJITType.h in Headers */, > A77F1822164088B200640A47 /* CodeCache.h in Headers */, > 86E116B10FE75AC800B512BC /* CodeLocation.h in Headers */, >diff --git a/Source/JavaScriptCore/Sources.txt b/Source/JavaScriptCore/Sources.txt >index f5534441390d1a608aae0dc28ffbef31868329b4..183b0586276d2eaaed731381790fce73739a699a 100644 >--- a/Source/JavaScriptCore/Sources.txt >+++ b/Source/JavaScriptCore/Sources.txt >@@ -491,7 +491,6 @@ heap/Allocator.cpp > heap/BlockDirectory.cpp > heap/CellAttributes.cpp > heap/CellContainer.cpp >-heap/CodeBlockSet.cpp > heap/CollectionScope.cpp > heap/CollectorPhase.cpp > heap/CompleteSubspace.cpp >diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp >index 7b191cd2bec07ce930305cddc27376d8c67f9e5b..73507e6cdbc3707951e6e6c47056ca8e6160ff8c 100644 >--- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp >+++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp >@@ -39,7 +39,7 @@ > #include "BytecodeUseDef.h" > #include "CallLinkStatus.h" > #include "CodeBlockInlines.h" >-#include "CodeBlockSet.h" >+#include "CodeBlockSubspaceInlines.h" > #include "DFGCapabilities.h" > #include "DFGCommon.h" > #include "DFGDriver.h" >@@ -321,7 +321,7 @@ CodeBlock::CodeBlock(VM* vm, Structure* structure, CopyParsedBlockTag, CodeBlock > ASSERT(source().provider()); > setNumParameters(other.numParameters()); > >- vm->heap.codeBlockSet().add(this); >+ vm->codeBlockSpace.add(this); > } > > void CodeBlock::finishCreation(VM& vm, CopyParsedBlockTag, CodeBlock& other) >@@ -373,7 +373,7 @@ CodeBlock::CodeBlock(VM* vm, Structure* structure, ScriptExecutable* ownerExecut > ASSERT(source().provider()); > setNumParameters(unlinkedCodeBlock->numParameters()); > >- vm->heap.codeBlockSet().add(this); >+ vm->codeBlockSpace.add(this); > } > > // The main purpose of this function is to generate linked bytecode from unlinked bytecode. The process >@@ -813,7 +813,7 @@ CodeBlock::~CodeBlock() > { > VM& vm = *m_vm; > >- vm.heap.codeBlockSet().remove(this); >+ vm.codeBlockSpace.remove(this); > > if (UNLIKELY(vm.m_perBytecodeProfiler)) > vm.m_perBytecodeProfiler->notifyDestruction(this); >@@ -973,8 +973,6 @@ void CodeBlock::visitChildren(SlotVisitor& visitor) > > stronglyVisitStrongReferences(locker, visitor); > stronglyVisitWeakReferences(locker, visitor); >- >- VM::SpaceAndSet::setFor(*subspace()).add(this); > } > > bool CodeBlock::shouldVisitStrongly(const ConcurrentJSLocker& locker) >@@ -1373,8 +1371,6 @@ void CodeBlock::finalizeUnconditionally(VM& vm) > dfgCommon->recordedStatuses.finalize(vm); > } > #endif // ENABLE(DFG_JIT) >- >- VM::SpaceAndSet::setFor(*subspace()).remove(this); > } > > void CodeBlock::destroy(JSCell* cell) >diff --git a/Source/JavaScriptCore/bytecode/EvalCodeBlock.h b/Source/JavaScriptCore/bytecode/EvalCodeBlock.h >index b9f28d02c7142947d981cb07a9c5522a081fa79e..7f4b8feffb75b168b0a706858a33494877de5aad 100644 >--- a/Source/JavaScriptCore/bytecode/EvalCodeBlock.h >+++ b/Source/JavaScriptCore/bytecode/EvalCodeBlock.h >@@ -39,9 +39,9 @@ class EvalCodeBlock final : public GlobalCodeBlock { > DECLARE_INFO; > > template<typename, SubspaceAccess> >- static IsoSubspace* subspaceFor(VM& vm) >+ static CodeBlockSubspace* subspaceFor(VM& vm) > { >- return &vm.codeBlockSpace.space; >+ return &vm.codeBlockSpace; > } > > static EvalCodeBlock* create(VM* vm, CopyParsedBlockTag, EvalCodeBlock& other) >diff --git a/Source/JavaScriptCore/bytecode/FunctionCodeBlock.h b/Source/JavaScriptCore/bytecode/FunctionCodeBlock.h >index 853fae95de3aa2842cd0c7658a56d13a9950eea5..4cf0f441fe588337bdda8509993eab0712b9e8b4 100644 >--- a/Source/JavaScriptCore/bytecode/FunctionCodeBlock.h >+++ b/Source/JavaScriptCore/bytecode/FunctionCodeBlock.h >@@ -42,7 +42,7 @@ class FunctionCodeBlock final : public CodeBlock { > template<typename, SubspaceAccess> > static IsoSubspace* subspaceFor(VM& vm) > { >- return &vm.codeBlockSpace.space; >+ return &vm.codeBlockSpace; > } > > static FunctionCodeBlock* create(VM* vm, CopyParsedBlockTag, FunctionCodeBlock& other) >diff --git a/Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h b/Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h >index 23556cd1c5b9800daffc62096acfc7e362cb45dd..479775b8d1f74e3658802a4464ad647bb9cad696 100644 >--- a/Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h >+++ b/Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h >@@ -40,9 +40,9 @@ class ModuleProgramCodeBlock final : public GlobalCodeBlock { > DECLARE_INFO; > > template<typename, SubspaceAccess> >- static IsoSubspace* subspaceFor(VM& vm) >+ static CodeBlockSubspace* subspaceFor(VM& vm) > { >- return &vm.codeBlockSpace.space; >+ return &vm.codeBlockSpace; > } > > static ModuleProgramCodeBlock* create(VM* vm, CopyParsedBlockTag, ModuleProgramCodeBlock& other) >diff --git a/Source/JavaScriptCore/bytecode/ProgramCodeBlock.h b/Source/JavaScriptCore/bytecode/ProgramCodeBlock.h >index eb795fd38e7080e5290ccb4019cf1fa71691f412..4439dd45f3fe951e53887435c9895e97b0e4f011 100644 >--- a/Source/JavaScriptCore/bytecode/ProgramCodeBlock.h >+++ b/Source/JavaScriptCore/bytecode/ProgramCodeBlock.h >@@ -40,9 +40,9 @@ class ProgramCodeBlock final : public GlobalCodeBlock { > DECLARE_INFO; > > template<typename, SubspaceAccess> >- static IsoSubspace* subspaceFor(VM& vm) >+ static CodeBlockSubspace* subspaceFor(VM& vm) > { >- return &vm.codeBlockSpace.space; >+ return &vm.codeBlockSpace; > } > > static ProgramCodeBlock* create(VM* vm, CopyParsedBlockTag, ProgramCodeBlock& other) >diff --git a/Source/JavaScriptCore/dfg/DFGCompilationKey.cpp b/Source/JavaScriptCore/dfg/DFGCompilationKey.cpp >index 20ad082cc4a0503ec96943c47c9b442af87ff55f..b9515db04e5364ea50b75e17892df8531a19c9db 100644 >--- a/Source/JavaScriptCore/dfg/DFGCompilationKey.cpp >+++ b/Source/JavaScriptCore/dfg/DFGCompilationKey.cpp >@@ -29,7 +29,6 @@ > #if ENABLE(DFG_JIT) > > #include "CodeBlock.h" >-#include "CodeBlockSet.h" > #include "JSCInlines.h" > > namespace JSC { namespace DFG { >diff --git a/Source/JavaScriptCore/heap/CodeBlockSet.cpp b/Source/JavaScriptCore/heap/CodeBlockSet.cpp >deleted file mode 100644 >index 49fcd84f4ad97aae0aaf3f193c86ea0613f6d8b7..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/heap/CodeBlockSet.cpp >+++ /dev/null >@@ -1,86 +0,0 @@ >-/* >- * Copyright (C) 2013-2017 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 "CodeBlockSet.h" >- >-#include "CodeBlock.h" >-#include "JSCInlines.h" >-#include "SuperSampler.h" >-#include <wtf/CommaPrinter.h> >- >-namespace JSC { >- >-CodeBlockSet::CodeBlockSet() >-{ >-} >- >-CodeBlockSet::~CodeBlockSet() >-{ >-} >- >-bool CodeBlockSet::contains(const AbstractLocker&, void* candidateCodeBlock) >-{ >- RELEASE_ASSERT(m_lock.isLocked()); >- CodeBlock* codeBlock = static_cast<CodeBlock*>(candidateCodeBlock); >- if (!HashSet<CodeBlock*>::isValidValue(codeBlock)) >- return false; >- return m_codeBlocks.contains(codeBlock); >-} >- >-void CodeBlockSet::clearCurrentlyExecuting() >-{ >- m_currentlyExecuting.clear(); >-} >- >-void CodeBlockSet::dump(PrintStream& out) const >-{ >- CommaPrinter comma; >- out.print("{codeBlocks = ["); >- for (CodeBlock* codeBlock : m_codeBlocks) >- out.print(comma, pointerDump(codeBlock)); >- out.print("], currentlyExecuting = ["); >- comma = CommaPrinter(); >- for (CodeBlock* codeBlock : m_currentlyExecuting) >- out.print(comma, pointerDump(codeBlock)); >- out.print("]}"); >-} >- >-void CodeBlockSet::add(CodeBlock* codeBlock) >-{ >- auto locker = holdLock(m_lock); >- auto result = m_codeBlocks.add(codeBlock); >- RELEASE_ASSERT(result); >-} >- >-void CodeBlockSet::remove(CodeBlock* codeBlock) >-{ >- auto locker = holdLock(m_lock); >- bool result = m_codeBlocks.remove(codeBlock); >- RELEASE_ASSERT(result); >-} >- >-} // namespace JSC >- >diff --git a/Source/JavaScriptCore/heap/CodeBlockSet.h b/Source/JavaScriptCore/heap/CodeBlockSet.h >deleted file mode 100644 >index c4c58274fcd0eb752bb614f60f680931edc79cbb..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/heap/CodeBlockSet.h >+++ /dev/null >@@ -1,80 +0,0 @@ >-/* >- * Copyright (C) 2013-2017 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 >- >-#include "CollectionScope.h" >-#include <wtf/HashSet.h> >-#include <wtf/Lock.h> >-#include <wtf/Noncopyable.h> >-#include <wtf/PrintStream.h> >- >-namespace JSC { >- >-class CodeBlock; >-class Heap; >-class JSCell; >-class VM; >- >-// CodeBlockSet tracks all CodeBlocks. Every CodeBlock starts out with one >-// reference coming in from GC. The GC is responsible for freeing CodeBlocks >-// once they hasOneRef() and nobody is running code from that CodeBlock. >- >-class CodeBlockSet { >- WTF_MAKE_FAST_ALLOCATED; >- WTF_MAKE_NONCOPYABLE(CodeBlockSet); >-public: >- CodeBlockSet(); >- ~CodeBlockSet(); >- >- void mark(const AbstractLocker&, CodeBlock* candidateCodeBlock); >- >- void clearCurrentlyExecuting(); >- >- bool contains(const AbstractLocker&, void* candidateCodeBlock); >- Lock& getLock() { return m_lock; } >- >- // Visits each CodeBlock in the heap until the visitor function returns true >- // to indicate that it is done iterating, or until every CodeBlock has been >- // visited. >- template<typename Functor> void iterate(const Functor&); >- template<typename Functor> void iterate(const AbstractLocker&, const Functor&); >- >- template<typename Functor> void iterateViaSubspaces(VM&, const Functor&); >- >- template<typename Functor> void iterateCurrentlyExecuting(const Functor&); >- >- void dump(PrintStream&) const; >- >- void add(CodeBlock*); >- void remove(CodeBlock*); >- >-private: >- HashSet<CodeBlock*> m_codeBlocks; >- HashSet<CodeBlock*> m_currentlyExecuting; >- Lock m_lock; >-}; >- >-} // namespace JSC >diff --git a/Source/JavaScriptCore/heap/CodeBlockSetInlines.h b/Source/JavaScriptCore/heap/CodeBlockSetInlines.h >deleted file mode 100644 >index 5ddbf494ab23e8080b9932a0d2f9e3cdecad5276..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/heap/CodeBlockSetInlines.h >+++ /dev/null >@@ -1,79 +0,0 @@ >-/* >- * Copyright (C) 2016-2018 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. >- * 3. Neither the name of Apple Inc. ("Apple") nor the names of >- * its contributors may be used to endorse or promote products derived >- * from this software without specific prior written permission. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 >- >-#include "CodeBlock.h" >-#include "CodeBlockSet.h" >- >-namespace JSC { >- >-inline void CodeBlockSet::mark(const AbstractLocker&, CodeBlock* codeBlock) >-{ >- if (!codeBlock) >- return; >- >- m_currentlyExecuting.add(codeBlock); >-} >- >-template<typename Functor> >-void CodeBlockSet::iterate(const Functor& functor) >-{ >- auto locker = holdLock(m_lock); >- iterate(locker, functor); >-} >- >-template<typename Functor> >-void CodeBlockSet::iterate(const AbstractLocker&, const Functor& functor) >-{ >- for (CodeBlock* codeBlock : m_codeBlocks) >- functor(codeBlock); >-} >- >-template<typename Functor> >-void CodeBlockSet::iterateViaSubspaces(VM& vm, const Functor& functor) >-{ >- vm.forEachCodeBlockSpace( >- [&] (auto& spaceAndSet) { >- spaceAndSet.space.forEachLiveCell( >- [&] (HeapCell* cell, HeapCell::Kind) { >- functor(jsCast<CodeBlock*>(static_cast<JSCell*>(cell))); >- }); >- }); >-} >- >-template<typename Functor> >-void CodeBlockSet::iterateCurrentlyExecuting(const Functor& functor) >-{ >- LockHolder locker(&m_lock); >- for (CodeBlock* codeBlock : m_currentlyExecuting) >- functor(codeBlock); >-} >- >-} // namespace JSC >- >diff --git a/Source/JavaScriptCore/heap/ConservativeRoots.cpp b/Source/JavaScriptCore/heap/ConservativeRoots.cpp >index a420fe8e625c993ed594d0acf58aecb76c8c995e..3177f9b093e7a52155d82c788e81c8654343cfeb 100644 >--- a/Source/JavaScriptCore/heap/ConservativeRoots.cpp >+++ b/Source/JavaScriptCore/heap/ConservativeRoots.cpp >@@ -27,7 +27,7 @@ > #include "ConservativeRoots.h" > > #include "CodeBlock.h" >-#include "CodeBlockSetInlines.h" >+#include "CodeBlockSubspaceInlines.h" > #include "HeapInlines.h" > #include "HeapUtil.h" > #include "JITStubRoutineSet.h" >@@ -117,10 +117,9 @@ void ConservativeRoots::add(void* begin, void* end) > > class CompositeMarkHook { > public: >- CompositeMarkHook(JITStubRoutineSet& stubRoutines, CodeBlockSet& codeBlocks, const AbstractLocker& locker) >+ CompositeMarkHook(JITStubRoutineSet& stubRoutines, CodeBlockSubspace& codeBlocks) > : m_stubRoutines(stubRoutines) > , m_codeBlocks(codeBlocks) >- , m_codeBlocksLocker(locker) > { > } > >@@ -132,20 +131,18 @@ class CompositeMarkHook { > void markKnownJSCell(JSCell* cell) > { > if (cell->type() == CodeBlockType) >- m_codeBlocks.mark(m_codeBlocksLocker, jsCast<CodeBlock*>(cell)); >+ m_codeBlocks.add(jsCast<CodeBlock*>(cell)); > } > > private: > JITStubRoutineSet& m_stubRoutines; >- CodeBlockSet& m_codeBlocks; >- const AbstractLocker& m_codeBlocksLocker; >+ CodeBlockSubspace& m_codeBlocks; > }; > > void ConservativeRoots::add( >- void* begin, void* end, JITStubRoutineSet& jitStubRoutines, CodeBlockSet& codeBlocks) >+ void* begin, void* end, JITStubRoutineSet& jitStubRoutines, CodeBlockSubspace& codeBlocks) > { >- LockHolder locker(codeBlocks.getLock()); >- CompositeMarkHook markHook(jitStubRoutines, codeBlocks, locker); >+ CompositeMarkHook markHook(jitStubRoutines, codeBlocks); > genericAddSpan(begin, end, markHook); > } > >diff --git a/Source/JavaScriptCore/heap/ConservativeRoots.h b/Source/JavaScriptCore/heap/ConservativeRoots.h >index 3c064a9b777b06d049f4fa07042764f89f6bde6a..6ba231a74300d438942464de8ee0b7fcc810cce4 100644 >--- a/Source/JavaScriptCore/heap/ConservativeRoots.h >+++ b/Source/JavaScriptCore/heap/ConservativeRoots.h >@@ -29,7 +29,7 @@ > > namespace JSC { > >-class CodeBlockSet; >+class CodeBlockSubspace; > class HeapCell; > class JITStubRoutineSet; > >@@ -39,7 +39,7 @@ class ConservativeRoots { > ~ConservativeRoots(); > > void add(void* begin, void* end); >- void add(void* begin, void* end, JITStubRoutineSet&, CodeBlockSet&); >+ void add(void* begin, void* end, JITStubRoutineSet&, CodeBlockSubspace&); > > size_t size() const; > HeapCell** roots() const; >diff --git a/Source/JavaScriptCore/heap/Heap.cpp b/Source/JavaScriptCore/heap/Heap.cpp >index 8d92313977d332bbebe3dcd7cebbe6336fa6073f..26e99ed273694c3206825168bd6a5e478fcd557a 100644 >--- a/Source/JavaScriptCore/heap/Heap.cpp >+++ b/Source/JavaScriptCore/heap/Heap.cpp >@@ -24,7 +24,7 @@ > #include "BlockDirectoryInlines.h" > #include "BuiltinExecutables.h" > #include "CodeBlock.h" >-#include "CodeBlockSetInlines.h" >+#include "CodeBlockSubspaceInlines.h" > #include "CollectingScope.h" > #include "ConservativeRoots.h" > #include "DFGWorklistInlines.h" >@@ -285,7 +285,6 @@ Heap::Heap(VM* vm, HeapType heapType) > , m_raceMarkStack(std::make_unique<MarkStackArray>()) > , m_constraintSet(std::make_unique<MarkingConstraintSet>(*this)) > , m_handleSet(vm) >- , m_codeBlocks(std::make_unique<CodeBlockSet>()) > , m_jitStubRoutines(std::make_unique<JITStubRoutineSet>()) > , m_vm(vm) > // We seed with 10ms so that GCActivityCallback::didAllocate doesn't continuously >@@ -349,13 +348,13 @@ void Heap::dumpHeapStatisticsAtVMDestruction() > unsigned counter = 0; > m_objectSpace.forEachBlock([&] (MarkedBlock::Handle* block) { > unsigned live = 0; >- block->forEachCell([&] (HeapCell* cell, HeapCell::Kind) { >+ block->forEachCell([&] (size_t, HeapCell* cell, HeapCell::Kind) { > if (cell->isLive()) > live++; > return IterationStatus::Continue; > }); > dataLogLn("[", counter++, "] ", block->cellSize(), ", ", live, " / ", block->cellsPerBlock(), " ", static_cast<double>(live) / block->cellsPerBlock() * 100, "% ", block->attributes(), " ", block->subspace()->name()); >- block->forEachCell([&] (HeapCell* heapCell, HeapCell::Kind kind) { >+ block->forEachCell([&] (size_t, HeapCell* heapCell, HeapCell::Kind kind) { > if (heapCell->isLive() && kind == HeapCell::Kind::JSCell) { > auto* cell = static_cast<JSCell*>(heapCell); > if (cell->isObject()) >@@ -590,10 +589,7 @@ void Heap::finalizeUnconditionalFinalizers() > vm()->builtinExecutables()->finalizeUnconditionally(); > if (vm()->m_inferredValueSpace) > finalizeMarkedUnconditionalFinalizers<InferredValue>(vm()->m_inferredValueSpace->space); >- vm()->forEachCodeBlockSpace( >- [&] (auto& space) { >- this->finalizeMarkedUnconditionalFinalizers<CodeBlock>(space.set); >- }); >+ finalizeMarkedUnconditionalFinalizers<CodeBlock>(vm()->codeBlockSpace); > finalizeMarkedUnconditionalFinalizers<ExecutableToCodeBlockEdge>(vm()->executableToCodeBlockEdgesWithFinalizers); > finalizeMarkedUnconditionalFinalizers<StructureRareData>(vm()->structureRareDataSpace); > if (vm()->m_weakSetSpace) >@@ -632,7 +628,7 @@ void Heap::completeAllJITPlans() > template<typename Func> > void Heap::iterateExecutingAndCompilingCodeBlocks(const Func& func) > { >- m_codeBlocks->iterateCurrentlyExecuting(func); >+ vm()->codeBlockSpace.iterateCurrentlyExecutingInGC(func); > if (VM::canUseJIT()) > DFG::iterateCodeBlocksForGC(*m_vm, func); > } >@@ -677,13 +673,13 @@ void Heap::assertMarkStacksEmpty() > > void Heap::gatherStackRoots(ConservativeRoots& roots) > { >- m_machineThreads->gatherConservativeRoots(roots, *m_jitStubRoutines, *m_codeBlocks, m_currentThreadState, m_currentThread); >+ m_machineThreads->gatherConservativeRoots(roots, *m_jitStubRoutines, m_vm->codeBlockSpace, m_currentThreadState, m_currentThread); > } > > void Heap::gatherJSStackRoots(ConservativeRoots& roots) > { > #if ENABLE(C_LOOP) >- m_vm->interpreter->cloopStack().gatherConservativeRoots(roots, *m_jitStubRoutines, *m_codeBlocks); >+ m_vm->interpreter->cloopStack().gatherConservativeRoots(roots, *m_jitStubRoutines, m_vm->codeBlockSpace); > #else > UNUSED_PARAM(roots); > #endif >@@ -962,7 +958,7 @@ void Heap::deleteAllUnlinkedCodeBlocks(DeleteAllCodeEffort effort) > void Heap::deleteUnmarkedCompiledCode() > { > vm()->forEachScriptExecutableSpace([] (auto& space) { space.space.sweep(); }); >- vm()->forEachCodeBlockSpace([] (auto& space) { space.space.sweep(); }); // Sweeping must occur before deleting stubs, otherwise the stubs might still think they're alive as they get deleted. >+ vm()->codeBlockSpace.sweep(); // Sweeping must occur before deleting stubs, otherwise the stubs might still think they're alive as they get deleted. > m_jitStubRoutines->deleteUnmarkedJettisonedStubRoutines(); > } > >@@ -1505,11 +1501,11 @@ NEVER_INLINE bool Heap::runEndPhase(GCConductor conn) > removeDeadCompilerWorklistEntries(); > notifyIncrementalSweeper(); > >- m_codeBlocks->iterateCurrentlyExecuting( >+ vm()->codeBlockSpace.iterateCurrentlyExecutingInGC( > [&] (CodeBlock* codeBlock) { > writeBarrier(codeBlock); >+ vm()->codeBlockSpace.remove(codeBlock); > }); >- m_codeBlocks->clearCurrentlyExecuting(); > > m_objectSpace.prepareForAllocation(); > updateAllocationLimits(); >@@ -2525,12 +2521,12 @@ void Heap::forEachCodeBlockImpl(const ScopedLambda<void(CodeBlock*)>& func) > // We don't know the full set of CodeBlocks until compilation has terminated. > completeAllJITPlans(); > >- return m_codeBlocks->iterate(func); >+ return vm()->codeBlockSpace.iterate(func); > } > > void Heap::forEachCodeBlockIgnoringJITPlansImpl(const AbstractLocker& locker, const ScopedLambda<void(CodeBlock*)>& func) > { >- return m_codeBlocks->iterate(locker, func); >+ return vm()->codeBlockSpace.iterate(locker, func); > } > > void Heap::writeBarrierSlowPath(const JSCell* from) >diff --git a/Source/JavaScriptCore/heap/Heap.h b/Source/JavaScriptCore/heap/Heap.h >index 38f5321ad9d77c385b5eb2f9ca9512879830a7a6..ee454d8dfbc12350ed26a837f9fb7133870f7d3f 100644 >--- a/Source/JavaScriptCore/heap/Heap.h >+++ b/Source/JavaScriptCore/heap/Heap.h >@@ -51,7 +51,7 @@ > namespace JSC { > > class CodeBlock; >-class CodeBlockSet; >+class CodeBlockSubspace; > class CollectingScope; > class ConservativeRoots; > class GCDeferralContext; >@@ -274,8 +274,6 @@ class Heap { > > StructureIDTable& structureIDTable() { return m_structureIDTable; } > >- CodeBlockSet& codeBlockSet() { return *m_codeBlocks; } >- > #if USE(FOUNDATION) > template<typename T> void releaseSoon(RetainPtr<T>&&); > #endif >@@ -632,7 +630,6 @@ class Heap { > Vector<SlotVisitor*> m_availableParallelSlotVisitors; > > HandleSet m_handleSet; >- std::unique_ptr<CodeBlockSet> m_codeBlocks; > std::unique_ptr<JITStubRoutineSet> m_jitStubRoutines; > FinalizerOwner m_finalizerOwner; > >diff --git a/Source/JavaScriptCore/heap/IsoCellSet.cpp b/Source/JavaScriptCore/heap/IsoCellSet.cpp >index b8e430191e6b1dc29aa5c0f10cdd6e9bb198fda9..79103e167dedd4fdf1a0e43d5c7f260e7ddb36bf 100644 >--- a/Source/JavaScriptCore/heap/IsoCellSet.cpp >+++ b/Source/JavaScriptCore/heap/IsoCellSet.cpp >@@ -81,9 +81,8 @@ Ref<SharedTask<MarkedBlock::Handle*()>> IsoCellSet::parallelNotEmptyMarkedBlockS > return adoptRef(*new Task(*this)); > } > >-NEVER_INLINE Bitmap<MarkedBlock::atomsPerBlock>* IsoCellSet::addSlow(size_t blockIndex) >+NEVER_INLINE Bitmap<MarkedBlock::atomsPerBlock>* IsoCellSet::addSlow(const AbstractLocker&, size_t blockIndex) > { >- auto locker = holdLock(m_subspace.m_directory.m_bitvectorLock); > auto& bitsPtrRef = m_bits[blockIndex]; > auto* bits = bitsPtrRef.get(); > if (!bits) { >diff --git a/Source/JavaScriptCore/heap/IsoCellSet.h b/Source/JavaScriptCore/heap/IsoCellSet.h >index dada672c491dc0381f58fa1a672b6c6c0b7e2e58..cd10d835f64244c0afea5eb70d5b383e45487a7d 100644 >--- a/Source/JavaScriptCore/heap/IsoCellSet.h >+++ b/Source/JavaScriptCore/heap/IsoCellSet.h >@@ -39,17 +39,22 @@ class IsoSubspace; > > // Create a set of cells that are in an IsoSubspace. This allows concurrent O(1) set insertion and > // removal. Each such set should be thought of as a 0.8% increase in object size for objects in that >-// IsoSubspace (it's like adding 1 bit every 16 bytes, or 1 bit every 128 bits). >+// IsoSubspace (it's like adding 1 bit every 16 bytes, or 1 byte every 128 bits). > class IsoCellSet : public BasicRawSentinelNode<IsoCellSet> { > public: > IsoCellSet(IsoSubspace& subspace); > ~IsoCellSet(); > >- bool add(HeapCell* cell); // Returns true if the cell was newly added. >+ // Returns true if the cell was newly added. >+ bool add(HeapCell* cell); >+ bool add(const AbstractLocker&, HeapCell* cell); > >- bool remove(HeapCell* cell); // Returns true if the cell was previously present and got removed. >+ // Returns true if the cell was previously present and got removed. >+ bool remove(HeapCell* cell); >+ bool remove(const AbstractLocker&, HeapCell* cell); > > bool contains(HeapCell* cell) const; >+ bool containsConservative(void* pointer) const; > > JS_EXPORT_PRIVATE Ref<SharedTask<MarkedBlock::Handle*()>> parallelNotEmptyMarkedBlockSource(); > >@@ -63,11 +68,14 @@ class IsoCellSet : public BasicRawSentinelNode<IsoCellSet> { > > template<typename Func> > void forEachLiveCell(const Func&); >+ >+ template<typename Func> >+ void forEachCell(const Func&); > > private: > friend class IsoSubspace; > >- Bitmap<MarkedBlock::atomsPerBlock>* addSlow(size_t blockIndex); >+ Bitmap<MarkedBlock::atomsPerBlock>* addSlow(const AbstractLocker&, size_t blockIndex); > > void didResizeBits(size_t newSize); > void didRemoveBlock(size_t blockIndex); >diff --git a/Source/JavaScriptCore/heap/IsoCellSetInlines.h b/Source/JavaScriptCore/heap/IsoCellSetInlines.h >index ce7de8e190ea8e53f93364c7cf1fce5ed34a6f74..a90b6336d7f2f37bfc2abb5ce0119c7d4d14b9cc 100644 >--- a/Source/JavaScriptCore/heap/IsoCellSetInlines.h >+++ b/Source/JavaScriptCore/heap/IsoCellSetInlines.h >@@ -37,7 +37,17 @@ inline bool IsoCellSet::add(HeapCell* cell) > auto& bitsPtrRef = m_bits[atomIndices.blockIndex]; > auto* bits = bitsPtrRef.get(); > if (UNLIKELY(!bits)) >- bits = addSlow(atomIndices.blockIndex); >+ bits = addSlow(holdLock(m_subspace.m_directory.m_bitvectorLock), atomIndices.blockIndex); >+ return !bits->concurrentTestAndSet(atomIndices.atomNumber); >+} >+ >+inline bool IsoCellSet::add(const AbstractLocker& locker, HeapCell* cell) >+{ >+ AtomIndices atomIndices(cell); >+ auto& bitsPtrRef = m_bits[atomIndices.blockIndex]; >+ auto* bits = bitsPtrRef.get(); >+ if (UNLIKELY(!bits)) >+ bits = addSlow(locker, atomIndices.blockIndex); > return !bits->concurrentTestAndSet(atomIndices.atomNumber); > } > >@@ -51,6 +61,11 @@ inline bool IsoCellSet::remove(HeapCell* cell) > return bits->concurrentTestAndClear(atomIndices.atomNumber); > } > >+inline bool IsoCellSet::remove(const AbstractLocker&, HeapCell* cell) >+{ >+ return remove(cell); >+} >+ > inline bool IsoCellSet::contains(HeapCell* cell) const > { > AtomIndices atomIndices(cell); >@@ -60,6 +75,24 @@ inline bool IsoCellSet::contains(HeapCell* cell) const > return false; > } > >+inline bool IsoCellSet::containsConservative(void* pointer) const >+{ >+ BlockDirectory& directory = m_subspace.m_directory; >+ for (size_t blockIndex = 0; blockIndex < m_blocksWithBits.size(); ++blockIndex) { >+ if (m_blocksWithBits[blockIndex]) { >+ MarkedBlock::Handle* block = directory.m_blocks[blockIndex]; >+ if (MarkedBlock::blockFor(pointer) == &block->block()) { >+ AtomIndices atomIndices(static_cast<HeapCell*>(pointer)); >+ auto* bits = m_bits[atomIndices.blockIndex].get(); >+ if (bits) >+ return bits->get(atomIndices.atomNumber); >+ return false; >+ } >+ } >+ } >+ return false; >+} >+ > template<typename Func> > void IsoCellSet::forEachMarkedCell(const Func& func) > { >@@ -122,10 +155,26 @@ void IsoCellSet::forEachLiveCell(const Func& func) > [&] (size_t blockIndex) { > MarkedBlock::Handle* block = directory.m_blocks[blockIndex]; > >- // FIXME: We could optimize this by checking our bits before querying isLive. >- // OOPS! (need bug URL) > auto* bits = m_bits[blockIndex].get(); >- block->forEachLiveCell( >+ block->forEachCell( >+ [&] (size_t atomNumber, HeapCell* cell, HeapCell::Kind kind) -> IterationStatus { >+ if (bits->get(atomNumber) && block->isLive(cell)) >+ func(cell, kind); >+ return IterationStatus::Continue; >+ }); >+ }); >+} >+ >+template<typename Func> >+void IsoCellSet::forEachCell(const Func& func) >+{ >+ BlockDirectory& directory = m_subspace.m_directory; >+ m_blocksWithBits.forEachSetBit( >+ [&] (size_t blockIndex) { >+ MarkedBlock::Handle* block = directory.m_blocks[blockIndex]; >+ >+ auto* bits = m_bits[blockIndex].get(); >+ block->forEachCell( > [&] (size_t atomNumber, HeapCell* cell, HeapCell::Kind kind) -> IterationStatus { > if (bits->get(atomNumber)) > func(cell, kind); >diff --git a/Source/JavaScriptCore/heap/IsoSubspace.h b/Source/JavaScriptCore/heap/IsoSubspace.h >index efd5cd3828ebae4ff4ee609d21224243b8b4c3b8..b75d62ac47f521f4699d811af48c376b6ea6bbca 100644 >--- a/Source/JavaScriptCore/heap/IsoSubspace.h >+++ b/Source/JavaScriptCore/heap/IsoSubspace.h >@@ -47,7 +47,7 @@ class IsoSubspace : public Subspace { > void* allocate(VM&, size_t, GCDeferralContext*, AllocationFailureMode) override; > void* allocateNonVirtual(VM&, size_t, GCDeferralContext*, AllocationFailureMode); > >-private: >+protected: > friend class IsoCellSet; > > void didResizeBits(size_t newSize) override; >diff --git a/Source/JavaScriptCore/heap/MachineStackMarker.cpp b/Source/JavaScriptCore/heap/MachineStackMarker.cpp >index ab19c0e989937103ca41f39e87e30fca635fee71..775a27ef0e033800a65a4e76956a7a278fe60af6 100644 >--- a/Source/JavaScriptCore/heap/MachineStackMarker.cpp >+++ b/Source/JavaScriptCore/heap/MachineStackMarker.cpp >@@ -38,7 +38,7 @@ MachineThreads::MachineThreads() > } > > SUPPRESS_ASAN >-void MachineThreads::gatherFromCurrentThread(ConservativeRoots& conservativeRoots, JITStubRoutineSet& jitStubRoutines, CodeBlockSet& codeBlocks, CurrentThreadState& currentThreadState) >+void MachineThreads::gatherFromCurrentThread(ConservativeRoots& conservativeRoots, JITStubRoutineSet& jitStubRoutines, CodeBlockSubspace& codeBlocks, CurrentThreadState& currentThreadState) > { > if (currentThreadState.registerState) { > void* registersBegin = currentThreadState.registerState; >@@ -198,7 +198,7 @@ static void growBuffer(size_t size, void** buffer, size_t* capacity) > *buffer = fastMalloc(*capacity); > } > >-void MachineThreads::gatherConservativeRoots(ConservativeRoots& conservativeRoots, JITStubRoutineSet& jitStubRoutines, CodeBlockSet& codeBlocks, CurrentThreadState* currentThreadState, Thread* currentThread) >+void MachineThreads::gatherConservativeRoots(ConservativeRoots& conservativeRoots, JITStubRoutineSet& jitStubRoutines, CodeBlockSubspace& codeBlocks, CurrentThreadState* currentThreadState, Thread* currentThread) > { > if (currentThreadState) > gatherFromCurrentThread(conservativeRoots, jitStubRoutines, codeBlocks, *currentThreadState); >diff --git a/Source/JavaScriptCore/heap/MachineStackMarker.h b/Source/JavaScriptCore/heap/MachineStackMarker.h >index e29ee4004db4baab02a9af8ab00c8a0c2bc4e0e9..22fc0549f0ca9237d9b3752d162e3b728ee26ff4 100644 >--- a/Source/JavaScriptCore/heap/MachineStackMarker.h >+++ b/Source/JavaScriptCore/heap/MachineStackMarker.h >@@ -28,7 +28,7 @@ > > namespace JSC { > >-class CodeBlockSet; >+class CodeBlockSubspace; > class ConservativeRoots; > class Heap; > class JITStubRoutineSet; >@@ -45,7 +45,7 @@ class MachineThreads { > public: > MachineThreads(); > >- void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, CurrentThreadState*, Thread*); >+ void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSubspace&, CurrentThreadState*, Thread*); > > // Only needs to be called by clients that can use the same heap from multiple threads. > bool addCurrentThread() { return m_threadGroup->addCurrentThread() == ThreadGroupAddResult::NewlyAdded; } >@@ -54,7 +54,7 @@ class MachineThreads { > const ListHashSet<Ref<Thread>>& threads(const AbstractLocker& locker) const { return m_threadGroup->threads(locker); } > > private: >- void gatherFromCurrentThread(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, CurrentThreadState&); >+ void gatherFromCurrentThread(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSubspace&, CurrentThreadState&); > > void tryCopyOtherThreadStack(Thread&, void*, size_t capacity, size_t*); > bool tryCopyOtherThreadStacks(const AbstractLocker&, void*, size_t capacity, size_t*, Thread&); >diff --git a/Source/JavaScriptCore/heap/MarkedBlock.cpp b/Source/JavaScriptCore/heap/MarkedBlock.cpp >index 4954348738a789d237be7182934078c175189053..ca0fea1ab39605c5a2b81f389adc48f02b32a26a 100644 >--- a/Source/JavaScriptCore/heap/MarkedBlock.cpp >+++ b/Source/JavaScriptCore/heap/MarkedBlock.cpp >@@ -151,7 +151,7 @@ void MarkedBlock::Handle::stopAllocating(const FreeList& freeList) > blockFooter().m_newlyAllocatedVersion = heap()->objectSpace().newlyAllocatedVersion(); > > forEachCell( >- [&] (HeapCell* cell, HeapCell::Kind) -> IterationStatus { >+ [&] (size_t, HeapCell* cell, HeapCell::Kind) -> IterationStatus { > block().setNewlyAllocated(cell); > return IterationStatus::Continue; > }); >diff --git a/Source/JavaScriptCore/heap/MarkedBlock.h b/Source/JavaScriptCore/heap/MarkedBlock.h >index 4392932aec70fcf220848afe657e80f54b5799a1..570200d11354df2647534b4711b9ee31898e7bfe 100644 >--- a/Source/JavaScriptCore/heap/MarkedBlock.h >+++ b/Source/JavaScriptCore/heap/MarkedBlock.h >@@ -636,7 +636,7 @@ inline IterationStatus MarkedBlock::Handle::forEachCell(const Functor& functor) > HeapCell::Kind kind = m_attributes.cellKind; > for (size_t i = 0; i < m_endAtom; i += m_atomsPerCell) { > HeapCell* cell = reinterpret_cast_ptr<HeapCell*>(&m_block->atoms()[i]); >- if (functor(cell, kind) == IterationStatus::Done) >+ if (functor(i, cell, kind) == IterationStatus::Done) > return IterationStatus::Done; > } > return IterationStatus::Continue; >diff --git a/Source/JavaScriptCore/interpreter/CLoopStack.cpp b/Source/JavaScriptCore/interpreter/CLoopStack.cpp >index 52cc74a16ed838bbe8a895ac1e4816ac190258c3..e2c9d2bd0c44efa370e090e4412c6adde6d31442 100644 >--- a/Source/JavaScriptCore/interpreter/CLoopStack.cpp >+++ b/Source/JavaScriptCore/interpreter/CLoopStack.cpp >@@ -108,7 +108,7 @@ bool CLoopStack::grow(Register* newTopOfStack) > return true; > } > >-void CLoopStack::gatherConservativeRoots(ConservativeRoots& conservativeRoots, JITStubRoutineSet& jitStubRoutines, CodeBlockSet& codeBlocks) >+void CLoopStack::gatherConservativeRoots(ConservativeRoots& conservativeRoots, JITStubRoutineSet& jitStubRoutines, CodeBlockSubspace& codeBlocks) > { > conservativeRoots.add(currentStackPointer(), highAddress(), jitStubRoutines, codeBlocks); > } >diff --git a/Source/JavaScriptCore/interpreter/CLoopStack.h b/Source/JavaScriptCore/interpreter/CLoopStack.h >index 1f4d99d8b434e9b479e4837a29dfdc1bc5c7ab56..7b12197149b32471e2ce30dcd4614e05bf39b9cf 100644 >--- a/Source/JavaScriptCore/interpreter/CLoopStack.h >+++ b/Source/JavaScriptCore/interpreter/CLoopStack.h >@@ -36,7 +36,7 @@ > > namespace JSC { > >- class CodeBlockSet; >+ class CodeBlockSubspace; > class ConservativeRoots; > class JITStubRoutineSet; > class VM; >@@ -56,7 +56,7 @@ namespace JSC { > bool containsAddress(Register* address) { return (lowAddress() <= address && address < highAddress()); } > static size_t committedByteCount(); > >- void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&); >+ void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSubspace&); > void sanitizeStack(); > > inline void* currentStackPointer(); >diff --git a/Source/JavaScriptCore/runtime/CodeBlockSubspace.h b/Source/JavaScriptCore/runtime/CodeBlockSubspace.h >new file mode 100644 >index 0000000000000000000000000000000000000000..3abd5ba97f4d3749d56466071368d2bdf81a6d03 >--- /dev/null >+++ b/Source/JavaScriptCore/runtime/CodeBlockSubspace.h >@@ -0,0 +1,61 @@ >+/* >+ * Copyright (C) 2015 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 >+ >+#include "IsoCellSet.h" >+#include "IsoSubspace.h" >+ >+namespace JSC { >+ >+class CodeBlock; >+ >+class CodeBlockSubspace : public IsoSubspace { >+public: >+ CodeBlockSubspace(CString name, Heap& heap, HeapCellType* heapCellType, size_t size) >+ : IsoSubspace(name, heap, heapCellType, size) >+ , m_initialized(*this) >+ , m_currentlyExecutingInGC(*this) >+ { >+ } >+ >+ void add(CodeBlock*); >+ void remove(CodeBlock*); >+ bool contains(const AbstractLocker&, void* candidateCodeBlock); >+ template<typename Functor> void iterate(const Functor&); >+ template<typename Functor> void iterate(const AbstractLocker&, const Functor&); >+ >+ Lock& getLock() { return m_directory.bitvectorLock(); } >+ >+ void addCurrentlyExecutingInGC(CodeBlock*); >+ void removeCurrentlyExecutingInGC(CodeBlock*); >+ template<typename Functor> void iterateCurrentlyExecutingInGC(const Functor&); >+ >+private: >+ IsoCellSet m_initialized; >+ IsoCellSet m_currentlyExecutingInGC; >+}; >+ >+} // namespace JSC >diff --git a/Source/JavaScriptCore/runtime/CodeBlockSubspaceInlines.h b/Source/JavaScriptCore/runtime/CodeBlockSubspaceInlines.h >new file mode 100644 >index 0000000000000000000000000000000000000000..67aba2f491a434ebd60fe6b1059bce16c59833be >--- /dev/null >+++ b/Source/JavaScriptCore/runtime/CodeBlockSubspaceInlines.h >@@ -0,0 +1,87 @@ >+/* >+ * Copyright (C) 2015 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 >+ >+#include "CodeBlock.h" >+#include "CodeBlockSubspace.h" >+#include "IsoCellSetInlines.h" >+#include "IsoSubspace.h" >+ >+namespace JSC { >+ >+inline void CodeBlockSubspace::add(CodeBlock* codeBlock) >+{ >+ auto locker = holdLock(getLock()); >+ m_initialized.add(locker, codeBlock); >+} >+ >+inline void CodeBlockSubspace::remove(CodeBlock* codeBlock) >+{ >+ auto locker = holdLock(getLock()); >+ m_initialized.remove(locker, codeBlock); >+} >+ >+inline bool CodeBlockSubspace::contains(const AbstractLocker&, void* candidateCodeBlock) >+{ >+ return m_initialized.containsConservative(candidateCodeBlock); >+} >+ >+template<typename Functor> >+void CodeBlockSubspace::iterate(const Functor& functor) >+{ >+ auto locker = holdLock(getLock()); >+ iterate(locker, functor); >+} >+ >+template<typename Functor> >+void CodeBlockSubspace::iterate(const AbstractLocker&, const Functor& functor) >+{ >+ m_initialized.forEachCell( >+ [&] (HeapCell* cell, HeapCell::Kind) { >+ functor(jsCast<CodeBlock*>(static_cast<JSCell*>(cell))); >+ }); >+} >+ >+inline void CodeBlockSubspace::addCurrentlyExecutingInGC(CodeBlock* codeBlock) >+{ >+ m_currentlyExecutingInGC.add(codeBlock); >+} >+ >+inline void CodeBlockSubspace::removeCurrentlyExecutingInGC(CodeBlock* codeBlock) >+{ >+ m_currentlyExecutingInGC.remove(codeBlock); >+} >+ >+template<typename Functor> >+void CodeBlockSubspace::iterateCurrentlyExecutingInGC(const Functor& functor) >+{ >+ m_currentlyExecutingInGC.forEachMarkedCell( >+ [&] (HeapCell* cell, HeapCell::Kind) { >+ functor(jsCast<CodeBlock*>(static_cast<JSCell*>(cell))); >+ }); >+} >+ >+} // namespace JSC >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >index 64d468e83f49787c1043bad47437769b0b8b70aa..e2de1e5c6a8624aff186dec64138156c439a5c9d 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >@@ -50,7 +50,7 @@ > #include "CatchScope.h" > #include "ClonedArguments.h" > #include "CodeBlock.h" >-#include "CodeBlockSetInlines.h" >+#include "CodeBlockSubspaceInlines.h" > #include "CodeCache.h" > #include "ConsoleObject.h" > #include "DateConstructor.h" >@@ -2037,7 +2037,8 @@ void JSGlobalObject::bumpGlobalLexicalBindingEpoch(VM& vm) > if (++m_globalLexicalBindingEpoch == Options::thresholdForGlobalLexicalBindingEpoch()) { > // Since the epoch overflows, we should rewrite all the CodeBlock to adjust to the newly started generation. > m_globalLexicalBindingEpoch = 1; >- vm.heap.codeBlockSet().iterate([&] (CodeBlock* codeBlock) { >+ HeapIterationScope iterationScope(vm.heap); >+ vm.codeBlockSpace.iterate([&] (CodeBlock* codeBlock) { > if (codeBlock->globalObject() != this) > return; > codeBlock->notifyLexicalBindingUpdate(); >diff --git a/Source/JavaScriptCore/runtime/SamplingProfiler.cpp b/Source/JavaScriptCore/runtime/SamplingProfiler.cpp >index 3c2fb6f65d7ddd29d47bc84a22c05781effbbe71..30d3ffce99432ccd56d77d096b5690bae2f4f5c9 100644 >--- a/Source/JavaScriptCore/runtime/SamplingProfiler.cpp >+++ b/Source/JavaScriptCore/runtime/SamplingProfiler.cpp >@@ -31,7 +31,7 @@ > #include "CallFrame.h" > #include "CatchScope.h" > #include "CodeBlock.h" >-#include "CodeBlockSet.h" >+#include "CodeBlockSubspaceInlines.h" > #include "HeapIterationScope.h" > #include "HeapUtil.h" > #include "InlineCallFrame.h" >@@ -184,7 +184,7 @@ class FrameWalker { > { > if (!codeBlock) > return false; >- bool result = m_vm.heap.codeBlockSet().contains(m_codeBlockSetLocker, codeBlock); >+ bool result = m_vm.codeBlockSpace.contains(m_codeBlockSetLocker, codeBlock); > return result; > } > >@@ -341,7 +341,7 @@ void SamplingProfiler::takeSample(const AbstractLocker&, Seconds& stackTraceProc > Seconds nowTime = m_stopwatch->elapsedTime(); > > auto machineThreadsLocker = holdLock(m_vm.heap.machineThreads().getLock()); >- LockHolder codeBlockSetLocker(m_vm.heap.codeBlockSet().getLock()); >+ LockHolder codeBlockSetLocker(m_vm.codeBlockSpace.getLock()); > LockHolder executableAllocatorLocker(ExecutableAllocator::singleton().getLock()); > > auto didSuspend = m_jscExecutionThread->suspend(); >diff --git a/Source/JavaScriptCore/runtime/VM.h b/Source/JavaScriptCore/runtime/VM.h >index b985d47ea4d95edddc9c0cf36689653376f7d1df..0a1a379700c5cb1a0ce6175fb357ccd71dbe4717 100644 >--- a/Source/JavaScriptCore/runtime/VM.h >+++ b/Source/JavaScriptCore/runtime/VM.h >@@ -29,6 +29,7 @@ > #pragma once > > #include "CallData.h" >+#include "CodeBlockSubspace.h" > #include "CodeSpecializationKind.h" > #include "CompleteSubspace.h" > #include "ConcurrentJSLock.h" >@@ -450,17 +451,8 @@ class VM : public ThreadSafeRefCounted<VM>, public DoublyLinkedListNode<VM> { > } > }; > >- SpaceAndSet codeBlockSpace; >+ CodeBlockSubspace codeBlockSpace; > DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(inferredValueSpace) >- >- template<typename Func> >- void forEachCodeBlockSpace(const Func& func) >- { >- // This should not include webAssemblyCodeBlockSpace because this is about subsclasses of >- // JSC::CodeBlock. >- func(codeBlockSpace); >- } >- > DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(evalExecutableSpace) > DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(moduleProgramExecutableSpace) > SpaceAndSet functionExecutableSpace; >diff --git a/Source/JavaScriptCore/runtime/VMTraps.cpp b/Source/JavaScriptCore/runtime/VMTraps.cpp >index e66866c1851b6ad670bc957fbd7014d1183eb414..0352e56851ab27399f06f31dfe3447bfe98d669d 100644 >--- a/Source/JavaScriptCore/runtime/VMTraps.cpp >+++ b/Source/JavaScriptCore/runtime/VMTraps.cpp >@@ -28,7 +28,7 @@ > > #include "CallFrame.h" > #include "CodeBlock.h" >-#include "CodeBlockSet.h" >+#include "CodeBlockSubspaceInlines.h" > #include "DFGCommonData.h" > #include "ExceptionHelpers.h" > #include "HeapInlines.h" >@@ -109,7 +109,7 @@ void VMTraps::tryInstallTrapBreakpoints(SignalContext& context, StackBounds stac > > CallFrame* callFrame = reinterpret_cast<CallFrame*>(context.framePointer); > >- auto codeBlockSetLocker = holdLock(vm.heap.codeBlockSet().getLock()); >+ auto codeBlockSetLocker = holdLock(vm.codeBlockSpace.getLock()); > > CodeBlock* foundCodeBlock = nullptr; > EntryFrame* entryFrame = vm.topEntryFrame; >@@ -127,7 +127,7 @@ void VMTraps::tryInstallTrapBreakpoints(SignalContext& context, StackBounds stac > return; // Let the SignalSender try again later. > > CodeBlock* candidateCodeBlock = callFrame->unsafeCodeBlock(); >- if (candidateCodeBlock && vm.heap.codeBlockSet().contains(codeBlockSetLocker, candidateCodeBlock)) { >+ if (candidateCodeBlock && vm.codeBlockSpace.contains(codeBlockSetLocker, candidateCodeBlock)) { > foundCodeBlock = candidateCodeBlock; > break; > } >@@ -166,7 +166,7 @@ void VMTraps::invalidateCodeBlocksOnStack() > > void VMTraps::invalidateCodeBlocksOnStack(ExecState* topCallFrame) > { >- auto codeBlockSetLocker = holdLock(vm().heap.codeBlockSet().getLock()); >+ auto codeBlockSetLocker = holdLock(vm().codeBlockSpace.getLock()); > invalidateCodeBlocksOnStack(codeBlockSetLocker, topCallFrame); > } > >@@ -218,7 +218,7 @@ class VMTraps::SignalSender final : public AutomaticThread { > VM& vm = *currentCodeBlock->vm(); > > // We are in JIT code so it's safe to acquire this lock. >- auto codeBlockSetLocker = holdLock(vm.heap.codeBlockSet().getLock()); >+ auto codeBlockSetLocker = holdLock(vm.codeBlockSpace.getLock()); > bool sawCurrentCodeBlock = false; > vm.heap.forEachCodeBlockIgnoringJITPlans(codeBlockSetLocker, [&] (CodeBlock* codeBlock) { > // We want to jettison all code blocks that have vm traps breakpoints, otherwise we could hit them later. >@@ -340,7 +340,7 @@ void VMTraps::handleTraps(ExecState* exec, VMTraps::Mask mask) > auto scope = DECLARE_THROW_SCOPE(vm); > > { >- auto codeBlockSetLocker = holdLock(vm.heap.codeBlockSet().getLock()); >+ auto codeBlockSetLocker = holdLock(vm.codeBlockSpace.getLock()); > vm.heap.forEachCodeBlockIgnoringJITPlans(codeBlockSetLocker, [&] (CodeBlock* codeBlock) { > // We want to jettison all code blocks that have vm traps breakpoints, otherwise we could hit them later. > if (codeBlock->hasInstalledVMTrapBreakpoints()) >diff --git a/Source/JavaScriptCore/tools/VMInspector.cpp b/Source/JavaScriptCore/tools/VMInspector.cpp >index 6339fb9dc6e5cdbf0f637b6050846c2212a0c0f1..b0da4728f3e41beaa8462adcaeaa57dac56cc7f5 100644 >--- a/Source/JavaScriptCore/tools/VMInspector.cpp >+++ b/Source/JavaScriptCore/tools/VMInspector.cpp >@@ -27,7 +27,6 @@ > #include "VMInspector.h" > > #include "CodeBlock.h" >-#include "CodeBlockSet.h" > #include "HeapInlines.h" > #include "HeapIterationScope.h" > #include "JSCInlines.h" >@@ -158,7 +157,7 @@ auto VMInspector::codeBlockForMachinePC(const VMInspector::Locker&, void* machin > // Heap::forEachCodeBlockIgnoringJITPlans(). Hence, there's no risk of > // re-entering the lock and deadlocking on it. > >- auto& codeBlockSetLock = vm.heap.codeBlockSet().getLock(); >+ auto& codeBlockSetLock = vm.codeBlockSpace.getLock(); > bool isSafeToLock = ensureIsSafeToLock(codeBlockSetLock); > if (!isSafeToLock) { > hasTimeout = true;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186740
:
368426
|
368428
| 369261