| 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 1d0be05168a717ca6d8fb8bba5dc6cf103976c0c..f6f2fe57e784de4ca56ac809fe79a6e1b0c14f0d 100644
|
| --- a/third_party/WebKit/Source/platform/heap/HeapTest.cpp
|
| +++ b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
|
| @@ -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();
|
| }
|
| }
|
|
|
| @@ -282,8 +282,8 @@ private:
|
|
|
| class CountingVisitor : public Visitor {
|
| public:
|
| - CountingVisitor()
|
| - : Visitor(Visitor::ThreadLocalMarking)
|
| + explicit CountingVisitor(VisitorScope* visitorScope)
|
| + : Visitor(Visitor::ThreadLocalMarking, visitorScope)
|
| , m_count(0)
|
| {
|
| }
|
| @@ -414,10 +414,11 @@ private:
|
| // previously run tests in this process.
|
| static void clearOutOldGarbage()
|
| {
|
| + Heap& 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;
|
| }
|
| }
|
| @@ -559,7 +560,7 @@ protected:
|
| // and freed.
|
| EXPECT_TRUE(longLivingPersistent.leakPtr());
|
|
|
| - ThreadState::detach();
|
| + ThreadState::detachCurrentThread();
|
| atomicDecrement(&m_threadsToFinish);
|
| }
|
| };
|
| @@ -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);
|
| }
|
| };
|
| @@ -775,7 +776,7 @@ public:
|
| void* operator new(size_t size)
|
| {
|
| ThreadState* state = ThreadState::current();
|
| - return Heap::allocateOnHeapIndex(state, size, BlinkGC::NodeHeapIndex, GCInfoTrait<IntNode>::index());
|
| + return Heap::allocateOnArenaIndex(state, size, BlinkGC::NodeArenaIndex, GCInfoTrait<IntNode>::index());
|
| }
|
|
|
| static IntNode* create(int i)
|
| @@ -1033,8 +1034,9 @@ int RefCountedAndGarbageCollected2::s_destructorCalls = 0;
|
|
|
| class RefCountedGarbageCollectedVisitor : public CountingVisitor {
|
| public:
|
| - RefCountedGarbageCollectedVisitor(int expected, void** objects)
|
| - : m_count(0)
|
| + RefCountedGarbageCollectedVisitor(int expected, void** objects, VisitorScope* visitorScope)
|
| + : CountingVisitor(visitorScope)
|
| + , m_count(0)
|
| , m_expectedCount(expected)
|
| , m_expectedObjects(objects)
|
| {
|
| @@ -1762,8 +1764,9 @@ TEST(HeapTest, ThreadPersistent)
|
|
|
| TEST(HeapTest, BasicFunctionality)
|
| {
|
| + Heap& heap = ThreadState::current()->heap();
|
| clearOutOldGarbage();
|
| - size_t initialObjectPayloadSize = Heap::objectPayloadSizeForTesting();
|
| + size_t initialObjectPayloadSize = heap.objectPayloadSizeForTesting();
|
| {
|
| size_t slack = 0;
|
|
|
| @@ -1772,7 +1775,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);
|
| @@ -1784,9 +1787,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);
|
| @@ -1804,10 +1807,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);
|
| @@ -1823,9 +1826,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));
|
| }
|
|
|
| {
|
| @@ -1838,16 +1841,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();
|
| @@ -1855,13 +1858,13 @@ 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];
|
| @@ -1885,12 +1888,13 @@ TEST(HeapTest, BasicFunctionality)
|
|
|
| TEST(HeapTest, SimpleAllocation)
|
| {
|
| + Heap& 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));
|
| @@ -2218,10 +2222,11 @@ TEST(HeapTest, WideTest)
|
|
|
| TEST(HeapTest, HashMapOfMembers)
|
| {
|
| + Heap& heap = ThreadState::current()->heap();
|
| IntWrapper::s_destructorCalls = 0;
|
|
|
| clearOutOldGarbage();
|
| - size_t initialObjectPayloadSize = Heap::objectPayloadSizeForTesting();
|
| + size_t initialObjectPayloadSize = heap.objectPayloadSizeForTesting();
|
| {
|
| typedef HeapHashMap<
|
| Member<IntWrapper>,
|
| @@ -2233,11 +2238,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
|
| @@ -2247,7 +2252,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());
|
| @@ -2264,7 +2269,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.
|
| @@ -2277,7 +2282,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;
|
| @@ -2289,7 +2294,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));
|
| @@ -2297,34 +2302,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)
|
| {
|
| + Heap& 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)
|
| {
|
| + Heap& 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;
|
| {
|
| @@ -2333,7 +2340,7 @@ 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));
|
| @@ -2341,7 +2348,7 @@ TEST(HeapTest, LargeHeapObjects)
|
| EXPECT_EQ('b', object->get(object->length() - 1));
|
| size_t expectedLargeHeapObjectPayloadSize = Heap::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
|
| @@ -2357,13 +2364,13 @@ TEST(HeapTest, LargeHeapObjects)
|
| object = LargeHeapObject::create();
|
| }
|
| clearOutOldGarbage();
|
| - EXPECT_TRUE(Heap::allocatedSpace() == afterAllocation);
|
| + EXPECT_TRUE(heap.heapStats().allocatedSpace() == 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();
|
| @@ -3596,37 +3603,41 @@ TEST(HeapTest, RefCountedGarbageCollectedWithStackPointers)
|
| pointer1 = object1.get();
|
| pointer2 = object2.get();
|
| void* objects[2] = { object1.get(), object2.get() };
|
| - RefCountedGarbageCollectedVisitor visitor(2, objects);
|
| + VisitorScope visitorScope(ThreadState::current(), BlinkGC::GCWithSweep);
|
| + RefCountedGarbageCollectedVisitor visitor(2, objects, &visitorScope);
|
| ThreadState::current()->visitPersistents(&visitor);
|
| EXPECT_TRUE(visitor.validate());
|
| -
|
| - conservativelyCollectGarbage();
|
| - EXPECT_EQ(0, RefCountedAndGarbageCollected::s_destructorCalls);
|
| - EXPECT_EQ(0, RefCountedAndGarbageCollected2::s_destructorCalls);
|
| }
|
| conservativelyCollectGarbage();
|
| EXPECT_EQ(0, RefCountedAndGarbageCollected::s_destructorCalls);
|
| EXPECT_EQ(0, RefCountedAndGarbageCollected2::s_destructorCalls);
|
|
|
| - // At this point, the reference counts of object1 and object2 are 0.
|
| - // Only pointer1 and pointer2 keep references to object1 and object2.
|
| - void* objects[] = { 0 };
|
| - RefCountedGarbageCollectedVisitor visitor(0, objects);
|
| - ThreadState::current()->visitPersistents(&visitor);
|
| - EXPECT_TRUE(visitor.validate());
|
| + conservativelyCollectGarbage();
|
| + EXPECT_EQ(0, RefCountedAndGarbageCollected::s_destructorCalls);
|
| + EXPECT_EQ(0, RefCountedAndGarbageCollected2::s_destructorCalls);
|
| +
|
| + {
|
| + // At this point, the reference counts of object1 and object2 are 0.
|
| + // Only pointer1 and pointer2 keep references to object1 and object2.
|
| + void* objects[] = { 0 };
|
| + VisitorScope visitorScope(ThreadState::current(), BlinkGC::GCWithSweep);
|
| + RefCountedGarbageCollectedVisitor visitor(0, objects, &visitorScope);
|
| + ThreadState::current()->visitPersistents(&visitor);
|
| + EXPECT_TRUE(visitor.validate());
|
| + }
|
|
|
| {
|
| Persistent<RefCountedAndGarbageCollected> object1(pointer1);
|
| Persistent<RefCountedAndGarbageCollected2> object2(pointer2);
|
| void* objects[2] = { object1.get(), object2.get() };
|
| - RefCountedGarbageCollectedVisitor visitor(2, objects);
|
| + VisitorScope visitorScope(ThreadState::current(), BlinkGC::GCWithSweep);
|
| + RefCountedGarbageCollectedVisitor visitor(2, objects, &visitorScope);
|
| ThreadState::current()->visitPersistents(&visitor);
|
| EXPECT_TRUE(visitor.validate());
|
| -
|
| - conservativelyCollectGarbage();
|
| - EXPECT_EQ(0, RefCountedAndGarbageCollected::s_destructorCalls);
|
| - EXPECT_EQ(0, RefCountedAndGarbageCollected2::s_destructorCalls);
|
| }
|
| + conservativelyCollectGarbage();
|
| + EXPECT_EQ(0, RefCountedAndGarbageCollected::s_destructorCalls);
|
| + EXPECT_EQ(0, RefCountedAndGarbageCollected2::s_destructorCalls);
|
|
|
| conservativelyCollectGarbage();
|
| EXPECT_EQ(0, RefCountedAndGarbageCollected::s_destructorCalls);
|
| @@ -3763,13 +3774,13 @@ TEST(HeapTest, Comparisons)
|
|
|
| TEST(HeapTest, CheckAndMarkPointer)
|
| {
|
| + Heap& heap = ThreadState::current()->heap();
|
| clearOutOldGarbage();
|
|
|
| Vector<Address> objectAddresses;
|
| Vector<Address> endAddresses;
|
| Address largeObjectAddress;
|
| Address largeObjectEndAddress;
|
| - CountingVisitor visitor;
|
| for (int i = 0; i < 10; i++) {
|
| SimpleObject* object = SimpleObject::create();
|
| Address objectAddress = reinterpret_cast<Address>(object);
|
| @@ -3788,17 +3799,19 @@ TEST(HeapTest, CheckAndMarkPointer)
|
| // to allocate anything again. We do this by forcing a GC after doing the
|
| // checkAndMarkPointer tests.
|
| {
|
| + VisitorScope visitorScope(ThreadState::current(), BlinkGC::GCWithSweep);
|
| + CountingVisitor visitor(&visitorScope);
|
| TestGCScope scope(BlinkGC::HeapPointersOnStack);
|
| 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();
|
| }
|
| @@ -3807,9 +3820,11 @@ TEST(HeapTest, CheckAndMarkPointer)
|
| // however we don't rely on that below since we don't have any allocations.
|
| clearOutOldGarbage();
|
| {
|
| + VisitorScope visitorScope(ThreadState::current(), BlinkGC::GCWithSweep);
|
| + CountingVisitor visitor(&visitorScope);
|
| TestGCScope scope(BlinkGC::HeapPointersOnStack);
|
| 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
|
| @@ -3818,12 +3833,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
|
| @@ -4744,7 +4759,7 @@ private:
|
| testing::yieldCurrentThread();
|
| }
|
|
|
| - ThreadState::detach();
|
| + ThreadState::detachCurrentThread();
|
| s_sleeperRunning = false;
|
| }
|
|
|
| @@ -5455,7 +5470,7 @@ private:
|
| // and the above sweep was the one finalizing the worker object.
|
| parkWorkerThread();
|
|
|
| - ThreadState::detach();
|
| + ThreadState::detachCurrentThread();
|
| }
|
|
|
| static volatile uintptr_t s_workerObjectPointer;
|
| @@ -5568,7 +5583,7 @@ private:
|
| }
|
|
|
| wakeMainThread();
|
| - ThreadState::detach();
|
| + ThreadState::detachCurrentThread();
|
| }
|
|
|
| static volatile uintptr_t s_workerObjectPointer;
|
| @@ -5736,7 +5751,7 @@ private:
|
| // Tell the main thread the worker has done its sweep.
|
| wakeMainThread();
|
|
|
| - ThreadState::detach();
|
| + ThreadState::detachCurrentThread();
|
| }
|
|
|
| static volatile IntWrapper* s_workerObjectPointer;
|
| @@ -5784,7 +5799,7 @@ private:
|
| wakeMainThread();
|
| parkWorkerThread();
|
|
|
| - ThreadState::detach();
|
| + ThreadState::detachCurrentThread();
|
| wakeMainThread();
|
| }
|
| };
|
| @@ -5820,7 +5835,8 @@ private:
|
|
|
| TEST(HeapTest, TraceIfNeeded)
|
| {
|
| - CountingVisitor visitor;
|
| + VisitorScope visitorScope(ThreadState::current(), BlinkGC::GCWithSweep);
|
| + CountingVisitor visitor(&visitorScope);
|
|
|
| {
|
| TraceIfNeededTester<RefPtr<OffHeapInt>>* m_offHeap = TraceIfNeededTester<RefPtr<OffHeapInt>>::create(OffHeapInt::create(42));
|
| @@ -6454,7 +6470,7 @@ void workerThreadMainForCrossThreadWeakPersistentTest(DestructorLockingObject**
|
| parkWorkerThread();
|
|
|
| // Step 6: Finish.
|
| - ThreadState::detach();
|
| + ThreadState::detachCurrentThread();
|
| wakeMainThread();
|
| }
|
|
|
|
|