GCEnum.h (6183B)
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/. */ 6 7 /* 8 * GC-internal enum definitions. 9 */ 10 11 #ifndef gc_GCEnum_h 12 #define gc_GCEnum_h 13 14 #include <stdint.h> 15 16 #include "js/MemoryFunctions.h" // JS_FOR_EACH_PUBLIC_MEMORY_USE 17 18 namespace js { 19 20 // [SMDOC] AllowGC template parameter 21 // 22 // AllowGC is a template parameter for functions that support both with and 23 // without GC operation. 24 // 25 // The CanGC variant of the function can trigger a garbage collection, and 26 // should set a pending exception on failure. 27 // 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 }; 35 36 namespace gc { 37 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 53 }; 54 55 #define JS_FOR_EACH_ZEAL_MODE(D) \ 56 D(RootsChange, 1) \ 57 D(Alloc, 2) \ 58 D(VerifierPre, 4) \ 59 D(VerifierPost, 5) \ 60 D(YieldBeforeRootMarking, 6) \ 61 D(GenerationalGC, 7) \ 62 D(YieldBeforeMarking, 8) \ 63 D(YieldBeforeSweeping, 9) \ 64 D(IncrementalMultipleSlices, 10) \ 65 D(IncrementalMarkingValidator, 11) \ 66 D(ElementsBarrier, 12) \ 67 D(CheckHashTablesOnMinorGC, 13) \ 68 D(Compact, 14) \ 69 D(CheckHeapAfterGC, 15) \ 70 D(YieldBeforeSweepingAtoms, 17) \ 71 D(CheckGrayMarking, 18) \ 72 D(YieldBeforeSweepingCaches, 19) \ 73 D(YieldBeforeSweepingObjects, 21) \ 74 D(YieldBeforeSweepingNonObjects, 22) \ 75 D(YieldBeforeSweepingPropMapTrees, 23) \ 76 D(CheckWeakMapMarking, 24) \ 77 D(YieldWhileGrayMarking, 25) \ 78 D(CheckHeapBeforeMinorGC, 26) 79 80 enum class ZealMode { 81 #define ZEAL_MODE(name, value) name = value, 82 JS_FOR_EACH_ZEAL_MODE(ZEAL_MODE) 83 #undef ZEAL_MODE 84 Count, 85 Limit = Count - 1 86 }; 87 88 } /* namespace gc */ 89 90 // Reasons we reset an ongoing incremental GC or perform a non-incremental GC. 91 #define GC_ABORT_REASONS(D) \ 92 D(None, 0) \ 93 D(NonIncrementalRequested, 1) \ 94 D(AbortRequested, 2) \ 95 D(Unused1, 3) \ 96 D(IncrementalDisabled, 4) \ 97 D(ModeChange, 5) \ 98 D(MallocBytesTrigger, 6) \ 99 D(GCBytesTrigger, 7) \ 100 D(ZoneChange, 8) \ 101 D(CompartmentRevived, 9) \ 102 D(GrayRootBufferingFailed, 10) \ 103 D(JitCodeBytesTrigger, 11) 104 enum class GCAbortReason { 105 #define MAKE_REASON(name, num) name = num, 106 GC_ABORT_REASONS(MAKE_REASON) 107 #undef MAKE_REASON 108 }; 109 110 #define JS_FOR_EACH_INTERNAL_MEMORY_USE(_) \ 111 _(ArrayBufferContents) \ 112 _(StringContents) \ 113 _(ScriptPrivateData) \ 114 _(WeakMapObject) \ 115 _(ShapeSetForAdd) \ 116 _(PropMapChildren) \ 117 _(PropMapTable) \ 118 _(ModuleBindingMap) \ 119 _(ModuleCyclicFields) \ 120 _(ModuleSyntheticFields) \ 121 _(ModuleExports) \ 122 _(ModuleImportAttributes) \ 123 _(BaselineScript) \ 124 _(IonScript) \ 125 _(ArgumentsData) \ 126 _(RareArgumentsData) \ 127 _(RegExpSharedBytecode) \ 128 _(RegExpSharedNamedCaptureData) \ 129 _(RegExpSharedNamedCaptureSliceData) \ 130 _(TypedArrayElements) \ 131 _(NativeIterator) \ 132 _(JitScript) \ 133 _(ScriptDebugScript) \ 134 _(BreakpointSite) \ 135 _(Breakpoint) \ 136 _(WasmInstanceExports) \ 137 _(WasmInstanceScopes) \ 138 _(WasmInstanceGlobals) \ 139 _(WasmInstanceInstance) \ 140 _(WasmMemoryObservers) \ 141 _(WasmGlobalCell) \ 142 _(WasmResolveResponseClosure) \ 143 _(WasmModule) \ 144 _(WasmTableTable) \ 145 _(WasmExceptionData) \ 146 _(WasmTagType) \ 147 _(FileObjectFile) \ 148 _(Debugger) \ 149 _(DebuggerFrameGeneratorInfo) \ 150 _(DebuggerFrameIterData) \ 151 _(DebuggerOnStepHandler) \ 152 _(DebuggerOnPopHandler) \ 153 _(ICUObject) \ 154 _(IntlOptions) \ 155 _(FinalizationRegistryRecordVector) \ 156 _(FinalizationRegistryRegistrations) \ 157 _(FinalizationRecordVector) \ 158 _(TrackedAllocPolicy) \ 159 _(SharedArrayRawBuffer) \ 160 _(XDRBufferElements) \ 161 _(GlobalObjectData) \ 162 _(ProxyExternalValueArray) \ 163 _(GraphLoadingStateRecord) 164 165 #define JS_FOR_EACH_MEMORY_USE(_) \ 166 JS_FOR_EACH_PUBLIC_MEMORY_USE(_) \ 167 JS_FOR_EACH_INTERNAL_MEMORY_USE(_) 168 169 enum class MemoryUse : uint8_t { 170 #define DEFINE_MEMORY_USE(Name) Name, 171 JS_FOR_EACH_MEMORY_USE(DEFINE_MEMORY_USE) 172 #undef DEFINE_MEMORY_USE 173 }; 174 175 } /* namespace js */ 176 177 #endif /* gc_GCEnum_h */