| 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 |
_(MapObjectData) \ |
| 115 |
_(BigIntDigits) \ |
| 116 |
_(ScopeData) \ |
| 117 |
_(WeakMapObject) \ |
| 118 |
_(ShapeSetForAdd) \ |
| 119 |
_(PropMapChildren) \ |
| 120 |
_(PropMapTable) \ |
| 121 |
_(ModuleBindingMap) \ |
| 122 |
_(ModuleCyclicFields) \ |
| 123 |
_(ModuleSyntheticFields) \ |
| 124 |
_(ModuleExports) \ |
| 125 |
_(ModuleImportAttributes) \ |
| 126 |
_(BaselineScript) \ |
| 127 |
_(IonScript) \ |
| 128 |
_(ArgumentsData) \ |
| 129 |
_(RareArgumentsData) \ |
| 130 |
_(RegExpSharedBytecode) \ |
| 131 |
_(RegExpSharedNamedCaptureData) \ |
| 132 |
_(RegExpSharedNamedCaptureSliceData) \ |
| 133 |
_(TypedArrayElements) \ |
| 134 |
_(NativeIterator) \ |
| 135 |
_(JitScript) \ |
| 136 |
_(ScriptDebugScript) \ |
| 137 |
_(BreakpointSite) \ |
| 138 |
_(Breakpoint) \ |
| 139 |
_(ForOfPIC) \ |
| 140 |
_(ForOfPICStub) \ |
| 141 |
_(WasmInstanceExports) \ |
| 142 |
_(WasmInstanceScopes) \ |
| 143 |
_(WasmInstanceGlobals) \ |
| 144 |
_(WasmInstanceInstance) \ |
| 145 |
_(WasmMemoryObservers) \ |
| 146 |
_(WasmGlobalCell) \ |
| 147 |
_(WasmResolveResponseClosure) \ |
| 148 |
_(WasmModule) \ |
| 149 |
_(WasmTableTable) \ |
| 150 |
_(WasmExceptionData) \ |
| 151 |
_(WasmTagType) \ |
| 152 |
_(FileObjectFile) \ |
| 153 |
_(Debugger) \ |
| 154 |
_(DebuggerFrameGeneratorInfo) \ |
| 155 |
_(DebuggerFrameIterData) \ |
| 156 |
_(DebuggerOnStepHandler) \ |
| 157 |
_(DebuggerOnPopHandler) \ |
| 158 |
_(ICUObject) \ |
| 159 |
_(FinalizationRegistryRecordVector) \ |
| 160 |
_(FinalizationRegistryRegistrations) \ |
| 161 |
_(FinalizationRecordVector) \ |
| 162 |
_(TrackedAllocPolicy) \ |
| 163 |
_(SharedArrayRawBuffer) \ |
| 164 |
_(XDRBufferElements) \ |
| 165 |
_(GlobalObjectData) \ |
| 166 |
_(ProxyExternalValueArray) \ |
| 167 |
_(WasmTrailerBlock) |
| 168 |
|
| 169 |
#define JS_FOR_EACH_MEMORY_USE(_) \ |
| 170 |
JS_FOR_EACH_PUBLIC_MEMORY_USE(_) \ |
| 171 |
JS_FOR_EACH_INTERNAL_MEMORY_USE(_) |
| 172 |
|
| 173 |
enum class MemoryUse : uint8_t { |
| 174 |
#define DEFINE_MEMORY_USE(Name) Name, |
| 175 |
JS_FOR_EACH_MEMORY_USE(DEFINE_MEMORY_USE) |
| 176 |
#undef DEFINE_MEMORY_USE |
| 177 |
}; |
| 178 |
|
| 179 |
} /* namespace js */ |
| 180 |
|
| 181 |
#endif /* gc_GCEnum_h */ |