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/. */
8 * GC-internal enum definitions.
16 #include "js/MemoryFunctions.h" // JS_FOR_EACH_PUBLIC_MEMORY_USE
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 };
38 // The phases of an incremental GC.
50 #define MAKE_STATE(name) name,
55 #define JS_FOR_EACH_ZEAL_MODE(D) \
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) \
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)
79 #define ZEAL_MODE(name, value) name = value,
80 JS_FOR_EACH_ZEAL_MODE(ZEAL_MODE
)
88 // Reasons we reset an ongoing incremental GC or perform a non-incremental GC.
89 #define GC_ABORT_REASONS(D) \
91 D(NonIncrementalRequested, 1) \
92 D(AbortRequested, 2) \
94 D(IncrementalDisabled, 4) \
96 D(MallocBytesTrigger, 6) \
97 D(GCBytesTrigger, 7) \
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
)
108 #define JS_FOR_EACH_INTERNAL_MEMORY_USE(_) \
109 _(ArrayBufferContents) \
113 _(ScriptPrivateData) \
121 _(ModuleBindingMap) \
122 _(ModuleCyclicFields) \
123 _(ModuleSyntheticFields) \
128 _(RareArgumentsData) \
129 _(RegExpSharedBytecode) \
130 _(RegExpSharedNamedCaptureData) \
131 _(TypedArrayElements) \
134 _(ScriptDebugScript) \
139 _(WasmInstanceExports) \
140 _(WasmInstanceScopes) \
141 _(WasmInstanceGlobals) \
142 _(WasmInstanceInstance) \
143 _(WasmMemoryObservers) \
145 _(WasmResolveResponseClosure) \
148 _(WasmExceptionData) \
152 _(DebuggerFrameGeneratorInfo) \
153 _(DebuggerFrameIterData) \
154 _(DebuggerOnStepHandler) \
155 _(DebuggerOnPopHandler) \
157 _(FinalizationRegistryRecordVector) \
158 _(FinalizationRegistryRegistrations) \
159 _(FinalizationRecordVector) \
160 _(TrackedAllocPolicy) \
161 _(SharedArrayRawBuffer) \
162 _(XDRBufferElements) \
163 _(GlobalObjectData) \
164 _(ProxyExternalValueArray) \
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
179 #endif /* gc_GCEnum_h */