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

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

Issue 2229403003: Revert of [heap] Switch to 500k pages (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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') | test/cctest/test-serialize.cc » ('j') | 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 // The available value is conservative such that it may report 471 // The available value is conservative such that it may report
472 // zero prior to heap exhaustion. 472 // zero prior to heap exhaustion.
473 CHECK(lo->Available() < available || available == 0); 473 CHECK(lo->Available() < available || available == 0);
474 } 474 }
475 475
476 CHECK(!lo->IsEmpty()); 476 CHECK(!lo->IsEmpty());
477 477
478 CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE).IsRetry()); 478 CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE).IsRetry());
479 } 479 }
480 480
481 TEST(SizeOfInitialHeap) { 481
482 TEST(SizeOfFirstPageIsLargeEnough) {
482 if (i::FLAG_always_opt) return; 483 if (i::FLAG_always_opt) return;
483 // Bootstrapping without a snapshot causes more allocations. 484 // Bootstrapping without a snapshot causes more allocations.
484 CcTest::InitializeVM(); 485 CcTest::InitializeVM();
485 Isolate* isolate = CcTest::i_isolate(); 486 Isolate* isolate = CcTest::i_isolate();
486 if (!isolate->snapshot_available()) return; 487 if (!isolate->snapshot_available()) return;
487 HandleScope scope(isolate); 488 HandleScope scope(isolate);
488 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); 489 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
489 // Skip this test on the custom snapshot builder. 490 // Skip this test on the custom snapshot builder.
490 if (!CcTest::global() 491 if (!CcTest::global()
491 ->Get(context, v8_str("assertEquals")) 492 ->Get(context, v8_str("assertEquals"))
492 .ToLocalChecked() 493 .ToLocalChecked()
493 ->IsUndefined()) { 494 ->IsUndefined()) {
494 return; 495 return;
495 } 496 }
496 497
497 // The limit for each space for an empty isolate containing just the 498 // If this test fails due to enabling experimental natives that are not part
498 // snapshot. 499 // of the snapshot, we may need to adjust CalculateFirstPageSizes.
499 const size_t kMaxInitialSizePerSpace = 1536 * KB; // 1.5MB
500 500
501 // Freshly initialized VM gets by with the snapshot size (which is below 501 // Freshly initialized VM gets by with one page per space.
502 // kMaxInitialSizePerSpace per space).
503 Heap* heap = isolate->heap();
504 int page_count[LAST_PAGED_SPACE + 1];
505 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { 502 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) {
506 // Debug code can be very large, so skip CODE_SPACE if we are generating it. 503 // Debug code can be very large, so skip CODE_SPACE if we are generating it.
507 if (i == CODE_SPACE && i::FLAG_debug_code) continue; 504 if (i == CODE_SPACE && i::FLAG_debug_code) continue;
508 505 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages());
509 page_count[i] = heap->paged_space(i)->CountTotalPages();
510 // Check that the initial heap is also below the limit.
511 CHECK_LT(static_cast<size_t>(heap->paged_space(i)->CommittedMemory()),
512 kMaxInitialSizePerSpace);
513 } 506 }
514 507
515 // Executing the empty script gets by with the same number of pages, i.e., 508 // Executing the empty script gets by with one page per space.
516 // requires no extra space.
517 CompileRun("/*empty*/"); 509 CompileRun("/*empty*/");
518 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { 510 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) {
519 // Debug code can be very large, so skip CODE_SPACE if we are generating it. 511 // Debug code can be very large, so skip CODE_SPACE if we are generating it.
520 if (i == CODE_SPACE && i::FLAG_debug_code) continue; 512 if (i == CODE_SPACE && i::FLAG_debug_code) continue;
521 CHECK_EQ(page_count[i], isolate->heap()->paged_space(i)->CountTotalPages()); 513 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages());
522 } 514 }
523 515
524 // No large objects required to perform the above steps. 516 // No large objects required to perform the above steps.
525 CHECK(isolate->heap()->lo_space()->IsEmpty()); 517 CHECK(isolate->heap()->lo_space()->IsEmpty());
526 } 518 }
527 519
528 static HeapObject* AllocateUnaligned(NewSpace* space, int size) { 520 static HeapObject* AllocateUnaligned(NewSpace* space, int size) {
529 AllocationResult allocation = space->AllocateRawUnaligned(size); 521 AllocationResult allocation = space->AllocateRawUnaligned(size);
530 CHECK(!allocation.IsRetry()); 522 CHECK(!allocation.IsRetry());
531 HeapObject* filler = NULL; 523 HeapObject* filler = NULL;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 new_space->RemoveAllocationObserver(&observer2); 676 new_space->RemoveAllocationObserver(&observer2);
685 677
686 CHECK_EQ(observer1.count(), 32); 678 CHECK_EQ(observer1.count(), 32);
687 CHECK_EQ(observer2.count(), 28); 679 CHECK_EQ(observer2.count(), 28);
688 } 680 }
689 isolate->Dispose(); 681 isolate->Dispose();
690 } 682 }
691 683
692 } // namespace internal 684 } // namespace internal
693 } // namespace v8 685 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698