Changeset 240965 in webkit
- Timestamp:
- Feb 4, 2019 10:32:08 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 70 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSCallbackFunction.h
r230813 r240965 38 38 typedef InternalFunction Base; 39 39 40 template<typename CellType >40 template<typename CellType, SubspaceAccess mode> 41 41 static IsoSubspace* subspaceFor(VM& vm) 42 42 { 43 return &vm.callbackFunctionSpace;43 return vm.callbackFunctionSpace<mode>(); 44 44 } 45 45 -
trunk/Source/JavaScriptCore/API/ObjCCallbackFunction.h
r230813 r240965 49 49 typedef InternalFunction Base; 50 50 51 template<typename CellType >51 template<typename CellType, SubspaceAccess mode> 52 52 static IsoSubspace* subspaceFor(VM& vm) 53 53 { 54 return &vm.objCCallbackFunctionSpace;54 return vm.objCCallbackFunctionSpace<mode>(); 55 55 } 56 56 -
trunk/Source/JavaScriptCore/API/glib/JSCCallbackFunction.h
r239427 r240965 41 41 typedef InternalFunction Base; 42 42 43 template<typename CellType >43 template<typename CellType, SubspaceAccess> 44 44 static IsoSubspace* subspaceFor(VM& vm) 45 45 { -
trunk/Source/JavaScriptCore/CMakeLists.txt
r240823 r240965 938 938 runtime/StructureRareDataInlines.h 939 939 runtime/StructureTransitionTable.h 940 runtime/SubspaceAccess.h 940 941 runtime/Symbol.h 941 942 runtime/SymbolPrototype.h -
trunk/Source/JavaScriptCore/ChangeLog
r240960 r240965 1 2019-02-04 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Shrink size of VM by lazily allocating IsoSubspaces for non-common types 4 https://bugs.webkit.org/show_bug.cgi?id=193993 5 6 Reviewed by Keith Miller. 7 8 JSC::VM has a lot of IsoSubspaces, and each takes 504B. This unnecessarily makes VM so large. 9 And some of them are rarely used. We should allocate it lazily. 10 11 In this patch, we make some `IsoSubspaces` `std::unique_ptr<IsoSubspace>`. And we add ensureXXXSpace 12 functions which allocate IsoSubspaces lazily. This function is used by subspaceFor<> in each class. 13 And we also add subspaceForConcurrently<> function, which is called from concurrent JIT tiers. This 14 returns nullptr if the subspace is not allocated yet. JSCell::subspaceFor now takes second template 15 parameter which tells the function whether subspaceFor is concurrently done. If the IsoSubspace is 16 lazily created, we may return nullptr for the concurrent access. We ensure the space's initialization 17 by using WTF::storeStoreFence when lazily allocating it. 18 19 In GC's constraint solving, we may touch these lazily allocated spaces. At that time, we check the 20 existence of the space before touching this. This is not racy because the main thread is stopped when 21 the constraint solving is working. 22 23 This changes sizeof(VM) from 64736 to 56472. 24 25 Another interesting thing is that we removed `PreventCollectionScope preventCollectionScope(heap);` in 26 `Subspace::initialize`. This is really dangerous API since it easily causes dead-lock between the 27 collector and the mutator if IsoSubspace is dynamically created. We do want to make IsoSubspaces 28 dynamically-created ones since the requirement of the pre-allocation poses a scalability problem 29 of IsoSubspace adoption because IsoSubspace is large. Registered Subspace is only touched in the 30 EndPhase, and the peripheries should be stopped when running EndPhase. Thus, as long as the main thread 31 can run this IsoSubspace code, the collector is never EndPhase. So this is safe. 32 33 * API/JSCallbackFunction.h: 34 * API/ObjCCallbackFunction.h: 35 (JSC::ObjCCallbackFunction::subspaceFor): 36 * API/glib/JSCCallbackFunction.h: 37 * CMakeLists.txt: 38 * JavaScriptCore.xcodeproj/project.pbxproj: 39 * bytecode/CodeBlock.cpp: 40 (JSC::CodeBlock::visitChildren): 41 (JSC::CodeBlock::finalizeUnconditionally): 42 * bytecode/CodeBlock.h: 43 * bytecode/EvalCodeBlock.h: 44 * bytecode/ExecutableToCodeBlockEdge.h: 45 * bytecode/FunctionCodeBlock.h: 46 * bytecode/ModuleProgramCodeBlock.h: 47 * bytecode/ProgramCodeBlock.h: 48 * bytecode/UnlinkedFunctionExecutable.cpp: 49 (JSC::UnlinkedFunctionExecutable::unlinkedCodeBlockFor): 50 * bytecode/UnlinkedFunctionExecutable.h: 51 * dfg/DFGSpeculativeJIT.cpp: 52 (JSC::DFG::SpeculativeJIT::emitAllocateRawObject): 53 (JSC::DFG::SpeculativeJIT::compileMakeRope): 54 (JSC::DFG::SpeculativeJIT::compileNewObject): 55 * ftl/FTLLowerDFGToB3.cpp: 56 (JSC::FTL::DFG::LowerDFGToB3::compileMakeRope): 57 (JSC::FTL::DFG::LowerDFGToB3::compileMaterializeNewObject): 58 (JSC::FTL::DFG::LowerDFGToB3::allocateObject): 59 (JSC::FTL::DFG::LowerDFGToB3::allocateVariableSizedObject): 60 (JSC::FTL::DFG::LowerDFGToB3::allocateVariableSizedCell): 61 * heap/Heap.cpp: 62 (JSC::Heap::finalizeUnconditionalFinalizers): 63 (JSC::Heap::deleteAllCodeBlocks): 64 (JSC::Heap::deleteAllUnlinkedCodeBlocks): 65 (JSC::Heap::addCoreConstraints): 66 * heap/Subspace.cpp: 67 (JSC::Subspace::initialize): 68 * jit/AssemblyHelpers.h: 69 (JSC::AssemblyHelpers::emitAllocateJSObjectWithKnownSize): 70 (JSC::AssemblyHelpers::emitAllocateVariableSizedCell): 71 * jit/JITOpcodes.cpp: 72 (JSC::JIT::emit_op_new_object): 73 * jit/JITOpcodes32_64.cpp: 74 (JSC::JIT::emit_op_new_object): 75 * runtime/DirectArguments.h: 76 * runtime/DirectEvalExecutable.h: 77 * runtime/ErrorInstance.h: 78 (JSC::ErrorInstance::subspaceFor): 79 * runtime/ExecutableBase.h: 80 * runtime/FunctionExecutable.h: 81 * runtime/IndirectEvalExecutable.h: 82 * runtime/InferredValue.cpp: 83 (JSC::InferredValue::visitChildren): 84 * runtime/InferredValue.h: 85 * runtime/InferredValueInlines.h: 86 (JSC::InferredValue::finalizeUnconditionally): 87 * runtime/InternalFunction.h: 88 * runtime/JSAsyncFunction.h: 89 * runtime/JSAsyncGeneratorFunction.h: 90 * runtime/JSBoundFunction.h: 91 * runtime/JSCell.h: 92 (JSC::subspaceFor): 93 (JSC::subspaceForConcurrently): 94 * runtime/JSCellInlines.h: 95 (JSC::allocatorForNonVirtualConcurrently): 96 * runtime/JSCustomGetterSetterFunction.h: 97 * runtime/JSDestructibleObject.h: 98 * runtime/JSFunction.h: 99 * runtime/JSGeneratorFunction.h: 100 * runtime/JSImmutableButterfly.h: 101 * runtime/JSLexicalEnvironment.h: 102 (JSC::JSLexicalEnvironment::subspaceFor): 103 * runtime/JSNativeStdFunction.h: 104 * runtime/JSSegmentedVariableObject.h: 105 * runtime/JSString.h: 106 * runtime/ModuleProgramExecutable.h: 107 * runtime/NativeExecutable.h: 108 * runtime/ProgramExecutable.h: 109 * runtime/PropertyMapHashTable.h: 110 * runtime/ProxyRevoke.h: 111 * runtime/ScopedArguments.h: 112 * runtime/ScriptExecutable.cpp: 113 (JSC::ScriptExecutable::clearCode): 114 (JSC::ScriptExecutable::installCode): 115 * runtime/Structure.h: 116 * runtime/StructureRareData.h: 117 * runtime/SubspaceAccess.h: Copied from Source/JavaScriptCore/runtime/InferredValueInlines.h. 118 * runtime/VM.cpp: 119 (JSC::VM::VM): 120 * runtime/VM.h: 121 (JSC::VM::SpaceAndSet::SpaceAndSet): 122 (JSC::VM::SpaceAndSet::setFor): 123 (JSC::VM::forEachScriptExecutableSpace): 124 (JSC::VM::SpaceAndFinalizerSet::SpaceAndFinalizerSet): Deleted. 125 (JSC::VM::SpaceAndFinalizerSet::finalizerSetFor): Deleted. 126 (JSC::VM::ScriptExecutableSpaceAndSet::ScriptExecutableSpaceAndSet): Deleted. 127 (JSC::VM::ScriptExecutableSpaceAndSet::clearableCodeSetFor): Deleted. 128 (JSC::VM::UnlinkedFunctionExecutableSpaceAndSet::UnlinkedFunctionExecutableSpaceAndSet): Deleted. 129 (JSC::VM::UnlinkedFunctionExecutableSpaceAndSet::clearableCodeSetFor): Deleted. 130 * runtime/WeakMapImpl.h: 131 (JSC::WeakMapImpl::subspaceFor): 132 * wasm/js/JSWebAssemblyCodeBlock.h: 133 * wasm/js/JSWebAssemblyMemory.h: 134 * wasm/js/WebAssemblyFunction.h: 135 * wasm/js/WebAssemblyWrapperFunction.h: 136 1 137 2019-02-04 Keith Miller <keith_miller@apple.com> 2 138 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r240823 r240965 1766 1766 E3794E761B77EB97005543AE /* ModuleAnalyzer.h in Headers */ = {isa = PBXBuildFile; fileRef = E3794E741B77EB97005543AE /* ModuleAnalyzer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1767 1767 E3893A1D2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E3893A1C2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h */; }; 1768 E39006212208BFC4001019CF /* SubspaceAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = E39006202208BFC3001019CF /* SubspaceAccess.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1768 1769 E393ADD81FE702D00022D681 /* WeakMapImplInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E393ADD71FE702CC0022D681 /* WeakMapImplInlines.h */; }; 1769 1770 E39D45F51D39005600B3B377 /* InterpreterInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E39D9D841D39000600667282 /* InterpreterInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4704 4705 E380A76B1DCD7195000F89E6 /* MacroAssemblerHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerHelpers.h; sourceTree = "<group>"; }; 4705 4706 E380D66B1F19249D00A59095 /* BuiltinNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BuiltinNames.cpp; sourceTree = "<group>"; }; 4706 E3893A1C2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AsyncFromSyncIteratorPrototype.lut.h;path = AsyncFromSyncIteratorPrototype.lut.h; sourceTree = "<group>"; };4707 E3893A1C2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncFromSyncIteratorPrototype.lut.h; sourceTree = "<group>"; }; 4707 4708 E38D060B1F8E814100649CF2 /* JSScriptFetchParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScriptFetchParameters.h; sourceTree = "<group>"; }; 4708 4709 E38D060C1F8E814100649CF2 /* ScriptFetchParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptFetchParameters.h; sourceTree = "<group>"; }; 4709 4710 E38D060D1F8E814100649CF2 /* JSScriptFetchParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScriptFetchParameters.cpp; sourceTree = "<group>"; }; 4711 E39006202208BFC3001019CF /* SubspaceAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubspaceAccess.h; sourceTree = "<group>"; }; 4710 4712 E393ADD71FE702CC0022D681 /* WeakMapImplInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakMapImplInlines.h; sourceTree = "<group>"; }; 4711 4713 E3963CEC1B73F75000EB4CE5 /* NodesAnalyzeModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NodesAnalyzeModule.cpp; sourceTree = "<group>"; }; … … 7165 7167 C20BA92C16BB1C1500B3AEA2 /* StructureRareDataInlines.h */, 7166 7168 BC9041470EB9250900FE26FA /* StructureTransitionTable.h */, 7169 E39006202208BFC3001019CF /* SubspaceAccess.h */, 7167 7170 705B41A31A6E501E00716757 /* Symbol.cpp */, 7168 7171 705B41A41A6E501E00716757 /* Symbol.h */, … … 9693 9696 0F44767020C5E2B4008B2C36 /* StubInfoSummary.h in Headers */, 9694 9697 0F7DF1371E2970E10095951B /* Subspace.h in Headers */, 9698 E39006212208BFC4001019CF /* SubspaceAccess.h in Headers */, 9695 9699 0F7DF1381E2970E40095951B /* SubspaceInlines.h in Headers */, 9696 9700 0F4A38FA1C8E13DF00190318 /* SuperSampler.h in Headers */, -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r240938 r240965 998 998 stronglyVisitWeakReferences(locker, visitor); 999 999 1000 VM::SpaceAnd FinalizerSet::finalizerSetFor(*subspace()).add(this);1000 VM::SpaceAndSet::setFor(*subspace()).add(this); 1001 1001 } 1002 1002 … … 1393 1393 #endif // ENABLE(DFG_JIT) 1394 1394 1395 VM::SpaceAnd FinalizerSet::finalizerSetFor(*subspace()).remove(this);1395 VM::SpaceAndSet::setFor(*subspace()).remove(this); 1396 1396 } 1397 1397 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r240893 r240965 115 115 static const bool needsDestruction = true; 116 116 117 template<typename >117 template<typename, SubspaceAccess> 118 118 static void subspaceFor(VM&) { } 119 119 -
trunk/Source/JavaScriptCore/bytecode/EvalCodeBlock.h
r240864 r240965 39 39 DECLARE_INFO; 40 40 41 template<typename >41 template<typename, SubspaceAccess> 42 42 static IsoSubspace* subspaceFor(VM& vm) 43 43 { -
trunk/Source/JavaScriptCore/bytecode/ExecutableToCodeBlockEdge.h
r240951 r240965 41 41 static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal; 42 42 43 template<typename CellType >43 template<typename CellType, SubspaceAccess> 44 44 static IsoSubspace* subspaceFor(VM& vm) 45 45 { -
trunk/Source/JavaScriptCore/bytecode/FunctionCodeBlock.h
r240864 r240965 40 40 DECLARE_INFO; 41 41 42 template<typename >42 template<typename, SubspaceAccess> 43 43 static IsoSubspace* subspaceFor(VM& vm) 44 44 { -
trunk/Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h
r240864 r240965 40 40 DECLARE_INFO; 41 41 42 template<typename >42 template<typename, SubspaceAccess> 43 43 static IsoSubspace* subspaceFor(VM& vm) 44 44 { -
trunk/Source/JavaScriptCore/bytecode/ProgramCodeBlock.h
r240864 r240965 40 40 DECLARE_INFO; 41 41 42 template<typename >42 template<typename, SubspaceAccess> 43 43 static IsoSubspace* subspaceFor(VM& vm) 44 44 { -
trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp
r240521 r240965 238 238 break; 239 239 } 240 vm.unlinkedFunctionExecutableSpace. clearableCodeSet.add(this);240 vm.unlinkedFunctionExecutableSpace.set.add(this); 241 241 return result; 242 242 } -
trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
r240511 r240965 62 62 static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal; 63 63 64 template<typename CellType >64 template<typename CellType, SubspaceAccess> 65 65 static IsoSubspace* subspaceFor(VM& vm) 66 66 { … … 121 121 m_unlinkedCodeBlockForCall.clear(); 122 122 m_unlinkedCodeBlockForConstruct.clear(); 123 vm.unlinkedFunctionExecutableSpace. clearableCodeSet.remove(this);123 vm.unlinkedFunctionExecutableSpace.set.remove(this); 124 124 } 125 125 -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r240878 r240965 131 131 132 132 size_t allocationSize = JSFinalObject::allocationSize(inlineCapacity); 133 Allocator allocator = subspaceFor<JSFinalObject>(*m_jit.vm())->allocatorForNonVirtual(allocationSize, AllocatorForMode::AllocatorIfExists);133 Allocator allocator = allocatorForNonVirtualConcurrently<JSFinalObject>(*m_jit.vm(), allocationSize, AllocatorForMode::AllocatorIfExists); 134 134 if (allocator) { 135 135 emitAllocateJSObject(resultGPR, JITAllocator::constant(allocator), scratchGPR, TrustedImmPtr(structure), storageGPR, scratch2GPR, slowCases); … … 4360 4360 4361 4361 JITCompiler::JumpList slowPath; 4362 Allocator allocatorValue = subspaceFor<JSRopeString>(*m_jit.vm())->allocatorForNonVirtual(sizeof(JSRopeString), AllocatorForMode::AllocatorIfExists);4362 Allocator allocatorValue = allocatorForNonVirtualConcurrently<JSRopeString>(*m_jit.vm(), sizeof(JSRopeString), AllocatorForMode::AllocatorIfExists); 4363 4363 emitAllocateJSCell(resultGPR, JITAllocator::constant(allocatorValue), allocatorGPR, TrustedImmPtr(m_jit.graph().registerStructure(m_jit.vm()->stringStructure.get())), scratchGPR, slowPath); 4364 4364 … … 12541 12541 RegisteredStructure structure = node->structure(); 12542 12542 size_t allocationSize = JSFinalObject::allocationSize(structure->inlineCapacity()); 12543 Allocator allocatorValue = subspaceFor<JSFinalObject>(*m_jit.vm())->allocatorForNonVirtual(allocationSize, AllocatorForMode::AllocatorIfExists); 12544 12543 Allocator allocatorValue = allocatorForNonVirtualConcurrently<JSFinalObject>(*m_jit.vm(), allocationSize, AllocatorForMode::AllocatorIfExists); 12545 12544 if (!allocatorValue) 12546 12545 slowPath.append(m_jit.jump()); -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r240959 r240965 6473 6473 LBasicBlock lastNext = m_out.insertNewBlocksBefore(slowPath); 6474 6474 6475 Allocator allocator = subspaceFor<JSRopeString>(vm())->allocatorForNonVirtual(sizeof(JSRopeString), AllocatorForMode::AllocatorIfExists);6475 Allocator allocator = allocatorForNonVirtualConcurrently<JSRopeString>(vm(), sizeof(JSRopeString), AllocatorForMode::AllocatorIfExists); 6476 6476 6477 6477 LValue result = allocateCell( … … 10724 10724 if (structure->outOfLineCapacity() || hasIndexedProperties(structure->indexingType())) { 10725 10725 size_t allocationSize = JSFinalObject::allocationSize(structure->inlineCapacity()); 10726 Allocator cellAllocator = subspaceFor<JSFinalObject>(vm())->allocatorForNonVirtual(allocationSize, AllocatorForMode::AllocatorIfExists);10726 Allocator cellAllocator = allocatorForNonVirtualConcurrently<JSFinalObject>(vm(), allocationSize, AllocatorForMode::AllocatorIfExists); 10727 10727 10728 10728 bool hasIndexingHeader = hasIndexedProperties(structure->indexingType()); … … 13191 13191 size_t size, StructureType structure, LValue butterfly, LBasicBlock slowPath) 13192 13192 { 13193 Allocator allocator = subspaceFor<ClassType>(vm())->allocatorForNonVirtual(size, AllocatorForMode::AllocatorIfExists);13193 Allocator allocator = allocatorForNonVirtualConcurrently<ClassType>(vm(), size, AllocatorForMode::AllocatorIfExists); 13194 13194 return allocateObject( 13195 13195 m_out.constIntPtr(allocator.localAllocator()), structure, butterfly, slowPath); … … 13255 13255 LValue size, RegisteredStructure structure, LValue butterfly, LBasicBlock slowPath) 13256 13256 { 13257 LValue allocator = allocatorForSize(*subspaceFor<ClassType>(vm()), size, slowPath); 13257 CompleteSubspace* subspace = subspaceForConcurrently<ClassType>(vm()); 13258 RELEASE_ASSERT_WITH_MESSAGE(subspace, "CompleteSubspace is always allocated"); 13259 LValue allocator = allocatorForSize(*subspace, size, slowPath); 13258 13260 return allocateObject(allocator, structure, butterfly, slowPath); 13259 13261 } … … 13263 13265 LValue size, Structure* structure, LBasicBlock slowPath) 13264 13266 { 13265 LValue allocator = allocatorForSize(*subspaceFor<ClassType>(vm()), size, slowPath); 13267 CompleteSubspace* subspace = subspaceForConcurrently<ClassType>(vm()); 13268 RELEASE_ASSERT_WITH_MESSAGE(subspace, "CompleteSubspace is always allocated"); 13269 LValue allocator = allocatorForSize(*subspace, size, slowPath); 13266 13270 return allocateCell(allocator, structure, slowPath); 13267 13271 } … … 13270 13274 { 13271 13275 size_t allocationSize = JSFinalObject::allocationSize(structure.get()->inlineCapacity()); 13272 Allocator allocator = subspaceFor<JSFinalObject>(vm())->allocatorForNonVirtual(allocationSize, AllocatorForMode::AllocatorIfExists);13276 Allocator allocator = allocatorForNonVirtualConcurrently<JSFinalObject>(vm(), allocationSize, AllocatorForMode::AllocatorIfExists); 13273 13277 13274 13278 // FIXME: If the allocator is null, we could simply emit a normal C call to the allocator -
trunk/Source/JavaScriptCore/heap/AlignedMemoryAllocator.cpp
r226822 r240965 28 28 29 29 #include "BlockDirectory.h" 30 #include "Heap.h" 30 31 #include "Subspace.h" 31 32 … … 45 46 46 47 if (m_directories.isEmpty()) { 48 ASSERT(!mayBeGCThread() || directory->heap()->worldIsStopped()); 47 49 for (Subspace* subspace = m_subspaces.first(); subspace; subspace = subspace->nextSubspaceInAlignedMemoryAllocator()) 48 50 subspace->didCreateFirstDirectory(directory); -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r240637 r240965 568 568 void Heap::finalizeUnconditionalFinalizers() 569 569 { 570 finalizeMarkedUnconditionalFinalizers<InferredValue>(vm()->inferredValuesWithFinalizers); 570 if (vm()->m_inferredValueSpace) 571 finalizeMarkedUnconditionalFinalizers<InferredValue>(vm()->m_inferredValueSpace->space); 571 572 vm()->forEachCodeBlockSpace( 572 573 [&] (auto& space) { 573 this->finalizeMarkedUnconditionalFinalizers<CodeBlock>(space. finalizerSet);574 this->finalizeMarkedUnconditionalFinalizers<CodeBlock>(space.set); 574 575 }); 575 576 finalizeMarkedUnconditionalFinalizers<ExecutableToCodeBlockEdge>(vm()->executableToCodeBlockEdgesWithFinalizers); 576 finalizeMarkedUnconditionalFinalizers<JSWeakSet>(vm()->weakSetSpace); 577 finalizeMarkedUnconditionalFinalizers<JSWeakMap>(vm()->weakMapSpace); 578 finalizeMarkedUnconditionalFinalizers<ErrorInstance>(vm()->errorInstanceSpace); 577 if (vm()->m_weakSetSpace) 578 finalizeMarkedUnconditionalFinalizers<JSWeakSet>(*vm()->m_weakSetSpace); 579 if (vm()->m_weakMapSpace) 580 finalizeMarkedUnconditionalFinalizers<JSWeakMap>(*vm()->m_weakMapSpace); 581 if (vm()->m_errorInstanceSpace) 582 finalizeMarkedUnconditionalFinalizers<ErrorInstance>(*vm()->m_errorInstanceSpace); 579 583 580 584 #if ENABLE(WEBASSEMBLY) 581 finalizeMarkedUnconditionalFinalizers<JSWebAssemblyCodeBlock>(vm()->webAssemblyCodeBlockSpace); 585 if (vm()->m_webAssemblyCodeBlockSpace) 586 finalizeMarkedUnconditionalFinalizers<JSWebAssemblyCodeBlock>(*vm()->m_webAssemblyCodeBlockSpace); 582 587 #endif 583 588 } … … 881 886 [&] (auto& spaceAndSet) { 882 887 HeapIterationScope heapIterationScope(*this); 883 auto& clearableCodeSet = spaceAndSet.clearableCodeSet;884 clearableCodeSet.forEachLiveCell(888 auto& set = spaceAndSet.set; 889 set.forEachLiveCell( 885 890 [&] (HeapCell* cell, HeapCell::Kind) { 886 891 ScriptExecutable* executable = static_cast<ScriptExecutable*>(cell); 887 executable->clearCode( clearableCodeSet);892 executable->clearCode(set); 888 893 }); 889 894 }); … … 897 902 // it uses a callee check, but then it will call into dead code. 898 903 HeapIterationScope heapIterationScope(*this); 899 vm.webAssemblyCodeBlockSpace.forEachLiveCell([&] (HeapCell* cell, HeapCell::Kind kind) { 900 ASSERT_UNUSED(kind, kind == HeapCell::JSCell); 901 JSWebAssemblyCodeBlock* codeBlock = static_cast<JSWebAssemblyCodeBlock*>(cell); 902 codeBlock->clearJSCallICs(vm); 903 }); 904 if (vm.m_webAssemblyCodeBlockSpace) { 905 vm.m_webAssemblyCodeBlockSpace->forEachLiveCell([&] (HeapCell* cell, HeapCell::Kind kind) { 906 ASSERT_UNUSED(kind, kind == HeapCell::JSCell); 907 JSWebAssemblyCodeBlock* codeBlock = static_cast<JSWebAssemblyCodeBlock*>(cell); 908 codeBlock->clearJSCallICs(vm); 909 }); 910 } 904 911 } 905 912 #endif … … 917 924 918 925 HeapIterationScope heapIterationScope(*this); 919 vm.unlinkedFunctionExecutableSpace. clearableCodeSet.forEachLiveCell(926 vm.unlinkedFunctionExecutableSpace.set.forEachLiveCell( 920 927 [&] (HeapCell* cell, HeapCell::Kind) { 921 928 UnlinkedFunctionExecutable* executable = static_cast<UnlinkedFunctionExecutable*>(cell); … … 2731 2738 2732 2739 add(vm.executableToCodeBlockEdgesWithConstraints); 2733 add(vm.weakMapSpace); 2740 if (vm.m_weakMapSpace) 2741 add(*vm.m_weakMapSpace); 2734 2742 }, 2735 2743 ConstraintVolatility::GreyedByMarking, -
trunk/Source/JavaScriptCore/heap/MarkedSpace.cpp
r240216 r240965 259 259 void MarkedSpace::prepareForAllocation() 260 260 { 261 ASSERT(!mayBeGCThread() || m_heap->worldIsStopped()); 261 262 for (Subspace* subspace : m_subspaces) 262 263 subspace->prepareForAllocation(); -
trunk/Source/JavaScriptCore/heap/Subspace.cpp
r240216 r240965 51 51 52 52 Heap& heap = *m_space.heap(); 53 PreventCollectionScope preventCollectionScope(heap);54 53 heap.objectSpace().m_subspaces.append(this); 55 54 m_alignedMemoryAllocator->registerSubspace(this); -
trunk/Source/JavaScriptCore/jit/AssemblyHelpers.h
r240023 r240965 1753 1753 GPRReg scratchGPR2, JumpList& slowPath, size_t size) 1754 1754 { 1755 Allocator allocator = subspaceFor<ClassType>(vm)->allocatorForNonVirtual(size, AllocatorForMode::AllocatorIfExists);1755 Allocator allocator = allocatorForNonVirtualConcurrently<ClassType>(vm, size, AllocatorForMode::AllocatorIfExists); 1756 1756 emitAllocateJSObject(resultGPR, JITAllocator::constant(allocator), scratchGPR1, structure, storage, scratchGPR2, slowPath); 1757 1757 } … … 1770 1770 void emitAllocateVariableSizedCell(VM& vm, GPRReg resultGPR, StructureType structure, GPRReg allocationSize, GPRReg scratchGPR1, GPRReg scratchGPR2, JumpList& slowPath) 1771 1771 { 1772 CompleteSubspace& subspace = *subspaceFor<ClassType>(vm); 1773 emitAllocateVariableSized(resultGPR, subspace, allocationSize, scratchGPR1, scratchGPR2, slowPath); 1772 CompleteSubspace* subspace = subspaceForConcurrently<ClassType>(vm); 1773 RELEASE_ASSERT_WITH_MESSAGE(subspace, "CompleteSubspace is always allocated"); 1774 emitAllocateVariableSized(resultGPR, *subspace, allocationSize, scratchGPR1, scratchGPR2, slowPath); 1774 1775 emitStoreStructureWithTypeInfo(structure, resultGPR, scratchGPR2); 1775 1776 } -
trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp
r240637 r240965 97 97 Structure* structure = metadata.m_objectAllocationProfile.structure(); 98 98 size_t allocationSize = JSFinalObject::allocationSize(structure->inlineCapacity()); 99 Allocator allocator = subspaceFor<JSFinalObject>(*m_vm)->allocatorForNonVirtual(allocationSize, AllocatorForMode::AllocatorIfExists);99 Allocator allocator = allocatorForNonVirtualConcurrently<JSFinalObject>(*m_vm, allocationSize, AllocatorForMode::AllocatorIfExists); 100 100 101 101 RegisterID resultReg = regT0; -
trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
r240637 r240965 85 85 Structure* structure = metadata.m_objectAllocationProfile.structure(); 86 86 size_t allocationSize = JSFinalObject::allocationSize(structure->inlineCapacity()); 87 Allocator allocator = subspaceFor<JSFinalObject>(*m_vm)->allocatorForNonVirtual(allocationSize, AllocatorForMode::AllocatorIfExists);87 Allocator allocator = allocatorForNonVirtualConcurrently<JSFinalObject>(*m_vm, allocationSize, AllocatorForMode::AllocatorIfExists); 88 88 89 89 RegisterID resultReg = returnValueGPR; -
trunk/Source/JavaScriptCore/runtime/DirectArguments.h
r236697 r240965 47 47 48 48 public: 49 template<typename CellType >49 template<typename CellType, SubspaceAccess> 50 50 static CompleteSubspace* subspaceFor(VM& vm) 51 51 { 52 RELEASE_ASSERT(!CellType::needsDestruction);52 static_assert(!CellType::needsDestruction, ""); 53 53 return &vm.jsValueGigacageCellSpace; 54 54 } -
trunk/Source/JavaScriptCore/runtime/DirectEvalExecutable.h
r233039 r240965 32 32 class DirectEvalExecutable final : public EvalExecutable { 33 33 public: 34 template<typename CellType >34 template<typename CellType, SubspaceAccess mode> 35 35 static IsoSubspace* subspaceFor(VM& vm) 36 36 { 37 return &vm.directEvalExecutableSpace.space;37 return vm.directEvalExecutableSpace<mode>(); 38 38 } 39 39 -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.h
r232314 r240965 73 73 bool materializeErrorInfoIfNeeded(VM&, PropertyName); 74 74 75 template<typename CellType >75 template<typename CellType, SubspaceAccess mode> 76 76 static IsoSubspace* subspaceFor(VM& vm) 77 77 { 78 return &vm.errorInstanceSpace;78 return vm.errorInstanceSpace<mode>(); 79 79 } 80 80 -
trunk/Source/JavaScriptCore/runtime/ExecutableBase.h
r240938 r240965 85 85 86 86 // Force subclasses to override this. 87 template<typename >87 template<typename, SubspaceAccess> 88 88 static void subspaceFor(VM&) { } 89 89 -
trunk/Source/JavaScriptCore/runtime/FunctionExecutable.h
r240938 r240965 41 41 static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal; 42 42 43 template<typename CellType >43 template<typename CellType, SubspaceAccess> 44 44 static IsoSubspace* subspaceFor(VM& vm) 45 45 { -
trunk/Source/JavaScriptCore/runtime/IndirectEvalExecutable.h
r233039 r240965 32 32 class IndirectEvalExecutable final : public EvalExecutable { 33 33 public: 34 template<typename CellType >34 template<typename CellType, SubspaceAccess mode> 35 35 static IsoSubspace* subspaceFor(VM& vm) 36 36 { 37 return &vm.indirectEvalExecutableSpace.space;37 return vm.indirectEvalExecutableSpace<mode>(); 38 38 } 39 39 -
trunk/Source/JavaScriptCore/runtime/InferredValue.cpp
r240796 r240965 64 64 return; 65 65 66 visitor.vm().inferredValuesWithFinalizers.add(inferredValue);66 VM::SpaceAndSet::setFor(*inferredValue->subspace()).add(inferredValue); 67 67 } 68 68 -
trunk/Source/JavaScriptCore/runtime/InferredValue.h
r239191 r240965 46 46 typedef JSCell Base; 47 47 48 template<typename CellType >48 template<typename CellType, SubspaceAccess mode> 49 49 static IsoSubspace* subspaceFor(VM& vm) 50 50 { 51 return &vm.inferredValueSpace;51 return vm.inferredValueSpace<mode>(); 52 52 } 53 53 -
trunk/Source/JavaScriptCore/runtime/InferredValueInlines.h
r225887 r240965 41 41 } 42 42 43 vm.inferredValuesWithFinalizers.remove(this);43 VM::SpaceAndSet::setFor(*subspace()).remove(this); 44 44 } 45 45 -
trunk/Source/JavaScriptCore/runtime/InternalFunction.h
r233245 r240965 39 39 static const unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance | ImplementsDefaultHasInstance | OverridesGetCallData; 40 40 41 template<typename CellType >41 template<typename CellType, SubspaceAccess> 42 42 static IsoSubspace* subspaceFor(VM& vm) 43 43 { -
trunk/Source/JavaScriptCore/runtime/JSAsyncFunction.h
r240888 r240965 39 39 const static unsigned StructureFlags = Base::StructureFlags; 40 40 41 template<typename CellType >41 template<typename CellType, SubspaceAccess> 42 42 static IsoSubspace* subspaceFor(VM& vm) 43 43 { -
trunk/Source/JavaScriptCore/runtime/JSAsyncGeneratorFunction.h
r240888 r240965 39 39 const static unsigned StructureFlags = Base::StructureFlags; 40 40 41 template<typename CellType >41 template<typename CellType, SubspaceAccess> 42 42 static IsoSubspace* subspaceFor(VM& vm) 43 43 { -
trunk/Source/JavaScriptCore/runtime/JSBoundFunction.h
r239191 r240965 43 43 static_assert(StructureFlags & ImplementsHasInstance, ""); 44 44 45 template<typename CellType >45 template<typename CellType, SubspaceAccess mode> 46 46 static IsoSubspace* subspaceFor(VM& vm) 47 47 { 48 return &vm.boundFunctionSpace;48 return vm.boundFunctionSpace<mode>(); 49 49 } 50 50 -
trunk/Source/JavaScriptCore/runtime/JSCell.h
r240951 r240965 33 33 #include "JSTypeInfo.h" 34 34 #include "SlotVisitor.h" 35 #include "SubspaceAccess.h" 35 36 #include "TypedArrayType.h" 36 37 #include "WriteBarrier.h" … … 89 90 // FIXME: Refer to Subspace by reference. 90 91 // https://bugs.webkit.org/show_bug.cgi?id=166988 91 template<typename CellType >92 template<typename CellType, SubspaceAccess> 92 93 static CompleteSubspace* subspaceFor(VM&); 93 94 … … 295 296 inline auto subspaceFor(VM& vm) 296 297 { 297 return Type::template subspaceFor<Type >(vm);298 return Type::template subspaceFor<Type, SubspaceAccess::OnMainThread>(vm); 298 299 } 299 300 301 template<typename Type> 302 inline auto subspaceForConcurrently(VM& vm) 303 { 304 return Type::template subspaceFor<Type, SubspaceAccess::Concurrently>(vm); 305 } 306 300 307 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSCellInlines.h
r240951 r240965 26 26 #pragma once 27 27 28 #include "AllocatorForMode.h" 28 29 #include "AllocatorInlines.h" 29 30 #include "CompleteSubspaceInlines.h" … … 146 147 } 147 148 148 template<typename CellType >149 template<typename CellType, SubspaceAccess> 149 150 CompleteSubspace* JSCell::subspaceFor(VM& vm) 150 151 { … … 152 153 return &vm.destructibleCellSpace; 153 154 return &vm.cellSpace; 155 } 156 157 template<typename Type> 158 inline Allocator allocatorForNonVirtualConcurrently(VM& vm, size_t allocationSize, AllocatorForMode mode) 159 { 160 if (auto* subspace = subspaceForConcurrently<Type>(vm)) 161 return subspace->allocatorForNonVirtual(allocationSize, mode); 162 return { }; 154 163 } 155 164 -
trunk/Source/JavaScriptCore/runtime/JSCustomGetterSetterFunction.h
r229413 r240965 41 41 static const unsigned StructureFlags = Base::StructureFlags; 42 42 43 template<typename CellType >43 template<typename CellType, SubspaceAccess mode> 44 44 static IsoSubspace* subspaceFor(VM& vm) 45 45 { 46 return &vm.customGetterSetterFunctionSpace;46 return vm.customGetterSetterFunctionSpace<mode>(); 47 47 } 48 48 -
trunk/Source/JavaScriptCore/runtime/JSDestructibleObject.h
r225632 r240965 38 38 static const bool needsDestruction = true; 39 39 40 template<typename CellType >40 template<typename CellType, SubspaceAccess> 41 41 static CompleteSubspace* subspaceFor(VM& vm) 42 42 { -
trunk/Source/JavaScriptCore/runtime/JSFunction.h
r232337 r240965 63 63 public: 64 64 65 template<typename CellType >65 template<typename CellType, SubspaceAccess> 66 66 static IsoSubspace* subspaceFor(VM& vm) 67 67 { -
trunk/Source/JavaScriptCore/runtime/JSGeneratorFunction.h
r240888 r240965 67 67 const static unsigned StructureFlags = Base::StructureFlags; 68 68 69 template<typename CellType >69 template<typename CellType, SubspaceAccess> 70 70 static IsoSubspace* subspaceFor(VM& vm) 71 71 { -
trunk/Source/JavaScriptCore/runtime/JSImmutableButterfly.h
r239324 r240965 89 89 void copyToArguments(ExecState*, VirtualRegister firstElementDest, unsigned offset, unsigned length); 90 90 91 template<typename >91 template<typename, SubspaceAccess> 92 92 static CompleteSubspace* subspaceFor(VM& vm) 93 93 { -
trunk/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h
r230369 r240965 41 41 friend class LLIntOffsetsExtractor; 42 42 public: 43 template<typename CellType >43 template<typename CellType, SubspaceAccess> 44 44 static CompleteSubspace* subspaceFor(VM& vm) 45 45 { 46 RELEASE_ASSERT(!CellType::needsDestruction);46 static_assert(!CellType::needsDestruction, ""); 47 47 return &vm.jsValueGigacageCellSpace; 48 48 } -
trunk/Source/JavaScriptCore/runtime/JSNativeStdFunction.h
r237223 r240965 41 41 const static unsigned StructureFlags = Base::StructureFlags; 42 42 43 template<typename CellType >43 template<typename CellType, SubspaceAccess mode> 44 44 static IsoSubspace* subspaceFor(VM& vm) 45 45 { 46 return &vm.nativeStdFunctionSpace;46 return vm.nativeStdFunctionSpace<mode>(); 47 47 } 48 48 -
trunk/Source/JavaScriptCore/runtime/JSSegmentedVariableObject.h
r240204 r240965 91 91 static void destroy(JSCell*); 92 92 93 template<typename >93 template<typename, SubspaceAccess> 94 94 static CompleteSubspace* subspaceFor(VM& vm) 95 95 { -
trunk/Source/JavaScriptCore/runtime/JSString.h
r239427 r240965 90 90 // We specialize the string subspace to get the fastest possible sweep. This wouldn't be 91 91 // necessary if JSString didn't have a destructor. 92 template<typename >92 template<typename, SubspaceAccess> 93 93 static CompleteSubspace* subspaceFor(VM& vm) 94 94 { -
trunk/Source/JavaScriptCore/runtime/ModuleProgramExecutable.h
r233039 r240965 37 37 static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal; 38 38 39 template<typename CellType >39 template<typename CellType, SubspaceAccess mode> 40 40 static IsoSubspace* subspaceFor(VM& vm) 41 41 { 42 return &vm.moduleProgramExecutableSpace.space;42 return vm.moduleProgramExecutableSpace<mode>(); 43 43 } 44 44 -
trunk/Source/JavaScriptCore/runtime/NativeExecutable.h
r229547 r240965 45 45 static void destroy(JSCell*); 46 46 47 template<typename CellType >47 template<typename CellType, SubspaceAccess> 48 48 static IsoSubspace* subspaceFor(VM& vm) 49 49 { -
trunk/Source/JavaScriptCore/runtime/ProgramExecutable.h
r236904 r240965 37 37 static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal; 38 38 39 template<typename CellType >39 template<typename CellType, SubspaceAccess> 40 40 static IsoSubspace* subspaceFor(VM& vm) 41 41 { -
trunk/Source/JavaScriptCore/runtime/PropertyMapHashTable.h
r233625 r240965 124 124 static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal; 125 125 126 template<typename CellType >126 template<typename CellType, SubspaceAccess> 127 127 static IsoSubspace* subspaceFor(VM& vm) 128 128 { -
trunk/Source/JavaScriptCore/runtime/ProxyRevoke.h
r230813 r240965 37 37 static const unsigned StructureFlags = Base::StructureFlags; 38 38 39 template<typename CellType >39 template<typename CellType, SubspaceAccess mode> 40 40 static IsoSubspace* subspaceFor(VM& vm) 41 41 { 42 return &vm.proxyRevokeSpace;42 return vm.proxyRevokeSpace<mode>(); 43 43 } 44 44 -
trunk/Source/JavaScriptCore/runtime/ScopedArguments.h
r239198 r240965 44 44 45 45 public: 46 template<typename CellType >46 template<typename CellType, SubspaceAccess> 47 47 static CompleteSubspace* subspaceFor(VM& vm) 48 48 { 49 RELEASE_ASSERT(!CellType::needsDestruction);49 static_assert(!CellType::needsDestruction, ""); 50 50 return &vm.jsValueGigacageCellSpace; 51 51 } -
trunk/Source/JavaScriptCore/runtime/ScriptExecutable.cpp
r240938 r240965 69 69 { 70 70 Base::clearCode(); 71 ASSERT(&VM::S criptExecutableSpaceAndSet::clearableCodeSetFor(*subspace()) == &clearableCodeSet);71 ASSERT(&VM::SpaceAndSet::setFor(*subspace()) == &clearableCodeSet); 72 72 clearableCodeSet.remove(this); 73 73 } … … 150 150 } 151 151 152 auto& clearableCodeSet = VM::S criptExecutableSpaceAndSet::clearableCodeSetFor(*subspace());152 auto& clearableCodeSet = VM::SpaceAndSet::setFor(*subspace()); 153 153 if (hasClearableCode()) 154 154 clearableCodeSet.add(this); -
trunk/Source/JavaScriptCore/runtime/Structure.h
r240023 r240965 133 133 ~Structure(); 134 134 135 template<typename CellType >135 template<typename CellType, SubspaceAccess> 136 136 static IsoSubspace* subspaceFor(VM& vm) 137 137 { -
trunk/Source/JavaScriptCore/runtime/StructureRareData.h
r240327 r240965 44 44 static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal; 45 45 46 template<typename CellType >46 template<typename CellType, SubspaceAccess> 47 47 static IsoSubspace* subspaceFor(VM& vm) 48 48 { -
trunk/Source/JavaScriptCore/runtime/SubspaceAccess.h
r240964 r240965 1 1 /* 2 * Copyright (C) 201 7Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 26 #pragma once 27 27 28 #include "InferredValue.h"29 30 28 namespace JSC { 31 29 32 void InferredValue::finalizeUnconditionally(VM& vm) 33 { 34 JSValue value = m_value.get(); 35 36 if (value && value.isCell()) { 37 if (Heap::isMarked(value.asCell())) 38 return; 39 40 invalidate(vm, StringFireDetail("InferredValue clean-up during GC")); 41 } 42 43 vm.inferredValuesWithFinalizers.remove(this); 30 enum class SubspaceAccess { 31 OnMainThread, 32 Concurrently, 33 }; 34 44 35 } 45 46 } // namespace JSC47 -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r240888 r240965 288 288 , eagerlySweptDestructibleObjectSpace("Eagerly Swept JSDestructibleObject", heap, destructibleObjectHeapCellType.get(), fastMallocAllocator.get()) 289 289 , segmentedVariableObjectSpace("JSSegmentedVariableObjectSpace", heap, segmentedVariableObjectHeapCellType.get(), fastMallocAllocator.get()) 290 , boundFunctionSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), JSBoundFunction)291 , callbackFunctionSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), JSCallbackFunction)292 , customGetterSetterFunctionSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), JSCustomGetterSetterFunction)293 290 , executableToCodeBlockEdgeSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), ExecutableToCodeBlockEdge) 294 291 , functionSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), JSFunction) 295 , inferredValueSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), InferredValue)296 292 , internalFunctionSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), InternalFunction) 297 293 , nativeExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), NativeExecutable) 298 , nativeStdFunctionSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), JSNativeStdFunction)299 #if JSC_OBJC_API_ENABLED300 , objCCallbackFunctionSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), ObjCCallbackFunction)301 #endif302 294 , propertyTableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), PropertyTable) 303 , proxyRevokeSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), ProxyRevoke)304 295 , structureRareDataSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), StructureRareData) 305 296 , structureSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), Structure) 306 , weakSetSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), JSWeakSet)307 , weakMapSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), JSWeakMap)308 , errorInstanceSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), ErrorInstance)309 #if ENABLE(WEBASSEMBLY)310 , webAssemblyCodeBlockSpace ISO_SUBSPACE_INIT(heap, webAssemblyCodeBlockHeapCellType.get(), JSWebAssemblyCodeBlock)311 , webAssemblyFunctionSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), WebAssemblyFunction)312 , webAssemblyWrapperFunctionSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), WebAssemblyWrapperFunction)313 #endif314 297 , executableToCodeBlockEdgesWithConstraints(executableToCodeBlockEdgeSpace) 315 298 , executableToCodeBlockEdgesWithFinalizers(executableToCodeBlockEdgeSpace) 316 , inferredValuesWithFinalizers(inferredValueSpace)317 299 , codeBlockSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), CodeBlock) 318 , directEvalExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), DirectEvalExecutable)319 300 , functionExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), FunctionExecutable) 320 , indirectEvalExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), IndirectEvalExecutable)321 , moduleProgramExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), ModuleProgramExecutable)322 301 , programExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), ProgramExecutable) 323 302 , unlinkedFunctionExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), UnlinkedFunctionExecutable) … … 1240 1219 } 1241 1220 1221 #define DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(name, heapCellType, type) \ 1222 IsoSubspace* VM::name##Slow() \ 1223 { \ 1224 ASSERT(!m_##name); \ 1225 auto space = std::make_unique<IsoSubspace> ISO_SUBSPACE_INIT(heap, heapCellType, type); \ 1226 WTF::storeStoreFence(); \ 1227 m_##name = WTFMove(space); \ 1228 return m_##name.get(); \ 1229 } 1230 1231 1232 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(boundFunctionSpace, cellHeapCellType.get(), JSBoundFunction) 1233 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(callbackFunctionSpace, destructibleObjectHeapCellType.get(), JSCallbackFunction) 1234 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(customGetterSetterFunctionSpace, cellHeapCellType.get(), JSCustomGetterSetterFunction) 1235 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(errorInstanceSpace, destructibleObjectHeapCellType.get(), ErrorInstance) 1236 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(nativeStdFunctionSpace, cellHeapCellType.get(), JSNativeStdFunction) 1237 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(proxyRevokeSpace, destructibleObjectHeapCellType.get(), ProxyRevoke) 1238 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(weakMapSpace, destructibleObjectHeapCellType.get(), JSWeakMap) 1239 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(weakSetSpace, destructibleObjectHeapCellType.get(), JSWeakSet) 1240 #if JSC_OBJC_API_ENABLED 1241 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(objCCallbackFunctionSpace, destructibleObjectHeapCellType.get(), ObjCCallbackFunction) 1242 #endif 1243 #if ENABLE(WEBASSEMBLY) 1244 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(webAssemblyCodeBlockSpace, webAssemblyCodeBlockHeapCellType.get(), JSWebAssemblyCodeBlock) 1245 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(webAssemblyFunctionSpace, cellHeapCellType.get(), WebAssemblyFunction) 1246 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(webAssemblyWrapperFunctionSpace, cellHeapCellType.get(), WebAssemblyWrapperFunction) 1247 #endif 1248 1249 #undef DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW 1250 1251 #define DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW(name, heapCellType, type) \ 1252 IsoSubspace* VM::name##Slow() \ 1253 { \ 1254 ASSERT(!m_##name); \ 1255 auto space = std::make_unique<SpaceAndSet> ISO_SUBSPACE_INIT(heap, heapCellType, type); \ 1256 WTF::storeStoreFence(); \ 1257 m_##name = WTFMove(space); \ 1258 return &m_##name->space; \ 1259 } 1260 1261 DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW(inferredValueSpace, destructibleCellHeapCellType.get(), InferredValue) 1262 DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW(directEvalExecutableSpace, destructibleCellHeapCellType.get(), DirectEvalExecutable) 1263 DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW(indirectEvalExecutableSpace, destructibleCellHeapCellType.get(), IndirectEvalExecutable) 1264 DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW(moduleProgramExecutableSpace, destructibleCellHeapCellType.get(), ModuleProgramExecutable) 1265 1266 #undef DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW 1267 1242 1268 JSGlobalObject* VM::vmEntryGlobalObject(const CallFrame* callFrame) const 1243 1269 { -
trunk/Source/JavaScriptCore/runtime/VM.h
r240888 r240965 52 52 #include "Strong.h" 53 53 #include "StructureCache.h" 54 #include "SubspaceAccess.h" 54 55 #include "VMTraps.h" 55 56 #include "WasmContext.h" … … 367 368 CompleteSubspace segmentedVariableObjectSpace; 368 369 369 IsoSubspace boundFunctionSpace;370 IsoSubspace callbackFunctionSpace;371 IsoSubspace customGetterSetterFunctionSpace;372 370 IsoSubspace executableToCodeBlockEdgeSpace; 373 371 IsoSubspace functionSpace; 374 IsoSubspace inferredValueSpace;375 372 IsoSubspace internalFunctionSpace; 376 373 IsoSubspace nativeExecutableSpace; 377 IsoSubspace nativeStdFunctionSpace;378 #if JSC_OBJC_API_ENABLED379 IsoSubspace objCCallbackFunctionSpace;380 #endif381 374 IsoSubspace propertyTableSpace; 382 IsoSubspace proxyRevokeSpace;383 375 IsoSubspace structureRareDataSpace; 384 376 IsoSubspace structureSpace; 385 IsoSubspace weakSetSpace; 386 IsoSubspace weakMapSpace; 387 IsoSubspace errorInstanceSpace; 377 378 #define DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(name) \ 379 template<SubspaceAccess mode> \ 380 IsoSubspace* name() \ 381 { \ 382 if (m_##name || mode == SubspaceAccess::Concurrently) \ 383 return m_##name.get(); \ 384 return name##Slow(); \ 385 } \ 386 IsoSubspace* name##Slow(); \ 387 std::unique_ptr<IsoSubspace> m_##name; 388 389 390 #if JSC_OBJC_API_ENABLED 391 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(objCCallbackFunctionSpace) 392 #endif 393 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(boundFunctionSpace) 394 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(callbackFunctionSpace) 395 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(customGetterSetterFunctionSpace) 396 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(errorInstanceSpace) 397 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(nativeStdFunctionSpace) 398 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(proxyRevokeSpace) 399 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(weakSetSpace) 400 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(weakMapSpace) 388 401 #if ENABLE(WEBASSEMBLY) 389 IsoSubspace webAssemblyCodeBlockSpace; 390 IsoSubspace webAssemblyFunctionSpace; 391 IsoSubspace webAssemblyWrapperFunctionSpace; 392 #endif 402 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyCodeBlockSpace) 403 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyFunctionSpace) 404 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyWrapperFunctionSpace) 405 #endif 406 407 #undef DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER 393 408 394 409 IsoCellSet executableToCodeBlockEdgesWithConstraints; 395 410 IsoCellSet executableToCodeBlockEdgesWithFinalizers; 396 IsoCellSet inferredValuesWithFinalizers; 397 398 struct SpaceAndFinalizerSet { 411 412 #define DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(name) \ 413 template<SubspaceAccess mode> \ 414 IsoSubspace* name() \ 415 { \ 416 if (auto* spaceAndSet = m_##name.get()) \ 417 return &spaceAndSet->space; \ 418 if (mode == SubspaceAccess::Concurrently) \ 419 return nullptr; \ 420 return name##Slow(); \ 421 } \ 422 IsoSubspace* name##Slow(); \ 423 std::unique_ptr<SpaceAndSet> m_##name; 424 425 struct SpaceAndSet { 426 WTF_MAKE_STRUCT_FAST_ALLOCATED; 427 399 428 IsoSubspace space; 400 IsoCellSet finalizerSet;429 IsoCellSet set; 401 430 402 431 template<typename... Arguments> 403 SpaceAnd FinalizerSet(Arguments&&... arguments)432 SpaceAndSet(Arguments&&... arguments) 404 433 : space(std::forward<Arguments>(arguments)...) 405 , finalizerSet(space)434 , set(space) 406 435 { 407 436 } 408 437 409 static IsoCellSet& finalizerSetFor(Subspace& space)438 static IsoCellSet& setFor(Subspace& space) 410 439 { 411 440 return *bitwise_cast<IsoCellSet*>( 412 441 bitwise_cast<char*>(&space) - 413 OBJECT_OFFSETOF(SpaceAnd FinalizerSet, space) +414 OBJECT_OFFSETOF(SpaceAnd FinalizerSet, finalizerSet));442 OBJECT_OFFSETOF(SpaceAndSet, space) + 443 OBJECT_OFFSETOF(SpaceAndSet, set)); 415 444 } 416 445 }; 417 446 418 SpaceAndFinalizerSet codeBlockSpace; 447 SpaceAndSet codeBlockSpace; 448 DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(inferredValueSpace) 419 449 420 450 template<typename Func> … … 426 456 } 427 457 428 struct ScriptExecutableSpaceAndSet { 429 IsoSubspace space; 430 IsoCellSet clearableCodeSet; 431 432 template<typename... Arguments> 433 ScriptExecutableSpaceAndSet(Arguments&&... arguments) 434 : space(std::forward<Arguments>(arguments)...) 435 , clearableCodeSet(space) 436 { } 437 438 static IsoCellSet& clearableCodeSetFor(Subspace& space) 439 { 440 return *bitwise_cast<IsoCellSet*>( 441 bitwise_cast<char*>(&space) - 442 OBJECT_OFFSETOF(ScriptExecutableSpaceAndSet, space) + 443 OBJECT_OFFSETOF(ScriptExecutableSpaceAndSet, clearableCodeSet)); 444 } 445 }; 446 447 ScriptExecutableSpaceAndSet directEvalExecutableSpace; 448 ScriptExecutableSpaceAndSet functionExecutableSpace; 449 ScriptExecutableSpaceAndSet indirectEvalExecutableSpace; 450 ScriptExecutableSpaceAndSet moduleProgramExecutableSpace; 451 ScriptExecutableSpaceAndSet programExecutableSpace; 458 DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(directEvalExecutableSpace) 459 DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(indirectEvalExecutableSpace) 460 DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(moduleProgramExecutableSpace) 461 SpaceAndSet functionExecutableSpace; 462 SpaceAndSet programExecutableSpace; 452 463 453 464 template<typename Func> 454 465 void forEachScriptExecutableSpace(const Func& func) 455 466 { 456 func(directEvalExecutableSpace); 467 if (m_directEvalExecutableSpace) 468 func(*m_directEvalExecutableSpace); 457 469 func(functionExecutableSpace); 458 func(indirectEvalExecutableSpace); 459 func(moduleProgramExecutableSpace); 470 if (m_indirectEvalExecutableSpace) 471 func(*m_indirectEvalExecutableSpace); 472 if (m_moduleProgramExecutableSpace) 473 func(*m_moduleProgramExecutableSpace); 460 474 func(programExecutableSpace); 461 475 } 462 476 463 struct UnlinkedFunctionExecutableSpaceAndSet { 464 IsoSubspace space; 465 IsoCellSet clearableCodeSet; 466 467 template<typename... Arguments> 468 UnlinkedFunctionExecutableSpaceAndSet(Arguments&&... arguments) 469 : space(std::forward<Arguments>(arguments)...) 470 , clearableCodeSet(space) 471 { } 472 473 static IsoCellSet& clearableCodeSetFor(Subspace& space) 474 { 475 return *bitwise_cast<IsoCellSet*>( 476 bitwise_cast<char*>(&space) - 477 OBJECT_OFFSETOF(UnlinkedFunctionExecutableSpaceAndSet, space) + 478 OBJECT_OFFSETOF(UnlinkedFunctionExecutableSpaceAndSet, clearableCodeSet)); 479 } 480 }; 481 482 UnlinkedFunctionExecutableSpaceAndSet unlinkedFunctionExecutableSpace; 477 SpaceAndSet unlinkedFunctionExecutableSpace; 478 479 #undef DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER 483 480 484 481 VMType vmType; -
trunk/Source/JavaScriptCore/runtime/WeakMapImpl.h
r233765 r240965 303 303 } 304 304 305 template<typename CellType >305 template<typename CellType, SubspaceAccess mode> 306 306 static IsoSubspace* subspaceFor(VM& vm) 307 307 { 308 308 if (isWeakMap()) 309 return &vm.weakMapSpace;310 return &vm.weakSetSpace;309 return vm.weakMapSpace<mode>(); 310 return vm.weakSetSpace<mode>(); 311 311 } 312 312 -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCodeBlock.h
r232080 r240965 60 60 } 61 61 62 template<typename CellType >62 template<typename CellType, SubspaceAccess mode> 63 63 static IsoSubspace* subspaceFor(VM& vm) 64 64 { 65 return &vm.webAssemblyCodeBlockSpace;65 return vm.webAssemblyCodeBlockSpace<mode>(); 66 66 } 67 67 -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h
r229413 r240965 44 44 typedef JSDestructibleObject Base; 45 45 46 template<typename CellType >46 template<typename CellType, SubspaceAccess> 47 47 static CompleteSubspace* subspaceFor(VM& vm) 48 48 { -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.h
r230748 r240965 50 50 const static unsigned StructureFlags = Base::StructureFlags; 51 51 52 template<typename CellType >52 template<typename CellType, SubspaceAccess mode> 53 53 static IsoSubspace* subspaceFor(VM& vm) 54 54 { 55 return &vm.webAssemblyFunctionSpace;55 return vm.webAssemblyFunctionSpace<mode>(); 56 56 } 57 57 -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.h
r230096 r240965 41 41 const static unsigned StructureFlags = Base::StructureFlags; 42 42 43 template<typename CellType >43 template<typename CellType, SubspaceAccess mode> 44 44 static IsoSubspace* subspaceFor(VM& vm) 45 45 { 46 return &vm.webAssemblyWrapperFunctionSpace;46 return vm.webAssemblyWrapperFunctionSpace<mode>(); 47 47 } 48 48 -
trunk/Source/WebCore/ChangeLog
r240963 r240965 1 2019-02-04 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Shrink size of VM by lazily allocating IsoSubspaces for non-common types 4 https://bugs.webkit.org/show_bug.cgi?id=193993 5 6 Reviewed by Keith Miller. 7 8 * bindings/scripts/CodeGeneratorJS.pm: 9 (GenerateHeader): 10 * bridge/runtime_method.h: 11 1 12 2019-02-04 Simon Fraser <simon.fraser@apple.com> 2 13 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r240557 r240965 2759 2759 push(@headerContent, " static void visitOutputConstraints(JSCell*, JSC::SlotVisitor&);\n"); 2760 2760 my $subspaceFunc = IsDOMGlobalObject($interface) ? "globalObjectOutputConstraintSubspaceFor" : "outputConstraintSubspaceFor"; 2761 push(@headerContent, " template<typename > static JSC::CompleteSubspace* subspaceFor(JSC::VM& vm) { return $subspaceFunc(vm); }\n");2761 push(@headerContent, " template<typename, JSC::SubspaceAccess> static JSC::CompleteSubspace* subspaceFor(JSC::VM& vm) { return $subspaceFunc(vm); }\n"); 2762 2762 } 2763 2763 } -
trunk/Source/WebCore/bridge/runtime_method.h
r231839 r240965 38 38 static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetCallData; 39 39 40 template<typename CellType >40 template<typename CellType, JSC::SubspaceAccess> 41 41 static IsoSubspace* subspaceFor(VM& vm) 42 42 { -
trunk/Source/WebKit/ChangeLog
r240963 r240965 1 2019-02-04 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Shrink size of VM by lazily allocating IsoSubspaces for non-common types 4 https://bugs.webkit.org/show_bug.cgi?id=193993 5 6 Reviewed by Keith Miller. 7 8 * WebProcess/Plugins/Netscape/JSNPMethod.h: 9 * WebProcess/Plugins/Netscape/JSNPObject.h: 10 1 11 2019-02-04 Simon Fraser <simon.fraser@apple.com> 2 12 -
trunk/Source/WebKit/WebProcess/Plugins/Netscape/JSNPMethod.h
r230813 r240965 42 42 typedef JSC::InternalFunction Base; 43 43 44 template<typename CellType >44 template<typename CellType, JSC::SubspaceAccess> 45 45 static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) 46 46 { -
trunk/Source/WebKit/WebProcess/Plugins/Netscape/JSNPObject.h
r231839 r240965 47 47 static const unsigned StructureFlags = Base::StructureFlags | JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | JSC::OverridesGetCallData; 48 48 49 template<typename CellType >49 template<typename CellType, JSC::SubspaceAccess> 50 50 static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) 51 51 {
Note: See TracChangeset
for help on using the changeset viewer.