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

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

Issue 2311203002: Move kMaxRegularHeapObjectSize into globals (Closed)
Patch Set: Saving the file helps... Created 4 years, 3 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-mark-compact.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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(), 360 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(),
361 0)); 361 0));
362 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 362 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
363 363
364 NewSpace new_space(heap); 364 NewSpace new_space(heap);
365 365
366 CHECK(new_space.SetUp(CcTest::heap()->InitialSemiSpaceSize(), 366 CHECK(new_space.SetUp(CcTest::heap()->InitialSemiSpaceSize(),
367 CcTest::heap()->InitialSemiSpaceSize())); 367 CcTest::heap()->InitialSemiSpaceSize()));
368 CHECK(new_space.HasBeenSetUp()); 368 CHECK(new_space.HasBeenSetUp());
369 369
370 while (new_space.Available() >= Page::kMaxRegularHeapObjectSize) { 370 while (new_space.Available() >= kMaxRegularHeapObjectSize) {
371 Object* obj = 371 Object* obj = new_space.AllocateRawUnaligned(kMaxRegularHeapObjectSize)
372 new_space.AllocateRawUnaligned(Page::kMaxRegularHeapObjectSize) 372 .ToObjectChecked();
373 .ToObjectChecked();
374 CHECK(new_space.Contains(HeapObject::cast(obj))); 373 CHECK(new_space.Contains(HeapObject::cast(obj)));
375 } 374 }
376 375
377 new_space.TearDown(); 376 new_space.TearDown();
378 memory_allocator->TearDown(); 377 memory_allocator->TearDown();
379 delete memory_allocator; 378 delete memory_allocator;
380 } 379 }
381 380
382 381
383 TEST(OldSpace) { 382 TEST(OldSpace) {
384 Isolate* isolate = CcTest::i_isolate(); 383 Isolate* isolate = CcTest::i_isolate();
385 Heap* heap = isolate->heap(); 384 Heap* heap = isolate->heap();
386 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 385 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
387 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(), 386 CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize(),
388 0)); 387 0));
389 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 388 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
390 389
391 OldSpace* s = new OldSpace(heap, OLD_SPACE, NOT_EXECUTABLE); 390 OldSpace* s = new OldSpace(heap, OLD_SPACE, NOT_EXECUTABLE);
392 CHECK(s != NULL); 391 CHECK(s != NULL);
393 392
394 CHECK(s->SetUp()); 393 CHECK(s->SetUp());
395 394
396 while (s->Available() > 0) { 395 while (s->Available() > 0) {
397 s->AllocateRawUnaligned(Page::kMaxRegularHeapObjectSize).ToObjectChecked(); 396 s->AllocateRawUnaligned(kMaxRegularHeapObjectSize).ToObjectChecked();
398 } 397 }
399 398
400 delete s; 399 delete s;
401 memory_allocator->TearDown(); 400 memory_allocator->TearDown();
402 delete memory_allocator; 401 delete memory_allocator;
403 } 402 }
404 403
405 404
406 TEST(CompactionSpace) { 405 TEST(CompactionSpace) {
407 Isolate* isolate = CcTest::i_isolate(); 406 Isolate* isolate = CcTest::i_isolate();
(...skipping 10 matching lines...) Expand all
418 CHECK(compaction_space->SetUp()); 417 CHECK(compaction_space->SetUp());
419 418
420 OldSpace* old_space = new OldSpace(heap, OLD_SPACE, NOT_EXECUTABLE); 419 OldSpace* old_space = new OldSpace(heap, OLD_SPACE, NOT_EXECUTABLE);
421 CHECK(old_space != NULL); 420 CHECK(old_space != NULL);
422 CHECK(old_space->SetUp()); 421 CHECK(old_space->SetUp());
423 422
424 // Cannot loop until "Available()" since we initially have 0 bytes available 423 // Cannot loop until "Available()" since we initially have 0 bytes available
425 // and would thus neither grow, nor be able to allocate an object. 424 // and would thus neither grow, nor be able to allocate an object.
426 const int kNumObjects = 100; 425 const int kNumObjects = 100;
427 const int kNumObjectsPerPage = 426 const int kNumObjectsPerPage =
428 compaction_space->AreaSize() / Page::kMaxRegularHeapObjectSize; 427 compaction_space->AreaSize() / kMaxRegularHeapObjectSize;
429 const int kExpectedPages = 428 const int kExpectedPages =
430 (kNumObjects + kNumObjectsPerPage - 1) / kNumObjectsPerPage; 429 (kNumObjects + kNumObjectsPerPage - 1) / kNumObjectsPerPage;
431 for (int i = 0; i < kNumObjects; i++) { 430 for (int i = 0; i < kNumObjects; i++) {
432 compaction_space->AllocateRawUnaligned(Page::kMaxRegularHeapObjectSize) 431 compaction_space->AllocateRawUnaligned(kMaxRegularHeapObjectSize)
433 .ToObjectChecked(); 432 .ToObjectChecked();
434 } 433 }
435 int pages_in_old_space = old_space->CountTotalPages(); 434 int pages_in_old_space = old_space->CountTotalPages();
436 int pages_in_compaction_space = compaction_space->CountTotalPages(); 435 int pages_in_compaction_space = compaction_space->CountTotalPages();
437 CHECK_EQ(pages_in_compaction_space, kExpectedPages); 436 CHECK_EQ(pages_in_compaction_space, kExpectedPages);
438 CHECK_LE(pages_in_old_space, 1); 437 CHECK_LE(pages_in_old_space, 1);
439 438
440 old_space->MergeCompactionSpace(compaction_space); 439 old_space->MergeCompactionSpace(compaction_space);
441 CHECK_EQ(old_space->CountTotalPages(), 440 CHECK_EQ(old_space->CountTotalPages(),
442 pages_in_old_space + pages_in_compaction_space); 441 pages_in_old_space + pages_in_compaction_space);
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 HeapObject* filler = 787 HeapObject* filler =
789 HeapObject::FromAddress(array->address() + array->Size()); 788 HeapObject::FromAddress(array->address() + array->Size());
790 CHECK_EQ(filler->map(), CcTest::heap()->two_pointer_filler_map()); 789 CHECK_EQ(filler->map(), CcTest::heap()->two_pointer_filler_map());
791 790
792 const size_t shrinked = page->ShrinkToHighWaterMark(); 791 const size_t shrinked = page->ShrinkToHighWaterMark();
793 CHECK_EQ(0, shrinked); 792 CHECK_EQ(0, shrinked);
794 } 793 }
795 794
796 } // namespace internal 795 } // namespace internal
797 } // namespace v8 796 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/heap/test-mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698