Changeset 87441 in webkit


Ignore:
Timestamp:
May 26, 2011 3:43:07 PM (13 years ago)
Author:
ggaren@apple.com
Message:

2011-05-26 Geoffrey Garen <ggaren@apple.com>

Reviewed by Oliver Hunt.

Moved Heap-related functions out of JSCell.h and into respective header files
https://bugs.webkit.org/show_bug.cgi?id=61567

  • heap/Heap.h: (JSC::Heap::allocate): (JSC::Heap::heap):
  • heap/MarkedBlock.h: (JSC::MarkedBlock::allocate):
  • heap/MarkedSpace.h: (JSC::MarkedSpace::sizeClassFor): (JSC::MarkedSpace::allocate):
  • runtime/JSCell.h: (JSC::JSCell::destructor):
Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r87440 r87441  
     12011-05-26  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Moved Heap-related functions out of JSCell.h and into respective header files
     6        https://bugs.webkit.org/show_bug.cgi?id=61567
     7
     8        * heap/Heap.h:
     9        (JSC::Heap::allocate):
     10        (JSC::Heap::heap):
     11        * heap/MarkedBlock.h:
     12        (JSC::MarkedBlock::allocate):
     13        * heap/MarkedSpace.h:
     14        (JSC::MarkedSpace::sizeClassFor):
     15        (JSC::MarkedSpace::allocate):
     16        * runtime/JSCell.h:
     17        (JSC::JSCell::destructor):
     18
    1192011-05-26  Geoffrey Garen  <ggaren@apple.com>
    220
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r87434 r87441  
    194194    }
    195195
     196    inline void* Heap::allocate(size_t bytes)
     197    {
     198        ASSERT(isValidAllocation(bytes));
     199
     200        m_operationInProgress = Allocation;
     201        void* result = m_markedSpace.allocate(bytes);
     202        m_operationInProgress = NoOperation;
     203        if (result)
     204            return result;
     205
     206        return allocateSlowCase(bytes);
     207    }
     208
     209    inline Heap* Heap::heap(JSValue v)
     210    {
     211        if (!v.isCell())
     212            return 0;
     213        return heap(v.asCell());
     214    }
     215
     216    inline Heap* Heap::heap(JSCell* c)
     217    {
     218        return MarkedSpace::heap(c);
     219    }
     220
    196221} // namespace JSC
    197222
  • trunk/Source/JavaScriptCore/heap/MarkedBlock.h

    r87427 r87441  
    3737
    3838    static const size_t KB = 1024;
     39   
     40    void destructor(JSCell*); // Defined in JSCell.h.
    3941
    4042    class MarkedBlock : public DoublyLinkedListNode<MarkedBlock> {
     
    198200    }
    199201
     202    inline void* MarkedBlock::allocate()
     203    {
     204        while (m_nextAtom < m_endAtom) {
     205            if (!m_marks.testAndSet(m_nextAtom)) {
     206                JSCell* cell = reinterpret_cast<JSCell*>(&atoms()[m_nextAtom]);
     207                m_nextAtom += m_atomsPerCell;
     208                destructor(cell);
     209                return cell;
     210            }
     211            m_nextAtom += m_atomsPerCell;
     212        }
     213
     214        return 0;
     215    }
     216   
    200217} // namespace JSC
    201218
  • trunk/Source/JavaScriptCore/heap/MarkedSpace.h

    r85533 r87441  
    173173    }
    174174
     175    inline MarkedSpace::SizeClass& MarkedSpace::sizeClassFor(size_t bytes)
     176    {
     177        ASSERT(bytes && bytes < maxCellSize);
     178        if (bytes < preciseCutoff)
     179            return m_preciseSizeClasses[(bytes - 1) / preciseStep];
     180        return m_impreciseSizeClasses[(bytes - 1) / impreciseStep];
     181    }
     182
     183    inline void* MarkedSpace::allocate(size_t bytes)
     184    {
     185        SizeClass& sizeClass = sizeClassFor(bytes);
     186        return allocateFromSizeClass(sizeClass);
     187    }
     188   
    175189    inline MarkedSpace::SizeClass::SizeClass()
    176190        : nextBlock(0)
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r87434 r87441  
    7373        friend class StructureChain;
    7474        friend class RegExp;
     75        friend void destructor(JSCell*);
     76
    7577        enum CreatingEarlyCellTag { CreatingEarlyCell };
    7678
     
    346348    }
    347349
    348     inline Heap* Heap::heap(JSValue v)
    349     {
    350         if (!v.isCell())
    351             return 0;
    352         return heap(v.asCell());
    353     }
    354 
    355     inline Heap* Heap::heap(JSCell* c)
    356     {
    357         return MarkedSpace::heap(c);
    358     }
    359 
    360350#if ENABLE(JSC_ZOMBIES)
    361351    inline bool JSValue::isZombie() const
     
    365355#endif
    366356
    367     inline void* MarkedBlock::allocate()
    368     {
    369         while (m_nextAtom < m_endAtom) {
    370             if (!m_marks.testAndSet(m_nextAtom)) {
    371                 JSCell* cell = reinterpret_cast<JSCell*>(&atoms()[m_nextAtom]);
    372                 m_nextAtom += m_atomsPerCell;
    373                 cell->~JSCell();
    374                 return cell;
    375             }
    376             m_nextAtom += m_atomsPerCell;
    377         }
    378 
    379         return 0;
     357    inline void* JSCell::operator new(size_t size, JSGlobalData* globalData)
     358    {
     359        return globalData->heap.allocate(size);
     360    }
     361
     362    inline void* JSCell::operator new(size_t size, ExecState* exec)
     363    {
     364        return exec->heap()->allocate(size);
    380365    }
    381366   
    382     inline MarkedSpace::SizeClass& MarkedSpace::sizeClassFor(size_t bytes)
    383     {
    384         ASSERT(bytes && bytes < maxCellSize);
    385         if (bytes < preciseCutoff)
    386             return m_preciseSizeClasses[(bytes - 1) / preciseStep];
    387         return m_impreciseSizeClasses[(bytes - 1) / impreciseStep];
    388     }
    389 
    390     inline void* MarkedSpace::allocate(size_t bytes)
    391     {
    392         SizeClass& sizeClass = sizeClassFor(bytes);
    393         return allocateFromSizeClass(sizeClass);
    394     }
    395    
    396     inline void* Heap::allocate(size_t bytes)
    397     {
    398         ASSERT(isValidAllocation(bytes));
    399 
    400         m_operationInProgress = Allocation;
    401         void* result = m_markedSpace.allocate(bytes);
    402         m_operationInProgress = NoOperation;
    403         if (result)
    404             return result;
    405 
    406         return allocateSlowCase(bytes);
    407     }
    408 
    409     inline void* JSCell::operator new(size_t size, JSGlobalData* globalData)
    410     {
    411         return globalData->heap.allocate(size);
    412     }
    413 
    414     inline void* JSCell::operator new(size_t size, ExecState* exec)
    415     {
    416         return exec->heap()->allocate(size);
     367    inline void destructor(JSCell* cell)
     368    {
     369        cell->~JSCell();
    417370    }
    418371
Note: See TracChangeset for help on using the changeset viewer.