| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 149 |
| 150 | 150 |
| 151 static void VerifyMemoryChunk(Isolate* isolate, | 151 static void VerifyMemoryChunk(Isolate* isolate, |
| 152 Heap* heap, | 152 Heap* heap, |
| 153 CodeRange* code_range, | 153 CodeRange* code_range, |
| 154 size_t reserve_area_size, | 154 size_t reserve_area_size, |
| 155 size_t commit_area_size, | 155 size_t commit_area_size, |
| 156 size_t second_commit_area_size, | 156 size_t second_commit_area_size, |
| 157 Executability executable) { | 157 Executability executable) { |
| 158 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 158 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
| 159 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(), | 159 CHECK(memory_allocator->SetUp(heap->MaxReserved(), 0)); |
| 160 0)); | |
| 161 { | 160 { |
| 162 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); | 161 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); |
| 163 TestCodeRangeScope test_code_range_scope(isolate, code_range); | 162 TestCodeRangeScope test_code_range_scope(isolate, code_range); |
| 164 | 163 |
| 165 size_t header_size = (executable == EXECUTABLE) | 164 size_t header_size = (executable == EXECUTABLE) |
| 166 ? MemoryAllocator::CodePageGuardStartOffset() | 165 ? MemoryAllocator::CodePageGuardStartOffset() |
| 167 : MemoryChunk::kObjectStartOffset; | 166 : MemoryChunk::kObjectStartOffset; |
| 168 size_t guard_size = | 167 size_t guard_size = |
| 169 (executable == EXECUTABLE) ? MemoryAllocator::CodePageGuardSize() : 0; | 168 (executable == EXECUTABLE) ? MemoryAllocator::CodePageGuardSize() : 0; |
| 170 | 169 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 201 } | 200 } |
| 202 memory_allocator->TearDown(); | 201 memory_allocator->TearDown(); |
| 203 delete memory_allocator; | 202 delete memory_allocator; |
| 204 } | 203 } |
| 205 | 204 |
| 206 | 205 |
| 207 TEST(Regress3540) { | 206 TEST(Regress3540) { |
| 208 Isolate* isolate = CcTest::i_isolate(); | 207 Isolate* isolate = CcTest::i_isolate(); |
| 209 Heap* heap = isolate->heap(); | 208 Heap* heap = isolate->heap(); |
| 210 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 209 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
| 211 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(), | 210 CHECK(memory_allocator->SetUp(heap->MaxReserved(), 0)); |
| 212 0)); | |
| 213 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); | 211 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); |
| 214 CodeRange* code_range = new CodeRange(isolate); | 212 CodeRange* code_range = new CodeRange(isolate); |
| 215 size_t code_range_size = | 213 size_t code_range_size = |
| 216 kMinimumCodeRangeSize > 0 ? kMinimumCodeRangeSize : 3 * Page::kPageSize; | 214 kMinimumCodeRangeSize > 0 ? kMinimumCodeRangeSize : 3 * Page::kPageSize; |
| 217 if (!code_range->SetUp(code_range_size)) { | 215 if (!code_range->SetUp(code_range_size)) { |
| 218 return; | 216 return; |
| 219 } | 217 } |
| 220 | 218 |
| 221 Address address; | 219 Address address; |
| 222 size_t size; | 220 size_t size; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 300 } |
| 303 } | 301 } |
| 304 | 302 |
| 305 | 303 |
| 306 TEST(MemoryAllocator) { | 304 TEST(MemoryAllocator) { |
| 307 Isolate* isolate = CcTest::i_isolate(); | 305 Isolate* isolate = CcTest::i_isolate(); |
| 308 Heap* heap = isolate->heap(); | 306 Heap* heap = isolate->heap(); |
| 309 | 307 |
| 310 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 308 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
| 311 CHECK(memory_allocator != nullptr); | 309 CHECK(memory_allocator != nullptr); |
| 312 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(), | 310 CHECK(memory_allocator->SetUp(heap->MaxReserved(), 0)); |
| 313 0)); | |
| 314 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); | 311 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); |
| 315 | 312 |
| 316 { | 313 { |
| 317 int total_pages = 0; | 314 int total_pages = 0; |
| 318 OldSpace faked_space(heap, OLD_SPACE, NOT_EXECUTABLE); | 315 OldSpace faked_space(heap, OLD_SPACE, NOT_EXECUTABLE); |
| 319 Page* first_page = memory_allocator->AllocatePage( | 316 Page* first_page = memory_allocator->AllocatePage( |
| 320 faked_space.AreaSize(), static_cast<PagedSpace*>(&faked_space), | 317 faked_space.AreaSize(), static_cast<PagedSpace*>(&faked_space), |
| 321 NOT_EXECUTABLE); | 318 NOT_EXECUTABLE); |
| 322 | 319 |
| 323 first_page->InsertAfter(faked_space.anchor()->prev_page()); | 320 first_page->InsertAfter(faked_space.anchor()->prev_page()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 350 } | 347 } |
| 351 memory_allocator->TearDown(); | 348 memory_allocator->TearDown(); |
| 352 delete memory_allocator; | 349 delete memory_allocator; |
| 353 } | 350 } |
| 354 | 351 |
| 355 | 352 |
| 356 TEST(NewSpace) { | 353 TEST(NewSpace) { |
| 357 Isolate* isolate = CcTest::i_isolate(); | 354 Isolate* isolate = CcTest::i_isolate(); |
| 358 Heap* heap = isolate->heap(); | 355 Heap* heap = isolate->heap(); |
| 359 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 356 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
| 360 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(), | 357 CHECK(memory_allocator->SetUp(heap->MaxReserved(), 0)); |
| 361 0)); | |
| 362 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); | 358 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); |
| 363 | 359 |
| 364 NewSpace new_space(heap); | 360 NewSpace new_space(heap); |
| 365 | 361 |
| 366 CHECK(new_space.SetUp(CcTest::heap()->InitialSemiSpaceSize(), | 362 CHECK(new_space.SetUp(CcTest::heap()->InitialSemiSpaceSize(), |
| 367 CcTest::heap()->InitialSemiSpaceSize())); | 363 CcTest::heap()->InitialSemiSpaceSize())); |
| 368 CHECK(new_space.HasBeenSetUp()); | 364 CHECK(new_space.HasBeenSetUp()); |
| 369 | 365 |
| 370 while (new_space.Available() >= kMaxRegularHeapObjectSize) { | 366 while (new_space.Available() >= kMaxRegularHeapObjectSize) { |
| 371 CHECK(new_space.Contains( | 367 CHECK(new_space.Contains( |
| 372 new_space.AllocateRawUnaligned(kMaxRegularHeapObjectSize) | 368 new_space.AllocateRawUnaligned(kMaxRegularHeapObjectSize) |
| 373 .ToObjectChecked())); | 369 .ToObjectChecked())); |
| 374 } | 370 } |
| 375 | 371 |
| 376 new_space.TearDown(); | 372 new_space.TearDown(); |
| 377 memory_allocator->TearDown(); | 373 memory_allocator->TearDown(); |
| 378 delete memory_allocator; | 374 delete memory_allocator; |
| 379 } | 375 } |
| 380 | 376 |
| 381 | 377 |
| 382 TEST(OldSpace) { | 378 TEST(OldSpace) { |
| 383 Isolate* isolate = CcTest::i_isolate(); | 379 Isolate* isolate = CcTest::i_isolate(); |
| 384 Heap* heap = isolate->heap(); | 380 Heap* heap = isolate->heap(); |
| 385 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 381 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
| 386 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(), | 382 CHECK(memory_allocator->SetUp(heap->MaxReserved(), 0)); |
| 387 0)); | |
| 388 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); | 383 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); |
| 389 | 384 |
| 390 OldSpace* s = new OldSpace(heap, OLD_SPACE, NOT_EXECUTABLE); | 385 OldSpace* s = new OldSpace(heap, OLD_SPACE, NOT_EXECUTABLE); |
| 391 CHECK(s != NULL); | 386 CHECK(s != NULL); |
| 392 | 387 |
| 393 CHECK(s->SetUp()); | 388 CHECK(s->SetUp()); |
| 394 | 389 |
| 395 while (s->Available() > 0) { | 390 while (s->Available() > 0) { |
| 396 s->AllocateRawUnaligned(kMaxRegularHeapObjectSize).ToObjectChecked(); | 391 s->AllocateRawUnaligned(kMaxRegularHeapObjectSize).ToObjectChecked(); |
| 397 } | 392 } |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 HeapObject* filler = | 752 HeapObject* filler = |
| 758 HeapObject::FromAddress(array->address() + array->Size()); | 753 HeapObject::FromAddress(array->address() + array->Size()); |
| 759 CHECK_EQ(filler->map(), CcTest::heap()->two_pointer_filler_map()); | 754 CHECK_EQ(filler->map(), CcTest::heap()->two_pointer_filler_map()); |
| 760 | 755 |
| 761 const size_t shrinked = page->ShrinkToHighWaterMark(); | 756 const size_t shrinked = page->ShrinkToHighWaterMark(); |
| 762 CHECK_EQ(0u, shrinked); | 757 CHECK_EQ(0u, shrinked); |
| 763 } | 758 } |
| 764 | 759 |
| 765 } // namespace internal | 760 } // namespace internal |
| 766 } // namespace v8 | 761 } // namespace v8 |
| OLD | NEW |