Ignore:
Timestamp:
Feb 10, 2012, 2:44:09 PM (13 years ago)
Author:
[email protected]
Message:

Split MarkedSpace into destructor and destructor-free subspaces
https://bugs.webkit.org/show_bug.cgi?id=77761

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::emitAllocateJSFinalObject): Switched over to use destructor-free space.

  • heap/Heap.h:

(JSC::Heap::allocatorForObjectWithoutDestructor): Added to give clients (e.g. the JIT) the ability to
pick which subspace they want to allocate out of.
(JSC::Heap::allocatorForObjectWithDestructor): Ditto.
(Heap):
(JSC::Heap::allocateWithDestructor): Added private function for CellAllocator to use.
(JSC):
(JSC::Heap::allocateWithoutDestructor): Ditto.

  • heap/MarkedAllocator.cpp: Added the cellsNeedDestruction flag to allocators so that they can allocate

their MarkedBlocks correctly.
(JSC::MarkedAllocator::allocateBlock):

  • heap/MarkedAllocator.h:

(JSC::MarkedAllocator::cellsNeedDestruction):
(MarkedAllocator):
(JSC::MarkedAllocator::MarkedAllocator):
(JSC):
(JSC::MarkedAllocator::init): Replaced custom set functions, which were only used upon initialization, with
an init function that does all of that stuff in fewer lines.

  • heap/MarkedBlock.cpp:

(JSC::MarkedBlock::create):
(JSC::MarkedBlock::recycle):
(JSC::MarkedBlock::MarkedBlock):
(JSC::MarkedBlock::callDestructor): Templatized, along with specializedSweep and sweepHelper, to make
checking the m_cellsNeedDestructor flag faster and cleaner looking.
(JSC):
(JSC::MarkedBlock::specializedSweep):
(JSC::MarkedBlock::sweep):
(JSC::MarkedBlock::sweepHelper):

  • heap/MarkedBlock.h:

(MarkedBlock):
(JSC::MarkedBlock::cellsNeedDestruction):
(JSC):

  • heap/MarkedSpace.cpp:

(JSC::MarkedSpace::MarkedSpace):
(JSC::MarkedSpace::resetAllocators):
(JSC::MarkedSpace::canonicalizeCellLivenessData):
(JSC::TakeIfUnmarked::operator()):

  • heap/MarkedSpace.h:

(MarkedSpace):
(Subspace):
(JSC::MarkedSpace::allocatorFor): Needed function to differentiate between the two broad subspaces of
allocators.
(JSC):
(JSC::MarkedSpace::destructorAllocatorFor): Ditto.
(JSC::MarkedSpace::allocateWithoutDestructor): Ditto.
(JSC::MarkedSpace::allocateWithDestructor): Ditto.
(JSC::MarkedSpace::forEachBlock):

  • jit/JIT.h:
  • jit/JITInlineMethods.h: Modified to use the proper allocator for JSFinalObjects and others.

(JSC::JIT::emitAllocateBasicJSObject):
(JSC::JIT::emitAllocateJSFinalObject):
(JSC::JIT::emitAllocateJSFunction):

  • runtime/JSArray.cpp:

(JSC):

  • runtime/JSArray.h:

(JSArray):
(JSC::JSArray::create):
(JSC):
(JSC::JSArray::tryCreateUninitialized):

  • runtime/JSCell.h:

(JSCell):
(JSC):
(NeedsDestructor): Template struct that calculates at compile time whether the class in question requires
destruction or not using the compiler type trait has_trivial_destructor. allocateCell then checks this
constant to decide whether to allocate in the destructor or destructor-free parts of the heap.
(JSC::allocateCell):

  • runtime/JSFunction.cpp:

(JSC):

  • runtime/JSFunction.h:

(JSFunction):

  • runtime/JSObject.cpp:

(JSC):

  • runtime/JSObject.h:

(JSNonFinalObject):
(JSC):
(JSFinalObject):
(JSC::JSFinalObject::create):

Source/WebCore:

No new tests.

  • bindings/js/JSDOMWindowShell.cpp: Removed old operator new, which was just used in the create

function so that we can use allocateCell instead.
(WebCore):

  • bindings/js/JSDOMWindowShell.h:

(WebCore::JSDOMWindowShell::create):
(JSDOMWindowShell):

  • bindings/scripts/CodeGeneratorJS.pm: Added destructor back to root JS DOM nodes (e.g. JSNode, etc)

because their destroy functions need to be called, so we don't want the NeedsDestructor struct to
think they don't need destruction due to having empty/trivial destructors.
Removed ASSERT_HAS_TRIVIAL_DESTRUCTOR from all JS DOM wrapper auto-generated objects because their
ancestors now have non-trivial destructors.
(GenerateHeader):
(GenerateImplementation):
(GenerateConstructorDefinition):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r106676 r107445  
    9696        inline bool isBusy();
    9797       
    98         MarkedAllocator& allocatorForObject(size_t bytes) { return m_objectSpace.allocatorFor(bytes); }
    99         void* allocate(size_t);
     98        MarkedAllocator& allocatorForObjectWithoutDestructor(size_t bytes) { return m_objectSpace.allocatorFor(bytes); }
     99        MarkedAllocator& allocatorForObjectWithDestructor(size_t bytes) { return m_objectSpace.destructorAllocatorFor(bytes); }
    100100        CheckedBoolean tryAllocateStorage(size_t, void**);
    101101        CheckedBoolean tryReallocateStorage(void**, size_t, size_t);
     
    143143        friend class SlotVisitor;
    144144        friend class CodeBlock;
     145        template<typename T> friend void* allocateCell(Heap&);
     146
     147        void* allocateWithDestructor(size_t);
     148        void* allocateWithoutDestructor(size_t);
    145149
    146150        size_t waterMark();
     
    335339    }
    336340
    337     inline void* Heap::allocate(size_t bytes)
     341    inline void* Heap::allocateWithDestructor(size_t bytes)
    338342    {
    339343        ASSERT(isValidAllocation(bytes));
    340         return m_objectSpace.allocate(bytes);
     344        return m_objectSpace.allocateWithDestructor(bytes);
     345    }
     346   
     347    inline void* Heap::allocateWithoutDestructor(size_t bytes)
     348    {
     349        ASSERT(isValidAllocation(bytes));
     350        return m_objectSpace.allocateWithoutDestructor(bytes);
    341351    }
    342352   
Note: See TracChangeset for help on using the changeset viewer.