| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 | 669 |
| 670 bool ThreadState::shouldForceConservativeGC() | 670 bool ThreadState::shouldForceConservativeGC() |
| 671 { | 671 { |
| 672 // TODO(haraken): 400% is too large. Lower the heap growing factor. | 672 // TODO(haraken): 400% is too large. Lower the heap growing factor. |
| 673 return judgeGCThreshold(32 * 1024 * 1024, 5.0); | 673 return judgeGCThreshold(32 * 1024 * 1024, 5.0); |
| 674 } | 674 } |
| 675 | 675 |
| 676 void ThreadState::scheduleV8FollowupGCIfNeeded() | 676 void ThreadState::scheduleV8FollowupGCIfNeeded() |
| 677 { | 677 { |
| 678 ASSERT(checkThread()); | 678 ASSERT(checkThread()); |
| 679 Heap::reportMemoryUsageForTracing(); |
| 680 |
| 679 if (isGCForbidden()) | 681 if (isGCForbidden()) |
| 680 return; | 682 return; |
| 681 | 683 |
| 682 if (isSweepingInProgress()) | 684 if (isSweepingInProgress()) |
| 683 return; | 685 return; |
| 684 ASSERT(!sweepForbidden()); | 686 ASSERT(!sweepForbidden()); |
| 685 | 687 |
| 686 Heap::reportMemoryUsageForTracing(); | |
| 687 if (shouldScheduleV8FollowupGC()) | 688 if (shouldScheduleV8FollowupGC()) |
| 688 schedulePreciseGC(); | 689 schedulePreciseGC(); |
| 689 } | 690 } |
| 690 | 691 |
| 691 void ThreadState::schedulePageNavigationGCIfNeeded(float estimatedRemovalRatio) | 692 void ThreadState::schedulePageNavigationGCIfNeeded(float estimatedRemovalRatio) |
| 692 { | 693 { |
| 693 ASSERT(checkThread()); | 694 ASSERT(checkThread()); |
| 695 Heap::reportMemoryUsageForTracing(); |
| 696 |
| 694 if (isGCForbidden()) | 697 if (isGCForbidden()) |
| 695 return; | 698 return; |
| 696 | 699 |
| 697 // Finish on-going lazy sweeping. | 700 // Finish on-going lazy sweeping. |
| 698 // TODO(haraken): It might not make sense to force completeSweep() for all | 701 // TODO(haraken): It might not make sense to force completeSweep() for all |
| 699 // page navigations. | 702 // page navigations. |
| 700 completeSweep(); | 703 completeSweep(); |
| 701 ASSERT(!isSweepingInProgress()); | 704 ASSERT(!isSweepingInProgress()); |
| 702 ASSERT(!sweepForbidden()); | 705 ASSERT(!sweepForbidden()); |
| 703 | 706 |
| 704 Heap::reportMemoryUsageForTracing(); | |
| 705 if (shouldSchedulePageNavigationGC(estimatedRemovalRatio)) | 707 if (shouldSchedulePageNavigationGC(estimatedRemovalRatio)) |
| 706 schedulePageNavigationGC(); | 708 schedulePageNavigationGC(); |
| 707 } | 709 } |
| 708 | 710 |
| 709 void ThreadState::schedulePageNavigationGC() | 711 void ThreadState::schedulePageNavigationGC() |
| 710 { | 712 { |
| 711 ASSERT(checkThread()); | 713 ASSERT(checkThread()); |
| 712 ASSERT(!isSweepingInProgress()); | 714 ASSERT(!isSweepingInProgress()); |
| 713 setGCState(PageNavigationGCScheduled); | 715 setGCState(PageNavigationGCScheduled); |
| 714 } | 716 } |
| 715 | 717 |
| 716 void ThreadState::scheduleGCIfNeeded() | 718 void ThreadState::scheduleGCIfNeeded() |
| 717 { | 719 { |
| 718 ASSERT(checkThread()); | 720 ASSERT(checkThread()); |
| 721 Heap::reportMemoryUsageForTracing(); |
| 722 |
| 719 if (isGCForbidden()) | 723 if (isGCForbidden()) |
| 720 return; | 724 return; |
| 721 | 725 |
| 722 // Allocation is allowed during sweeping, but those allocations should not | 726 // Allocation is allowed during sweeping, but those allocations should not |
| 723 // trigger nested GCs. | 727 // trigger nested GCs. |
| 724 if (isSweepingInProgress()) | 728 if (isSweepingInProgress()) |
| 725 return; | 729 return; |
| 726 ASSERT(!sweepForbidden()); | 730 ASSERT(!sweepForbidden()); |
| 727 | 731 |
| 728 Heap::reportMemoryUsageForTracing(); | |
| 729 | |
| 730 if (shouldForceMemoryPressureGC()) { | 732 if (shouldForceMemoryPressureGC()) { |
| 731 Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::Conserva
tiveGC); | 733 Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::Conserva
tiveGC); |
| 732 return; | 734 return; |
| 733 } | 735 } |
| 734 if (shouldForceConservativeGC()) { | 736 if (shouldForceConservativeGC()) { |
| 735 Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::Conserva
tiveGC); | 737 Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::Conserva
tiveGC); |
| 736 return; | 738 return; |
| 737 } | 739 } |
| 738 if (shouldSchedulePreciseGC()) | 740 if (shouldSchedulePreciseGC()) |
| 739 schedulePreciseGC(); | 741 schedulePreciseGC(); |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 } | 1225 } |
| 1224 | 1226 |
| 1225 void ThreadState::resumeThreads() | 1227 void ThreadState::resumeThreads() |
| 1226 { | 1228 { |
| 1227 s_safePointBarrier->resumeOthers(); | 1229 s_safePointBarrier->resumeOthers(); |
| 1228 } | 1230 } |
| 1229 | 1231 |
| 1230 void ThreadState::safePoint(StackState stackState) | 1232 void ThreadState::safePoint(StackState stackState) |
| 1231 { | 1233 { |
| 1232 ASSERT(checkThread()); | 1234 ASSERT(checkThread()); |
| 1235 Heap::reportMemoryUsageForTracing(); |
| 1236 |
| 1233 runScheduledGC(stackState); | 1237 runScheduledGC(stackState); |
| 1234 ASSERT(!m_atSafePoint); | 1238 ASSERT(!m_atSafePoint); |
| 1235 m_stackState = stackState; | 1239 m_stackState = stackState; |
| 1236 m_atSafePoint = true; | 1240 m_atSafePoint = true; |
| 1237 s_safePointBarrier->checkAndPark(this); | 1241 s_safePointBarrier->checkAndPark(this); |
| 1238 m_atSafePoint = false; | 1242 m_atSafePoint = false; |
| 1239 m_stackState = HeapPointersOnStack; | 1243 m_stackState = HeapPointersOnStack; |
| 1240 preSweep(); | 1244 preSweep(); |
| 1241 } | 1245 } |
| 1242 | 1246 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 json->beginArray(it->key.ascii().data()); | 1607 json->beginArray(it->key.ascii().data()); |
| 1604 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1608 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
| 1605 json->pushInteger(it->value.ages[age]); | 1609 json->pushInteger(it->value.ages[age]); |
| 1606 json->endArray(); | 1610 json->endArray(); |
| 1607 } | 1611 } |
| 1608 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); | 1612 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); |
| 1609 } | 1613 } |
| 1610 #endif | 1614 #endif |
| 1611 | 1615 |
| 1612 } // namespace blink | 1616 } // namespace blink |
| OLD | NEW |