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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // thread. | 178 // thread. |
179 ThreadTerminationGC, | 179 ThreadTerminationGC, |
180 }; | 180 }; |
181 | 181 |
182 // See setGCState() for possible state transitions. | 182 // See setGCState() for possible state transitions. |
183 enum GCState { | 183 enum GCState { |
184 NoGCScheduled, | 184 NoGCScheduled, |
185 IdleGCScheduled, | 185 IdleGCScheduled, |
186 PreciseGCScheduled, | 186 PreciseGCScheduled, |
187 FullGCScheduled, | 187 FullGCScheduled, |
| 188 PageNavigationGCScheduled, |
188 GCRunning, | 189 GCRunning, |
189 EagerSweepScheduled, | 190 EagerSweepScheduled, |
190 LazySweepScheduled, | 191 LazySweepScheduled, |
191 Sweeping, | 192 Sweeping, |
192 SweepingAndIdleGCScheduled, | 193 SweepingAndIdleGCScheduled, |
193 SweepingAndPreciseGCScheduled, | 194 SweepingAndPreciseGCScheduled, |
194 }; | 195 }; |
195 | 196 |
196 enum HeapIndices { | 197 enum HeapIndices { |
197 EagerSweepHeapIndex = 0, | 198 EagerSweepHeapIndex = 0, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 #endif | 323 #endif |
323 | 324 |
324 void didV8MajorGC(); | 325 void didV8MajorGC(); |
325 | 326 |
326 void performIdleGC(double deadlineSeconds); | 327 void performIdleGC(double deadlineSeconds); |
327 void performIdleLazySweep(double deadlineSeconds); | 328 void performIdleLazySweep(double deadlineSeconds); |
328 | 329 |
329 void scheduleIdleGC(); | 330 void scheduleIdleGC(); |
330 void scheduleIdleLazySweep(); | 331 void scheduleIdleLazySweep(); |
331 void schedulePreciseGC(); | 332 void schedulePreciseGC(); |
| 333 void schedulePageNavigationGCIfNeeded(float estimatedRemovalRatio); |
| 334 void schedulePageNavigationGC(); |
332 void scheduleGCIfNeeded(); | 335 void scheduleGCIfNeeded(); |
333 void setGCState(GCState); | 336 void setGCState(GCState); |
334 GCState gcState() const; | 337 GCState gcState() const; |
335 bool isInGC() const { return gcState() == GCRunning; } | 338 bool isInGC() const { return gcState() == GCRunning; } |
336 bool isSweepingInProgress() const | 339 bool isSweepingInProgress() const |
337 { | 340 { |
338 return gcState() == Sweeping || gcState() == SweepingAndPreciseGCSchedul
ed || gcState() == SweepingAndIdleGCScheduled; | 341 return gcState() == Sweeping || gcState() == SweepingAndPreciseGCSchedul
ed || gcState() == SweepingAndIdleGCScheduled; |
339 } | 342 } |
340 | 343 |
341 // A GC runs in the following sequence. | 344 // A GC runs in the following sequence. |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 // shouldSchedule{Precise,Idle}GC and shouldForceConservativeGC | 674 // shouldSchedule{Precise,Idle}GC and shouldForceConservativeGC |
672 // implement the heuristics that are used to determine when to collect garba
ge. | 675 // implement the heuristics that are used to determine when to collect garba
ge. |
673 // If shouldForceConservativeGC returns true, we force the garbage | 676 // If shouldForceConservativeGC returns true, we force the garbage |
674 // collection immediately. Otherwise, if should*GC returns true, we | 677 // collection immediately. Otherwise, if should*GC returns true, we |
675 // record that we should garbage collect the next time we return | 678 // record that we should garbage collect the next time we return |
676 // to the event loop. If both return false, we don't need to | 679 // to the event loop. If both return false, we don't need to |
677 // collect garbage at this point. | 680 // collect garbage at this point. |
678 bool shouldScheduleIdleGC(); | 681 bool shouldScheduleIdleGC(); |
679 bool shouldSchedulePreciseGC(); | 682 bool shouldSchedulePreciseGC(); |
680 bool shouldForceConservativeGC(); | 683 bool shouldForceConservativeGC(); |
| 684 // estimatedRemovalRatio is the estimated ratio of objects that will be no |
| 685 // longer necessary due to the navigation. |
| 686 bool shouldSchedulePageNavigationGC(float estimatedRemovalRatio); |
681 | 687 |
682 // Internal helper for GC policy handling code. Returns true if | 688 // Internal helper for GC policy handling code. Returns true if |
683 // an urgent conservative GC is now needed due to memory pressure. | 689 // an urgent conservative GC is now needed due to memory pressure. |
684 bool shouldForceMemoryPressureGC(); | 690 bool shouldForceMemoryPressureGC(); |
685 size_t estimatedLiveObjectSize(); | 691 size_t estimatedLiveObjectSize(); |
686 size_t currentObjectSize(); | 692 size_t currentObjectSize(); |
687 | 693 |
688 void runScheduledGC(StackState); | 694 void runScheduledGC(StackState); |
689 | 695 |
690 void eagerSweep(); | 696 void eagerSweep(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 }; | 809 }; |
804 | 810 |
805 template<> class ThreadStateFor<AnyThread> { | 811 template<> class ThreadStateFor<AnyThread> { |
806 public: | 812 public: |
807 static ThreadState* state() { return ThreadState::current(); } | 813 static ThreadState* state() { return ThreadState::current(); } |
808 }; | 814 }; |
809 | 815 |
810 } // namespace blink | 816 } // namespace blink |
811 | 817 |
812 #endif // ThreadState_h | 818 #endif // ThreadState_h |
OLD | NEW |