Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: src/heap/heap.h

Issue 2310143002: [heap] Introduce enum of garbage collection reasons. (Closed)
Patch Set: fix win Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HEAP_HEAP_H_ 5 #ifndef V8_HEAP_HEAP_H_
6 #define V8_HEAP_HEAP_H_ 6 #define V8_HEAP_HEAP_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 #include <map> 9 #include <map>
10 10
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 341
342 enum ArrayStorageAllocationMode { 342 enum ArrayStorageAllocationMode {
343 DONT_INITIALIZE_ARRAY_ELEMENTS, 343 DONT_INITIALIZE_ARRAY_ELEMENTS,
344 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE 344 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE
345 }; 345 };
346 346
347 enum class ClearRecordedSlots { kYes, kNo }; 347 enum class ClearRecordedSlots { kYes, kNo };
348 348
349 enum class ClearBlackArea { kYes, kNo }; 349 enum class ClearBlackArea { kYes, kNo };
350 350
351 enum class GarbageCollectionReason {
352 kUnknown,
353 kAllocationFailure,
354 kAllocationLimit,
355 kContextDisposal,
356 kCountersExtension,
357 kDebugger,
358 kDeserializer,
359 kExternalMemoryPressure,
360 kFinalizeMarkingViaStackGuard,
361 kFinalizeMarkingViaTask,
362 kFullHashtable,
363 kHeapProfiler,
364 kIdleTask,
365 kLastResort,
366 kLowMemoryNotification,
367 kMakeHeapIterable,
368 kMemoryPressure,
369 kMemoryReducer,
370 kRuntime,
371 kSamplingProfiler,
372 kSnapshotCreator,
373 kTesting
374 };
375
351 // A queue of objects promoted during scavenge. Each object is accompanied by 376 // A queue of objects promoted during scavenge. Each object is accompanied by
352 // its size to avoid dereferencing a map pointer for scanning. The last page in 377 // its size to avoid dereferencing a map pointer for scanning. The last page in
353 // to-space is used for the promotion queue. On conflict during scavenge, the 378 // to-space is used for the promotion queue. On conflict during scavenge, the
354 // promotion queue is allocated externally and all entries are copied to the 379 // promotion queue is allocated externally and all entries are copied to the
355 // external queue. 380 // external queue.
356 class PromotionQueue { 381 class PromotionQueue {
357 public: 382 public:
358 explicit PromotionQueue(Heap* heap) 383 explicit PromotionQueue(Heap* heap)
359 : front_(nullptr), 384 : front_(nullptr),
360 rear_(nullptr), 385 rear_(nullptr),
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 void DisableInlineAllocation(); 1097 void DisableInlineAllocation();
1073 1098
1074 // =========================================================================== 1099 // ===========================================================================
1075 // Methods triggering GCs. =================================================== 1100 // Methods triggering GCs. ===================================================
1076 // =========================================================================== 1101 // ===========================================================================
1077 1102
1078 // Performs garbage collection operation. 1103 // Performs garbage collection operation.
1079 // Returns whether there is a chance that another major GC could 1104 // Returns whether there is a chance that another major GC could
1080 // collect more garbage. 1105 // collect more garbage.
1081 inline bool CollectGarbage( 1106 inline bool CollectGarbage(
1082 AllocationSpace space, const char* gc_reason = NULL, 1107 AllocationSpace space, GarbageCollectionReason gc_reason,
1083 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); 1108 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
1084 1109
1085 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is 1110 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is
1086 // non-zero, then the slower precise sweeper is used, which leaves the heap 1111 // non-zero, then the slower precise sweeper is used, which leaves the heap
1087 // in a state where we can iterate over the heap visiting all objects. 1112 // in a state where we can iterate over the heap visiting all objects.
1088 void CollectAllGarbage( 1113 void CollectAllGarbage(
1089 int flags = kFinalizeIncrementalMarkingMask, const char* gc_reason = NULL, 1114 int flags, GarbageCollectionReason gc_reason,
1090 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); 1115 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
1091 1116
1092 // Last hope GC, should try to squeeze as much as possible. 1117 // Last hope GC, should try to squeeze as much as possible.
1093 void CollectAllAvailableGarbage(const char* gc_reason = NULL); 1118 void CollectAllAvailableGarbage(GarbageCollectionReason gc_reason);
1094 1119
1095 // Reports and external memory pressure event, either performs a major GC or 1120 // Reports and external memory pressure event, either performs a major GC or
1096 // completes incremental marking in order to free external resources. 1121 // completes incremental marking in order to free external resources.
1097 void ReportExternalMemoryPressure(const char* gc_reason = NULL); 1122 void ReportExternalMemoryPressure();
1098 1123
1099 // Invoked when GC was requested via the stack guard. 1124 // Invoked when GC was requested via the stack guard.
1100 void HandleGCRequest(); 1125 void HandleGCRequest();
1101 1126
1102 // =========================================================================== 1127 // ===========================================================================
1103 // Iterators. ================================================================ 1128 // Iterators. ================================================================
1104 // =========================================================================== 1129 // ===========================================================================
1105 1130
1106 // Iterates over all roots in the heap. 1131 // Iterates over all roots in the heap.
1107 void IterateRoots(ObjectVisitor* v, VisitMode mode); 1132 void IterateRoots(ObjectVisitor* v, VisitMode mode);
(...skipping 30 matching lines...) Expand all
1138 1163
1139 void ClearRecordedSlot(HeapObject* object, Object** slot); 1164 void ClearRecordedSlot(HeapObject* object, Object** slot);
1140 void ClearRecordedSlotRange(Address start, Address end); 1165 void ClearRecordedSlotRange(Address start, Address end);
1141 1166
1142 // =========================================================================== 1167 // ===========================================================================
1143 // Incremental marking API. ================================================== 1168 // Incremental marking API. ==================================================
1144 // =========================================================================== 1169 // ===========================================================================
1145 1170
1146 // Start incremental marking and ensure that idle time handler can perform 1171 // Start incremental marking and ensure that idle time handler can perform
1147 // incremental steps. 1172 // incremental steps.
1148 void StartIdleIncrementalMarking(); 1173 void StartIdleIncrementalMarking(GarbageCollectionReason gc_reason);
1149 1174
1150 // Starts incremental marking assuming incremental marking is currently 1175 // Starts incremental marking assuming incremental marking is currently
1151 // stopped. 1176 // stopped.
1152 void StartIncrementalMarking(int gc_flags = kNoGCFlags, 1177 void StartIncrementalMarking(
1153 const GCCallbackFlags gc_callback_flags = 1178 int gc_flags, GarbageCollectionReason gc_reason,
1154 GCCallbackFlags::kNoGCCallbackFlags, 1179 GCCallbackFlags gc_callback_flags = GCCallbackFlags::kNoGCCallbackFlags);
1155 const char* reason = nullptr);
1156 1180
1157 void StartIncrementalMarkingIfNeeded(int gc_flags = kNoGCFlags, 1181 void StartIncrementalMarkingIfAllocationLimitIsReached(
1158 const GCCallbackFlags gc_callback_flags = 1182 int gc_flags,
1159 GCCallbackFlags::kNoGCCallbackFlags, 1183 GCCallbackFlags gc_callback_flags = GCCallbackFlags::kNoGCCallbackFlags);
1160 const char* reason = nullptr);
1161 1184
1162 void FinalizeIncrementalMarkingIfComplete(const char* comment); 1185 void FinalizeIncrementalMarkingIfComplete(GarbageCollectionReason gc_reason);
1163 1186
1164 bool TryFinalizeIdleIncrementalMarking(double idle_time_in_ms); 1187 bool TryFinalizeIdleIncrementalMarking(double idle_time_in_ms,
1188 GarbageCollectionReason gc_reason);
1165 1189
1166 void RegisterReservationsForBlackAllocation(Reservation* reservations); 1190 void RegisterReservationsForBlackAllocation(Reservation* reservations);
1167 1191
1168 IncrementalMarking* incremental_marking() { return incremental_marking_; } 1192 IncrementalMarking* incremental_marking() { return incremental_marking_; }
1169 1193
1170 // =========================================================================== 1194 // ===========================================================================
1171 // Embedder heap tracer support. ============================================= 1195 // Embedder heap tracer support. =============================================
1172 // =========================================================================== 1196 // ===========================================================================
1173 1197
1174 void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer); 1198 void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 void EnsureFillerObjectAtTop(); 1630 void EnsureFillerObjectAtTop();
1607 1631
1608 // Ensure that we have swept all spaces in such a way that we can iterate 1632 // Ensure that we have swept all spaces in such a way that we can iterate
1609 // over all objects. May cause a GC. 1633 // over all objects. May cause a GC.
1610 void MakeHeapIterable(); 1634 void MakeHeapIterable();
1611 1635
1612 // Performs garbage collection operation. 1636 // Performs garbage collection operation.
1613 // Returns whether there is a chance that another major GC could 1637 // Returns whether there is a chance that another major GC could
1614 // collect more garbage. 1638 // collect more garbage.
1615 bool CollectGarbage( 1639 bool CollectGarbage(
1616 GarbageCollector collector, const char* gc_reason, 1640 GarbageCollector collector, GarbageCollectionReason gc_reason,
1617 const char* collector_reason, 1641 const char* collector_reason,
1618 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); 1642 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
1619 1643
1620 // Performs garbage collection 1644 // Performs garbage collection
1621 // Returns whether there is a chance another major GC could 1645 // Returns whether there is a chance another major GC could
1622 // collect more garbage. 1646 // collect more garbage.
1623 bool PerformGarbageCollection( 1647 bool PerformGarbageCollection(
1624 GarbageCollector collector, 1648 GarbageCollector collector,
1625 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); 1649 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
1626 1650
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 1705
1682 void ConfigureInitialOldGenerationSize(); 1706 void ConfigureInitialOldGenerationSize();
1683 1707
1684 bool HasLowYoungGenerationAllocationRate(); 1708 bool HasLowYoungGenerationAllocationRate();
1685 bool HasLowOldGenerationAllocationRate(); 1709 bool HasLowOldGenerationAllocationRate();
1686 double YoungGenerationMutatorUtilization(); 1710 double YoungGenerationMutatorUtilization();
1687 double OldGenerationMutatorUtilization(); 1711 double OldGenerationMutatorUtilization();
1688 1712
1689 void ReduceNewSpaceSize(); 1713 void ReduceNewSpaceSize();
1690 1714
1691 bool TryFinalizeIdleIncrementalMarking(
1692 double idle_time_in_ms, size_t size_of_objects,
1693 size_t mark_compact_speed_in_bytes_per_ms);
1694
1695 GCIdleTimeHeapState ComputeHeapState(); 1715 GCIdleTimeHeapState ComputeHeapState();
1696 1716
1697 bool PerformIdleTimeAction(GCIdleTimeAction action, 1717 bool PerformIdleTimeAction(GCIdleTimeAction action,
1698 GCIdleTimeHeapState heap_state, 1718 GCIdleTimeHeapState heap_state,
1699 double deadline_in_ms); 1719 double deadline_in_ms);
1700 1720
1701 void IdleNotificationEpilogue(GCIdleTimeAction action, 1721 void IdleNotificationEpilogue(GCIdleTimeAction action,
1702 GCIdleTimeHeapState heap_state, double start_ms, 1722 GCIdleTimeHeapState heap_state, double start_ms,
1703 double deadline_in_ms); 1723 double deadline_in_ms);
1704 1724
1705 inline void UpdateAllocationsHash(HeapObject* object); 1725 inline void UpdateAllocationsHash(HeapObject* object);
1706 inline void UpdateAllocationsHash(uint32_t value); 1726 inline void UpdateAllocationsHash(uint32_t value);
1707 void PrintAlloctionsHash(); 1727 void PrintAlloctionsHash();
1708 1728
1709 void AddToRingBuffer(const char* string); 1729 void AddToRingBuffer(const char* string);
1710 void GetFromRingBuffer(char* buffer); 1730 void GetFromRingBuffer(char* buffer);
1711 1731
1712 void CompactRetainedMaps(ArrayList* retained_maps); 1732 void CompactRetainedMaps(ArrayList* retained_maps);
1713 1733
1714 void CollectGarbageOnMemoryPressure(const char* source); 1734 void CollectGarbageOnMemoryPressure();
1715 1735
1716 // Attempt to over-approximate the weak closure by marking object groups and 1736 // Attempt to over-approximate the weak closure by marking object groups and
1717 // implicit references from global handles, but don't atomically complete 1737 // implicit references from global handles, but don't atomically complete
1718 // marking. If we continue to mark incrementally, we might have marked 1738 // marking. If we continue to mark incrementally, we might have marked
1719 // objects that die later. 1739 // objects that die later.
1720 void FinalizeIncrementalMarking(const char* gc_reason); 1740 void FinalizeIncrementalMarking(GarbageCollectionReason gc_reason);
1721 1741
1722 // Returns the timer used for a given GC type. 1742 // Returns the timer used for a given GC type.
1723 // - GCScavenger: young generation GC 1743 // - GCScavenger: young generation GC
1724 // - GCCompactor: full GC 1744 // - GCCompactor: full GC
1725 // - GCFinalzeMC: finalization of incremental full GC 1745 // - GCFinalzeMC: finalization of incremental full GC
1726 // - GCFinalizeMCReduceMemory: finalization of incremental full GC with 1746 // - GCFinalizeMCReduceMemory: finalization of incremental full GC with
1727 // memory reduction 1747 // memory reduction
1728 HistogramTimer* GCTypeTimer(GarbageCollector collector); 1748 HistogramTimer* GCTypeTimer(GarbageCollector collector);
1729 1749
1730 // =========================================================================== 1750 // ===========================================================================
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 friend class LargeObjectSpace; 2632 friend class LargeObjectSpace;
2613 friend class NewSpace; 2633 friend class NewSpace;
2614 friend class PagedSpace; 2634 friend class PagedSpace;
2615 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); 2635 DISALLOW_COPY_AND_ASSIGN(AllocationObserver);
2616 }; 2636 };
2617 2637
2618 } // namespace internal 2638 } // namespace internal
2619 } // namespace v8 2639 } // namespace v8
2620 2640
2621 #endif // V8_HEAP_HEAP_H_ 2641 #endif // V8_HEAP_HEAP_H_
OLDNEW
« src/heap/gc-tracer.h ('K') | « src/heap/gc-tracer.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698