Changeset 163450 in webkit


Ignore:
Timestamp:
Feb 5, 2014, 9:31:47 AM (11 years ago)
Author:
mhahnenberg@apple.com
Message:

Malloc called beneath MachineThreads::gatherFromOtherThread(), while forbidden
https://bugs.webkit.org/show_bug.cgi?id=128202

Reviewed by Geoffrey Garen.

This patch uses the new GCSegmentedArray to replace the Vector that was used
to record the set of currently executing CodeBlocks during the conservative
stack scan. This is primarily to avoid the possibility of the Vector resizing
while FastMalloc is forbidden.

  • heap/BlockAllocator.h:
  • heap/CodeBlockSet.cpp:

(JSC::CodeBlockSet::CodeBlockSet):
(JSC::CodeBlockSet::rememberCurrentlyExecutingCodeBlocks):

  • heap/CodeBlockSet.h:
  • heap/GCSegmentedArray.h:

(JSC::GCSegmentedArray::begin):
(JSC::GCSegmentedArray::end):
(JSC::GCSegmentedArrayIterator::GCSegmentedArrayIterator):
(JSC::GCSegmentedArrayIterator::get):
(JSC::GCSegmentedArrayIterator::operator*):
(JSC::GCSegmentedArrayIterator::operator->):
(JSC::GCSegmentedArrayIterator::operator==):
(JSC::GCSegmentedArrayIterator::operator!=):
(JSC::GCSegmentedArrayIterator::operator++):

  • heap/Heap.cpp:

(JSC::Heap::Heap):

Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r163444 r163450  
     12014-02-05  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        Malloc called beneath MachineThreads::gatherFromOtherThread(), while forbidden
     4        https://bugs.webkit.org/show_bug.cgi?id=128202
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        This patch uses the new GCSegmentedArray to replace the Vector that was used
     9        to record the set of currently executing CodeBlocks during the conservative
     10        stack scan. This is primarily to avoid the possibility of the Vector resizing
     11        while FastMalloc is forbidden.
     12
     13        * heap/BlockAllocator.h:
     14        * heap/CodeBlockSet.cpp:
     15        (JSC::CodeBlockSet::CodeBlockSet):
     16        (JSC::CodeBlockSet::rememberCurrentlyExecutingCodeBlocks):
     17        * heap/CodeBlockSet.h:
     18        * heap/GCSegmentedArray.h:
     19        (JSC::GCSegmentedArray::begin):
     20        (JSC::GCSegmentedArray::end):
     21        (JSC::GCSegmentedArrayIterator::GCSegmentedArrayIterator):
     22        (JSC::GCSegmentedArrayIterator::get):
     23        (JSC::GCSegmentedArrayIterator::operator*):
     24        (JSC::GCSegmentedArrayIterator::operator->):
     25        (JSC::GCSegmentedArrayIterator::operator==):
     26        (JSC::GCSegmentedArrayIterator::operator!=):
     27        (JSC::GCSegmentedArrayIterator::operator++):
     28        * heap/Heap.cpp:
     29        (JSC::Heap::Heap):
     30
    1312014-02-05  Wojciech Bielawski  <w.bielawski@samsung.com>
    232
  • trunk/Source/JavaScriptCore/heap/BlockAllocator.h

    r163419 r163450  
    4040
    4141class BlockAllocator;
     42class CodeBlock;
    4243class CopiedBlock;
    4344class CopyWorkListSegment;
     
    234235REGION_SET_FOR(WeakBlock, m_fourKBBlockRegionSet);
    235236REGION_SET_FOR(GCArraySegment<const JSCell*>, m_fourKBBlockRegionSet);
     237REGION_SET_FOR(GCArraySegment<CodeBlock*>, m_fourKBBlockRegionSet);
    236238REGION_SET_FOR(CopyWorkListSegment, m_workListRegionSet);
    237239REGION_SET_FOR(HandleBlock, m_fourKBBlockRegionSet);
  • trunk/Source/JavaScriptCore/heap/CodeBlockSet.cpp

    r162377 r163450  
    3434static const bool verbose = false;
    3535
    36 CodeBlockSet::CodeBlockSet() { }
     36CodeBlockSet::CodeBlockSet(BlockAllocator& blockAllocator)
     37    : m_currentlyExecuting(blockAllocator)
     38{
     39}
    3740
    3841CodeBlockSet::~CodeBlockSet()
     
    110113{
    111114#if ENABLE(GGC)
    112     for (size_t i = 0; i < m_currentlyExecuting.size(); ++i)
    113         heap->addToRememberedSet(m_currentlyExecuting[i]->ownerExecutable());
     115    for (CodeBlock* codeBlock : m_currentlyExecuting)
     116        heap->addToRememberedSet(codeBlock->ownerExecutable());
    114117    m_currentlyExecuting.clear();
    115118#else
  • trunk/Source/JavaScriptCore/heap/CodeBlockSet.h

    r162598 r163450  
    2727#define CodeBlockSet_h
    2828
     29#include "GCSegmentedArray.h"
    2930#include <wtf/HashSet.h>
    3031#include <wtf/Noncopyable.h>
    3132#include <wtf/PassRefPtr.h>
    3233#include <wtf/RefPtr.h>
    33 #include <wtf/Vector.h>
    3434
    3535namespace JSC {
    3636
     37class BlockAllocator;
    3738class CodeBlock;
    3839class Heap;
     
    4748
    4849public:
    49     CodeBlockSet();
     50    CodeBlockSet(BlockAllocator&);
    5051    ~CodeBlockSet();
    5152   
     
    8990    // and all, but that seemed like overkill.
    9091    HashSet<CodeBlock* > m_set;
    91     Vector<CodeBlock*> m_currentlyExecuting;
     92    GCSegmentedArray<CodeBlock*> m_currentlyExecuting;
    9293};
    9394
  • trunk/Source/JavaScriptCore/heap/GCSegmentedArray.h

    r163414 r163450  
    6060};
    6161
     62template <typename T> class GCSegmentedArrayIterator;
     63
    6264template <typename T>
    6365class GCSegmentedArray {
     66    friend class GCSegmentedArrayIterator<T>;
    6467public:
    6568    GCSegmentedArray(BlockAllocator&);
     
    7780    void fillVector(Vector<T>&);
    7881    void clear();
     82
     83    typedef GCSegmentedArrayIterator<T> iterator;
     84    iterator begin() { return GCSegmentedArrayIterator<T>(m_segments.head(), m_top); }
     85    iterator end() { return GCSegmentedArrayIterator<T>(); }
    7986
    8087protected:
     
    101108};
    102109
     110template <typename T>
     111class GCSegmentedArrayIterator {
     112    friend class GCSegmentedArray<T>;
     113public:
     114    GCSegmentedArrayIterator()
     115        : m_currentSegment(0)
     116        , m_currentOffset(0)
     117    {
     118    }
     119
     120    T& get() { return m_currentSegment->data()[m_currentOffset]; }
     121    T& operator*() { return get(); }
     122    T& operator->() { return get(); }
     123
     124    bool operator==(const GCSegmentedArrayIterator& other)
     125    {
     126        return m_currentSegment == other.m_currentSegment && m_currentOffset == other.m_currentOffset;
     127    }
     128
     129    bool operator!=(const GCSegmentedArrayIterator& other)
     130    {
     131        return !(*this == other);
     132    }
     133
     134    GCSegmentedArrayIterator& operator++()
     135    {
     136        ASSERT(m_currentSegment);
     137
     138        m_currentOffset++;
     139
     140        if (m_currentOffset >= m_offsetLimit) {
     141            m_currentSegment = m_currentSegment->next();
     142            m_currentOffset = 0;
     143            m_offsetLimit = GCSegmentedArray<T>::s_segmentCapacity;
     144        }
     145
     146        return *this;
     147    }
     148
     149private:
     150    GCSegmentedArrayIterator(GCArraySegment<T>* start, size_t top)
     151        : m_currentSegment(start)
     152        , m_currentOffset(0)
     153        , m_offsetLimit(top)
     154    {
     155        if (!m_offsetLimit)
     156            m_currentSegment = nullptr;
     157    }
     158
     159    GCArraySegment<T>* m_currentSegment;
     160    size_t m_currentOffset;
     161    size_t m_offsetLimit;
     162};
     163
    103164} // namespace JSC
    104165
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r163027 r163450  
    271271    , m_copyVisitor(m_sharedData)
    272272    , m_handleSet(vm)
     273    , m_codeBlocks(m_blockAllocator)
    273274    , m_isSafeToCollect(false)
    274275    , m_writeBarrierBuffer(256)
Note: See TracChangeset for help on using the changeset viewer.