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

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

Issue 2490523003: [heap] Use size_t for heap and space counters. (Closed)
Patch Set: more fixes Created 4 years, 1 month 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-alloc.cc ('k') | test/cctest/heap/test-spaces.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 2332
2333 CcTest::InitializeVM(); 2333 CcTest::InitializeVM();
2334 Heap* heap = CcTest::heap(); 2334 Heap* heap = CcTest::heap();
2335 NewSpace* new_space = heap->new_space(); 2335 NewSpace* new_space = heap->new_space();
2336 2336
2337 if (heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) { 2337 if (heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) {
2338 return; 2338 return;
2339 } 2339 }
2340 2340
2341 // Explicitly growing should double the space capacity. 2341 // Explicitly growing should double the space capacity.
2342 intptr_t old_capacity, new_capacity; 2342 size_t old_capacity, new_capacity;
2343 old_capacity = new_space->TotalCapacity(); 2343 old_capacity = new_space->TotalCapacity();
2344 new_space->Grow(); 2344 new_space->Grow();
2345 new_capacity = new_space->TotalCapacity(); 2345 new_capacity = new_space->TotalCapacity();
2346 CHECK_EQ(2 * old_capacity, new_capacity); 2346 CHECK_EQ(2 * old_capacity, new_capacity);
2347 2347
2348 old_capacity = new_space->TotalCapacity(); 2348 old_capacity = new_space->TotalCapacity();
2349 { 2349 {
2350 v8::HandleScope temporary_scope(CcTest::isolate()); 2350 v8::HandleScope temporary_scope(CcTest::isolate());
2351 heap::SimulateFullSpace(new_space); 2351 heap::SimulateFullSpace(new_space);
2352 } 2352 }
(...skipping 27 matching lines...) Expand all
2380 2380
2381 TEST(CollectingAllAvailableGarbageShrinksNewSpace) { 2381 TEST(CollectingAllAvailableGarbageShrinksNewSpace) {
2382 CcTest::InitializeVM(); 2382 CcTest::InitializeVM();
2383 Heap* heap = CcTest::heap(); 2383 Heap* heap = CcTest::heap();
2384 if (heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) { 2384 if (heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) {
2385 return; 2385 return;
2386 } 2386 }
2387 2387
2388 v8::HandleScope scope(CcTest::isolate()); 2388 v8::HandleScope scope(CcTest::isolate());
2389 NewSpace* new_space = heap->new_space(); 2389 NewSpace* new_space = heap->new_space();
2390 intptr_t old_capacity, new_capacity; 2390 size_t old_capacity, new_capacity;
2391 old_capacity = new_space->TotalCapacity(); 2391 old_capacity = new_space->TotalCapacity();
2392 new_space->Grow(); 2392 new_space->Grow();
2393 new_capacity = new_space->TotalCapacity(); 2393 new_capacity = new_space->TotalCapacity();
2394 CHECK_EQ(2 * old_capacity, new_capacity); 2394 CHECK_EQ(2 * old_capacity, new_capacity);
2395 { 2395 {
2396 v8::HandleScope temporary_scope(CcTest::isolate()); 2396 v8::HandleScope temporary_scope(CcTest::isolate());
2397 heap::SimulateFullSpace(new_space); 2397 heap::SimulateFullSpace(new_space);
2398 } 2398 }
2399 CcTest::CollectAllAvailableGarbage(); 2399 CcTest::CollectAllAvailableGarbage();
2400 new_capacity = new_space->TotalCapacity(); 2400 new_capacity = new_space->TotalCapacity();
(...skipping 3270 matching lines...) Expand 10 before | Expand all | Expand 10 after
5671 // (2) and will create promotion queue entries at the end of the second 5671 // (2) and will create promotion queue entries at the end of the second
5672 // semi-space page during the next scavenge when it promotes the objects to 5672 // semi-space page during the next scavenge when it promotes the objects to
5673 // the old generation. The first allocation of (3) will fill up the first 5673 // the old generation. The first allocation of (3) will fill up the first
5674 // semi-space page. The second allocation in (3) will not fit into the 5674 // semi-space page. The second allocation in (3) will not fit into the
5675 // first semi-space page, but it will overwrite the promotion queue which 5675 // first semi-space page, but it will overwrite the promotion queue which
5676 // are in the second semi-space page. If the right guards are in place, the 5676 // are in the second semi-space page. If the right guards are in place, the
5677 // promotion queue will be evacuated in that case. 5677 // promotion queue will be evacuated in that case.
5678 5678
5679 5679
5680 CHECK(new_space->IsAtMaximumCapacity()); 5680 CHECK(new_space->IsAtMaximumCapacity());
5681 CHECK(i::FLAG_min_semi_space_size * MB == new_space->TotalCapacity()); 5681 CHECK_EQ(static_cast<size_t>(i::FLAG_min_semi_space_size * MB),
5682 new_space->TotalCapacity());
5682 5683
5683 // Call the scavenger two times to get an empty new space 5684 // Call the scavenger two times to get an empty new space
5684 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); 5685 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting);
5685 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); 5686 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting);
5686 5687
5687 // First create a few objects which will survive a scavenge, and will get 5688 // First create a few objects which will survive a scavenge, and will get
5688 // promoted to the old generation later on. These objects will create 5689 // promoted to the old generation later on. These objects will create
5689 // promotion queue entries at the end of the second semi-space page. 5690 // promotion queue entries at the end of the second semi-space page.
5690 const int number_handles = 12; 5691 const int number_handles = 12;
5691 Handle<FixedArray> handles[number_handles]; 5692 Handle<FixedArray> handles[number_handles];
5692 for (int i = 0; i < number_handles; i++) { 5693 for (int i = 0; i < number_handles; i++) {
5693 handles[i] = i_isolate->factory()->NewFixedArray(1, NOT_TENURED); 5694 handles[i] = i_isolate->factory()->NewFixedArray(1, NOT_TENURED);
5694 } 5695 }
5695 5696
5696 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); 5697 heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting);
5697 CHECK(i::FLAG_min_semi_space_size * MB == new_space->TotalCapacity()); 5698 CHECK_EQ(static_cast<size_t>(i::FLAG_min_semi_space_size * MB),
5699 new_space->TotalCapacity());
5698 5700
5699 // Fill-up the first semi-space page. 5701 // Fill-up the first semi-space page.
5700 heap::FillUpOnePage(new_space); 5702 heap::FillUpOnePage(new_space);
5701 5703
5702 // Create a small object to initialize the bump pointer on the second 5704 // Create a small object to initialize the bump pointer on the second
5703 // semi-space page. 5705 // semi-space page.
5704 Handle<FixedArray> small = 5706 Handle<FixedArray> small =
5705 i_isolate->factory()->NewFixedArray(1, NOT_TENURED); 5707 i_isolate->factory()->NewFixedArray(1, NOT_TENURED);
5706 CHECK(heap->InNewSpace(*small)); 5708 CHECK(heap->InNewSpace(*small));
5707 5709
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after
7018 SlotSet::FREE_EMPTY_BUCKETS); 7020 SlotSet::FREE_EMPTY_BUCKETS);
7019 slots[chunk->area_end() - kPointerSize] = false; 7021 slots[chunk->area_end() - kPointerSize] = false;
7020 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) { 7022 RememberedSet<OLD_TO_NEW>::Iterate(chunk, [&slots](Address addr) {
7021 CHECK(slots[addr]); 7023 CHECK(slots[addr]);
7022 return KEEP_SLOT; 7024 return KEEP_SLOT;
7023 }); 7025 });
7024 } 7026 }
7025 7027
7026 } // namespace internal 7028 } // namespace internal
7027 } // namespace v8 7029 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/heap/test-alloc.cc ('k') | test/cctest/heap/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698