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

Side by Side Diff: test/cctest/heap/test-spaces.cc

Issue 1900423002: [heap] Merge NewSpacePage into Page (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 309 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
310 CHECK(memory_allocator != nullptr); 310 CHECK(memory_allocator != nullptr);
311 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(), 311 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(),
312 0)); 312 0));
313 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 313 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
314 314
315 { 315 {
316 int total_pages = 0; 316 int total_pages = 0;
317 OldSpace faked_space(heap, OLD_SPACE, NOT_EXECUTABLE); 317 OldSpace faked_space(heap, OLD_SPACE, NOT_EXECUTABLE);
318 Page* first_page = memory_allocator->AllocatePage<Page>( 318 Page* first_page = memory_allocator->AllocatePage(
319 faked_space.AreaSize(), static_cast<PagedSpace*>(&faked_space), 319 faked_space.AreaSize(), static_cast<PagedSpace*>(&faked_space),
320 NOT_EXECUTABLE); 320 NOT_EXECUTABLE);
321 321
322 first_page->InsertAfter(faked_space.anchor()->prev_page()); 322 first_page->InsertAfter(faked_space.anchor()->prev_page());
323 CHECK(first_page->is_valid()); 323 CHECK(Page::IsValid(first_page));
324 CHECK(first_page->next_page() == faked_space.anchor()); 324 CHECK(first_page->next_page() == faked_space.anchor());
325 total_pages++; 325 total_pages++;
326 326
327 for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) { 327 for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) {
328 CHECK(p->owner() == &faked_space); 328 CHECK(p->owner() == &faked_space);
329 } 329 }
330 330
331 // Again, we should get n or n - 1 pages. 331 // Again, we should get n or n - 1 pages.
332 Page* other = memory_allocator->AllocatePage<Page>( 332 Page* other = memory_allocator->AllocatePage(
333 faked_space.AreaSize(), static_cast<PagedSpace*>(&faked_space), 333 faked_space.AreaSize(), static_cast<PagedSpace*>(&faked_space),
334 NOT_EXECUTABLE); 334 NOT_EXECUTABLE);
335 CHECK(other->is_valid()); 335 CHECK(Page::IsValid(other));
336 total_pages++; 336 total_pages++;
337 other->InsertAfter(first_page); 337 other->InsertAfter(first_page);
338 int page_count = 0; 338 int page_count = 0;
339 for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) { 339 for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) {
340 CHECK(p->owner() == &faked_space); 340 CHECK(p->owner() == &faked_space);
341 page_count++; 341 page_count++;
342 } 342 }
343 CHECK(total_pages == page_count); 343 CHECK(total_pages == page_count);
344 344
345 Page* second_page = first_page->next_page(); 345 Page* second_page = first_page->next_page();
346 CHECK(second_page->is_valid()); 346 CHECK(Page::IsValid(second_page));
347 347
348 // OldSpace's destructor will tear down the space and free up all pages. 348 // OldSpace's destructor will tear down the space and free up all pages.
349 } 349 }
350 memory_allocator->TearDown(); 350 memory_allocator->TearDown();
351 delete memory_allocator; 351 delete memory_allocator;
352 } 352 }
353 353
354 354
355 TEST(NewSpace) { 355 TEST(NewSpace) {
356 Isolate* isolate = CcTest::i_isolate(); 356 Isolate* isolate = CcTest::i_isolate();
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 new_space->RemoveAllocationObserver(&observer2); 673 new_space->RemoveAllocationObserver(&observer2);
674 674
675 CHECK_EQ(observer1.count(), 32); 675 CHECK_EQ(observer1.count(), 32);
676 CHECK_EQ(observer2.count(), 28); 676 CHECK_EQ(observer2.count(), 28);
677 } 677 }
678 isolate->Dispose(); 678 isolate->Dispose();
679 } 679 }
680 680
681 } // namespace internal 681 } // namespace internal
682 } // namespace v8 682 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698