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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 { | 663 { |
664 return judgeGCThreshold(512 * 1024, 1.5 * (1 - estimatedRemovalRatio)); | 664 return judgeGCThreshold(512 * 1024, 1.5 * (1 - estimatedRemovalRatio)); |
665 } | 665 } |
666 | 666 |
667 bool ThreadState::shouldForceConservativeGC() | 667 bool ThreadState::shouldForceConservativeGC() |
668 { | 668 { |
669 // TODO(haraken): 400% is too large. Lower the heap growing factor. | 669 // TODO(haraken): 400% is too large. Lower the heap growing factor. |
670 return judgeGCThreshold(32 * 1024 * 1024, 5.0); | 670 return judgeGCThreshold(32 * 1024 * 1024, 5.0); |
671 } | 671 } |
672 | 672 |
| 673 bool ThreadState::forceMemoryPressureGCIfNeeded() |
| 674 { |
| 675 if (!shouldForceMemoryPressureGC()) |
| 676 return false; |
| 677 completeSweep(); |
| 678 if (!shouldForceMemoryPressureGC()) |
| 679 return false; |
| 680 |
| 681 Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::Conservative
GC); |
| 682 return true; |
| 683 } |
| 684 |
673 void ThreadState::scheduleV8FollowupGCIfNeeded(V8GCType gcType) | 685 void ThreadState::scheduleV8FollowupGCIfNeeded(V8GCType gcType) |
674 { | 686 { |
675 ASSERT(checkThread()); | 687 ASSERT(checkThread()); |
676 Heap::reportMemoryUsageForTracing(); | 688 Heap::reportMemoryUsageForTracing(); |
677 | 689 |
678 if (isGCForbidden()) | 690 if (isGCForbidden()) |
679 return; | 691 return; |
680 | 692 |
| 693 // If V8 has acted on a memory pressure signal and performed a major GC, |
| 694 // follow up, if needed. |
| 695 if (gcType == V8MajorGC && forceMemoryPressureGCIfNeeded()) |
| 696 return; |
| 697 |
681 if (isSweepingInProgress()) | 698 if (isSweepingInProgress()) |
682 return; | 699 return; |
683 ASSERT(!sweepForbidden()); | 700 ASSERT(!sweepForbidden()); |
684 | 701 |
685 if (shouldScheduleV8FollowupGC()) | 702 if (shouldScheduleV8FollowupGC()) |
686 schedulePreciseGC(); | 703 schedulePreciseGC(); |
687 else if (gcType == V8MinorGC) | 704 else if (gcType == V8MinorGC) |
688 scheduleIdleGC(); | 705 scheduleIdleGC(); |
689 } | 706 } |
690 | 707 |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 json->beginArray(it->key.ascii().data()); | 1622 json->beginArray(it->key.ascii().data()); |
1606 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1623 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
1607 json->pushInteger(it->value.ages[age]); | 1624 json->pushInteger(it->value.ages[age]); |
1608 json->endArray(); | 1625 json->endArray(); |
1609 } | 1626 } |
1610 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); | 1627 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); |
1611 } | 1628 } |
1612 #endif | 1629 #endif |
1613 | 1630 |
1614 } // namespace blink | 1631 } // namespace blink |
OLD | NEW |