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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 310 |
311 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 311 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
312 CHECK(memory_allocator != nullptr); | 312 CHECK(memory_allocator != nullptr); |
313 CHECK(memory_allocator->SetUp(heap->MaxReserved(), | 313 CHECK(memory_allocator->SetUp(heap->MaxReserved(), |
314 heap->MaxExecutableSize())); | 314 heap->MaxExecutableSize())); |
315 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); | 315 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); |
316 | 316 |
317 { | 317 { |
318 int total_pages = 0; | 318 int total_pages = 0; |
319 OldSpace faked_space(heap, OLD_SPACE, NOT_EXECUTABLE); | 319 OldSpace faked_space(heap, OLD_SPACE, NOT_EXECUTABLE); |
320 Page* first_page = memory_allocator->AllocatePage( | 320 Page* first_page = memory_allocator->AllocatePage<Page>( |
321 faked_space.AreaSize(), &faked_space, NOT_EXECUTABLE); | 321 faked_space.AreaSize(), static_cast<PagedSpace*>(&faked_space), |
| 322 NOT_EXECUTABLE); |
322 | 323 |
323 first_page->InsertAfter(faked_space.anchor()->prev_page()); | 324 first_page->InsertAfter(faked_space.anchor()->prev_page()); |
324 CHECK(first_page->is_valid()); | 325 CHECK(first_page->is_valid()); |
325 CHECK(first_page->next_page() == faked_space.anchor()); | 326 CHECK(first_page->next_page() == faked_space.anchor()); |
326 total_pages++; | 327 total_pages++; |
327 | 328 |
328 for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) { | 329 for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) { |
329 CHECK(p->owner() == &faked_space); | 330 CHECK(p->owner() == &faked_space); |
330 } | 331 } |
331 | 332 |
332 // Again, we should get n or n - 1 pages. | 333 // Again, we should get n or n - 1 pages. |
333 Page* other = memory_allocator->AllocatePage(faked_space.AreaSize(), | 334 Page* other = memory_allocator->AllocatePage<Page>( |
334 &faked_space, NOT_EXECUTABLE); | 335 faked_space.AreaSize(), static_cast<PagedSpace*>(&faked_space), |
| 336 NOT_EXECUTABLE); |
335 CHECK(other->is_valid()); | 337 CHECK(other->is_valid()); |
336 total_pages++; | 338 total_pages++; |
337 other->InsertAfter(first_page); | 339 other->InsertAfter(first_page); |
338 int page_count = 0; | 340 int page_count = 0; |
339 for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) { | 341 for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) { |
340 CHECK(p->owner() == &faked_space); | 342 CHECK(p->owner() == &faked_space); |
341 page_count++; | 343 page_count++; |
342 } | 344 } |
343 CHECK(total_pages == page_count); | 345 CHECK(total_pages == page_count); |
344 | 346 |
(...skipping 10 matching lines...) Expand all Loading... |
355 TEST(NewSpace) { | 357 TEST(NewSpace) { |
356 Isolate* isolate = CcTest::i_isolate(); | 358 Isolate* isolate = CcTest::i_isolate(); |
357 Heap* heap = isolate->heap(); | 359 Heap* heap = isolate->heap(); |
358 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 360 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
359 CHECK(memory_allocator->SetUp(heap->MaxReserved(), | 361 CHECK(memory_allocator->SetUp(heap->MaxReserved(), |
360 heap->MaxExecutableSize())); | 362 heap->MaxExecutableSize())); |
361 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); | 363 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); |
362 | 364 |
363 NewSpace new_space(heap); | 365 NewSpace new_space(heap); |
364 | 366 |
365 CHECK(new_space.SetUp(CcTest::heap()->ReservedSemiSpaceSize(), | 367 CHECK(new_space.SetUp(CcTest::heap()->InitialSemiSpaceSize(), |
366 CcTest::heap()->ReservedSemiSpaceSize())); | 368 CcTest::heap()->InitialSemiSpaceSize())); |
367 CHECK(new_space.HasBeenSetUp()); | 369 CHECK(new_space.HasBeenSetUp()); |
368 | 370 |
369 while (new_space.Available() >= Page::kMaxRegularHeapObjectSize) { | 371 while (new_space.Available() >= Page::kMaxRegularHeapObjectSize) { |
370 Object* obj = | 372 Object* obj = |
371 new_space.AllocateRawUnaligned(Page::kMaxRegularHeapObjectSize) | 373 new_space.AllocateRawUnaligned(Page::kMaxRegularHeapObjectSize) |
372 .ToObjectChecked(); | 374 .ToObjectChecked(); |
373 CHECK(new_space.Contains(HeapObject::cast(obj))); | 375 CHECK(new_space.Contains(HeapObject::cast(obj))); |
374 } | 376 } |
375 | 377 |
376 new_space.TearDown(); | 378 new_space.TearDown(); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 new_space->RemoveAllocationObserver(&observer2); | 675 new_space->RemoveAllocationObserver(&observer2); |
674 | 676 |
675 CHECK_EQ(observer1.count(), 32); | 677 CHECK_EQ(observer1.count(), 32); |
676 CHECK_EQ(observer2.count(), 28); | 678 CHECK_EQ(observer2.count(), 28); |
677 } | 679 } |
678 isolate->Dispose(); | 680 isolate->Dispose(); |
679 } | 681 } |
680 | 682 |
681 } // namespace internal | 683 } // namespace internal |
682 } // namespace v8 | 684 } // namespace v8 |
OLD | NEW |