Changeset 240965 in webkit


Ignore:
Timestamp:
Feb 4, 2019 10:32:08 PM (5 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Shrink size of VM by lazily allocating IsoSubspaces for non-common types
https://bugs.webkit.org/show_bug.cgi?id=193993

Reviewed by Keith Miller.

Source/JavaScriptCore:

JSC::VM has a lot of IsoSubspaces, and each takes 504B. This unnecessarily makes VM so large.
And some of them are rarely used. We should allocate it lazily.

In this patch, we make some IsoSubspaces std::unique_ptr<IsoSubspace>. And we add ensureXXXSpace
functions which allocate IsoSubspaces lazily. This function is used by subspaceFor<> in each class.
And we also add subspaceForConcurrently<> function, which is called from concurrent JIT tiers. This
returns nullptr if the subspace is not allocated yet. JSCell::subspaceFor now takes second template
parameter which tells the function whether subspaceFor is concurrently done. If the IsoSubspace is
lazily created, we may return nullptr for the concurrent access. We ensure the space's initialization
by using WTF::storeStoreFence when lazily allocating it.

In GC's constraint solving, we may touch these lazily allocated spaces. At that time, we check the
existence of the space before touching this. This is not racy because the main thread is stopped when
the constraint solving is working.

This changes sizeof(VM) from 64736 to 56472.

Another interesting thing is that we removed PreventCollectionScope preventCollectionScope(heap); in
Subspace::initialize. This is really dangerous API since it easily causes dead-lock between the
collector and the mutator if IsoSubspace is dynamically created. We do want to make IsoSubspaces
dynamically-created ones since the requirement of the pre-allocation poses a scalability problem
of IsoSubspace adoption because IsoSubspace is large. Registered Subspace is only touched in the
EndPhase, and the peripheries should be stopped when running EndPhase. Thus, as long as the main thread
can run this IsoSubspace code, the collector is never EndPhase. So this is safe.

  • API/JSCallbackFunction.h:
  • API/ObjCCallbackFunction.h:

(JSC::ObjCCallbackFunction::subspaceFor):

  • API/glib/JSCCallbackFunction.h:
  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::visitChildren):
(JSC::CodeBlock::finalizeUnconditionally):

  • bytecode/CodeBlock.h:
  • bytecode/EvalCodeBlock.h:
  • bytecode/ExecutableToCodeBlockEdge.h:
  • bytecode/FunctionCodeBlock.h:
  • bytecode/ModuleProgramCodeBlock.h:
  • bytecode/ProgramCodeBlock.h:
  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::UnlinkedFunctionExecutable::unlinkedCodeBlockFor):

  • bytecode/UnlinkedFunctionExecutable.h:
  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::emitAllocateRawObject):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
(JSC::DFG::SpeculativeJIT::compileNewObject):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileMakeRope):
(JSC::FTL::DFG::LowerDFGToB3::compileMaterializeNewObject):
(JSC::FTL::DFG::LowerDFGToB3::allocateObject):
(JSC::FTL::DFG::LowerDFGToB3::allocateVariableSizedObject):
(JSC::FTL::DFG::LowerDFGToB3::allocateVariableSizedCell):

  • heap/Heap.cpp:

(JSC::Heap::finalizeUnconditionalFinalizers):
(JSC::Heap::deleteAllCodeBlocks):
(JSC::Heap::deleteAllUnlinkedCodeBlocks):
(JSC::Heap::addCoreConstraints):

  • heap/Subspace.cpp:

(JSC::Subspace::initialize):

  • jit/AssemblyHelpers.h:

(JSC::AssemblyHelpers::emitAllocateJSObjectWithKnownSize):
(JSC::AssemblyHelpers::emitAllocateVariableSizedCell):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_new_object):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::emit_op_new_object):

  • runtime/DirectArguments.h:
  • runtime/DirectEvalExecutable.h:
  • runtime/ErrorInstance.h:

(JSC::ErrorInstance::subspaceFor):

  • runtime/ExecutableBase.h:
  • runtime/FunctionExecutable.h:
  • runtime/IndirectEvalExecutable.h:
  • runtime/InferredValue.cpp:

(JSC::InferredValue::visitChildren):

  • runtime/InferredValue.h:
  • runtime/InferredValueInlines.h:

(JSC::InferredValue::finalizeUnconditionally):

  • runtime/InternalFunction.h:
  • runtime/JSAsyncFunction.h:
  • runtime/JSAsyncGeneratorFunction.h:
  • runtime/JSBoundFunction.h:
  • runtime/JSCell.h:

(JSC::subspaceFor):
(JSC::subspaceForConcurrently):

  • runtime/JSCellInlines.h:

(JSC::allocatorForNonVirtualConcurrently):

  • runtime/JSCustomGetterSetterFunction.h:
  • runtime/JSDestructibleObject.h:
  • runtime/JSFunction.h:
  • runtime/JSGeneratorFunction.h:
  • runtime/JSImmutableButterfly.h:
  • runtime/JSLexicalEnvironment.h:

(JSC::JSLexicalEnvironment::subspaceFor):

  • runtime/JSNativeStdFunction.h:
  • runtime/JSSegmentedVariableObject.h:
  • runtime/JSString.h:
  • runtime/ModuleProgramExecutable.h:
  • runtime/NativeExecutable.h:
  • runtime/ProgramExecutable.h:
  • runtime/PropertyMapHashTable.h:
  • runtime/ProxyRevoke.h:
  • runtime/ScopedArguments.h:
  • runtime/ScriptExecutable.cpp:

(JSC::ScriptExecutable::clearCode):
(JSC::ScriptExecutable::installCode):

  • runtime/Structure.h:
  • runtime/StructureRareData.h:
  • runtime/SubspaceAccess.h: Copied from Source/JavaScriptCore/runtime/InferredValueInlines.h.
  • runtime/VM.cpp:

(JSC::VM::VM):

  • runtime/VM.h:

(JSC::VM::SpaceAndSet::SpaceAndSet):
(JSC::VM::SpaceAndSet::setFor):
(JSC::VM::forEachScriptExecutableSpace):
(JSC::VM::SpaceAndFinalizerSet::SpaceAndFinalizerSet): Deleted.
(JSC::VM::SpaceAndFinalizerSet::finalizerSetFor): Deleted.
(JSC::VM::ScriptExecutableSpaceAndSet::ScriptExecutableSpaceAndSet): Deleted.
(JSC::VM::ScriptExecutableSpaceAndSet::clearableCodeSetFor): Deleted.
(JSC::VM::UnlinkedFunctionExecutableSpaceAndSet::UnlinkedFunctionExecutableSpaceAndSet): Deleted.
(JSC::VM::UnlinkedFunctionExecutableSpaceAndSet::clearableCodeSetFor): Deleted.

  • runtime/WeakMapImpl.h:

(JSC::WeakMapImpl::subspaceFor):

  • wasm/js/JSWebAssemblyCodeBlock.h:
  • wasm/js/JSWebAssemblyMemory.h:
  • wasm/js/WebAssemblyFunction.h:
  • wasm/js/WebAssemblyWrapperFunction.h:

Source/WebCore:

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):

  • bridge/runtime_method.h:

Source/WebKit:

  • WebProcess/Plugins/Netscape/JSNPMethod.h:
  • WebProcess/Plugins/Netscape/JSNPObject.h:
Location:
trunk/Source
Files:
70 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSCallbackFunction.h

    r230813 r240965  
    3838    typedef InternalFunction Base;
    3939
    40     template<typename CellType>
     40    template<typename CellType, SubspaceAccess mode>
    4141    static IsoSubspace* subspaceFor(VM& vm)
    4242    {
    43         return &vm.callbackFunctionSpace;
     43        return vm.callbackFunctionSpace<mode>();
    4444    }
    4545
  • trunk/Source/JavaScriptCore/API/ObjCCallbackFunction.h

    r230813 r240965  
    4949    typedef InternalFunction Base;
    5050
    51     template<typename CellType>
     51    template<typename CellType, SubspaceAccess mode>
    5252    static IsoSubspace* subspaceFor(VM& vm)
    5353    {
    54         return &vm.objCCallbackFunctionSpace;
     54        return vm.objCCallbackFunctionSpace<mode>();
    5555    }
    5656
  • trunk/Source/JavaScriptCore/API/glib/JSCCallbackFunction.h

    r239427 r240965  
    4141    typedef InternalFunction Base;
    4242
    43     template<typename CellType>
     43    template<typename CellType, SubspaceAccess>
    4444    static IsoSubspace* subspaceFor(VM& vm)
    4545    {
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r240823 r240965  
    938938    runtime/StructureRareDataInlines.h
    939939    runtime/StructureTransitionTable.h
     940    runtime/SubspaceAccess.h
    940941    runtime/Symbol.h
    941942    runtime/SymbolPrototype.h
  • trunk/Source/JavaScriptCore/ChangeLog

    r240960 r240965  
     12019-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
    11372019-02-04  Keith Miller  <keith_miller@apple.com>
    2138
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r240823 r240965  
    17661766                E3794E761B77EB97005543AE /* ModuleAnalyzer.h in Headers */ = {isa = PBXBuildFile; fileRef = E3794E741B77EB97005543AE /* ModuleAnalyzer.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17671767                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, ); }; };
    17681769                E393ADD81FE702D00022D681 /* WeakMapImplInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E393ADD71FE702CC0022D681 /* WeakMapImplInlines.h */; };
    17691770                E39D45F51D39005600B3B377 /* InterpreterInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E39D9D841D39000600667282 /* InterpreterInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    47044705                E380A76B1DCD7195000F89E6 /* MacroAssemblerHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerHelpers.h; sourceTree = "<group>"; };
    47054706                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>"; };
    47074708                E38D060B1F8E814100649CF2 /* JSScriptFetchParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScriptFetchParameters.h; sourceTree = "<group>"; };
    47084709                E38D060C1F8E814100649CF2 /* ScriptFetchParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptFetchParameters.h; sourceTree = "<group>"; };
    47094710                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>"; };
    47104712                E393ADD71FE702CC0022D681 /* WeakMapImplInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakMapImplInlines.h; sourceTree = "<group>"; };
    47114713                E3963CEC1B73F75000EB4CE5 /* NodesAnalyzeModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NodesAnalyzeModule.cpp; sourceTree = "<group>"; };
     
    71657167                                C20BA92C16BB1C1500B3AEA2 /* StructureRareDataInlines.h */,
    71667168                                BC9041470EB9250900FE26FA /* StructureTransitionTable.h */,
     7169                                E39006202208BFC3001019CF /* SubspaceAccess.h */,
    71677170                                705B41A31A6E501E00716757 /* Symbol.cpp */,
    71687171                                705B41A41A6E501E00716757 /* Symbol.h */,
     
    96939696                                0F44767020C5E2B4008B2C36 /* StubInfoSummary.h in Headers */,
    96949697                                0F7DF1371E2970E10095951B /* Subspace.h in Headers */,
     9698                                E39006212208BFC4001019CF /* SubspaceAccess.h in Headers */,
    96959699                                0F7DF1381E2970E40095951B /* SubspaceInlines.h in Headers */,
    96969700                                0F4A38FA1C8E13DF00190318 /* SuperSampler.h in Headers */,
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r240938 r240965  
    998998    stronglyVisitWeakReferences(locker, visitor);
    999999   
    1000     VM::SpaceAndFinalizerSet::finalizerSetFor(*subspace()).add(this);
     1000    VM::SpaceAndSet::setFor(*subspace()).add(this);
    10011001}
    10021002
     
    13931393#endif // ENABLE(DFG_JIT)
    13941394
    1395     VM::SpaceAndFinalizerSet::finalizerSetFor(*subspace()).remove(this);
     1395    VM::SpaceAndSet::setFor(*subspace()).remove(this);
    13961396}
    13971397
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r240893 r240965  
    115115    static const bool needsDestruction = true;
    116116
    117     template<typename>
     117    template<typename, SubspaceAccess>
    118118    static void subspaceFor(VM&) { }
    119119
  • trunk/Source/JavaScriptCore/bytecode/EvalCodeBlock.h

    r240864 r240965  
    3939    DECLARE_INFO;
    4040
    41     template<typename>
     41    template<typename, SubspaceAccess>
    4242    static IsoSubspace* subspaceFor(VM& vm)
    4343    {
  • trunk/Source/JavaScriptCore/bytecode/ExecutableToCodeBlockEdge.h

    r240951 r240965  
    4141    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    4242
    43     template<typename CellType>
     43    template<typename CellType, SubspaceAccess>
    4444    static IsoSubspace* subspaceFor(VM& vm)
    4545    {
  • trunk/Source/JavaScriptCore/bytecode/FunctionCodeBlock.h

    r240864 r240965  
    4040    DECLARE_INFO;
    4141
    42     template<typename>
     42    template<typename, SubspaceAccess>
    4343    static IsoSubspace* subspaceFor(VM& vm)
    4444    {
  • trunk/Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h

    r240864 r240965  
    4040    DECLARE_INFO;
    4141
    42     template<typename>
     42    template<typename, SubspaceAccess>
    4343    static IsoSubspace* subspaceFor(VM& vm)
    4444    {
  • trunk/Source/JavaScriptCore/bytecode/ProgramCodeBlock.h

    r240864 r240965  
    4040    DECLARE_INFO;
    4141
    42     template<typename>
     42    template<typename, SubspaceAccess>
    4343    static IsoSubspace* subspaceFor(VM& vm)
    4444    {
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp

    r240521 r240965  
    238238        break;
    239239    }
    240     vm.unlinkedFunctionExecutableSpace.clearableCodeSet.add(this);
     240    vm.unlinkedFunctionExecutableSpace.set.add(this);
    241241    return result;
    242242}
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h

    r240511 r240965  
    6262    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    6363
    64     template<typename CellType>
     64    template<typename CellType, SubspaceAccess>
    6565    static IsoSubspace* subspaceFor(VM& vm)
    6666    {
     
    121121        m_unlinkedCodeBlockForCall.clear();
    122122        m_unlinkedCodeBlockForConstruct.clear();
    123         vm.unlinkedFunctionExecutableSpace.clearableCodeSet.remove(this);
     123        vm.unlinkedFunctionExecutableSpace.set.remove(this);
    124124    }
    125125
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r240878 r240965  
    131131
    132132    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);
    134134    if (allocator) {
    135135        emitAllocateJSObject(resultGPR, JITAllocator::constant(allocator), scratchGPR, TrustedImmPtr(structure), storageGPR, scratch2GPR, slowCases);
     
    43604360   
    43614361    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);
    43634363    emitAllocateJSCell(resultGPR, JITAllocator::constant(allocatorValue), allocatorGPR, TrustedImmPtr(m_jit.graph().registerStructure(m_jit.vm()->stringStructure.get())), scratchGPR, slowPath);
    43644364       
     
    1254112541    RegisteredStructure structure = node->structure();
    1254212542    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);
    1254512544    if (!allocatorValue)
    1254612545        slowPath.append(m_jit.jump());
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r240959 r240965  
    64736473        LBasicBlock lastNext = m_out.insertNewBlocksBefore(slowPath);
    64746474       
    6475         Allocator allocator = subspaceFor<JSRopeString>(vm())->allocatorForNonVirtual(sizeof(JSRopeString), AllocatorForMode::AllocatorIfExists);
     6475        Allocator allocator = allocatorForNonVirtualConcurrently<JSRopeString>(vm(), sizeof(JSRopeString), AllocatorForMode::AllocatorIfExists);
    64766476       
    64776477        LValue result = allocateCell(
     
    1072410724            if (structure->outOfLineCapacity() || hasIndexedProperties(structure->indexingType())) {
    1072510725                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);
    1072710727
    1072810728                bool hasIndexingHeader = hasIndexedProperties(structure->indexingType());
     
    1319113191        size_t size, StructureType structure, LValue butterfly, LBasicBlock slowPath)
    1319213192    {
    13193         Allocator allocator = subspaceFor<ClassType>(vm())->allocatorForNonVirtual(size, AllocatorForMode::AllocatorIfExists);
     13193        Allocator allocator = allocatorForNonVirtualConcurrently<ClassType>(vm(), size, AllocatorForMode::AllocatorIfExists);
    1319413194        return allocateObject(
    1319513195            m_out.constIntPtr(allocator.localAllocator()), structure, butterfly, slowPath);
     
    1325513255        LValue size, RegisteredStructure structure, LValue butterfly, LBasicBlock slowPath)
    1325613256    {
    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);
    1325813260        return allocateObject(allocator, structure, butterfly, slowPath);
    1325913261    }
     
    1326313265        LValue size, Structure* structure, LBasicBlock slowPath)
    1326413266    {
    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);
    1326613270        return allocateCell(allocator, structure, slowPath);
    1326713271    }
     
    1327013274    {
    1327113275        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);
    1327313277       
    1327413278        // 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  
    2828
    2929#include "BlockDirectory.h"
     30#include "Heap.h"
    3031#include "Subspace.h"
    3132
     
    4546   
    4647    if (m_directories.isEmpty()) {
     48        ASSERT(!mayBeGCThread() || directory->heap()->worldIsStopped());
    4749        for (Subspace* subspace = m_subspaces.first(); subspace; subspace = subspace->nextSubspaceInAlignedMemoryAllocator())
    4850            subspace->didCreateFirstDirectory(directory);
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r240637 r240965  
    568568void Heap::finalizeUnconditionalFinalizers()
    569569{
    570     finalizeMarkedUnconditionalFinalizers<InferredValue>(vm()->inferredValuesWithFinalizers);
     570    if (vm()->m_inferredValueSpace)
     571        finalizeMarkedUnconditionalFinalizers<InferredValue>(vm()->m_inferredValueSpace->space);
    571572    vm()->forEachCodeBlockSpace(
    572573        [&] (auto& space) {
    573             this->finalizeMarkedUnconditionalFinalizers<CodeBlock>(space.finalizerSet);
     574            this->finalizeMarkedUnconditionalFinalizers<CodeBlock>(space.set);
    574575        });
    575576    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);
    579583
    580584#if ENABLE(WEBASSEMBLY)
    581     finalizeMarkedUnconditionalFinalizers<JSWebAssemblyCodeBlock>(vm()->webAssemblyCodeBlockSpace);
     585    if (vm()->m_webAssemblyCodeBlockSpace)
     586        finalizeMarkedUnconditionalFinalizers<JSWebAssemblyCodeBlock>(*vm()->m_webAssemblyCodeBlockSpace);
    582587#endif
    583588}
     
    881886        [&] (auto& spaceAndSet) {
    882887            HeapIterationScope heapIterationScope(*this);
    883             auto& clearableCodeSet = spaceAndSet.clearableCodeSet;
    884             clearableCodeSet.forEachLiveCell(
     888            auto& set = spaceAndSet.set;
     889            set.forEachLiveCell(
    885890                [&] (HeapCell* cell, HeapCell::Kind) {
    886891                    ScriptExecutable* executable = static_cast<ScriptExecutable*>(cell);
    887                     executable->clearCode(clearableCodeSet);
     892                    executable->clearCode(set);
    888893                });
    889894        });
     
    897902        // it uses a callee check, but then it will call into dead code.
    898903        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        }
    904911    }
    905912#endif
     
    917924
    918925    HeapIterationScope heapIterationScope(*this);
    919     vm.unlinkedFunctionExecutableSpace.clearableCodeSet.forEachLiveCell(
     926    vm.unlinkedFunctionExecutableSpace.set.forEachLiveCell(
    920927        [&] (HeapCell* cell, HeapCell::Kind) {
    921928            UnlinkedFunctionExecutable* executable = static_cast<UnlinkedFunctionExecutable*>(cell);
     
    27312738           
    27322739            add(vm.executableToCodeBlockEdgesWithConstraints);
    2733             add(vm.weakMapSpace);
     2740            if (vm.m_weakMapSpace)
     2741                add(*vm.m_weakMapSpace);
    27342742        },
    27352743        ConstraintVolatility::GreyedByMarking,
  • trunk/Source/JavaScriptCore/heap/MarkedSpace.cpp

    r240216 r240965  
    259259void MarkedSpace::prepareForAllocation()
    260260{
     261    ASSERT(!mayBeGCThread() || m_heap->worldIsStopped());
    261262    for (Subspace* subspace : m_subspaces)
    262263        subspace->prepareForAllocation();
  • trunk/Source/JavaScriptCore/heap/Subspace.cpp

    r240216 r240965  
    5151
    5252    Heap& heap = *m_space.heap();
    53     PreventCollectionScope preventCollectionScope(heap);
    5453    heap.objectSpace().m_subspaces.append(this);
    5554    m_alignedMemoryAllocator->registerSubspace(this);
  • trunk/Source/JavaScriptCore/jit/AssemblyHelpers.h

    r240023 r240965  
    17531753        GPRReg scratchGPR2, JumpList& slowPath, size_t size)
    17541754    {
    1755         Allocator allocator = subspaceFor<ClassType>(vm)->allocatorForNonVirtual(size, AllocatorForMode::AllocatorIfExists);
     1755        Allocator allocator = allocatorForNonVirtualConcurrently<ClassType>(vm, size, AllocatorForMode::AllocatorIfExists);
    17561756        emitAllocateJSObject(resultGPR, JITAllocator::constant(allocator), scratchGPR1, structure, storage, scratchGPR2, slowPath);
    17571757    }
     
    17701770    void emitAllocateVariableSizedCell(VM& vm, GPRReg resultGPR, StructureType structure, GPRReg allocationSize, GPRReg scratchGPR1, GPRReg scratchGPR2, JumpList& slowPath)
    17711771    {
    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);
    17741775        emitStoreStructureWithTypeInfo(structure, resultGPR, scratchGPR2);
    17751776    }
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r240637 r240965  
    9797    Structure* structure = metadata.m_objectAllocationProfile.structure();
    9898    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);
    100100
    101101    RegisterID resultReg = regT0;
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r240637 r240965  
    8585    Structure* structure = metadata.m_objectAllocationProfile.structure();
    8686    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);
    8888
    8989    RegisterID resultReg = returnValueGPR;
  • trunk/Source/JavaScriptCore/runtime/DirectArguments.h

    r236697 r240965  
    4747   
    4848public:
    49     template<typename CellType>
     49    template<typename CellType, SubspaceAccess>
    5050    static CompleteSubspace* subspaceFor(VM& vm)
    5151    {
    52         RELEASE_ASSERT(!CellType::needsDestruction);
     52        static_assert(!CellType::needsDestruction, "");
    5353        return &vm.jsValueGigacageCellSpace;
    5454    }
  • trunk/Source/JavaScriptCore/runtime/DirectEvalExecutable.h

    r233039 r240965  
    3232class DirectEvalExecutable final : public EvalExecutable {
    3333public:
    34     template<typename CellType>
     34    template<typename CellType, SubspaceAccess mode>
    3535    static IsoSubspace* subspaceFor(VM& vm)
    3636    {
    37         return &vm.directEvalExecutableSpace.space;
     37        return vm.directEvalExecutableSpace<mode>();
    3838    }
    3939
  • trunk/Source/JavaScriptCore/runtime/ErrorInstance.h

    r232314 r240965  
    7373    bool materializeErrorInfoIfNeeded(VM&, PropertyName);
    7474
    75     template<typename CellType>
     75    template<typename CellType, SubspaceAccess mode>
    7676    static IsoSubspace* subspaceFor(VM& vm)
    7777    {
    78         return &vm.errorInstanceSpace;
     78        return vm.errorInstanceSpace<mode>();
    7979    }
    8080
  • trunk/Source/JavaScriptCore/runtime/ExecutableBase.h

    r240938 r240965  
    8585   
    8686    // Force subclasses to override this.
    87     template<typename>
     87    template<typename, SubspaceAccess>
    8888    static void subspaceFor(VM&) { }
    8989       
  • trunk/Source/JavaScriptCore/runtime/FunctionExecutable.h

    r240938 r240965  
    4141    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    4242
    43     template<typename CellType>
     43    template<typename CellType, SubspaceAccess>
    4444    static IsoSubspace* subspaceFor(VM& vm)
    4545    {
  • trunk/Source/JavaScriptCore/runtime/IndirectEvalExecutable.h

    r233039 r240965  
    3232class IndirectEvalExecutable final : public EvalExecutable {
    3333public:
    34     template<typename CellType>
     34    template<typename CellType, SubspaceAccess mode>
    3535    static IsoSubspace* subspaceFor(VM& vm)
    3636    {
    37         return &vm.indirectEvalExecutableSpace.space;
     37        return vm.indirectEvalExecutableSpace<mode>();
    3838    }
    3939
  • trunk/Source/JavaScriptCore/runtime/InferredValue.cpp

    r240796 r240965  
    6464        return;
    6565   
    66     visitor.vm().inferredValuesWithFinalizers.add(inferredValue);
     66    VM::SpaceAndSet::setFor(*inferredValue->subspace()).add(inferredValue);
    6767}
    6868
  • trunk/Source/JavaScriptCore/runtime/InferredValue.h

    r239191 r240965  
    4646    typedef JSCell Base;
    4747   
    48     template<typename CellType>
     48    template<typename CellType, SubspaceAccess mode>
    4949    static IsoSubspace* subspaceFor(VM& vm)
    5050    {
    51         return &vm.inferredValueSpace;
     51        return vm.inferredValueSpace<mode>();
    5252    }
    5353
  • trunk/Source/JavaScriptCore/runtime/InferredValueInlines.h

    r225887 r240965  
    4141    }
    4242   
    43     vm.inferredValuesWithFinalizers.remove(this);
     43    VM::SpaceAndSet::setFor(*subspace()).remove(this);
    4444}
    4545
  • trunk/Source/JavaScriptCore/runtime/InternalFunction.h

    r233245 r240965  
    3939    static const unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance | ImplementsDefaultHasInstance | OverridesGetCallData;
    4040
    41     template<typename CellType>
     41    template<typename CellType, SubspaceAccess>
    4242    static IsoSubspace* subspaceFor(VM& vm)
    4343    {
  • trunk/Source/JavaScriptCore/runtime/JSAsyncFunction.h

    r240888 r240965  
    3939    const static unsigned StructureFlags = Base::StructureFlags;
    4040
    41     template<typename CellType>
     41    template<typename CellType, SubspaceAccess>
    4242    static IsoSubspace* subspaceFor(VM& vm)
    4343    {
  • trunk/Source/JavaScriptCore/runtime/JSAsyncGeneratorFunction.h

    r240888 r240965  
    3939    const static unsigned StructureFlags = Base::StructureFlags;
    4040
    41     template<typename CellType>
     41    template<typename CellType, SubspaceAccess>
    4242    static IsoSubspace* subspaceFor(VM& vm)
    4343    {
  • trunk/Source/JavaScriptCore/runtime/JSBoundFunction.h

    r239191 r240965  
    4343    static_assert(StructureFlags & ImplementsHasInstance, "");
    4444
    45     template<typename CellType>
     45    template<typename CellType, SubspaceAccess mode>
    4646    static IsoSubspace* subspaceFor(VM& vm)
    4747    {
    48         return &vm.boundFunctionSpace;
     48        return vm.boundFunctionSpace<mode>();
    4949    }
    5050
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r240951 r240965  
    3333#include "JSTypeInfo.h"
    3434#include "SlotVisitor.h"
     35#include "SubspaceAccess.h"
    3536#include "TypedArrayType.h"
    3637#include "WriteBarrier.h"
     
    8990    // FIXME: Refer to Subspace by reference.
    9091    // https://bugs.webkit.org/show_bug.cgi?id=166988
    91     template<typename CellType>
     92    template<typename CellType, SubspaceAccess>
    9293    static CompleteSubspace* subspaceFor(VM&);
    9394
     
    295296inline auto subspaceFor(VM& vm)
    296297{
    297     return Type::template subspaceFor<Type>(vm);
     298    return Type::template subspaceFor<Type, SubspaceAccess::OnMainThread>(vm);
    298299}
    299300
     301template<typename Type>
     302inline auto subspaceForConcurrently(VM& vm)
     303{
     304    return Type::template subspaceFor<Type, SubspaceAccess::Concurrently>(vm);
     305}
     306
    300307} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSCellInlines.h

    r240951 r240965  
    2626#pragma once
    2727
     28#include "AllocatorForMode.h"
    2829#include "AllocatorInlines.h"
    2930#include "CompleteSubspaceInlines.h"
     
    146147}
    147148
    148 template<typename CellType>
     149template<typename CellType, SubspaceAccess>
    149150CompleteSubspace* JSCell::subspaceFor(VM& vm)
    150151{
     
    152153        return &vm.destructibleCellSpace;
    153154    return &vm.cellSpace;
     155}
     156
     157template<typename Type>
     158inline 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 { };
    154163}
    155164
  • trunk/Source/JavaScriptCore/runtime/JSCustomGetterSetterFunction.h

    r229413 r240965  
    4141    static const unsigned StructureFlags = Base::StructureFlags;
    4242
    43     template<typename CellType>
     43    template<typename CellType, SubspaceAccess mode>
    4444    static IsoSubspace* subspaceFor(VM& vm)
    4545    {
    46         return &vm.customGetterSetterFunctionSpace;
     46        return vm.customGetterSetterFunctionSpace<mode>();
    4747    }
    4848
  • trunk/Source/JavaScriptCore/runtime/JSDestructibleObject.h

    r225632 r240965  
    3838    static const bool needsDestruction = true;
    3939   
    40     template<typename CellType>
     40    template<typename CellType, SubspaceAccess>
    4141    static CompleteSubspace* subspaceFor(VM& vm)
    4242    {
  • trunk/Source/JavaScriptCore/runtime/JSFunction.h

    r232337 r240965  
    6363public:
    6464   
    65     template<typename CellType>
     65    template<typename CellType, SubspaceAccess>
    6666    static IsoSubspace* subspaceFor(VM& vm)
    6767    {
  • trunk/Source/JavaScriptCore/runtime/JSGeneratorFunction.h

    r240888 r240965  
    6767    const static unsigned StructureFlags = Base::StructureFlags;
    6868
    69     template<typename CellType>
     69    template<typename CellType, SubspaceAccess>
    7070    static IsoSubspace* subspaceFor(VM& vm)
    7171    {
  • trunk/Source/JavaScriptCore/runtime/JSImmutableButterfly.h

    r239324 r240965  
    8989    void copyToArguments(ExecState*, VirtualRegister firstElementDest, unsigned offset, unsigned length);
    9090
    91     template<typename>
     91    template<typename, SubspaceAccess>
    9292    static CompleteSubspace* subspaceFor(VM& vm)
    9393    {
  • trunk/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h

    r230369 r240965  
    4141    friend class LLIntOffsetsExtractor;
    4242public:
    43     template<typename CellType>
     43    template<typename CellType, SubspaceAccess>
    4444    static CompleteSubspace* subspaceFor(VM& vm)
    4545    {
    46         RELEASE_ASSERT(!CellType::needsDestruction);
     46        static_assert(!CellType::needsDestruction, "");
    4747        return &vm.jsValueGigacageCellSpace;
    4848    }
  • trunk/Source/JavaScriptCore/runtime/JSNativeStdFunction.h

    r237223 r240965  
    4141    const static unsigned StructureFlags = Base::StructureFlags;
    4242
    43     template<typename CellType>
     43    template<typename CellType, SubspaceAccess mode>
    4444    static IsoSubspace* subspaceFor(VM& vm)
    4545    {
    46         return &vm.nativeStdFunctionSpace;
     46        return vm.nativeStdFunctionSpace<mode>();
    4747    }
    4848
  • trunk/Source/JavaScriptCore/runtime/JSSegmentedVariableObject.h

    r240204 r240965  
    9191    static void destroy(JSCell*);
    9292   
    93     template<typename>
     93    template<typename, SubspaceAccess>
    9494    static CompleteSubspace* subspaceFor(VM& vm)
    9595    {
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r239427 r240965  
    9090    // We specialize the string subspace to get the fastest possible sweep. This wouldn't be
    9191    // necessary if JSString didn't have a destructor.
    92     template<typename>
     92    template<typename, SubspaceAccess>
    9393    static CompleteSubspace* subspaceFor(VM& vm)
    9494    {
  • trunk/Source/JavaScriptCore/runtime/ModuleProgramExecutable.h

    r233039 r240965  
    3737    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    3838
    39     template<typename CellType>
     39    template<typename CellType, SubspaceAccess mode>
    4040    static IsoSubspace* subspaceFor(VM& vm)
    4141    {
    42         return &vm.moduleProgramExecutableSpace.space;
     42        return vm.moduleProgramExecutableSpace<mode>();
    4343    }
    4444
  • trunk/Source/JavaScriptCore/runtime/NativeExecutable.h

    r229547 r240965  
    4545    static void destroy(JSCell*);
    4646   
    47     template<typename CellType>
     47    template<typename CellType, SubspaceAccess>
    4848    static IsoSubspace* subspaceFor(VM& vm)
    4949    {
  • trunk/Source/JavaScriptCore/runtime/ProgramExecutable.h

    r236904 r240965  
    3737    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    3838
    39     template<typename CellType>
     39    template<typename CellType, SubspaceAccess>
    4040    static IsoSubspace* subspaceFor(VM& vm)
    4141    {
  • trunk/Source/JavaScriptCore/runtime/PropertyMapHashTable.h

    r233625 r240965  
    124124    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    125125
    126     template<typename CellType>
     126    template<typename CellType, SubspaceAccess>
    127127    static IsoSubspace* subspaceFor(VM& vm)
    128128    {
  • trunk/Source/JavaScriptCore/runtime/ProxyRevoke.h

    r230813 r240965  
    3737    static const unsigned StructureFlags = Base::StructureFlags;
    3838
    39     template<typename CellType>
     39    template<typename CellType, SubspaceAccess mode>
    4040    static IsoSubspace* subspaceFor(VM& vm)
    4141    {
    42         return &vm.proxyRevokeSpace;
     42        return vm.proxyRevokeSpace<mode>();
    4343    }
    4444
  • trunk/Source/JavaScriptCore/runtime/ScopedArguments.h

    r239198 r240965  
    4444
    4545public:
    46     template<typename CellType>
     46    template<typename CellType, SubspaceAccess>
    4747    static CompleteSubspace* subspaceFor(VM& vm)
    4848    {
    49         RELEASE_ASSERT(!CellType::needsDestruction);
     49        static_assert(!CellType::needsDestruction, "");
    5050        return &vm.jsValueGigacageCellSpace;
    5151    }
  • trunk/Source/JavaScriptCore/runtime/ScriptExecutable.cpp

    r240938 r240965  
    6969{
    7070    Base::clearCode();
    71     ASSERT(&VM::ScriptExecutableSpaceAndSet::clearableCodeSetFor(*subspace()) == &clearableCodeSet);
     71    ASSERT(&VM::SpaceAndSet::setFor(*subspace()) == &clearableCodeSet);
    7272    clearableCodeSet.remove(this);
    7373}
     
    150150    }
    151151
    152     auto& clearableCodeSet = VM::ScriptExecutableSpaceAndSet::clearableCodeSetFor(*subspace());
     152    auto& clearableCodeSet = VM::SpaceAndSet::setFor(*subspace());
    153153    if (hasClearableCode())
    154154        clearableCodeSet.add(this);
  • trunk/Source/JavaScriptCore/runtime/Structure.h

    r240023 r240965  
    133133    ~Structure();
    134134   
    135     template<typename CellType>
     135    template<typename CellType, SubspaceAccess>
    136136    static IsoSubspace* subspaceFor(VM& vm)
    137137    {
  • trunk/Source/JavaScriptCore/runtime/StructureRareData.h

    r240327 r240965  
    4444    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    4545
    46     template<typename CellType>
     46    template<typename CellType, SubspaceAccess>
    4747    static IsoSubspace* subspaceFor(VM& vm)
    4848    {
  • trunk/Source/JavaScriptCore/runtime/SubspaceAccess.h

    r240964 r240965  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (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.
    2424 */
    2525
    2626#pragma once
    2727
    28 #include "InferredValue.h"
    29 
    3028namespace JSC {
    3129
    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);
     30enum class SubspaceAccess {
     31    OnMainThread,
     32    Concurrently,
     33};
     34
    4435}
    45 
    46 } // namespace JSC
    47 
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r240888 r240965  
    288288    , eagerlySweptDestructibleObjectSpace("Eagerly Swept JSDestructibleObject", heap, destructibleObjectHeapCellType.get(), fastMallocAllocator.get())
    289289    , 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)
    293290    , executableToCodeBlockEdgeSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), ExecutableToCodeBlockEdge)
    294291    , functionSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), JSFunction)
    295     , inferredValueSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), InferredValue)
    296292    , internalFunctionSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), InternalFunction)
    297293    , nativeExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), NativeExecutable)
    298     , nativeStdFunctionSpace ISO_SUBSPACE_INIT(heap, cellHeapCellType.get(), JSNativeStdFunction)
    299 #if JSC_OBJC_API_ENABLED
    300     , objCCallbackFunctionSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), ObjCCallbackFunction)
    301 #endif
    302294    , propertyTableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), PropertyTable)
    303     , proxyRevokeSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), ProxyRevoke)
    304295    , structureRareDataSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), StructureRareData)
    305296    , 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 #endif
    314297    , executableToCodeBlockEdgesWithConstraints(executableToCodeBlockEdgeSpace)
    315298    , executableToCodeBlockEdgesWithFinalizers(executableToCodeBlockEdgeSpace)
    316     , inferredValuesWithFinalizers(inferredValueSpace)
    317299    , codeBlockSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), CodeBlock)
    318     , directEvalExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), DirectEvalExecutable)
    319300    , 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)
    322301    , programExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), ProgramExecutable)
    323302    , unlinkedFunctionExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), UnlinkedFunctionExecutable)
     
    12401219}
    12411220
     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
     1232DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(boundFunctionSpace, cellHeapCellType.get(), JSBoundFunction)
     1233DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(callbackFunctionSpace, destructibleObjectHeapCellType.get(), JSCallbackFunction)
     1234DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(customGetterSetterFunctionSpace, cellHeapCellType.get(), JSCustomGetterSetterFunction)
     1235DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(errorInstanceSpace, destructibleObjectHeapCellType.get(), ErrorInstance)
     1236DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(nativeStdFunctionSpace, cellHeapCellType.get(), JSNativeStdFunction)
     1237DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(proxyRevokeSpace, destructibleObjectHeapCellType.get(), ProxyRevoke)
     1238DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(weakMapSpace, destructibleObjectHeapCellType.get(), JSWeakMap)
     1239DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(weakSetSpace, destructibleObjectHeapCellType.get(), JSWeakSet)
     1240#if JSC_OBJC_API_ENABLED
     1241DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(objCCallbackFunctionSpace, destructibleObjectHeapCellType.get(), ObjCCallbackFunction)
     1242#endif
     1243#if ENABLE(WEBASSEMBLY)
     1244DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(webAssemblyCodeBlockSpace, webAssemblyCodeBlockHeapCellType.get(), JSWebAssemblyCodeBlock)
     1245DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(webAssemblyFunctionSpace, cellHeapCellType.get(), WebAssemblyFunction)
     1246DYNAMIC_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
     1261DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW(inferredValueSpace, destructibleCellHeapCellType.get(), InferredValue)
     1262DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW(directEvalExecutableSpace, destructibleCellHeapCellType.get(), DirectEvalExecutable)
     1263DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW(indirectEvalExecutableSpace, destructibleCellHeapCellType.get(), IndirectEvalExecutable)
     1264DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW(moduleProgramExecutableSpace, destructibleCellHeapCellType.get(), ModuleProgramExecutable)
     1265
     1266#undef DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW
     1267
    12421268JSGlobalObject* VM::vmEntryGlobalObject(const CallFrame* callFrame) const
    12431269{
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r240888 r240965  
    5252#include "Strong.h"
    5353#include "StructureCache.h"
     54#include "SubspaceAccess.h"
    5455#include "VMTraps.h"
    5556#include "WasmContext.h"
     
    367368    CompleteSubspace segmentedVariableObjectSpace;
    368369   
    369     IsoSubspace boundFunctionSpace;
    370     IsoSubspace callbackFunctionSpace;
    371     IsoSubspace customGetterSetterFunctionSpace;
    372370    IsoSubspace executableToCodeBlockEdgeSpace;
    373371    IsoSubspace functionSpace;
    374     IsoSubspace inferredValueSpace;
    375372    IsoSubspace internalFunctionSpace;
    376373    IsoSubspace nativeExecutableSpace;
    377     IsoSubspace nativeStdFunctionSpace;
    378 #if JSC_OBJC_API_ENABLED
    379     IsoSubspace objCCallbackFunctionSpace;
    380 #endif
    381374    IsoSubspace propertyTableSpace;
    382     IsoSubspace proxyRevokeSpace;
    383375    IsoSubspace structureRareDataSpace;
    384376    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)
    388401#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
    393408   
    394409    IsoCellSet executableToCodeBlockEdgesWithConstraints;
    395410    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
    399428        IsoSubspace space;
    400         IsoCellSet finalizerSet;
     429        IsoCellSet set;
    401430       
    402431        template<typename... Arguments>
    403         SpaceAndFinalizerSet(Arguments&&... arguments)
     432        SpaceAndSet(Arguments&&... arguments)
    404433            : space(std::forward<Arguments>(arguments)...)
    405             , finalizerSet(space)
     434            , set(space)
    406435        {
    407436        }
    408437       
    409         static IsoCellSet& finalizerSetFor(Subspace& space)
     438        static IsoCellSet& setFor(Subspace& space)
    410439        {
    411440            return *bitwise_cast<IsoCellSet*>(
    412441                bitwise_cast<char*>(&space) -
    413                 OBJECT_OFFSETOF(SpaceAndFinalizerSet, space) +
    414                 OBJECT_OFFSETOF(SpaceAndFinalizerSet, finalizerSet));
     442                OBJECT_OFFSETOF(SpaceAndSet, space) +
     443                OBJECT_OFFSETOF(SpaceAndSet, set));
    415444        }
    416445    };
    417446   
    418     SpaceAndFinalizerSet codeBlockSpace;
     447    SpaceAndSet codeBlockSpace;
     448    DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(inferredValueSpace)
    419449
    420450    template<typename Func>
     
    426456    }
    427457
    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;
    452463
    453464    template<typename Func>
    454465    void forEachScriptExecutableSpace(const Func& func)
    455466    {
    456         func(directEvalExecutableSpace);
     467        if (m_directEvalExecutableSpace)
     468            func(*m_directEvalExecutableSpace);
    457469        func(functionExecutableSpace);
    458         func(indirectEvalExecutableSpace);
    459         func(moduleProgramExecutableSpace);
     470        if (m_indirectEvalExecutableSpace)
     471            func(*m_indirectEvalExecutableSpace);
     472        if (m_moduleProgramExecutableSpace)
     473            func(*m_moduleProgramExecutableSpace);
    460474        func(programExecutableSpace);
    461475    }
    462476
    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
    483480
    484481    VMType vmType;
  • trunk/Source/JavaScriptCore/runtime/WeakMapImpl.h

    r233765 r240965  
    303303    }
    304304
    305     template<typename CellType>
     305    template<typename CellType, SubspaceAccess mode>
    306306    static IsoSubspace* subspaceFor(VM& vm)
    307307    {
    308308        if (isWeakMap())
    309             return &vm.weakMapSpace;
    310         return &vm.weakSetSpace;
     309            return vm.weakMapSpace<mode>();
     310        return vm.weakSetSpace<mode>();
    311311    }
    312312
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCodeBlock.h

    r232080 r240965  
    6060    }
    6161
    62     template<typename CellType>
     62    template<typename CellType, SubspaceAccess mode>
    6363    static IsoSubspace* subspaceFor(VM& vm)
    6464    {
    65         return &vm.webAssemblyCodeBlockSpace;
     65        return vm.webAssemblyCodeBlockSpace<mode>();
    6666    }
    6767
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h

    r229413 r240965  
    4444    typedef JSDestructibleObject Base;
    4545
    46     template<typename CellType>
     46    template<typename CellType, SubspaceAccess>
    4747    static CompleteSubspace* subspaceFor(VM& vm)
    4848    {
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.h

    r230748 r240965  
    5050    const static unsigned StructureFlags = Base::StructureFlags;
    5151
    52     template<typename CellType>
     52    template<typename CellType, SubspaceAccess mode>
    5353    static IsoSubspace* subspaceFor(VM& vm)
    5454    {
    55         return &vm.webAssemblyFunctionSpace;
     55        return vm.webAssemblyFunctionSpace<mode>();
    5656    }
    5757
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.h

    r230096 r240965  
    4141    const static unsigned StructureFlags = Base::StructureFlags;
    4242
    43     template<typename CellType>
     43    template<typename CellType, SubspaceAccess mode>
    4444    static IsoSubspace* subspaceFor(VM& vm)
    4545    {
    46         return &vm.webAssemblyWrapperFunctionSpace;
     46        return vm.webAssemblyWrapperFunctionSpace<mode>();
    4747    }
    4848
  • trunk/Source/WebCore/ChangeLog

    r240963 r240965  
     12019-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
    1122019-02-04  Simon Fraser  <simon.fraser@apple.com>
    213
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r240557 r240965  
    27592759            push(@headerContent, "    static void visitOutputConstraints(JSCell*, JSC::SlotVisitor&);\n");
    27602760            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");
    27622762        }
    27632763    }
  • trunk/Source/WebCore/bridge/runtime_method.h

    r231839 r240965  
    3838    static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetCallData;
    3939
    40     template<typename CellType>
     40    template<typename CellType, JSC::SubspaceAccess>
    4141    static IsoSubspace* subspaceFor(VM& vm)
    4242    {
  • trunk/Source/WebKit/ChangeLog

    r240963 r240965  
     12019-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
    1112019-02-04  Simon Fraser  <simon.fraser@apple.com>
    212
  • trunk/Source/WebKit/WebProcess/Plugins/Netscape/JSNPMethod.h

    r230813 r240965  
    4242    typedef JSC::InternalFunction Base;
    4343
    44     template<typename CellType>
     44    template<typename CellType, JSC::SubspaceAccess>
    4545    static JSC::IsoSubspace* subspaceFor(JSC::VM& vm)
    4646    {
  • trunk/Source/WebKit/WebProcess/Plugins/Netscape/JSNPObject.h

    r231839 r240965  
    4747    static const unsigned StructureFlags = Base::StructureFlags | JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | JSC::OverridesGetCallData;
    4848
    49     template<typename CellType>
     49    template<typename CellType, JSC::SubspaceAccess>
    5050    static JSC::IsoSubspace* subspaceFor(JSC::VM& vm)
    5151    {
Note: See TracChangeset for help on using the changeset viewer.