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

Unified Diff: test/cctest/test-heap.cc

Issue 7995004: Cleanup and enable GrowAndShrinkNewSpace test case. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 9a2e0177dc0273583f2d2186ce958922b6910d63..245afcf6c799532e29fb4c05d09e0585ba815d09 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -1224,36 +1224,45 @@ TEST(TestSizeOfObjectsVsHeapIteratorPrecision) {
TEST(GrowAndShrinkNewSpace) {
InitializeVM();
- v8::HandleScope scope;
NewSpace* new_space = HEAP->new_space();
// Explicitly growing should double the space capacity.
- int old_capacity, new_capacity;
+ intptr_t old_capacity, new_capacity;
old_capacity = new_space->Capacity();
new_space->Grow();
new_capacity = new_space->Capacity();
- ASSERT_EQ(2 * old_capacity, new_capacity);
+ CHECK_EQ(2 * old_capacity, new_capacity);
- // Fill up new space to the point that it is almost full.
- while (new_space->SizeAsInt() + FixedArray::SizeFor(1000) < new_capacity) {
- ASSERT(HEAP->InNewSpace(*FACTORY->NewFixedArray(1000, NOT_TENURED)));
+ // Fill up new space to the point that it is completely full. Make sure
+ // that the scavenger does not undo the filling.
+ old_capacity = new_space->Capacity();
+ {
+ v8::HandleScope scope;
+ AlwaysAllocateScope always_allocate;
+ intptr_t available = new_space->EffectiveCapacity() - new_space->Size();
+ intptr_t number_of_fillers = (available / FixedArray::SizeFor(1000)) - 10;
+ for (intptr_t i = 0; i < number_of_fillers; i++) {
+ CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(1000, NOT_TENURED)));
+ }
}
+ new_capacity = new_space->Capacity();
+ CHECK_EQ(old_capacity, new_capacity);
// Explicitly shrinking should not affect space capacity.
old_capacity = new_space->Capacity();
new_space->Shrink();
new_capacity = new_space->Capacity();
- ASSERT_EQ(old_capacity, new_capacity);
+ CHECK_EQ(old_capacity, new_capacity);
- // Perform scavenge to empty the new space.
+ // Let the scavenger empty the new space.
HEAP->CollectGarbage(NEW_SPACE);
- ASSERT_LE(new_space->SizeAsInt(), old_capacity);
+ CHECK_LE(new_space->Size(), old_capacity);
// Explicitly shrinking should halve the space capacity.
old_capacity = new_space->Capacity();
new_space->Shrink();
new_capacity = new_space->Capacity();
- ASSERT_EQ(old_capacity, 2 * new_capacity);
+ CHECK_EQ(old_capacity, 2 * new_capacity);
// Consecutive shrinking should not affect space capacity.
old_capacity = new_space->Capacity();
@@ -1261,5 +1270,5 @@ TEST(GrowAndShrinkNewSpace) {
new_space->Shrink();
new_space->Shrink();
new_capacity = new_space->Capacity();
- ASSERT_EQ(old_capacity, new_capacity);
+ CHECK_EQ(old_capacity, new_capacity);
}
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698