Bug 1506774 - Discard TypeScripts whenever we discard JIT code. r=jonco
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 13 Nov 2018 10:39:00 +0000
changeset 446027 34ee07ca08e9ca5418d83574be6c1f6bbf3b5a3e
parent 446026 25413533daa2119771a046431854918b3f42d017
child 446028 b208cb6b1aa4eeed3f8d6943e5904bd4c12bf37e
push id109819
push usernerli@mozilla.com
push dateTue, 13 Nov 2018 16:35:04 +0000
treeherdermozilla-inbound@b0cacbf71b3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1506774, 1506479
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1506774 - Discard TypeScripts whenever we discard JIT code. r=jonco Bug 1506479 started unifying discarding of TypeScript and JIT code. This patch removes the JIT_SCRIPT_RELEASE_TYPES_PERIOD heuristic so we now use the same preserve-code heuristics for both. Differential Revision: https://phabricator.services.mozilla.com/D11737
js/src/gc/GC.cpp
js/src/gc/GCRuntime.h
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -988,17 +988,16 @@ GCRuntime::GCRuntime(JSRuntime* rt) :
     numActiveZoneIters(0),
     cleanUpEverything(false),
     grayBufferState(GCRuntime::GrayBufferState::Unused),
     grayBitsValid(false),
     majorGCTriggerReason(JS::gcreason::NO_REASON),
     fullGCForAtomsRequested_(false),
     minorGCNumber(0),
     majorGCNumber(0),
-    jitReleaseNumber(0),
     number(0),
     isFull(false),
     incrementalState(gc::State::NotActive),
     initialState(gc::State::NotActive),
 #ifdef JS_GC_ZEAL
     useZeal(false),
 #endif
     lastMarkSlice(false),
@@ -1336,22 +1335,16 @@ js::gc::DumpArenaInfo()
                 Arena::thingSize(kind),
                 Arena::thingsPerArena(kind),
                 Arena::firstThingOffset(kind) - ArenaHeaderSize);
     }
 }
 
 #endif // JS_GC_ZEAL
 
-/*
- * Lifetime in number of major GCs for type sets attached to scripts containing
- * observed types.
- */
-static const unsigned JIT_SCRIPT_RELEASE_TYPES_PERIOD = 20;
-
 bool
 GCRuntime::init(uint32_t maxbytes, uint32_t maxNurseryBytes)
 {
     MOZ_ASSERT(SystemPageSize());
 
     {
         AutoLockGCBgAlloc lock(rt);
 
@@ -1359,18 +1352,16 @@ GCRuntime::init(uint32_t maxbytes, uint3
         MOZ_ALWAYS_TRUE(tunables.setParameter(JSGC_MAX_NURSERY_BYTES, maxNurseryBytes, lock));
         setMaxMallocBytes(TuningDefaults::MaxMallocBytes, lock);
 
         const char* size = getenv("JSGC_MARK_STACK_LIMIT");
         if (size) {
             setMarkStackLimit(atoi(size), lock);
         }
 
-        jitReleaseNumber = majorGCNumber + JIT_SCRIPT_RELEASE_TYPES_PERIOD;
-
         if (!nursery().init(maxNurseryBytes, lock)) {
             return false;
         }
     }
 
 #ifdef JS_GC_ZEAL
     const char* zealSpec = getenv("JS_GC_ZEAL");
     if (zealSpec && zealSpec[0] && !parseAndSetZeal(zealSpec)) {
@@ -3956,43 +3947,16 @@ GCRuntime::waitBackgroundSweepEnd()
     sweepTask.join();
 
     // TODO: Improve assertion to work in incremental GC?
     if (!isIncrementalGCInProgress()) {
         assertBackgroundSweepingFinished();
     }
 }
 
-bool
-GCRuntime::shouldReleaseObservedTypes()
-{
-    bool releaseTypes = false;
-
-    if (cleanUpEverything) {
-        releaseTypes = true;
-    }
-
-#ifdef JS_GC_ZEAL
-    if (zealModeBits != 0) {
-        releaseTypes = true;
-    }
-#endif
-
-    /* We may miss the exact target GC due to resets. */
-    if (majorGCNumber >= jitReleaseNumber) {
-        releaseTypes = true;
-    }
-
-    if (releaseTypes) {
-        jitReleaseNumber = majorGCNumber + JIT_SCRIPT_RELEASE_TYPES_PERIOD;
-    }
-
-    return releaseTypes;
-}
-
 struct IsAboutToBeFinalizedFunctor {
     template <typename T> bool operator()(Cell** t) {
         mozilla::DebugOnly<const Cell*> prior = *t;
         bool result = IsAboutToBeFinalizedUnbarriered(reinterpret_cast<T**>(t));
         // Sweep should not have to deal with moved pointers, since moving GC
         // handles updating the UID table manually.
         MOZ_ASSERT(*t == prior);
         return result;
@@ -4554,22 +4518,24 @@ GCRuntime::prepareZonesForCollection(JS:
      */
     MOZ_ASSERT_IF(reason == JS::gcreason::DELAYED_ATOMS_GC, atomsZone->isGCMarking());
 
     /* Check that at least one zone is scheduled for collection. */
     return any;
 }
 
 static void
-DiscardJITCodeForGC(JSRuntime* rt, bool releaseTypes)
+DiscardJITCodeForGC(JSRuntime* rt)
 {
     js::CancelOffThreadIonCompile(rt, JS::Zone::Mark);
     for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
         gcstats::AutoPhase ap(rt->gc.stats(), gcstats::PhaseKind::MARK_DISCARD_CODE);
-        zone->discardJitCode(rt->defaultFreeOp(), /* discardBaselineCode = */ true, releaseTypes);
+        zone->discardJitCode(rt->defaultFreeOp(),
+                             /* discardBaselineCode = */ true,
+                             /* releaseTypes = */ true);
     }
 }
 
 static void
 RelazifyFunctionsForShrinkingGC(JSRuntime* rt)
 {
     gcstats::AutoPhase ap(rt->gc.stats(), gcstats::PhaseKind::RELAZIFY_FUNCTIONS);
     for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
@@ -4666,17 +4632,17 @@ GCRuntime::beginMarkPhase(JS::gcreason::
         Maybe<AutoRunParallelTask> bufferGrayRoots;
         if (isIncremental) {
             bufferGrayRoots.emplace(rt, BufferGrayRoots, gcstats::PhaseKind::BUFFER_GRAY_ROOTS, helperLock);
         }
         AutoUnlockHelperThreadState unlock(helperLock);
 
         // Discard JIT code. For incremental collections, the sweep phase will
         // also discard JIT code.
-        DiscardJITCodeForGC(rt, shouldReleaseObservedTypes());
+        DiscardJITCodeForGC(rt);
 
         /*
          * Relazify functions after discarding JIT code (we can't relazify
          * functions with JIT code) and before the actual mark phase, so that
          * the current GC can collect the JSScripts we're unlinking here.  We do
          * this only when we're performing a shrinking GC, as too much
          * relazification can cause performance issues when we have to reparse
          * the same functions over and over.
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -627,17 +627,16 @@ class GCRuntime
 
     void beginSweepPhase(JS::gcreason::Reason reason, AutoGCSession& session);
     void groupZonesForSweeping(JS::gcreason::Reason reason);
     MOZ_MUST_USE bool findInterZoneEdges();
     void getNextSweepGroup();
     IncrementalProgress endMarkingSweepGroup(FreeOp* fop, SliceBudget& budget);
     void markIncomingCrossCompartmentPointers(MarkColor color);
     IncrementalProgress beginSweepingSweepGroup(FreeOp* fop, SliceBudget& budget);
-    bool shouldReleaseObservedTypes();
     void sweepDebuggerOnMainThread(FreeOp* fop);
     void sweepJitDataOnMainThread(FreeOp* fop);
     IncrementalProgress endSweepingSweepGroup(FreeOp* fop, SliceBudget& budget);
     IncrementalProgress performSweepActions(SliceBudget& sliceBudget);
     IncrementalProgress sweepTypeInformation(FreeOp* fop, SliceBudget& budget, Zone* zone);
     IncrementalProgress releaseSweptEmptyArenas(FreeOp* fop, SliceBudget& budget, Zone* zone);
     void startSweepingAtomsTable();
     IncrementalProgress sweepAtomsTable(FreeOp* fop, SliceBudget& budget);
@@ -811,19 +810,16 @@ class GCRuntime
     MainThreadData<bool> fullGCForAtomsRequested_;
 
     /* Incremented at the start of every minor GC. */
     MainThreadData<uint64_t> minorGCNumber;
 
     /* Incremented at the start of every major GC. */
     MainThreadData<uint64_t> majorGCNumber;
 
-    /* The major GC number at which to release observed type information. */
-    MainThreadData<uint64_t> jitReleaseNumber;
-
     /* Incremented on every GC slice. */
     MainThreadData<uint64_t> number;
 
     /* Whether the currently running GC can finish in multiple slices. */
     MainThreadData<bool> isIncremental;
 
     /* Whether all zones are being collected in first GC slice. */
     MainThreadData<bool> isFull;