js/src/gc/GCEnum.h
author Jon Coppeard <jcoppeard@mozilla.com>
Wed, 22 May 2019 20:29:10 +0000
changeset 475174 7cce412dd61b40d0ceda37ed32a64dda7d7b5e8d
parent 450767 d5542a14b416d3d7e4e846368ceb37d6714827aa
child 475401 83e89748aaac69c8ca94ef64847d9fd1640cbd63
permissions -rw-r--r--
Bug 1553491 - Renumber MarkColor to match intuition that 'black' is more marked than 'gray' r=sfink? Differential Revision: https://phabricator.services.mozilla.com/D32160

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * vim: set ts=8 sts=2 et sw=2 tw=80:
 * This Source Code Form is subject to the terms of the Mozilla Public
 * 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

#include <stdint.h>

namespace js {
namespace gc {

// Mark colors. Order is important here: the greater value the 'more marked' a
// cell is.
enum class MarkColor : uint8_t { Gray = 1, Black = 2 };

// The phases of an incremental GC.
#define GCSTATES(D) \
  D(NotActive)      \
  D(MarkRoots)      \
  D(Mark)           \
  D(Sweep)          \
  D(Finalize)       \
  D(Compact)        \
  D(Decommit)       \
  D(Finish)
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, 0)                    \
  D(NonIncrementalRequested, 1) \
  D(AbortRequested, 2)          \
  D(Unused1, 3)                 \
  D(IncrementalDisabled, 4)     \
  D(ModeChange, 5)              \
  D(MallocBytesTrigger, 6)      \
  D(GCBytesTrigger, 7)          \
  D(ZoneChange, 8)              \
  D(CompartmentRevived, 9)      \
  D(GrayRootBufferingFailed, 10)
enum class AbortReason {
#define MAKE_REASON(name, num) name = num,
  GC_ABORT_REASONS(MAKE_REASON)
#undef MAKE_REASON
};

#define JS_FOR_EACH_ZEAL_MODE(D)       \
  D(RootsChange, 1)                    \
  D(Alloc, 2)                          \
  D(VerifierPre, 4)                    \
  D(GenerationalGC, 7)                 \
  D(YieldBeforeMarking, 8)             \
  D(YieldBeforeSweeping, 9)            \
  D(IncrementalMultipleSlices, 10)     \
  D(IncrementalMarkingValidator, 11)   \
  D(ElementsBarrier, 12)               \
  D(CheckHashTablesOnMinorGC, 13)      \
  D(Compact, 14)                       \
  D(CheckHeapAfterGC, 15)              \
  D(CheckNursery, 16)                  \
  D(YieldBeforeSweepingAtoms, 17)      \
  D(CheckGrayMarking, 18)              \
  D(YieldBeforeSweepingCaches, 19)     \
  D(YieldBeforeSweepingTypes, 20)      \
  D(YieldBeforeSweepingObjects, 21)    \
  D(YieldBeforeSweepingNonObjects, 22) \
  D(YieldBeforeSweepingShapeTrees, 23) \
  D(CheckWeakMapMarking, 24)           \
  D(YieldWhileGrayMarking, 25)

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

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

#endif /* gc_GCEnum_h */