⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 277346 in webkit


Ignore:
Timestamp:
May 11, 2021, 5:52:09 PM (5 years ago)
Author:
ggaren@apple.com
Message:

ConservativeRoots triggers page demand on Speedometer
https://bugs.webkit.org/show_bug.cgi?id=225676

Reviewed by Saam Barati.

Use a Vector instead of OSAllocator to avoid mmap() and page fault --
and, like, come on.

Bump default inlineCapacity up to 1024 because we seem to overflow
frequently.

  • heap/ConservativeRoots.cpp:

(JSC::ConservativeRoots::ConservativeRoots):
(JSC::ConservativeRoots::~ConservativeRoots):
(JSC::ConservativeRoots::genericAddPointer):
(JSC::ConservativeRoots::grow): Deleted.

  • heap/ConservativeRoots.h:

(JSC::ConservativeRoots::roots const):
(JSC::ConservativeRoots::size const): Deleted.

  • heap/SlotVisitor.cpp:

(JSC::SlotVisitor::append):

  • heap/VerifierSlotVisitor.cpp:

(JSC::VerifierSlotVisitor::append):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r277326 r277346  
     12021-05-11  Geoffrey Garen  <ggaren@apple.com>
     2
     3        ConservativeRoots triggers page demand on Speedometer
     4        https://bugs.webkit.org/show_bug.cgi?id=225676
     5
     6        Reviewed by Saam Barati.
     7
     8        Use a Vector instead of OSAllocator to avoid mmap() and page fault --
     9        and, like, come on.
     10
     11        Bump default inlineCapacity up to 1024 because we seem to overflow
     12        frequently.
     13
     14        * heap/ConservativeRoots.cpp:
     15        (JSC::ConservativeRoots::ConservativeRoots):
     16        (JSC::ConservativeRoots::~ConservativeRoots):
     17        (JSC::ConservativeRoots::genericAddPointer):
     18        (JSC::ConservativeRoots::grow): Deleted.
     19        * heap/ConservativeRoots.h:
     20        (JSC::ConservativeRoots::roots const):
     21        (JSC::ConservativeRoots::size const): Deleted.
     22        * heap/SlotVisitor.cpp:
     23        (JSC::SlotVisitor::append):
     24        * heap/VerifierSlotVisitor.cpp:
     25        (JSC::VerifierSlotVisitor::append):
     26
    1272021-05-10  Filip Pizlo  <fpizlo@apple.com>
    228
  • trunk/Source/JavaScriptCore/heap/ConservativeRoots.cpp

    r261895 r277346  
    3939
    4040ConservativeRoots::ConservativeRoots(Heap& heap)
    41     : m_roots(m_inlineRoots)
    42     , m_size(0)
    43     , m_capacity(inlineCapacity)
    44     , m_heap(heap)
     41    : m_heap(heap)
    4542{
    4643}
     
    4845ConservativeRoots::~ConservativeRoots()
    4946{
    50     if (m_roots != m_inlineRoots)
    51         OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(HeapCell*));
    52 }
    53 
    54 void ConservativeRoots::grow()
    55 {
    56     size_t newCapacity = m_capacity == inlineCapacity ? nonInlineCapacity : m_capacity * 2;
    57     HeapCell** newRoots = static_cast<HeapCell**>(OSAllocator::reserveAndCommit(newCapacity * sizeof(HeapCell*)));
    58     memcpy(newRoots, m_roots, m_size * sizeof(HeapCell*));
    59     if (m_roots != m_inlineRoots)
    60         OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(HeapCell*));
    61     m_capacity = newCapacity;
    62     m_roots = newRoots;
    6347}
    6448
     
    7559                markHook.markKnownJSCell(static_cast<JSCell*>(p));
    7660           
    77             if (m_size == m_capacity)
    78                 grow();
    79            
    80             m_roots[m_size++] = bitwise_cast<HeapCell*>(p);
     61            m_roots.append(bitwise_cast<HeapCell*>(p));
    8162        });
    8263}
  • trunk/Source/JavaScriptCore/heap/ConservativeRoots.h

    r250005 r277346  
    3535
    3636class ConservativeRoots {
     37    static constexpr size_t inlineCapacity = 1024;
     38   
    3739public:
    3840    ConservativeRoots(Heap&);
     
    4244    void add(void* begin, void* end, JITStubRoutineSet&, CodeBlockSet&);
    4345   
    44     size_t size() const;
    45     HeapCell** roots() const;
     46    const Vector<HeapCell*, inlineCapacity>& roots() const { return m_roots; };
    4647
    4748private:
    48     static constexpr size_t inlineCapacity = 128;
    49     static constexpr size_t nonInlineCapacity = 8192 / sizeof(HeapCell*);
    50    
    5149    template<typename MarkHook>
    5250    void genericAddPointer(void*, HeapVersion markingVersion, HeapVersion newlyAllocatedVersion, TinyBloomFilter, MarkHook&);
     
    5553    void genericAddSpan(void*, void* end, MarkHook&);
    5654   
    57     void grow();
    58 
    59     HeapCell** m_roots;
    60     size_t m_size;
    61     size_t m_capacity;
    6255    Heap& m_heap;
    63     HeapCell* m_inlineRoots[inlineCapacity];
     56    Vector<HeapCell*, inlineCapacity> m_roots;
    6457};
    6558
    66 inline size_t ConservativeRoots::size() const
    67 {
    68     return m_size;
    69 }
    70 
    71 inline HeapCell** ConservativeRoots::roots() const
    72 {
    73     return m_roots;
    74 }
    75 
    7659} // namespace JSC
  • trunk/Source/JavaScriptCore/heap/SlotVisitor.cpp

    r273138 r277346  
    130130void SlotVisitor::append(const ConservativeRoots& conservativeRoots)
    131131{
    132     HeapCell** roots = conservativeRoots.roots();
    133     size_t size = conservativeRoots.size();
    134     for (size_t i = 0; i < size; ++i)
    135         appendJSCellOrAuxiliary(roots[i]);
     132    for (auto root : conservativeRoots.roots())
     133        appendJSCellOrAuxiliary(root);
    136134}
    137135
  • trunk/Source/JavaScriptCore/heap/VerifierSlotVisitor.cpp

    r275229 r277346  
    149149    };
    150150
    151     HeapCell** roots = conservativeRoots.roots();
    152     size_t size = conservativeRoots.size();
    153     for (size_t i = 0; i < size; ++i)
    154         appendJSCellOrAuxiliary(roots[i]);
     151    for (auto root : conservativeRoots.roots())
     152        appendJSCellOrAuxiliary(root);
    155153}
    156154
Note: See TracChangeset for help on using the changeset viewer.