[heap] Cleanup cctests

- Move into v8::internal::heap namespace
- Remove card marking ifdefs

Bug: 
Change-Id: Ifd5e5d96c6ab0fea85a3646e5b307583eb13e2c3
Reviewed-on: https://chromium-review.googlesource.com/612066
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47305}
This commit is contained in:
Michael Lippautz 2017-08-11 12:04:47 +02:00 committed by Commit Bot
parent f3d48f56a8
commit 1092155c16
17 changed files with 86 additions and 102 deletions

View File

@ -26,6 +26,11 @@
namespace v8 {
namespace internal {
namespace heap {
class HeapTester;
class TestMemoryAllocatorScope;
} // namespace heap
using v8::MemoryPressureLevel;
// Defines all the roots in Heap.
@ -2432,7 +2437,7 @@ class Heap {
friend class PagedSpace;
friend class Scavenger;
friend class StoreBuffer;
friend class TestMemoryAllocatorScope;
friend class heap::TestMemoryAllocatorScope;
// The allocator interface.
friend class Factory;
@ -2441,7 +2446,7 @@ class Heap {
friend class Isolate;
// Used in cctest.
friend class HeapTester;
friend class heap::HeapTester;
DISALLOW_COPY_AND_ASSIGN(Heap);
};

View File

@ -31,6 +31,11 @@
namespace v8 {
namespace internal {
namespace heap {
class HeapTester;
class TestCodeRangeScope;
} // namespace heap
class AllocationInfo;
class AllocationObserver;
class CompactionSpace;
@ -1432,7 +1437,7 @@ class V8_EXPORT_PRIVATE MemoryAllocator {
base::VirtualMemory last_chunk_;
Unmapper unmapper_;
friend class TestCodeRangeScope;
friend class heap::TestCodeRangeScope;
DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryAllocator);
};
@ -2224,7 +2229,7 @@ class V8_EXPORT_PRIVATE PagedSpace : NON_EXPORTED_BASE(public Space) {
friend class MarkCompactCollector;
// Used in cctest.
friend class HeapTester;
friend class heap::HeapTester;
};
enum SemiSpaceId { kFromSpace = 0, kToSpace = 1 };

View File

@ -40,6 +40,10 @@ class ConsoleDelegate;
namespace internal {
namespace heap {
class HeapTester;
} // namespace heap
class AccessCompilerData;
class AddressToIndexHashMap;
class AstStringConstants;
@ -1611,7 +1615,7 @@ class Isolate {
friend class ExecutionAccess;
friend class HandleScopeImplementer;
friend class HeapTester;
friend class heap::HeapTester;
friend class OptimizingCompileDispatcher;
friend class SweeperThread;
friend class ThreadManager;

View File

@ -43,28 +43,29 @@
V(RegressMissingWriteBarrierInAllocate) \
V(WriteBarriersInCopyJSObject)
#define HEAP_TEST(Name) \
CcTest register_test_##Name(v8::internal::HeapTester::Test##Name, __FILE__, \
#Name, true, true); \
void v8::internal::HeapTester::Test##Name()
#define HEAP_TEST(Name) \
CcTest register_test_##Name(v8::internal::heap::HeapTester::Test##Name, \
__FILE__, #Name, true, true); \
void v8::internal::heap::HeapTester::Test##Name()
#define UNINITIALIZED_HEAP_TEST(Name) \
CcTest register_test_##Name(v8::internal::HeapTester::Test##Name, __FILE__, \
#Name, true, false); \
void v8::internal::HeapTester::Test##Name()
#define UNINITIALIZED_HEAP_TEST(Name) \
CcTest register_test_##Name(v8::internal::heap::HeapTester::Test##Name, \
__FILE__, #Name, true, false); \
void v8::internal::heap::HeapTester::Test##Name()
#define THREADED_HEAP_TEST(Name) \
RegisterThreadedTest register_##Name(v8::internal::HeapTester::Test##Name, \
#Name); \
#define THREADED_HEAP_TEST(Name) \
RegisterThreadedTest register_##Name( \
v8::internal::heap::HeapTester::Test##Name, #Name); \
/* */ HEAP_TEST(Name)
namespace v8 {
namespace internal {
template <typename T>
class Handle;
namespace heap {
class HeapTester {
public:
#define DECLARE_STATIC(Name) static void Test##Name();
@ -84,6 +85,7 @@ class HeapTester {
static void ResetWeakHandle(bool global_gc);
};
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -37,8 +37,11 @@
using namespace v8::internal;
namespace v8 {
namespace internal {
namespace heap {
AllocationResult v8::internal::HeapTester::AllocateAfterFailures() {
AllocationResult HeapTester::AllocateAfterFailures() {
Heap* heap = CcTest::heap();
// New space.
@ -90,8 +93,7 @@ AllocationResult v8::internal::HeapTester::AllocateAfterFailures() {
return heap->true_value();
}
Handle<Object> v8::internal::HeapTester::TestAllocateAfterFailures() {
Handle<Object> HeapTester::TestAllocateAfterFailures() {
// Similar to what the CALL_AND_RETRY macro does in the last-resort case, we
// are wrapping the allocator function in an AlwaysAllocateScope. Test that
// all allocations succeed immediately without any retry.
@ -116,8 +118,8 @@ void TestGetter(
const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
HandleScope scope(isolate);
info.GetReturnValue().Set(v8::Utils::ToLocal(
v8::internal::HeapTester::TestAllocateAfterFailures()));
info.GetReturnValue().Set(
v8::Utils::ToLocal(HeapTester::TestAllocateAfterFailures()));
}
void TestSetter(v8::Local<v8::Name> name, v8::Local<v8::Value> value,
@ -196,6 +198,7 @@ unsigned int Pseudorandom() {
return lo & 0xFFFF;
}
namespace {
// Plain old data class. Represents a block of allocated memory.
class Block {
@ -207,6 +210,7 @@ class Block {
int size;
};
} // namespace
TEST(CodeRange) {
const size_t code_range_size = 32*MB;
@ -215,7 +219,7 @@ TEST(CodeRange) {
code_range.SetUp(code_range_size);
size_t current_allocated = 0;
size_t total_allocated = 0;
List< ::Block> blocks(1000);
List<Block> blocks(1000);
while (total_allocated < 5 * code_range_size) {
if (current_allocated < code_range_size / 10) {
@ -234,7 +238,7 @@ TEST(CodeRange) {
requested, requested - (2 * MemoryAllocator::CodePageGuardSize()),
&allocated);
CHECK(base != NULL);
blocks.Add(::Block(base, static_cast<int>(allocated)));
blocks.Add(Block(base, static_cast<int>(allocated)));
current_allocated += static_cast<int>(allocated);
total_allocated += static_cast<int>(allocated);
} else {
@ -250,3 +254,7 @@ TEST(CodeRange) {
}
}
}
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -22,6 +22,7 @@ bool IsTracked(i::JSArrayBuffer* buf) {
namespace v8 {
namespace internal {
namespace heap {
// The following tests make sure that JSArrayBuffer tracking works expected when
// moving the objects through various spaces during GC phases.
@ -371,5 +372,6 @@ TEST(ArrayBuffer_RetainedSizeDecreases) {
CHECK_EQ(0, retained_after - retained_before);
}
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -18,6 +18,7 @@
namespace v8 {
namespace internal {
namespace heap {
namespace {
@ -374,5 +375,6 @@ HEAP_TEST(CompactionPartiallyAbortedPageWithStoreBufferEntries) {
}
}
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -16,6 +16,7 @@
namespace v8 {
namespace internal {
namespace heap {
void PublishSegment(ConcurrentMarking::MarkingWorklist* worklist,
HeapObject* object) {
@ -57,5 +58,6 @@ TEST(ConcurrentMarkingReschedule) {
delete concurrent_marking;
}
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -57,6 +57,7 @@
namespace v8 {
namespace internal {
namespace heap {
// We only start allocation-site tracking with the second instantiation.
static const int kPretenureCreationCount =
@ -6222,5 +6223,6 @@ UNINITIALIZED_TEST(ReinitializeStringHashSeed) {
}
}
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -30,6 +30,7 @@ using v8::Isolate;
namespace v8 {
namespace internal {
namespace heap {
class MockPlatform : public TestPlatform {
public:
@ -74,5 +75,6 @@ TEST(IncrementalMarkingUsingTasks) {
CHECK(marking->IsStopped());
}
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -16,8 +16,9 @@
namespace v8 {
namespace internal {
namespace heap {
Page* v8::internal::HeapTester::AllocateByteArraysOnPage(
Page* HeapTester::AllocateByteArraysOnPage(
Heap* heap, std::vector<ByteArray*>* byte_arrays) {
const int kLength = 256 - ByteArray::kHeaderSize;
const int kSize = ByteArray::SizeFor(kLength);
@ -181,5 +182,6 @@ HEAP_TEST(InvalidatedSlotsResetObjectRegression) {
}
}
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -15,6 +15,7 @@
namespace v8 {
namespace internal {
namespace heap {
static Address AllocateLabBackingStore(Heap* heap, intptr_t size_in_bytes) {
AllocationResult result = heap->old_space()->AllocateRaw(
@ -283,5 +284,6 @@ TEST(AllocateAligned) {
}
#endif // V8_HOST_ARCH_32_BIT
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -52,6 +52,10 @@
using namespace v8::internal;
using v8::Just;
namespace v8 {
namespace internal {
namespace heap {
TEST(SequentialMarkingDeque) {
CcTest::InitializeVM();
SequentialMarkingDeque s(CcTest::i_isolate()->heap());
@ -364,3 +368,7 @@ TEST(Regress5829) {
}
#endif // __linux__ and !USE_SIMULATOR
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -15,6 +15,7 @@
namespace v8 {
namespace internal {
namespace heap {
namespace {
@ -197,5 +198,6 @@ UNINITIALIZED_HEAP_TEST(Regress658718) {
isolate->Dispose();
}
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -28,6 +28,7 @@
#include <stdlib.h>
#include "src/base/platform/platform.h"
#include "src/factory.h"
#include "src/heap/spaces-inl.h"
// FIXME(mstarzinger, marja): This is weird, but required because of the missing
// (disallowed) include: src/heap/incremental-marking.h -> src/objects-inl.h
@ -40,72 +41,7 @@
namespace v8 {
namespace internal {
#if 0
static void VerifyRegionMarking(Address page_start) {
#ifdef ENABLE_CARDMARKING_WRITE_BARRIER
Page* p = Page::FromAddress(page_start);
p->SetRegionMarks(Page::kAllRegionsCleanMarks);
for (Address addr = p->ObjectAreaStart();
addr < p->ObjectAreaEnd();
addr += kPointerSize) {
CHECK(!Page::FromAddress(addr)->IsRegionDirty(addr));
}
for (Address addr = p->ObjectAreaStart();
addr < p->ObjectAreaEnd();
addr += kPointerSize) {
Page::FromAddress(addr)->MarkRegionDirty(addr);
}
for (Address addr = p->ObjectAreaStart();
addr < p->ObjectAreaEnd();
addr += kPointerSize) {
CHECK(Page::FromAddress(addr)->IsRegionDirty(addr));
}
#endif
}
#endif
// TODO(gc) you can no longer allocate pages like this. Details are hidden.
#if 0
TEST(Page) {
byte* mem = NewArray<byte>(2*Page::kPageSize);
CHECK(mem != NULL);
Address start = reinterpret_cast<Address>(mem);
Address page_start = RoundUp(start, Page::kPageSize);
Page* p = Page::FromAddress(page_start);
// Initialized Page has heap pointer, normally set by memory_allocator.
p->heap_ = CcTest::heap();
CHECK(p->address() == page_start);
CHECK(p->is_valid());
p->opaque_header = 0;
p->SetIsLargeObjectPage(false);
CHECK(!p->next_page()->is_valid());
CHECK(p->ObjectAreaStart() == page_start + Page::kObjectStartOffset);
CHECK(p->ObjectAreaEnd() == page_start + Page::kPageSize);
CHECK(p->Offset(page_start + Page::kObjectStartOffset) ==
Page::kObjectStartOffset);
CHECK(p->Offset(page_start + Page::kPageSize) == Page::kPageSize);
CHECK(p->OffsetToAddress(Page::kObjectStartOffset) == p->ObjectAreaStart());
CHECK(p->OffsetToAddress(Page::kPageSize) == p->ObjectAreaEnd());
// test region marking
VerifyRegionMarking(page_start);
DeleteArray(mem);
}
#endif
namespace heap {
// Temporarily sets a given allocator in an isolate.
class TestMemoryAllocatorScope {
@ -759,5 +695,6 @@ TEST(ShrinkPageToHighWaterMarkTwoWordFiller) {
CHECK_EQ(0u, shrunk);
}
} // namespace heap
} // namespace internal
} // namespace v8

View File

@ -7787,8 +7787,7 @@ static void ResetUseValueAndSetFlag(
data.GetParameter()->flag = true;
}
void v8::internal::HeapTester::ResetWeakHandle(bool global_gc) {
void v8::internal::heap::HeapTester::ResetWeakHandle(bool global_gc) {
using v8::Context;
using v8::Local;
using v8::Object;
@ -7835,8 +7834,8 @@ void v8::internal::HeapTester::ResetWeakHandle(bool global_gc) {
THREADED_HEAP_TEST(ResetWeakHandle) {
v8::internal::HeapTester::ResetWeakHandle(false);
v8::internal::HeapTester::ResetWeakHandle(true);
v8::internal::heap::HeapTester::ResetWeakHandle(false);
v8::internal::heap::HeapTester::ResetWeakHandle(true);
}
static void InvokeScavenge() { CcTest::CollectGarbage(i::NEW_SPACE); }

View File

@ -6065,11 +6065,11 @@ TEST(Regress131642) {
// Import from test-heap.cc
namespace v8 {
namespace internal {
namespace heap {
int CountNativeContexts();
}
}
} // namespace heap
} // namespace internal
} // namespace v8
static void NopListener(const v8::Debug::EventDetails& event_details) {
}
@ -6078,15 +6078,15 @@ static void NopListener(const v8::Debug::EventDetails& event_details) {
TEST(DebuggerCreatesContextIffActive) {
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
CHECK_EQ(1, v8::internal::CountNativeContexts());
CHECK_EQ(1, v8::internal::heap::CountNativeContexts());
SetDebugEventListener(env->GetIsolate(), nullptr);
CompileRun("debugger;");
CHECK_EQ(1, v8::internal::CountNativeContexts());
CHECK_EQ(1, v8::internal::heap::CountNativeContexts());
SetDebugEventListener(env->GetIsolate(), NopListener);
CompileRun("debugger;");
CHECK_EQ(2, v8::internal::CountNativeContexts());
CHECK_EQ(2, v8::internal::heap::CountNativeContexts());
SetDebugEventListener(env->GetIsolate(), nullptr);
}