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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 // Heap::markedObjectSize() may be underestimated if any thread has not | 626 // Heap::markedObjectSize() may be underestimated if any thread has not |
627 // finished completeSweep(). | 627 // finished completeSweep(). |
628 size_t currentObjectSizeKb = currentObjectSize() >> 10; | 628 size_t currentObjectSizeKb = currentObjectSize() >> 10; |
629 // Schedule a precise GC if Oilpan has allocated more than 1 MB since | 629 // Schedule a precise GC if Oilpan has allocated more than 1 MB since |
630 // the last GC and the current memory usage is >50% larger than | 630 // the last GC and the current memory usage is >50% larger than |
631 // the estimated live memory usage. | 631 // the estimated live memory usage. |
632 return allocatedObjectSizeKb >= 1024 && currentObjectSizeKb > (estimatedLive
ObjectSizeKb * 3) / 2; | 632 return allocatedObjectSizeKb >= 1024 && currentObjectSizeKb > (estimatedLive
ObjectSizeKb * 3) / 2; |
633 #endif | 633 #endif |
634 } | 634 } |
635 | 635 |
| 636 bool ThreadState::shouldSchedulePreciseGCOnNavigation(float estimatedRemovalRati
o) |
| 637 { |
| 638 // Avoid potential overflow by truncating to Kb. |
| 639 size_t allocatedObjectSizeKb = Heap::allocatedObjectSize() >> 10; |
| 640 // The estimated size is updated when the main thread finishes lazy |
| 641 // sweeping. If this thread reaches here before the main thread finishes |
| 642 // lazy sweeping, the thread will use the estimated size of the last GC. |
| 643 size_t estimatedLiveObjectSizeKb = (estimatedLiveObjectSize() >> 10) * (1 -
estimatedRemovalRatio); |
| 644 // Heap::markedObjectSize() may be underestimated if any thread has not |
| 645 // finished completeSweep(). |
| 646 size_t currentObjectSizeKb = currentObjectSize() >> 10; |
| 647 // Schedule a precise GC if Oilpan has allocated more than 1 MB since |
| 648 // the last GC and the current memory usage is >50% larger than |
| 649 // the estimated live memory usage. |
| 650 return allocatedObjectSizeKb >= 1024 && currentObjectSizeKb > (estimatedLive
ObjectSizeKb * 3) / 2; |
| 651 } |
| 652 |
636 // TODO(haraken): We should improve the GC heuristics. | 653 // TODO(haraken): We should improve the GC heuristics. |
637 // These heuristics affect performance significantly. | 654 // These heuristics affect performance significantly. |
638 bool ThreadState::shouldForceConservativeGC() | 655 bool ThreadState::shouldForceConservativeGC() |
639 { | 656 { |
640 if (UNLIKELY(isGCForbidden())) | 657 if (UNLIKELY(isGCForbidden())) |
641 return false; | 658 return false; |
642 | 659 |
643 if (shouldForceMemoryPressureGC()) | 660 if (shouldForceMemoryPressureGC()) |
644 return true; | 661 return true; |
645 | 662 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 // Prevent that from happening by marking GCs as forbidden while | 901 // Prevent that from happening by marking GCs as forbidden while |
885 // one is initiated and later running. | 902 // one is initiated and later running. |
886 if (isGCForbidden()) | 903 if (isGCForbidden()) |
887 return; | 904 return; |
888 | 905 |
889 switch (gcState()) { | 906 switch (gcState()) { |
890 case FullGCScheduled: | 907 case FullGCScheduled: |
891 Heap::collectAllGarbage(); | 908 Heap::collectAllGarbage(); |
892 break; | 909 break; |
893 case PreciseGCScheduled: | 910 case PreciseGCScheduled: |
894 Heap::collectGarbage(NoHeapPointersOnStack, GCWithoutSweep, Heap::Precis
eGC); | 911 Heap::collectGarbage(NoHeapPointersOnStack, GCWithSweep, Heap::PreciseGC
); |
895 break; | 912 break; |
896 case IdleGCScheduled: | 913 case IdleGCScheduled: |
897 // Idle time GC will be scheduled by Blink Scheduler. | 914 // Idle time GC will be scheduled by Blink Scheduler. |
898 break; | 915 break; |
899 default: | 916 default: |
900 break; | 917 break; |
901 } | 918 } |
902 } | 919 } |
903 | 920 |
904 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() | 921 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 json->beginArray(it->key.ascii().data()); | 1530 json->beginArray(it->key.ascii().data()); |
1514 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1531 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
1515 json->pushInteger(it->value.ages[age]); | 1532 json->pushInteger(it->value.ages[age]); |
1516 json->endArray(); | 1533 json->endArray(); |
1517 } | 1534 } |
1518 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); | 1535 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); |
1519 } | 1536 } |
1520 #endif | 1537 #endif |
1521 | 1538 |
1522 } // namespace blink | 1539 } // namespace blink |
OLD | NEW |