Bug 1412912 - Split out interal enums into GCEnums.h r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 01 Nov 2017 15:37:54 +0000
changeset 690389 370c73377b901036c54071cd42517d6f1144b613
parent 690388 45eedc2acce303672f97a8752bfccfff7e23d9a0
child 690390 d9768f777cf5111c1c67bddddd81cc069cf25802
push id87288
push usercholler@mozilla.com
push dateWed, 01 Nov 2017 22:09:51 +0000
reviewerssfink
bugs1412912
milestone58.0a1
Bug 1412912 - Split out interal enums into GCEnums.h r=sfink
js/src/gc/GCEnum.h
js/src/jsgc.h
--- a/js/src/gc/GCEnum.h
+++ b/js/src/gc/GCEnum.h
@@ -1,25 +1,87 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * 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 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 */
 
 #endif /* gc_GCEnum_h */
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -1,15 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * 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/. */
 
-/* JS Garbage Collector. */
+/*
+ * JS engine garbage collector API.
+ */
 
 #ifndef jsgc_h
 #define jsgc_h
 
 #include "mozilla/Atomics.h"
 #include "mozilla/EnumeratedArray.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TimeStamp.h"
@@ -27,48 +29,16 @@ namespace js {
 namespace gcstats {
 struct Statistics;
 } // namespace gcstats
 
 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.
  *
  * The AllocKind is available as MapTypeToFinalizeKind<SomeType>::kind.
  */
 template <typename T> struct MapTypeToFinalizeKind {};
 #define EXPAND_MAPTYPETOFINALIZEKIND(allocKind, traceKind, type, sizedType) \
@@ -79,26 +49,18 @@ FOR_EACH_NONOBJECT_ALLOCKIND(EXPAND_MAPT
 #undef EXPAND_MAPTYPETOFINALIZEKIND
 
 template <typename T> struct ParticipatesInCC {};
 #define EXPAND_PARTICIPATES_IN_CC(_, type, addToCCKind) \
     template <> struct ParticipatesInCC<type> { static const bool value = addToCCKind; };
 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);
 
 extern void
 ReleaseAllJITCode(FreeOp* op);
 
 extern void
 PrepareForDebugGC(JSRuntime* rt);
@@ -267,41 +229,16 @@ inline void CheckGCThingAfterMovingGC(T*
 
 template <typename T>
 inline void CheckGCThingAfterMovingGC(const ReadBarriered<T*>& t);
 
 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
 };
 
 #ifdef JS_GC_ZEAL
 
 extern const char* ZealModeHelpText;
 
@@ -312,24 +249,20 @@ VerifyBarriers(JSRuntime* rt, VerifierTy
 void
 MaybeVerifyBarriers(JSContext* cx, bool always = false);
 
 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
 
 /*
  * Instances of this class set the |JSRuntime::suppressGC| flag for the duration
  * that they are live. Use of this class is highly discouraged. Please carefully
  * read the comment in vm/Runtime.h above |suppressGC| and take all appropriate
  * precautions before instantiating this class.