Index: test/cctest/test-spaces.cc |
diff --git a/test/cctest/test-spaces.cc b/test/cctest/test-spaces.cc |
index 00620944002c0c533fca61c844ff81d66e932891..3c59610065d6b568f4284b1d28e10f47b1370393 100644 |
--- a/test/cctest/test-spaces.cc |
+++ b/test/cctest/test-spaces.cc |
@@ -203,6 +203,28 @@ static void VerifyMemoryChunk(Isolate* isolate, |
} |
+TEST(Regress3540) { |
+ Isolate* isolate = CcTest::i_isolate(); |
+ isolate->InitializeLoggingAndCounters(); |
+ Heap* heap = isolate->heap(); |
+ CHECK(heap->ConfigureHeapDefault()); |
+ MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
+ CHECK( |
+ memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize())); |
+ TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); |
+ CodeRange* code_range = new CodeRange(isolate); |
+ const size_t code_range_size = 4 * MB; |
+ if (!code_range->SetUp(code_range_size)) return; |
+ size_t allocated_size; |
+ Address result; |
+ for (int i = 0; i < 5; i++) { |
+ result = code_range->AllocateRawMemory( |
+ code_range_size - MB, code_range_size - MB, &allocated_size); |
+ CHECK((result != NULL) == (i == 0)); |
+ } |
+} |
+ |
+ |
static unsigned int Pseudorandom() { |
static uint32_t lo = 2345; |
lo = 18273 * (lo & 0xFFFFF) + (lo >> 16); |