OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 | 2 |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "compilation-cache.h" | 7 #include "compilation-cache.h" |
8 #include "execution.h" | 8 #include "execution.h" |
9 #include "factory.h" | 9 #include "factory.h" |
10 #include "macro-assembler.h" | 10 #include "macro-assembler.h" |
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 TEST(TestSizeOfObjects) { | 1423 TEST(TestSizeOfObjects) { |
1424 v8::V8::Initialize(); | 1424 v8::V8::Initialize(); |
1425 | 1425 |
1426 // Get initial heap size after several full GCs, which will stabilize | 1426 // Get initial heap size after several full GCs, which will stabilize |
1427 // the heap size and return with sweeping finished completely. | 1427 // the heap size and return with sweeping finished completely. |
1428 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1428 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
1429 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1429 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
1430 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1430 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
1431 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1431 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
1432 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1432 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
1433 CHECK(HEAP->old_pointer_space()->IsSweepingComplete()); | 1433 CHECK(HEAP->old_pointer_space()->IsLazySweepingComplete()); |
1434 int initial_size = static_cast<int>(HEAP->SizeOfObjects()); | 1434 int initial_size = static_cast<int>(HEAP->SizeOfObjects()); |
1435 | 1435 |
1436 { | 1436 { |
1437 // Allocate objects on several different old-space pages so that | 1437 // Allocate objects on several different old-space pages so that |
1438 // lazy sweeping kicks in for subsequent GC runs. | 1438 // lazy sweeping kicks in for subsequent GC runs. |
1439 AlwaysAllocateScope always_allocate; | 1439 AlwaysAllocateScope always_allocate; |
1440 int filler_size = static_cast<int>(FixedArray::SizeFor(8192)); | 1440 int filler_size = static_cast<int>(FixedArray::SizeFor(8192)); |
1441 for (int i = 1; i <= 100; i++) { | 1441 for (int i = 1; i <= 100; i++) { |
1442 HEAP->AllocateFixedArray(8192, TENURED)->ToObjectChecked(); | 1442 HEAP->AllocateFixedArray(8192, TENURED)->ToObjectChecked(); |
1443 CHECK_EQ(initial_size + i * filler_size, | 1443 CHECK_EQ(initial_size + i * filler_size, |
1444 static_cast<int>(HEAP->SizeOfObjects())); | 1444 static_cast<int>(HEAP->SizeOfObjects())); |
1445 } | 1445 } |
1446 } | 1446 } |
1447 | 1447 |
1448 // The heap size should go back to initial size after a full GC, even | 1448 // The heap size should go back to initial size after a full GC, even |
1449 // though sweeping didn't finish yet. | 1449 // though sweeping didn't finish yet. |
1450 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1450 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
1451 | 1451 |
1452 // Normally sweeping would not be complete here, but no guarantees. | 1452 // Normally sweeping would not be complete here, but no guarantees. |
1453 | 1453 |
1454 CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects())); | 1454 CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects())); |
1455 | 1455 |
1456 // Advancing the sweeper step-wise should not change the heap size. | 1456 // Advancing the sweeper step-wise should not change the heap size. |
1457 while (!HEAP->old_pointer_space()->IsSweepingComplete()) { | 1457 while (!HEAP->old_pointer_space()->IsLazySweepingComplete()) { |
1458 HEAP->old_pointer_space()->AdvanceSweeper(KB); | 1458 HEAP->old_pointer_space()->AdvanceSweeper(KB); |
1459 CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects())); | 1459 CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects())); |
1460 } | 1460 } |
1461 } | 1461 } |
1462 | 1462 |
1463 | 1463 |
1464 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { | 1464 TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { |
1465 InitializeVM(); | 1465 InitializeVM(); |
1466 HEAP->EnsureHeapIsIterable(); | 1466 HEAP->EnsureHeapIsIterable(); |
1467 intptr_t size_of_objects_1 = HEAP->SizeOfObjects(); | 1467 intptr_t size_of_objects_1 = HEAP->SizeOfObjects(); |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2829 // Now optimize the function so that it is taken off the candidate list. | 2829 // Now optimize the function so that it is taken off the candidate list. |
2830 { | 2830 { |
2831 HandleScope inner_scope; | 2831 HandleScope inner_scope; |
2832 CompileRun("%OptimizeFunctionOnNextCall(f); f(3);"); | 2832 CompileRun("%OptimizeFunctionOnNextCall(f); f(3);"); |
2833 } | 2833 } |
2834 | 2834 |
2835 // This cycle will bust the heap and subsequent cycles will go ballistic. | 2835 // This cycle will bust the heap and subsequent cycles will go ballistic. |
2836 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 2836 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
2837 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 2837 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
2838 } | 2838 } |
OLD | NEW |