Bug 1874684 - Part 10: Replace BigInt with Int128 in RoundNumberToIncrement. r=mgaudet
[gecko.git] / js / src / gc / GCEnum.h
blobd60cfaea76658ec0b248d360b6367273a198c796
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 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /*
8 * GC-internal enum definitions.
9 */
11 #ifndef gc_GCEnum_h
12 #define gc_GCEnum_h
14 #include <stdint.h>
16 #include "js/MemoryFunctions.h" // JS_FOR_EACH_PUBLIC_MEMORY_USE
18 namespace js {
20 // [SMDOC] AllowGC template parameter
22 // AllowGC is a template parameter for functions that support both with and
23 // without GC operation.
25 // The CanGC variant of the function can trigger a garbage collection, and
26 // should set a pending exception on failure.
28 // The NoGC variant of the function cannot trigger a garbage collection, and
29 // should not set any pending exception on failure. This variant can be called
30 // in fast paths where the caller has unrooted pointers. The failure means we
31 // need to perform GC to allocate an object. The caller can fall back to a slow
32 // path that roots pointers before calling a CanGC variant of the function,
33 // without having to clear a pending exception.
34 enum AllowGC { NoGC = 0, CanGC = 1 };
36 namespace gc {
38 // The phases of an incremental GC.
39 #define GCSTATES(D) \
40 D(NotActive) \
41 D(Prepare) \
42 D(MarkRoots) \
43 D(Mark) \
44 D(Sweep) \
45 D(Finalize) \
46 D(Compact) \
47 D(Decommit) \
48 D(Finish)
49 enum class State {
50 #define MAKE_STATE(name) name,
51 GCSTATES(MAKE_STATE)
52 #undef MAKE_STATE
55 #define JS_FOR_EACH_ZEAL_MODE(D) \
56 D(RootsChange, 1) \
57 D(Alloc, 2) \
58 D(VerifierPre, 4) \
59 D(YieldBeforeRootMarking, 6) \
60 D(GenerationalGC, 7) \
61 D(YieldBeforeMarking, 8) \
62 D(YieldBeforeSweeping, 9) \
63 D(IncrementalMultipleSlices, 10) \
64 D(IncrementalMarkingValidator, 11) \
65 D(ElementsBarrier, 12) \
66 D(CheckHashTablesOnMinorGC, 13) \
67 D(Compact, 14) \
68 D(CheckHeapAfterGC, 15) \
69 D(YieldBeforeSweepingAtoms, 17) \
70 D(CheckGrayMarking, 18) \
71 D(YieldBeforeSweepingCaches, 19) \
72 D(YieldBeforeSweepingObjects, 21) \
73 D(YieldBeforeSweepingNonObjects, 22) \
74 D(YieldBeforeSweepingPropMapTrees, 23) \
75 D(CheckWeakMapMarking, 24) \
76 D(YieldWhileGrayMarking, 25)
78 enum class ZealMode {
79 #define ZEAL_MODE(name, value) name = value,
80 JS_FOR_EACH_ZEAL_MODE(ZEAL_MODE)
81 #undef ZEAL_MODE
82 Count,
83 Limit = Count - 1
86 } /* namespace gc */
88 // Reasons we reset an ongoing incremental GC or perform a non-incremental GC.
89 #define GC_ABORT_REASONS(D) \
90 D(None, 0) \
91 D(NonIncrementalRequested, 1) \
92 D(AbortRequested, 2) \
93 D(Unused1, 3) \
94 D(IncrementalDisabled, 4) \
95 D(ModeChange, 5) \
96 D(MallocBytesTrigger, 6) \
97 D(GCBytesTrigger, 7) \
98 D(ZoneChange, 8) \
99 D(CompartmentRevived, 9) \
100 D(GrayRootBufferingFailed, 10) \
101 D(JitCodeBytesTrigger, 11)
102 enum class GCAbortReason {
103 #define MAKE_REASON(name, num) name = num,
104 GC_ABORT_REASONS(MAKE_REASON)
105 #undef MAKE_REASON
108 #define JS_FOR_EACH_INTERNAL_MEMORY_USE(_) \
109 _(ArrayBufferContents) \
110 _(StringContents) \
111 _(ObjectElements) \
112 _(ObjectSlots) \
113 _(ScriptPrivateData) \
114 _(MapObjectTable) \
115 _(BigIntDigits) \
116 _(ScopeData) \
117 _(WeakMapObject) \
118 _(ShapeSetForAdd) \
119 _(PropMapChildren) \
120 _(PropMapTable) \
121 _(ModuleBindingMap) \
122 _(ModuleCyclicFields) \
123 _(ModuleSyntheticFields) \
124 _(ModuleExports) \
125 _(BaselineScript) \
126 _(IonScript) \
127 _(ArgumentsData) \
128 _(RareArgumentsData) \
129 _(RegExpSharedBytecode) \
130 _(RegExpSharedNamedCaptureData) \
131 _(TypedArrayElements) \
132 _(NativeIterator) \
133 _(JitScript) \
134 _(ScriptDebugScript) \
135 _(BreakpointSite) \
136 _(Breakpoint) \
137 _(ForOfPIC) \
138 _(ForOfPICStub) \
139 _(WasmInstanceExports) \
140 _(WasmInstanceScopes) \
141 _(WasmInstanceGlobals) \
142 _(WasmInstanceInstance) \
143 _(WasmMemoryObservers) \
144 _(WasmGlobalCell) \
145 _(WasmResolveResponseClosure) \
146 _(WasmModule) \
147 _(WasmTableTable) \
148 _(WasmExceptionData) \
149 _(WasmTagType) \
150 _(FileObjectFile) \
151 _(Debugger) \
152 _(DebuggerFrameGeneratorInfo) \
153 _(DebuggerFrameIterData) \
154 _(DebuggerOnStepHandler) \
155 _(DebuggerOnPopHandler) \
156 _(ICUObject) \
157 _(FinalizationRegistryRecordVector) \
158 _(FinalizationRegistryRegistrations) \
159 _(FinalizationRecordVector) \
160 _(TrackedAllocPolicy) \
161 _(SharedArrayRawBuffer) \
162 _(XDRBufferElements) \
163 _(GlobalObjectData) \
164 _(ProxyExternalValueArray) \
165 _(WasmTrailerBlock)
167 #define JS_FOR_EACH_MEMORY_USE(_) \
168 JS_FOR_EACH_PUBLIC_MEMORY_USE(_) \
169 JS_FOR_EACH_INTERNAL_MEMORY_USE(_)
171 enum class MemoryUse : uint8_t {
172 #define DEFINE_MEMORY_USE(Name) Name,
173 JS_FOR_EACH_MEMORY_USE(DEFINE_MEMORY_USE)
174 #undef DEFINE_MEMORY_USE
177 } /* namespace js */
179 #endif /* gc_GCEnum_h */