Ignore:
Timestamp:
Apr 19, 2012, 5:05:37 PM (13 years ago)
Author:
[email protected]
Message:

We're collecting pathologically due to small allocations
https://bugs.webkit.org/show_bug.cgi?id=84404

Reviewed by Geoffrey Garen.

No change in performance on run-jsc-benchmarks.

  • dfg/DFGSpeculativeJIT.h: Replacing m_firstFreeCell with m_freeList.

(JSC::DFG::SpeculativeJIT::emitAllocateBasicJSObject):

  • heap/CopiedSpace.cpp: Getting rid of any water mark related stuff, since it's no

longer useful.
(JSC::CopiedSpace::CopiedSpace):
(JSC::CopiedSpace::tryAllocateSlowCase): We now only call didAllocate here rather than
carrying out a somewhat complicated accounting job for our old water mark throughout CopiedSpace.
(JSC::CopiedSpace::tryAllocateOversize): Call the new didAllocate to notify the Heap of
newly allocated stuff.
(JSC::CopiedSpace::tryReallocateOversize):
(JSC::CopiedSpace::doneFillingBlock):
(JSC::CopiedSpace::doneCopying):
(JSC::CopiedSpace::destroy):

  • heap/CopiedSpace.h:

(CopiedSpace):

  • heap/CopiedSpaceInlineMethods.h:

(JSC::CopiedSpace::startedCopying):

  • heap/Heap.cpp: Removed water mark related stuff, replaced with new bytesAllocated and

bytesAllocatedLimit to track how much memory has been allocated since the last collection.
(JSC::Heap::Heap):
(JSC::Heap::reportExtraMemoryCostSlowCase):
(JSC::Heap::collect): We now set the new limit of bytes that we can allocate before triggering
a collection to be the size of the Heap after the previous collection. Thus, we still have our
2x allocation amount.
(JSC::Heap::didAllocate): Notifies the GC activity timer of how many bytes have been allocated
thus far and then adds the new number of bytes to the current total.
(JSC):

  • heap/Heap.h: Removed water mark related stuff.

(JSC::Heap::notifyIsSafeToCollect):
(Heap):
(JSC::Heap::shouldCollect):
(JSC):

  • heap/MarkedAllocator.cpp:

(JSC::MarkedAllocator::tryAllocateHelper): Refactored to use MarkedBlock's new FreeList struct.
(JSC::MarkedAllocator::allocateSlowCase):
(JSC::MarkedAllocator::addBlock):

  • heap/MarkedAllocator.h:

(MarkedAllocator):
(JSC::MarkedAllocator::MarkedAllocator):
(JSC::MarkedAllocator::allocate):
(JSC::MarkedAllocator::zapFreeList): Refactored to take in a FreeList instead of a FreeCell.

  • heap/MarkedBlock.cpp:

(JSC::MarkedBlock::specializedSweep):
(JSC::MarkedBlock::sweep):
(JSC::MarkedBlock::sweepHelper):
(JSC::MarkedBlock::zapFreeList):

  • heap/MarkedBlock.h:

(FreeList): Added a new struct that keeps track of the current MarkedAllocator's
free list including the number of bytes of stuff in the free list so that when the free list is
exhausted, the correct amount can be reported to Heap.
(MarkedBlock):
(JSC::MarkedBlock::FreeList::FreeList):
(JSC):

  • heap/MarkedSpace.cpp: Removing all water mark related stuff.

(JSC::MarkedSpace::MarkedSpace):
(JSC::MarkedSpace::resetAllocators):

  • heap/MarkedSpace.h:

(MarkedSpace):
(JSC):

  • heap/WeakSet.cpp:

(JSC::WeakSet::findAllocator): Refactored to use the didAllocate interface with the Heap. This
function still needs work though now that the Heap knows how many bytes have been allocated
since the last collection.

  • jit/JITInlineMethods.h: Refactored to use MarkedBlock's new FreeList struct.

(JSC::JIT::emitAllocateBasicJSObject): Ditto.

  • llint/LowLevelInterpreter.asm: Ditto.
  • runtime/GCActivityCallback.cpp:

(JSC::DefaultGCActivityCallback::didAllocate):

  • runtime/GCActivityCallback.h:

(JSC::GCActivityCallback::didAllocate): Renamed willAllocate to didAllocate to indicate that
the allocation that is being reported has already taken place.
(DefaultGCActivityCallback):

  • runtime/GCActivityCallbackCF.cpp:

(JSC):
(JSC::DefaultGCActivityCallback::didAllocate): Refactored to return early if the amount of
allocation since the last collection is not above a threshold (initially arbitrarily chosen to
be 128KB).

File:
1 edited

Legend:

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

    r114511 r114698  
    113113
    114114        void notifyIsSafeToCollect() { m_isSafeToCollect = true; }
     115
    115116        JS_EXPORT_PRIVATE void collectAllGarbage();
    116 
     117        enum SweepToggle { DoNotSweep, DoSweep };
     118        bool shouldCollect();
     119        void collect(SweepToggle);
    117120        void reportExtraMemoryCost(size_t cost);
    118121
     
    145148        void getConservativeRegisterRoots(HashSet<JSCell*>& roots);
    146149
    147         void addToWaterMark(size_t);
    148 
    149150        double lastGCLength() { return m_lastGCLength; }
    150151
    151152        JS_EXPORT_PRIVATE void discardAllCompiledCode();
     153
     154        void didAllocate(size_t);
    152155
    153156    private:
     
    164167        void* allocateWithoutDestructor(size_t);
    165168
    166         size_t waterMark();
    167         size_t highWaterMark();
    168         bool shouldCollect();
    169 
    170169        static const size_t minExtraCost = 256;
    171170        static const size_t maxExtraCost = 1024 * 1024;
     
    193192        void finalizeUnconditionalFinalizers();
    194193       
    195         enum SweepToggle { DoNotSweep, DoSweep };
    196         void collect(SweepToggle);
    197194        void shrink();
    198195        void releaseFreeBlocks();
     
    209206        const size_t m_minBytesPerCycle;
    210207        size_t m_lastFullGCSize;
    211         size_t m_highWaterMark;
     208
     209        size_t m_bytesAllocatedLimit;
     210        size_t m_bytesAllocated;
    212211       
    213212        OperationInProgress m_operationInProgress;
     
    258257        return m_objectSpace.nurseryWaterMark() >= m_minBytesPerCycle && m_isSafeToCollect;
    259258#else
    260         return waterMark() >= highWaterMark() && m_isSafeToCollect;
     259        return m_bytesAllocated > m_bytesAllocatedLimit && m_isSafeToCollect;
    261260#endif
    262261    }
     
    292291    {
    293292        MarkedBlock::blockFor(cell)->setMarked(cell);
    294     }
    295 
    296     inline size_t Heap::waterMark()
    297     {
    298         return m_objectSpace.waterMark() + m_storageSpace.waterMark();
    299     }
    300 
    301     inline size_t Heap::highWaterMark()
    302     {
    303         return m_highWaterMark;
    304     }
    305 
    306     inline void Heap::addToWaterMark(size_t size)
    307     {
    308         m_objectSpace.addToWaterMark(size);
    309         if (waterMark() > highWaterMark())
    310             collect(DoNotSweep);
    311293    }
    312294
Note: See TracChangeset for help on using the changeset viewer.