Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Unified Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 1477023003: Refactor the Heap into ThreadHeap to prepare for per thread heaps Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/heap/HeapTest.cpp
diff --git a/third_party/WebKit/Source/platform/heap/HeapTest.cpp b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
index c45c657dae06e3100c97c78d58634360673462ca..941d9040751ed9cc38fe410c7d57fe60b5874c32 100644
--- a/third_party/WebKit/Source/platform/heap/HeapTest.cpp
+++ b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
@@ -48,12 +48,12 @@ namespace blink {
static void preciselyCollectGarbage()
{
- Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC);
+ ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC);
}
static void conservativelyCollectGarbage()
{
- Heap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC);
+ ThreadHeap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC);
}
class IntWrapper : public GarbageCollectedFinalized<IntWrapper> {
@@ -157,11 +157,11 @@ public:
bool traceInCollection(VisitorDispatcher visitor, WTF::ShouldWeakPointersBeMarkedStrongly strongify)
{
visitor->traceInCollection(second, strongify);
- if (!Heap::isHeapObjectAlive(second))
+ if (!ThreadHeap::isHeapObjectAlive(second))
return true;
// FIXME: traceInCollection is also called from WeakProcessing to check if the entry is dead.
// The below if avoids calling trace in that case by only calling trace when |first| is not yet marked.
- if (!Heap::isHeapObjectAlive(first))
+ if (!ThreadHeap::isHeapObjectAlive(first))
visitor->trace(first);
return false;
}
@@ -244,8 +244,8 @@ public:
, m_parkedAllThreads(false)
{
ASSERT(m_state->checkThread());
- if (LIKELY(ThreadState::stopThreads())) {
- Heap::preGC();
+ if (LIKELY(m_state->heap().park())) {
+ m_state->heap().preGC();
m_parkedAllThreads = true;
}
}
@@ -257,8 +257,8 @@ public:
// Only cleanup if we parked all threads in which case the GC happened
// and we need to resume the other threads.
if (LIKELY(m_parkedAllThreads)) {
- Heap::postGC(BlinkGC::GCWithSweep);
- ThreadState::resumeThreads();
+ m_state->heap().postGC(BlinkGC::GCWithSweep);
+ m_state->heap().resume();
}
}
@@ -414,10 +414,11 @@ private:
// previously run tests in this process.
static void clearOutOldGarbage()
{
+ ThreadHeap& heap = ThreadState::current()->heap();
while (true) {
- size_t used = Heap::objectPayloadSizeForTesting();
+ size_t used = heap.objectPayloadSizeForTesting();
preciselyCollectGarbage();
- if (Heap::objectPayloadSizeForTesting() >= used)
+ if (heap.objectPayloadSizeForTesting() >= used)
break;
}
}
@@ -544,7 +545,7 @@ protected:
// Taking snapshot shouldn't have any bad side effect.
// TODO(haraken): This snapshot GC causes crashes, so disable
// it at the moment. Fix the crash and enable it.
- // Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::TakeSnapshot, BlinkGC::ForcedGC);
+ // ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::TakeSnapshot, BlinkGC::ForcedGC);
preciselyCollectGarbage();
EXPECT_EQ(wrapper->value(), 0x0bbac0de);
EXPECT_EQ((*globalPersistent)->value(), 0x0ed0cabb);
@@ -559,7 +560,7 @@ protected:
// and freed.
EXPECT_TRUE(longLivingPersistent.leakPtr());
- ThreadState::detach();
+ ThreadState::detachCurrentThread();
atomicDecrement(&m_threadsToFinish);
}
};
@@ -599,7 +600,7 @@ private:
// Taking snapshot shouldn't have any bad side effect.
// TODO(haraken): This snapshot GC causes crashes, so disable
// it at the moment. Fix the crash and enable it.
- // Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::TakeSnapshot, BlinkGC::ForcedGC);
+ // ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::TakeSnapshot, BlinkGC::ForcedGC);
preciselyCollectGarbage();
EXPECT_TRUE(weakMap->isEmpty());
EXPECT_TRUE(weakMap2.isEmpty());
@@ -607,7 +608,7 @@ private:
SafePointScope scope(BlinkGC::NoHeapPointersOnStack);
testing::yieldCurrentThread();
}
- ThreadState::detach();
+ ThreadState::detachCurrentThread();
atomicDecrement(&m_threadsToFinish);
}
};
@@ -676,7 +677,7 @@ protected:
// released. We verify that the draining of persistents proceeds
// as expected by dropping one Persistent<> per GC until there
// are none left.
- ThreadState::detach();
+ ThreadState::detachCurrentThread();
atomicDecrement(&m_threadsToFinish);
}
};
@@ -720,11 +721,11 @@ public:
DEFINE_INLINE_TRACE()
{
- EXPECT_TRUE(Heap::isHeapObjectAlive(this));
+ EXPECT_TRUE(ThreadHeap::isHeapObjectAlive(this));
if (!traceCount())
- EXPECT_FALSE(Heap::isHeapObjectAlive(m_traceCounter));
+ EXPECT_FALSE(ThreadHeap::isHeapObjectAlive(m_traceCounter));
else
- EXPECT_TRUE(Heap::isHeapObjectAlive(m_traceCounter));
+ EXPECT_TRUE(ThreadHeap::isHeapObjectAlive(m_traceCounter));
visitor->trace(m_traceCounter);
}
@@ -776,7 +777,7 @@ public:
{
ThreadState* state = ThreadState::current();
const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(IntNode);
- return Heap::allocateOnArenaIndex(state, size, BlinkGC::NodeArenaIndex, GCInfoTrait<IntNode>::index(), typeName);
+ return ThreadHeap::allocateOnArenaIndex(state, size, BlinkGC::NodeArenaIndex, GCInfoTrait<IntNode>::index(), typeName);
}
static IntNode* create(int i)
@@ -1100,7 +1101,7 @@ public:
void zapWeakMembers(Visitor* visitor)
{
- if (!Heap::isHeapObjectAlive(m_weakBar))
+ if (!ThreadHeap::isHeapObjectAlive(m_weakBar))
m_weakBar = 0;
}
@@ -1295,7 +1296,7 @@ public:
void zapWeakMembers(Visitor* visitor)
{
- if (m_data && !Heap::isHeapObjectAlive(m_data)) {
+ if (m_data && !ThreadHeap::isHeapObjectAlive(m_data)) {
m_data->willFinalize();
m_data = nullptr;
m_didCallWillFinalize = true;
@@ -1619,7 +1620,7 @@ class DynamicallySizedObject : public GarbageCollected<DynamicallySizedObject> {
public:
static DynamicallySizedObject* create(size_t size)
{
- void* slot = Heap::allocate<DynamicallySizedObject>(size);
+ void* slot = ThreadHeap::allocate<DynamicallySizedObject>(size);
return new (slot) DynamicallySizedObject();
}
@@ -1764,8 +1765,9 @@ TEST(HeapTest, ThreadPersistent)
TEST(HeapTest, BasicFunctionality)
{
+ ThreadHeap& heap = ThreadState::current()->heap();
clearOutOldGarbage();
- size_t initialObjectPayloadSize = Heap::objectPayloadSizeForTesting();
+ size_t initialObjectPayloadSize = heap.objectPayloadSizeForTesting();
{
size_t slack = 0;
@@ -1774,7 +1776,7 @@ TEST(HeapTest, BasicFunctionality)
size_t baseLevel = initialObjectPayloadSize;
bool testPagesAllocated = !baseLevel;
if (testPagesAllocated)
- EXPECT_EQ(Heap::allocatedSpace(), 0ul);
+ EXPECT_EQ(heap.heapStats().allocatedSpace(), 0ul);
// This allocates objects on the general heap which should add a page of memory.
DynamicallySizedObject* alloc32 = DynamicallySizedObject::create(32);
@@ -1786,9 +1788,9 @@ TEST(HeapTest, BasicFunctionality)
size_t total = 96;
- CheckWithSlack(baseLevel + total, Heap::objectPayloadSizeForTesting(), slack);
+ CheckWithSlack(baseLevel + total, heap.objectPayloadSizeForTesting(), slack);
if (testPagesAllocated)
- EXPECT_EQ(Heap::allocatedSpace(), blinkPageSize * 2);
+ EXPECT_EQ(heap.heapStats().allocatedSpace(), blinkPageSize * 2);
EXPECT_EQ(alloc32->get(0), 40);
EXPECT_EQ(alloc32->get(31), 40);
@@ -1806,10 +1808,10 @@ TEST(HeapTest, BasicFunctionality)
clearOutOldGarbage();
size_t total = 0;
size_t slack = 0;
- size_t baseLevel = Heap::objectPayloadSizeForTesting();
+ size_t baseLevel = heap.objectPayloadSizeForTesting();
bool testPagesAllocated = !baseLevel;
if (testPagesAllocated)
- EXPECT_EQ(Heap::allocatedSpace(), 0ul);
+ EXPECT_EQ(heap.heapStats().allocatedSpace(), 0ul);
size_t big = 1008;
Persistent<DynamicallySizedObject> bigArea = DynamicallySizedObject::create(big);
@@ -1825,9 +1827,9 @@ TEST(HeapTest, BasicFunctionality)
total += size;
persistents[persistentCount++] = new Persistent<DynamicallySizedObject>(DynamicallySizedObject::create(size));
slack += 4;
- CheckWithSlack(baseLevel + total, Heap::objectPayloadSizeForTesting(), slack);
+ CheckWithSlack(baseLevel + total, heap.objectPayloadSizeForTesting(), slack);
if (testPagesAllocated)
- EXPECT_EQ(0ul, Heap::allocatedSpace() & (blinkPageSize - 1));
+ EXPECT_EQ(0ul, heap.heapStats().allocatedSpace() & (blinkPageSize - 1));
}
{
@@ -1840,16 +1842,16 @@ TEST(HeapTest, BasicFunctionality)
EXPECT_TRUE(alloc32b != alloc64b);
total += 96;
- CheckWithSlack(baseLevel + total, Heap::objectPayloadSizeForTesting(), slack);
+ CheckWithSlack(baseLevel + total, heap.objectPayloadSizeForTesting(), slack);
if (testPagesAllocated)
- EXPECT_EQ(0ul, Heap::allocatedSpace() & (blinkPageSize - 1));
+ EXPECT_EQ(0ul, heap.heapStats().allocatedSpace() & (blinkPageSize - 1));
}
clearOutOldGarbage();
total -= 96;
slack -= 8;
if (testPagesAllocated)
- EXPECT_EQ(0ul, Heap::allocatedSpace() & (blinkPageSize - 1));
+ EXPECT_EQ(0ul, heap.heapStats().allocatedSpace() & (blinkPageSize - 1));
// Clear the persistent, so that the big area will be garbage collected.
bigArea.release();
@@ -1857,42 +1859,43 @@ TEST(HeapTest, BasicFunctionality)
total -= big;
slack -= 4;
- CheckWithSlack(baseLevel + total, Heap::objectPayloadSizeForTesting(), slack);
+ CheckWithSlack(baseLevel + total, heap.objectPayloadSizeForTesting(), slack);
if (testPagesAllocated)
- EXPECT_EQ(0ul, Heap::allocatedSpace() & (blinkPageSize - 1));
+ EXPECT_EQ(0ul, heap.heapStats().allocatedSpace() & (blinkPageSize - 1));
- CheckWithSlack(baseLevel + total, Heap::objectPayloadSizeForTesting(), slack);
+ CheckWithSlack(baseLevel + total, heap.objectPayloadSizeForTesting(), slack);
if (testPagesAllocated)
- EXPECT_EQ(0ul, Heap::allocatedSpace() & (blinkPageSize - 1));
+ EXPECT_EQ(0ul, heap.heapStats().allocatedSpace() & (blinkPageSize - 1));
for (size_t i = 0; i < persistentCount; i++) {
delete persistents[i];
persistents[i] = 0;
}
- uint8_t* address = reinterpret_cast<uint8_t*>(Heap::allocate<DynamicallySizedObject>(100));
+ uint8_t* address = reinterpret_cast<uint8_t*>(ThreadHeap::allocate<DynamicallySizedObject>(100));
for (int i = 0; i < 100; i++)
address[i] = i;
- address = reinterpret_cast<uint8_t*>(Heap::reallocate<DynamicallySizedObject>(address, 100000));
+ address = reinterpret_cast<uint8_t*>(ThreadHeap::reallocate<DynamicallySizedObject>(address, 100000));
for (int i = 0; i < 100; i++)
EXPECT_EQ(address[i], i);
- address = reinterpret_cast<uint8_t*>(Heap::reallocate<DynamicallySizedObject>(address, 50));
+ address = reinterpret_cast<uint8_t*>(ThreadHeap::reallocate<DynamicallySizedObject>(address, 50));
for (int i = 0; i < 50; i++)
EXPECT_EQ(address[i], i);
// This should be equivalent to free(address).
- EXPECT_EQ(reinterpret_cast<uintptr_t>(Heap::reallocate<DynamicallySizedObject>(address, 0)), 0ul);
+ EXPECT_EQ(reinterpret_cast<uintptr_t>(ThreadHeap::reallocate<DynamicallySizedObject>(address, 0)), 0ul);
// This should be equivalent to malloc(0).
- EXPECT_EQ(reinterpret_cast<uintptr_t>(Heap::reallocate<DynamicallySizedObject>(0, 0)), 0ul);
+ EXPECT_EQ(reinterpret_cast<uintptr_t>(ThreadHeap::reallocate<DynamicallySizedObject>(0, 0)), 0ul);
}
TEST(HeapTest, SimpleAllocation)
{
+ ThreadHeap& heap = ThreadState::current()->heap();
clearOutOldGarbage();
- EXPECT_EQ(0ul, Heap::objectPayloadSizeForTesting());
+ EXPECT_EQ(0ul, heap.objectPayloadSizeForTesting());
// Allocate an object in the heap.
HeapAllocatedArray* array = new HeapAllocatedArray();
- EXPECT_TRUE(Heap::objectPayloadSizeForTesting() >= sizeof(HeapAllocatedArray));
+ EXPECT_TRUE(heap.objectPayloadSizeForTesting() >= sizeof(HeapAllocatedArray));
// Sanity check of the contents in the heap.
EXPECT_EQ(0, array->at(0));
@@ -1969,7 +1972,7 @@ TEST(HeapTest, LazySweepingPages)
EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
for (int i = 0; i < 1000; i++)
SimpleFinalizedObject::create();
- Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep, BlinkGC::ForcedGC);
+ ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep, BlinkGC::ForcedGC);
EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
for (int i = 0; i < 10000; i++)
SimpleFinalizedObject::create();
@@ -1996,7 +1999,7 @@ TEST(HeapTest, LazySweepingLargeObjectPages)
EXPECT_EQ(0, LargeHeapObject::s_destructorCalls);
for (int i = 0; i < 10; i++)
LargeHeapObject::create();
- Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep, BlinkGC::ForcedGC);
+ ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep, BlinkGC::ForcedGC);
EXPECT_EQ(0, LargeHeapObject::s_destructorCalls);
for (int i = 0; i < 10; i++) {
LargeHeapObject::create();
@@ -2005,7 +2008,7 @@ TEST(HeapTest, LazySweepingLargeObjectPages)
LargeHeapObject::create();
LargeHeapObject::create();
EXPECT_EQ(10, LargeHeapObject::s_destructorCalls);
- Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep, BlinkGC::ForcedGC);
+ ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep, BlinkGC::ForcedGC);
EXPECT_EQ(10, LargeHeapObject::s_destructorCalls);
preciselyCollectGarbage();
EXPECT_EQ(22, LargeHeapObject::s_destructorCalls);
@@ -2080,7 +2083,7 @@ TEST(HeapTest, EagerlySweepingPages)
SimpleFinalizedEagerObject::create();
for (int i = 0; i < 100; i++)
SimpleFinalizedObjectInstanceOfTemplate::create();
- Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep, BlinkGC::ForcedGC);
+ ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep, BlinkGC::ForcedGC);
EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
EXPECT_EQ(100, SimpleFinalizedEagerObject::s_destructorCalls);
EXPECT_EQ(100, SimpleFinalizedObjectInstanceOfTemplate::s_destructorCalls);
@@ -2220,10 +2223,11 @@ TEST(HeapTest, WideTest)
TEST(HeapTest, HashMapOfMembers)
{
+ ThreadHeap& heap = ThreadState::current()->heap();
IntWrapper::s_destructorCalls = 0;
clearOutOldGarbage();
- size_t initialObjectPayloadSize = Heap::objectPayloadSizeForTesting();
+ size_t initialObjectPayloadSize = heap.objectPayloadSizeForTesting();
{
typedef HeapHashMap<
Member<IntWrapper>,
@@ -2235,11 +2239,11 @@ TEST(HeapTest, HashMapOfMembers)
Persistent<HeapObjectIdentityMap> map = new HeapObjectIdentityMap();
map->clear();
- size_t afterSetWasCreated = Heap::objectPayloadSizeForTesting();
+ size_t afterSetWasCreated = heap.objectPayloadSizeForTesting();
EXPECT_TRUE(afterSetWasCreated > initialObjectPayloadSize);
preciselyCollectGarbage();
- size_t afterGC = Heap::objectPayloadSizeForTesting();
+ size_t afterGC = heap.objectPayloadSizeForTesting();
EXPECT_EQ(afterGC, afterSetWasCreated);
// If the additions below cause garbage collections, these
@@ -2249,7 +2253,7 @@ TEST(HeapTest, HashMapOfMembers)
map->add(one, one);
- size_t afterOneAdd = Heap::objectPayloadSizeForTesting();
+ size_t afterOneAdd = heap.objectPayloadSizeForTesting();
EXPECT_TRUE(afterOneAdd > afterGC);
HeapObjectIdentityMap::iterator it(map->begin());
@@ -2266,7 +2270,7 @@ TEST(HeapTest, HashMapOfMembers)
// stack scanning as that could find a pointer to the
// old backing.
preciselyCollectGarbage();
- size_t afterAddAndGC = Heap::objectPayloadSizeForTesting();
+ size_t afterAddAndGC = heap.objectPayloadSizeForTesting();
EXPECT_TRUE(afterAddAndGC >= afterOneAdd);
EXPECT_EQ(map->size(), 2u); // Two different wrappings of '1' are distinct.
@@ -2279,7 +2283,7 @@ TEST(HeapTest, HashMapOfMembers)
EXPECT_EQ(gotten->value(), one->value());
EXPECT_EQ(gotten, one);
- size_t afterGC2 = Heap::objectPayloadSizeForTesting();
+ size_t afterGC2 = heap.objectPayloadSizeForTesting();
EXPECT_EQ(afterGC2, afterAddAndGC);
IntWrapper* dozen = 0;
@@ -2291,7 +2295,7 @@ TEST(HeapTest, HashMapOfMembers)
if (i == 12)
dozen = iWrapper;
}
- size_t afterAdding1000 = Heap::objectPayloadSizeForTesting();
+ size_t afterAdding1000 = heap.objectPayloadSizeForTesting();
EXPECT_TRUE(afterAdding1000 > afterGC2);
IntWrapper* gross(map->get(dozen));
@@ -2299,34 +2303,36 @@ TEST(HeapTest, HashMapOfMembers)
// This should clear out any junk backings created by all the adds.
preciselyCollectGarbage();
- size_t afterGC3 = Heap::objectPayloadSizeForTesting();
+ size_t afterGC3 = heap.objectPayloadSizeForTesting();
EXPECT_TRUE(afterGC3 <= afterAdding1000);
}
preciselyCollectGarbage();
// The objects 'one', anotherOne, and the 999 other pairs.
EXPECT_EQ(IntWrapper::s_destructorCalls, 2000);
- size_t afterGC4 = Heap::objectPayloadSizeForTesting();
+ size_t afterGC4 = heap.objectPayloadSizeForTesting();
EXPECT_EQ(afterGC4, initialObjectPayloadSize);
}
TEST(HeapTest, NestedAllocation)
{
+ ThreadHeap& heap = ThreadState::current()->heap();
clearOutOldGarbage();
- size_t initialObjectPayloadSize = Heap::objectPayloadSizeForTesting();
+ size_t initialObjectPayloadSize = heap.objectPayloadSizeForTesting();
{
Persistent<ConstructorAllocation> constructorAllocation = ConstructorAllocation::create();
}
clearOutOldGarbage();
- size_t afterFree = Heap::objectPayloadSizeForTesting();
+ size_t afterFree = heap.objectPayloadSizeForTesting();
EXPECT_TRUE(initialObjectPayloadSize == afterFree);
}
TEST(HeapTest, LargeHeapObjects)
{
+ ThreadHeap& heap = ThreadState::current()->heap();
clearOutOldGarbage();
- size_t initialObjectPayloadSize = Heap::objectPayloadSizeForTesting();
- size_t initialAllocatedSpace = Heap::allocatedSpace();
+ size_t initialObjectPayloadSize = heap.objectPayloadSizeForTesting();
+ size_t initialAllocatedSpace = heap.heapStats().allocatedSpace();
IntWrapper::s_destructorCalls = 0;
LargeHeapObject::s_destructorCalls = 0;
{
@@ -2335,15 +2341,15 @@ TEST(HeapTest, LargeHeapObjects)
ASSERT(ThreadState::current()->findPageFromAddress(object));
ASSERT(ThreadState::current()->findPageFromAddress(reinterpret_cast<char*>(object.get()) + sizeof(LargeHeapObject) - 1));
clearOutOldGarbage();
- size_t afterAllocation = Heap::allocatedSpace();
+ size_t afterAllocation = heap.heapStats().allocatedSpace();
{
object->set(0, 'a');
EXPECT_EQ('a', object->get(0));
object->set(object->length() - 1, 'b');
EXPECT_EQ('b', object->get(object->length() - 1));
- size_t expectedLargeHeapObjectPayloadSize = Heap::allocationSizeFromSize(sizeof(LargeHeapObject));
+ size_t expectedLargeHeapObjectPayloadSize = ThreadHeap::allocationSizeFromSize(sizeof(LargeHeapObject));
size_t expectedObjectPayloadSize = expectedLargeHeapObjectPayloadSize + sizeof(IntWrapper);
- size_t actualObjectPayloadSize = Heap::objectPayloadSizeForTesting() - initialObjectPayloadSize;
+ size_t actualObjectPayloadSize = heap.objectPayloadSizeForTesting() - initialObjectPayloadSize;
CheckWithSlack(expectedObjectPayloadSize, actualObjectPayloadSize, slack);
// There is probably space for the IntWrapper in a heap page without
// allocating extra pages. However, the IntWrapper allocation might cause
@@ -2359,13 +2365,13 @@ TEST(HeapTest, LargeHeapObjects)
object = LargeHeapObject::create();
}
clearOutOldGarbage();
- EXPECT_TRUE(Heap::allocatedSpace() == afterAllocation);
+ EXPECT_TRUE(ProcessHeap::totalAllocatedSpace() == afterAllocation);
EXPECT_EQ(10, IntWrapper::s_destructorCalls);
EXPECT_EQ(10, LargeHeapObject::s_destructorCalls);
}
clearOutOldGarbage();
- EXPECT_TRUE(initialObjectPayloadSize == Heap::objectPayloadSizeForTesting());
- EXPECT_TRUE(initialAllocatedSpace == Heap::allocatedSpace());
+ EXPECT_TRUE(initialObjectPayloadSize == heap.objectPayloadSizeForTesting());
+ EXPECT_TRUE(initialAllocatedSpace == heap.heapStats().allocatedSpace());
EXPECT_EQ(11, IntWrapper::s_destructorCalls);
EXPECT_EQ(11, LargeHeapObject::s_destructorCalls);
preciselyCollectGarbage();
@@ -3766,6 +3772,7 @@ TEST(HeapTest, Comparisons)
TEST(HeapTest, CheckAndMarkPointer)
{
+ ThreadHeap& heap = ThreadState::current()->heap();
clearOutOldGarbage();
Vector<Address> objectAddresses;
@@ -3793,15 +3800,15 @@ TEST(HeapTest, CheckAndMarkPointer)
TestGCScope scope(BlinkGC::HeapPointersOnStack);
CountingVisitor visitor(ThreadState::current());
EXPECT_TRUE(scope.allThreadsParked()); // Fail the test if we could not park all threads.
- Heap::flushHeapDoesNotContainCache();
+ heap.flushHeapDoesNotContainCache();
for (size_t i = 0; i < objectAddresses.size(); i++) {
- EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, objectAddresses[i]));
- EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, endAddresses[i]));
+ EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, objectAddresses[i]));
+ EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, endAddresses[i]));
}
EXPECT_EQ(objectAddresses.size() * 2, visitor.count());
visitor.reset();
- EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, largeObjectAddress));
- EXPECT_TRUE(Heap::checkAndMarkPointer(&visitor, largeObjectEndAddress));
+ EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, largeObjectAddress));
+ EXPECT_TRUE(heap.checkAndMarkPointer(&visitor, largeObjectEndAddress));
EXPECT_EQ(2ul, visitor.count());
visitor.reset();
}
@@ -3813,7 +3820,7 @@ TEST(HeapTest, CheckAndMarkPointer)
TestGCScope scope(BlinkGC::HeapPointersOnStack);
CountingVisitor visitor(ThreadState::current());
EXPECT_TRUE(scope.allThreadsParked());
- Heap::flushHeapDoesNotContainCache();
+ heap.flushHeapDoesNotContainCache();
for (size_t i = 0; i < objectAddresses.size(); i++) {
// We would like to assert that checkAndMarkPointer returned false
// here because the pointers no longer point into a valid object
@@ -3822,12 +3829,12 @@ TEST(HeapTest, CheckAndMarkPointer)
// whether it points at a valid object (this ensures the
// correctness of the page-based on-heap address caches), so we
// can't make that assert.
- Heap::checkAndMarkPointer(&visitor, objectAddresses[i]);
- Heap::checkAndMarkPointer(&visitor, endAddresses[i]);
+ heap.checkAndMarkPointer(&visitor, objectAddresses[i]);
+ heap.checkAndMarkPointer(&visitor, endAddresses[i]);
}
EXPECT_EQ(0ul, visitor.count());
- Heap::checkAndMarkPointer(&visitor, largeObjectAddress);
- Heap::checkAndMarkPointer(&visitor, largeObjectEndAddress);
+ heap.checkAndMarkPointer(&visitor, largeObjectAddress);
+ heap.checkAndMarkPointer(&visitor, largeObjectEndAddress);
EXPECT_EQ(0ul, visitor.count());
}
// This round of GC is important to make sure that the object start
@@ -4748,7 +4755,7 @@ private:
testing::yieldCurrentThread();
}
- ThreadState::detach();
+ ThreadState::detachCurrentThread();
s_sleeperRunning = false;
}
@@ -5026,7 +5033,7 @@ struct EmptyClearingHashSetTraits : HashTraits<WeakSet> {
bool liveEntriesFound = false;
WeakSet::iterator end = set.end();
for (WeakSet::iterator it = set.begin(); it != end; ++it) {
- if (Heap::isHeapObjectAlive(*it)) {
+ if (ThreadHeap::isHeapObjectAlive(*it)) {
liveEntriesFound = true;
break;
}
@@ -5459,7 +5466,7 @@ private:
// and the above sweep was the one finalizing the worker object.
parkWorkerThread();
- ThreadState::detach();
+ ThreadState::detachCurrentThread();
}
static volatile uintptr_t s_workerObjectPointer;
@@ -5572,7 +5579,7 @@ private:
}
wakeMainThread();
- ThreadState::detach();
+ ThreadState::detachCurrentThread();
}
static volatile uintptr_t s_workerObjectPointer;
@@ -5740,7 +5747,7 @@ private:
// Tell the main thread the worker has done its sweep.
wakeMainThread();
- ThreadState::detach();
+ ThreadState::detachCurrentThread();
}
static volatile IntWrapper* s_workerObjectPointer;
@@ -5954,7 +5961,7 @@ TEST(HeapTest, AllocationInSuperConstructorArgument)
{
AllocInSuperConstructorArgument* object = new AllocInSuperConstructorArgument();
EXPECT_TRUE(object);
- Heap::collectAllGarbage();
+ ThreadHeap::collectAllGarbage();
}
class NonNodeAllocatingNodeInDestructor : public GarbageCollectedFinalized<NonNodeAllocatingNodeInDestructor> {
@@ -6406,12 +6413,12 @@ void workerThreadMainForCrossThreadWeakPersistentTest(DestructorLockingObject**
parkWorkerThread();
// Step 4: Run a GC.
- Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC);
+ ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC);
wakeMainThread();
parkWorkerThread();
// Step 6: Finish.
- ThreadState::detach();
+ ThreadState::detachCurrentThread();
wakeMainThread();
}

Powered by Google App Engine
This is Rietveld 408576698