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

Unified Diff: test/cctest/test-spaces.cc

Issue 12049069: Revert r13494: "Use MemoryChunk-based allocation for deoptimization entry code" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-spaces.cc
diff --git a/test/cctest/test-spaces.cc b/test/cctest/test-spaces.cc
index 1f362d7e7afe71346fcb6f9cc76c5be0c05987d0..0e957048ee78ef0237db92202cf2cb4bad0030a5 100644
--- a/test/cctest/test-spaces.cc
+++ b/test/cctest/test-spaces.cc
@@ -121,148 +121,9 @@ class TestMemoryAllocatorScope {
DISALLOW_COPY_AND_ASSIGN(TestMemoryAllocatorScope);
};
-
-// Temporarily sets a given code range in an isolate.
-class TestCodeRangeScope {
- public:
- TestCodeRangeScope(Isolate* isolate, CodeRange* code_range)
- : isolate_(isolate),
- old_code_range_(isolate->code_range_) {
- isolate->code_range_ = code_range;
- }
-
- ~TestCodeRangeScope() {
- isolate_->code_range_ = old_code_range_;
- }
-
- private:
- Isolate* isolate_;
- CodeRange* old_code_range_;
-
- DISALLOW_COPY_AND_ASSIGN(TestCodeRangeScope);
-};
-
} } // namespace v8::internal
-static void VerifyMemoryChunk(Isolate* isolate,
- Heap* heap,
- CodeRange* code_range,
- size_t reserve_area_size,
- size_t commit_area_size,
- size_t second_commit_area_size,
- Executability executable) {
- MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
- CHECK(memory_allocator->SetUp(heap->MaxReserved(),
- heap->MaxExecutableSize()));
- TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator);
- TestCodeRangeScope test_code_range_scope(isolate, code_range);
-
- size_t header_size = (executable == EXECUTABLE)
- ? MemoryAllocator::CodePageGuardStartOffset()
- : MemoryChunk::kObjectStartOffset;
- size_t guard_size = (executable == EXECUTABLE)
- ? MemoryAllocator::CodePageGuardSize()
- : 0;
-
- MemoryChunk* memory_chunk = memory_allocator->AllocateChunk(reserve_area_size,
- commit_area_size,
- executable,
- NULL);
- size_t alignment = code_range->exists() ?
- MemoryChunk::kAlignment : OS::CommitPageSize();
- size_t reserved_size = ((executable == EXECUTABLE))
- ? RoundUp(header_size + guard_size + reserve_area_size + guard_size,
- alignment)
- : RoundUp(header_size + reserve_area_size, OS::CommitPageSize());
- CHECK(memory_chunk->size() == reserved_size);
- CHECK(memory_chunk->area_start() < memory_chunk->address() +
- memory_chunk->size());
- CHECK(memory_chunk->area_end() <= memory_chunk->address() +
- memory_chunk->size());
- CHECK(static_cast<size_t>(memory_chunk->area_size()) == commit_area_size);
-
- Address area_start = memory_chunk->area_start();
-
- memory_chunk->CommitArea(second_commit_area_size);
- CHECK(area_start == memory_chunk->area_start());
- CHECK(memory_chunk->area_start() < memory_chunk->address() +
- memory_chunk->size());
- CHECK(memory_chunk->area_end() <= memory_chunk->address() +
- memory_chunk->size());
- CHECK(static_cast<size_t>(memory_chunk->area_size()) ==
- second_commit_area_size);
-
- memory_allocator->Free(memory_chunk);
- memory_allocator->TearDown();
- delete memory_allocator;
-}
-
-
-static unsigned int Pseudorandom() {
- static uint32_t lo = 2345;
- lo = 18273 * (lo & 0xFFFFF) + (lo >> 16);
- return lo & 0xFFFFF;
-}
-
-
-TEST(MemoryChunk) {
- OS::SetUp();
- Isolate* isolate = Isolate::Current();
- isolate->InitializeLoggingAndCounters();
- Heap* heap = isolate->heap();
- CHECK(heap->ConfigureHeapDefault());
-
- size_t reserve_area_size = 1 * MB;
- size_t initial_commit_area_size, second_commit_area_size;
-
- for (int i = 0; i < 100; i++) {
- initial_commit_area_size = Pseudorandom();
- second_commit_area_size = Pseudorandom();
-
- // With CodeRange.
- CodeRange* code_range = new CodeRange(isolate);
- const int code_range_size = 32 * MB;
- if (!code_range->SetUp(code_range_size)) return;
-
- VerifyMemoryChunk(isolate,
- heap,
- code_range,
- reserve_area_size,
- initial_commit_area_size,
- second_commit_area_size,
- EXECUTABLE);
-
- VerifyMemoryChunk(isolate,
- heap,
- code_range,
- reserve_area_size,
- initial_commit_area_size,
- second_commit_area_size,
- NOT_EXECUTABLE);
- delete code_range;
-
- // Without CodeRange.
- code_range = NULL;
- VerifyMemoryChunk(isolate,
- heap,
- code_range,
- reserve_area_size,
- initial_commit_area_size,
- second_commit_area_size,
- EXECUTABLE);
-
- VerifyMemoryChunk(isolate,
- heap,
- code_range,
- reserve_area_size,
- initial_commit_area_size,
- second_commit_area_size,
- NOT_EXECUTABLE);
- }
-}
-
-
TEST(MemoryAllocator) {
OS::SetUp();
Isolate* isolate = Isolate::Current();
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698