Index: src/heap/heap.h |
diff --git a/src/heap/heap.h b/src/heap/heap.h |
index 75b09df527e03e285d860b1b69e07e14fe2f63e4..dad22900de7469901303e75481cdca933f4266cc 100644 |
--- a/src/heap/heap.h |
+++ b/src/heap/heap.h |
@@ -10,6 +10,7 @@ |
#include "src/allocation.h" |
#include "src/assert-scope.h" |
+#include "src/base/flags.h" |
#include "src/globals.h" |
#include "src/heap/gc-idle-time-handler.h" |
#include "src/heap/incremental-marking.h" |
@@ -609,6 +610,18 @@ class Heap { |
kSmiRootsStart = kStringTableRootIndex + 1 |
}; |
+ // Flags to indicate modes for a GC run. |
+ enum GCFlag { |
+ kNoGCFlags = 0u, |
+ kReduceMemoryFootprintMask = 1u << 0, |
+ kAbortIncrementalMarkingMask = 1u << 1, |
+ kFinalizeIncrementalMarkingMask = 1u << 2, |
+ |
+ // Making the heap iterable requires us to abort incremental marking. |
+ kMakeHeapIterableMask = kAbortIncrementalMarkingMask, |
+ }; |
+ typedef base::Flags<GCFlag> GCFlags; |
+ |
// Indicates whether live bytes adjustment is triggered |
// - from within the GC code before sweeping started (SEQUENTIAL_TO_SWEEPER), |
// - or from within GC (CONCURRENT_TO_SWEEPER), |
@@ -733,14 +746,6 @@ class Heap { |
// callee is only valid in sloppy mode. |
static const int kArgumentsCalleeIndex = 1; |
- static const int kNoGCFlags = 0; |
- static const int kReduceMemoryFootprintMask = 1; |
- static const int kAbortIncrementalMarkingMask = 2; |
- static const int kFinalizeIncrementalMarkingMask = 4; |
- |
- // Making the heap iterable requires us to abort incremental marking. |
- static const int kMakeHeapIterableMask = kAbortIncrementalMarkingMask; |
- |
// The roots that have an index less than this are always in old space. |
static const int kOldSpaceRoots = 0x20; |
@@ -1312,22 +1317,22 @@ class Heap { |
// Methods triggering GCs. =================================================== |
// =========================================================================== |
- // Performs garbage collection operation. |
+ // Perform a garbage collection operation in a given space. |
// Returns whether there is a chance that another major GC could |
// collect more garbage. |
inline bool CollectGarbage( |
- AllocationSpace space, const char* gc_reason = NULL, |
- const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
+ AllocationSpace space, const char* gc_reason = nullptr, |
+ const GCFlags flags = kNoGCFlags, |
+ const GCCallbackFlags callback_flags = kNoGCCallbackFlags); |
- // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is |
- // non-zero, then the slower precise sweeper is used, which leaves the heap |
- // in a state where we can iterate over the heap visiting all objects. |
+ // Performs a full garbage collection. |
void CollectAllGarbage( |
- int flags = kFinalizeIncrementalMarkingMask, const char* gc_reason = NULL, |
+ const char* gc_reason = nullptr, |
+ const GCFlags flags = Heap::kFinalizeIncrementalMarkingMask, |
const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
// Last hope GC, should try to squeeze as much as possible. |
- void CollectAllAvailableGarbage(const char* gc_reason = NULL); |
+ void CollectAllAvailableGarbage(const char* gc_reason = nullptr); |
// Invoked when GC was requested via the stack guard. |
void HandleGCRequest(); |
@@ -1362,7 +1367,7 @@ class Heap { |
// Starts incremental marking assuming incremental marking is currently |
// stopped. |
- void StartIncrementalMarking(int gc_flags = kNoGCFlags, |
+ void StartIncrementalMarking(const GCFlags = kNoGCFlags, |
const GCCallbackFlags gc_callback_flags = |
GCCallbackFlags::kNoGCCallbackFlags, |
const char* reason = nullptr); |
@@ -1671,7 +1676,7 @@ class Heap { |
ROOT_LIST(ROOT_ACCESSOR) |
#undef ROOT_ACCESSOR |
- void set_current_gc_flags(int flags) { |
+ void set_current_gc_flags(GCFlags flags) { |
current_gc_flags_ = flags; |
DCHECK(!ShouldFinalizeIncrementalMarking() || |
!ShouldAbortIncrementalMarking()); |
@@ -1713,17 +1718,13 @@ class Heap { |
// Performs garbage collection operation. |
// Returns whether there is a chance that another major GC could |
// collect more garbage. |
- bool CollectGarbage( |
- GarbageCollector collector, const char* gc_reason, |
- const char* collector_reason, |
- const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
+ bool CollectGarbage(GarbageCollector collector, const char* gc_reason, |
+ const char* collector_reason); |
// Performs garbage collection |
// Returns whether there is a chance another major GC could |
// collect more garbage. |
- bool PerformGarbageCollection( |
- GarbageCollector collector, |
- const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
+ bool PerformGarbageCollection(GarbageCollector collector); |
inline void UpdateOldSpaceLimits(); |
@@ -2343,7 +2344,7 @@ class Heap { |
bool configured_; |
// Currently set GC flags that are respected by all GC components. |
- int current_gc_flags_; |
+ GCFlags current_gc_flags_; |
// Currently set GC callback flags that are used to pass information between |
// the embedder and V8's GC. |