| OLD | NEW |
| 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 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 CHECK(heap->InNewSpace(*factory->NewFixedArray(32, NOT_TENURED))); | 2326 CHECK(heap->InNewSpace(*factory->NewFixedArray(32, NOT_TENURED))); |
| 2327 } | 2327 } |
| 2328 } | 2328 } |
| 2329 | 2329 |
| 2330 | 2330 |
| 2331 TEST(GrowAndShrinkNewSpace) { | 2331 TEST(GrowAndShrinkNewSpace) { |
| 2332 CcTest::InitializeVM(); | 2332 CcTest::InitializeVM(); |
| 2333 Heap* heap = CcTest::heap(); | 2333 Heap* heap = CcTest::heap(); |
| 2334 NewSpace* new_space = heap->new_space(); | 2334 NewSpace* new_space = heap->new_space(); |
| 2335 | 2335 |
| 2336 if (heap->ReservedSemiSpaceSize() == heap->InitialSemiSpaceSize() || | 2336 if (heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) { |
| 2337 heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) { | |
| 2338 // The max size cannot exceed the reserved size, since semispaces must be | |
| 2339 // always within the reserved space. We can't test new space growing and | |
| 2340 // shrinking if the reserved size is the same as the minimum (initial) size. | |
| 2341 return; | 2337 return; |
| 2342 } | 2338 } |
| 2343 | 2339 |
| 2344 // Explicitly growing should double the space capacity. | 2340 // Explicitly growing should double the space capacity. |
| 2345 intptr_t old_capacity, new_capacity; | 2341 intptr_t old_capacity, new_capacity; |
| 2346 old_capacity = new_space->TotalCapacity(); | 2342 old_capacity = new_space->TotalCapacity(); |
| 2347 new_space->Grow(); | 2343 new_space->Grow(); |
| 2348 new_capacity = new_space->TotalCapacity(); | 2344 new_capacity = new_space->TotalCapacity(); |
| 2349 CHECK(2 * old_capacity == new_capacity); | 2345 CHECK(2 * old_capacity == new_capacity); |
| 2350 | 2346 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2375 new_space->Shrink(); | 2371 new_space->Shrink(); |
| 2376 new_space->Shrink(); | 2372 new_space->Shrink(); |
| 2377 new_capacity = new_space->TotalCapacity(); | 2373 new_capacity = new_space->TotalCapacity(); |
| 2378 CHECK(old_capacity == new_capacity); | 2374 CHECK(old_capacity == new_capacity); |
| 2379 } | 2375 } |
| 2380 | 2376 |
| 2381 | 2377 |
| 2382 TEST(CollectingAllAvailableGarbageShrinksNewSpace) { | 2378 TEST(CollectingAllAvailableGarbageShrinksNewSpace) { |
| 2383 CcTest::InitializeVM(); | 2379 CcTest::InitializeVM(); |
| 2384 Heap* heap = CcTest::heap(); | 2380 Heap* heap = CcTest::heap(); |
| 2385 if (heap->ReservedSemiSpaceSize() == heap->InitialSemiSpaceSize() || | 2381 if (heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) { |
| 2386 heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) { | |
| 2387 // The max size cannot exceed the reserved size, since semispaces must be | |
| 2388 // always within the reserved space. We can't test new space growing and | |
| 2389 // shrinking if the reserved size is the same as the minimum (initial) size. | |
| 2390 return; | 2382 return; |
| 2391 } | 2383 } |
| 2392 | 2384 |
| 2393 v8::HandleScope scope(CcTest::isolate()); | 2385 v8::HandleScope scope(CcTest::isolate()); |
| 2394 NewSpace* new_space = heap->new_space(); | 2386 NewSpace* new_space = heap->new_space(); |
| 2395 intptr_t old_capacity, new_capacity; | 2387 intptr_t old_capacity, new_capacity; |
| 2396 old_capacity = new_space->TotalCapacity(); | 2388 old_capacity = new_space->TotalCapacity(); |
| 2397 new_space->Grow(); | 2389 new_space->Grow(); |
| 2398 new_capacity = new_space->TotalCapacity(); | 2390 new_capacity = new_space->TotalCapacity(); |
| 2399 CHECK(2 * old_capacity == new_capacity); | 2391 CHECK(2 * old_capacity == new_capacity); |
| (...skipping 4207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6607 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); | 6599 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(arrays[j], N - 1); |
| 6608 } | 6600 } |
| 6609 } | 6601 } |
| 6610 // Force allocation from the free list. | 6602 // Force allocation from the free list. |
| 6611 heap->set_force_oom(true); | 6603 heap->set_force_oom(true); |
| 6612 heap->CollectGarbage(OLD_SPACE); | 6604 heap->CollectGarbage(OLD_SPACE); |
| 6613 } | 6605 } |
| 6614 | 6606 |
| 6615 } // namespace internal | 6607 } // namespace internal |
| 6616 } // namespace v8 | 6608 } // namespace v8 |
| OLD | NEW |