Bug 1446693 - Include discardJitCode in AutoTraceSession for minor GC, r=jonco
authorSteve Fink <sfink@mozilla.com>
Thu, 05 Apr 2018 15:46:59 -0700
changeset 414194 ebfd7878694738571b24e90683ff423139859775
parent 414193 a98ad37316f62fa1a5231c59ae71677db24f689a
child 414195 da98166e73a816cb3973c799e1e9c46ec2bd9dc7
push id33861
push userccoroiu@mozilla.com
push dateWed, 18 Apr 2018 10:50:38 +0000
treeherdermozilla-central@4af4ae0aee55 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1446693
milestone61.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 1446693 - Include discardJitCode in AutoTraceSession for minor GC, r=jonco
js/src/gc/Nursery.cpp
js/src/gc/Nursery.h
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -720,18 +720,20 @@ js::Nursery::collect(JS::gcreason::Reaso
 
     // The analysis marks TenureCount as not problematic for GC hazards because
     // it is only used here, and ObjectGroup pointers are never
     // nursery-allocated.
     MOZ_ASSERT(!IsNurseryAllocable(AllocKind::OBJECT_GROUP));
 
     TenureCountCache tenureCounts;
     previousGC.reason = JS::gcreason::NO_REASON;
+    mozilla::Maybe<AutoTraceSession> session;
     if (!isEmpty()) {
-        doCollection(reason, tenureCounts);
+        session.emplace(rt, JS::HeapState::MinorCollecting);
+        doCollection(reason, session.ref(), tenureCounts);
     } else {
         previousGC.nurseryUsedBytes = 0;
         previousGC.nurseryCapacity = spaceToEnd(maxChunkCount());
         previousGC.nurseryLazyCapacity = spaceToEnd(allocatedChunkCount());
         previousGC.tenuredBytes = 0;
     }
 
     // Resize the nursery.
@@ -758,16 +760,17 @@ js::Nursery::collect(JS::gcreason::Reaso
                     group->setShouldPreTenure(cx);
                     pretenureCount++;
                 }
             }
         }
     }
     for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
         if (shouldPretenure && zone->allocNurseryStrings && zone->tenuredStrings >= 30 * 1000) {
+            MOZ_ASSERT(session.isSome(), "discarding JIT code must be in an AutoTraceSession");
             CancelOffThreadIonCompile(zone);
             bool preserving = zone->isPreservingCode();
             zone->setPreservingCode(false);
             zone->discardJitCode(rt->defaultFreeOp());
             zone->setPreservingCode(preserving);
             for (CompartmentsInZoneIter c(zone); !c.done(); c.next()) {
                 if (jit::JitCompartment* jitComp = c->jitCompartment()) {
                     jitComp->discardStubs();
@@ -787,16 +790,17 @@ js::Nursery::collect(JS::gcreason::Reaso
         disable();
     // Disable the nursery if the user changed the configuration setting.  The
     // nursery can only be re-enabled by resetting the configurationa and
     // restarting firefox.
     if (chunkCountLimit_ == 0)
         disable();
 
     endProfile(ProfileKey::Total);
+    session.reset(); // End the minor GC session, if running one.
     rt->gc.incMinorGcNumber();
 
     TimeDuration totalTime = profileDurations_[ProfileKey::Total];
     rt->addTelemetry(JS_TELEMETRY_GC_MINOR_US, totalTime.ToMicroseconds());
     rt->addTelemetry(JS_TELEMETRY_GC_MINOR_REASON, reason);
     if (totalTime.ToMilliseconds() > 1.0)
         rt->addTelemetry(JS_TELEMETRY_GC_MINOR_REASON_LONG, reason);
     rt->addTelemetry(JS_TELEMETRY_GC_NURSERY_BYTES, sizeOfHeapCommitted());
@@ -823,20 +827,20 @@ js::Nursery::collect(JS::gcreason::Reaso
                 }
             }
         }
     }
 }
 
 void
 js::Nursery::doCollection(JS::gcreason::Reason reason,
+                          AutoTraceSession& session,
                           TenureCountCache& tenureCounts)
 {
     JSRuntime* rt = runtime();
-    AutoTraceSession session(rt, JS::HeapState::MinorCollecting);
     AutoSetThreadIsPerformingGC performingGC;
     AutoStopVerifyingBarriers av(rt, false);
     AutoDisableProxyCheck disableStrictProxyChecking;
     mozilla::DebugOnly<AutoEnterOOMUnsafeRegion> oomUnsafeRegion;
 
     const size_t initialNurseryCapacity = spaceToEnd(maxChunkCount());
     const size_t initialNurseryUsedBytes = initialNurseryCapacity - freeSpace();
 
--- a/js/src/gc/Nursery.h
+++ b/js/src/gc/Nursery.h
@@ -51,16 +51,17 @@ class Nursery;
 struct NurseryChunk;
 class HeapSlot;
 class JSONPrinter;
 
 void SetGCZeal(JSRuntime*, uint8_t, uint32_t);
 
 namespace gc {
 class AutoMaybeStartBackgroundAllocation;
+class AutoTraceSession;
 struct Cell;
 class MinorCollectionTracer;
 class RelocationOverlay;
 struct TenureCountCache;
 enum class AllocKind : uint8_t;
 class TenuredCell;
 } /* namespace gc */
 
@@ -512,17 +513,18 @@ class Nursery
     uintptr_t position() const { return position_; }
 
     JSRuntime* runtime() const { return runtime_; }
 
     /* Common internal allocator function. */
     void* allocate(size_t size);
 
     void doCollection(JS::gcreason::Reason reason,
-                        gc::TenureCountCache& tenureCounts);
+                      gc::AutoTraceSession& sesssion,
+                      gc::TenureCountCache& tenureCounts);
 
     /*
      * Move the object at |src| in the Nursery to an already-allocated cell
      * |dst| in Tenured.
      */
     void collectToFixedPoint(TenuringTracer& trc, gc::TenureCountCache& tenureCounts);
 
     /* Handle relocation of slots/elements pointers stored in Ion frames. */