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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@163450 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/heap/CodeBlockSet.cpp b/Source/JavaScriptCore/heap/CodeBlockSet.cpp
index c04cbac..3fa3aca 100644
--- a/Source/JavaScriptCore/heap/CodeBlockSet.cpp
+++ b/Source/JavaScriptCore/heap/CodeBlockSet.cpp
@@ -33,7 +33,10 @@
 
 static const bool verbose = false;
 
-CodeBlockSet::CodeBlockSet() { }
+CodeBlockSet::CodeBlockSet(BlockAllocator& blockAllocator)
+    : m_currentlyExecuting(blockAllocator)
+{
+}
 
 CodeBlockSet::~CodeBlockSet()
 {
@@ -109,8 +112,8 @@
 void CodeBlockSet::rememberCurrentlyExecutingCodeBlocks(Heap* heap)
 {
 #if ENABLE(GGC)
-    for (size_t i = 0; i < m_currentlyExecuting.size(); ++i)
-        heap->addToRememberedSet(m_currentlyExecuting[i]->ownerExecutable());
+    for (CodeBlock* codeBlock : m_currentlyExecuting)
+        heap->addToRememberedSet(codeBlock->ownerExecutable());
     m_currentlyExecuting.clear();
 #else
     UNUSED_PARAM(heap);