Commit 07bd8710 authored by Jon Coppeard's avatar Jon Coppeard
Browse files

Bug 1412912 - Split out interal enums into GCEnums.h r=sfink

parent b889aa46
Loading
Loading
Loading
Loading
+63 −1
Original line number Diff line number Diff line
@@ -4,6 +4,10 @@
 * 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/. */

/*
 * GC-internal enum definitions.
 */

#ifndef gc_GCEnum_h
#define gc_GCEnum_h

@@ -12,13 +16,71 @@
namespace js {
namespace gc {

/* Mark colors to pass to markIfUnmarked. */
// Mark colors to pass to markIfUnmarked.
enum class MarkColor : uint32_t
{
    Black = 0,
    Gray
};

// The phases of an incremental GC.
#define GCSTATES(D) \
    D(NotActive) \
    D(MarkRoots) \
    D(Mark) \
    D(Sweep) \
    D(Finalize) \
    D(Compact) \
    D(Decommit)
enum class State {
#define MAKE_STATE(name) name,
    GCSTATES(MAKE_STATE)
#undef MAKE_STATE
};

// Reasons we reset an ongoing incremental GC or perform a non-incremental GC.
#define GC_ABORT_REASONS(D) \
    D(None) \
    D(NonIncrementalRequested) \
    D(AbortRequested) \
    D(Unused1) \
    D(IncrementalDisabled) \
    D(ModeChange) \
    D(MallocBytesTrigger) \
    D(GCBytesTrigger) \
    D(ZoneChange) \
    D(CompartmentRevived)
enum class AbortReason {
#define MAKE_REASON(name) name,
    GC_ABORT_REASONS(MAKE_REASON)
#undef MAKE_REASON
};

#define JS_FOR_EACH_ZEAL_MODE(D)       \
    D(RootsChange, 1)                  \
    D(Alloc, 2)                        \
    D(FrameGC, 3)                      \
    D(VerifierPre, 4)                  \
    D(FrameVerifierPre, 5)             \
    D(GenerationalGC, 7)               \
    D(IncrementalRootsThenFinish, 8)   \
    D(IncrementalMarkAllThenFinish, 9) \
    D(IncrementalMultipleSlices, 10)   \
    D(IncrementalMarkingValidator, 11) \
    D(ElementsBarrier, 12)             \
    D(CheckHashTablesOnMinorGC, 13)    \
    D(Compact, 14)                     \
    D(CheckHeapAfterGC, 15)            \
    D(CheckNursery, 16)                \
    D(IncrementalSweepThenFinish, 17)

enum class ZealMode {
#define ZEAL_MODE(name, value) name = value,
    JS_FOR_EACH_ZEAL_MODE(ZEAL_MODE)
#undef ZEAL_MODE
    Limit = 17
};

} /* namespace gc */
} /* namespace js */

+5 −72
Original line number Diff line number Diff line
@@ -4,7 +4,9 @@
 * 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/. */

/* JS Garbage Collector. */
/*
 * JS engine garbage collector API.
 */

#ifndef jsgc_h
#define jsgc_h
@@ -32,38 +34,6 @@ class Nursery;

namespace gc {

#define GCSTATES(D) \
    D(NotActive) \
    D(MarkRoots) \
    D(Mark) \
    D(Sweep) \
    D(Finalize) \
    D(Compact) \
    D(Decommit)
enum class State {
#define MAKE_STATE(name) name,
    GCSTATES(MAKE_STATE)
#undef MAKE_STATE
};

// Reasons we reset an ongoing incremental GC or perform a non-incremental GC.
#define GC_ABORT_REASONS(D) \
    D(None) \
    D(NonIncrementalRequested) \
    D(AbortRequested) \
    D(Unused1) \
    D(IncrementalDisabled) \
    D(ModeChange) \
    D(MallocBytesTrigger) \
    D(GCBytesTrigger) \
    D(ZoneChange) \
    D(CompartmentRevived)
enum class AbortReason {
#define MAKE_REASON(name) name,
    GC_ABORT_REASONS(MAKE_REASON)
#undef MAKE_REASON
};

/*
 * Map from C++ type to alloc kind for non-object types. JSObject does not have
 * a 1:1 mapping, so must use Arena::thingSize.
@@ -84,16 +54,8 @@ template <typename T> struct ParticipatesInCC {};
JS_FOR_EACH_TRACEKIND(EXPAND_PARTICIPATES_IN_CC)
#undef EXPAND_PARTICIPATES_IN_CC

/* The number of GC cycles an empty chunk can survive before been released. */
const size_t MAX_EMPTY_CHUNK_AGE = 4;

extern bool
InitializeStaticData();

} /* namespace gc */

class InterpreterFrame;

extern void
TraceRuntime(JSTracer* trc);

@@ -272,31 +234,6 @@ inline void CheckValueAfterMovingGC(const JS::Value& value);

#endif // JSGC_HASH_TABLE_CHECKS

#define JS_FOR_EACH_ZEAL_MODE(D)               \
            D(RootsChange, 1)                  \
            D(Alloc, 2)                        \
            D(FrameGC, 3)                      \
            D(VerifierPre, 4)                  \
            D(FrameVerifierPre, 5)             \
            D(GenerationalGC, 7)               \
            D(IncrementalRootsThenFinish, 8)   \
            D(IncrementalMarkAllThenFinish, 9) \
            D(IncrementalMultipleSlices, 10)   \
            D(IncrementalMarkingValidator, 11) \
            D(ElementsBarrier, 12)             \
            D(CheckHashTablesOnMinorGC, 13)    \
            D(Compact, 14)                     \
            D(CheckHeapAfterGC, 15)            \
            D(CheckNursery, 16)                \
            D(IncrementalSweepThenFinish, 17)

enum class ZealMode {
#define ZEAL_MODE(name, value) name = value,
    JS_FOR_EACH_ZEAL_MODE(ZEAL_MODE)
#undef ZEAL_MODE
    Limit = 17
};

enum VerifierType {
    PreBarrierVerifier
};
@@ -317,14 +254,10 @@ void DumpArenaInfo();
#else

static inline void
VerifyBarriers(JSRuntime* rt, VerifierType type)
{
}
VerifyBarriers(JSRuntime* rt, VerifierType type) {}

static inline void
MaybeVerifyBarriers(JSContext* cx, bool always = false)
{
}
MaybeVerifyBarriers(JSContext* cx, bool always = false) {}

#endif