GCEnum.h 5.16 KB
Newer Older
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
 * vim: set ts=8 sts=2 et sw=2 tw=80:
3
4
5
6
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

7
8
9
10
/*
 * GC-internal enum definitions.
 */

11
12
13
14
15
#ifndef gc_GCEnum_h
#define gc_GCEnum_h

#include <stdint.h>

16
#include "js/MemoryFunctions.h"  // JS_FOR_EACH_PUBLIC_MEMORY_USE
17

18
19
20
namespace js {
namespace gc {

21
22
23
// Mark colors. Order is important here: the greater value the 'more marked' a
// cell is.
enum class MarkColor : uint8_t { Gray = 1, Black = 2 };
24

25
26
// The phases of an incremental GC.
#define GCSTATES(D) \
27
28
29
30
31
32
  D(NotActive)      \
  D(MarkRoots)      \
  D(Mark)           \
  D(Sweep)          \
  D(Finalize)       \
  D(Compact)        \
33
34
  D(Decommit)       \
  D(Finish)
35
36
enum class State {
#define MAKE_STATE(name) name,
37
  GCSTATES(MAKE_STATE)
38
39
40
41
#undef MAKE_STATE
};

// Reasons we reset an ongoing incremental GC or perform a non-incremental GC.
42
43
44
45
46
47
48
49
50
51
52
53
54
#define GC_ABORT_REASONS(D)      \
  D(None, 0)                     \
  D(NonIncrementalRequested, 1)  \
  D(AbortRequested, 2)           \
  D(Unused1, 3)                  \
  D(IncrementalDisabled, 4)      \
  D(ModeChange, 5)               \
  D(MallocBytesTrigger, 6)       \
  D(GCBytesTrigger, 7)           \
  D(ZoneChange, 8)               \
  D(CompartmentRevived, 9)       \
  D(GrayRootBufferingFailed, 10) \
  D(JitCodeBytesTrigger, 11)
55
enum class AbortReason {
56
#define MAKE_REASON(name, num) name = num,
57
  GC_ABORT_REASONS(MAKE_REASON)
58
59
60
#undef MAKE_REASON
};

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#define JS_FOR_EACH_ZEAL_MODE(D)       \
  D(RootsChange, 1)                    \
  D(Alloc, 2)                          \
  D(VerifierPre, 4)                    \
  D(GenerationalGC, 7)                 \
  D(YieldBeforeMarking, 8)             \
  D(YieldBeforeSweeping, 9)            \
  D(IncrementalMultipleSlices, 10)     \
  D(IncrementalMarkingValidator, 11)   \
  D(ElementsBarrier, 12)               \
  D(CheckHashTablesOnMinorGC, 13)      \
  D(Compact, 14)                       \
  D(CheckHeapAfterGC, 15)              \
  D(CheckNursery, 16)                  \
  D(YieldBeforeSweepingAtoms, 17)      \
  D(CheckGrayMarking, 18)              \
  D(YieldBeforeSweepingCaches, 19)     \
  D(YieldBeforeSweepingTypes, 20)      \
  D(YieldBeforeSweepingObjects, 21)    \
  D(YieldBeforeSweepingNonObjects, 22) \
81
  D(YieldBeforeSweepingShapeTrees, 23) \
82
83
  D(CheckWeakMapMarking, 24)           \
  D(YieldWhileGrayMarking, 25)
84
85
86

enum class ZealMode {
#define ZEAL_MODE(name, value) name = value,
87
  JS_FOR_EACH_ZEAL_MODE(ZEAL_MODE)
88
#undef ZEAL_MODE
89
90
      Count,
  Limit = Count - 1
91
92
};

93
} /* namespace gc */
94

95
96
#define JS_FOR_EACH_INTERNAL_MEMORY_USE(_) \
  _(ArrayBufferContents)                   \
97
  _(StringContents)                        \
98
  _(ObjectElements)                        \
99
100
  _(ObjectSlots)                           \
  _(ScriptPrivateData)                     \
101
  _(MapObjectTable)                        \
102
  _(BigIntDigits)                          \
103
  _(ScopeData)                             \
104
  _(WeakMapObject)                         \
105
  _(ShapeChildren)                         \
106
  _(ShapeCache)                            \
107
108
  _(ModuleBindingMap)                      \
  _(BaselineScript)                        \
109
110
  _(IonScript)                             \
  _(ArgumentsData)                         \
111
  _(RareArgumentsData)                     \
112
  _(RegExpStatics)                         \
113
  _(RegExpSharedBytecode)                  \
114
  _(TypedArrayElements)                    \
115
  _(TypeDescrTraceList)                    \
116
  _(NativeIterator)                        \
117
  _(JitScript)                             \
118
119
  _(ObjectGroupAddendum)                   \
  _(ScriptDebugScript)                     \
120
  _(BreakpointSite)                        \
121
  _(Breakpoint)                            \
122
  _(ForOfPIC)                              \
123
124
125
126
127
128
129
  _(ForOfPICStub)                          \
  _(WasmInstanceExports)                   \
  _(WasmInstanceScopes)                    \
  _(WasmInstanceGlobals)                   \
  _(WasmInstanceInstance)                  \
  _(WasmMemoryObservers)                   \
  _(WasmGlobalCell)                        \
130
131
  _(WasmResolveResponseClosure)            \
  _(WasmModule)                            \
132
  _(WasmTableTable)                        \
133
134
135
136
137
138
  _(FileObjectFile)                        \
  _(Debugger)                              \
  _(DebuggerFrameGeneratorInfo)            \
  _(DebuggerFrameIterData)                 \
  _(DebuggerOnStepHandler)                 \
  _(DebuggerOnPopHandler)                  \
139
  _(RealmInstrumentation)                  \
140
  _(ICUObject)                             \
141
  _(FinalizationGroupRecordVector)         \
142
  _(FinalizationGroupRegistrations)        \
143
144
  _(FinalizationRecordVector)              \
  _(ZoneAllocPolicy)
145

146
147
#define JS_FOR_EACH_MEMORY_USE(_)  \
  JS_FOR_EACH_PUBLIC_MEMORY_USE(_) \
148
149
150
151
152
153
154
155
  JS_FOR_EACH_INTERNAL_MEMORY_USE(_)

enum class MemoryUse : uint8_t {
#define DEFINE_MEMORY_USE(Name) Name,
  JS_FOR_EACH_MEMORY_USE(DEFINE_MEMORY_USE)
#undef DEFINE_MEMORY_USE
};

156
157
158
} /* namespace js */

#endif /* gc_GCEnum_h */