Bug 1505689 part 6 - Merge TraceJitScripts into JitScript::trace. r=tcampbell
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 15 Aug 2019 16:13:57 +0000
changeset 488278 8bf0e43c0df043e3527a419e095e641ff52bfcb4
parent 488277 7db7c0c4fadd8303e1002a8f737d8f31a9400c4b
child 488279 f7a4be5909d3ee0fcf36d64979f50036e2938a07
push id113906
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 04:07:24 +0000
treeherdermozilla-inbound@d887276421d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1505689
milestone70.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 1505689 part 6 - Merge TraceJitScripts into JitScript::trace. r=tcampbell This also removes BaselineScript::Trace and IonScript::Trace that were just forwarding to the non-static trace(). Differential Revision: https://phabricator.services.mozilla.com/D41708
js/src/jit/BaselineJIT.cpp
js/src/jit/BaselineJIT.h
js/src/jit/Ion.cpp
js/src/jit/Ion.h
js/src/jit/IonCode.h
js/src/jit/JitFrames.cpp
js/src/jit/JitScript.cpp
js/src/vm/JSScript.cpp
--- a/js/src/jit/BaselineJIT.cpp
+++ b/js/src/jit/BaselineJIT.cpp
@@ -502,20 +502,16 @@ void BaselineScript::trace(JSTracer* trc
 
 /* static */
 void BaselineScript::writeBarrierPre(Zone* zone, BaselineScript* script) {
   if (zone->needsIncrementalBarrier()) {
     script->trace(zone->barrierTracer());
   }
 }
 
-void BaselineScript::Trace(JSTracer* trc, BaselineScript* script) {
-  script->trace(trc);
-}
-
 void BaselineScript::Destroy(JSFreeOp* fop, BaselineScript* script) {
   MOZ_ASSERT(!script->hasPendingIonBuilder());
 
   // This allocation is tracked by JSScript::setBaselineScriptImpl.
   fop->deleteUntracked(script);
 }
 
 void JS::DeletePolicy<js::jit::BaselineScript>::operator()(
--- a/js/src/jit/BaselineJIT.h
+++ b/js/src/jit/BaselineJIT.h
@@ -175,18 +175,16 @@ struct BaselineScript final {
 #  ifdef DEBUG
   bool traceLoggerScriptsEnabled_ = false;
   bool traceLoggerEngineEnabled_ = false;
 #  endif
   TraceLoggerEvent traceLoggerScriptEvent_ = {};
 #endif
 
  private:
-  void trace(JSTracer* trc);
-
   uint32_t retAddrEntriesOffset_ = 0;
   uint32_t retAddrEntries_ = 0;
 
   uint32_t osrEntriesOffset_ = 0;
   uint32_t osrEntries_ = 0;
 
   uint32_t debugTrapEntriesOffset_ = 0;
   uint32_t debugTrapEntries_ = 0;
@@ -283,19 +281,20 @@ struct BaselineScript final {
   static BaselineScript* New(JSScript* jsscript,
                              uint32_t warmUpCheckPrologueOffset,
                              uint32_t profilerEnterToggleOffset,
                              uint32_t profilerExitToggleOffset,
                              size_t retAddrEntries, size_t osrEntries,
                              size_t debugTrapEntries, size_t resumeEntries,
                              size_t traceLoggerToggleOffsetEntries);
 
-  static void Trace(JSTracer* trc, BaselineScript* script);
   static void Destroy(JSFreeOp* fop, BaselineScript* script);
 
+  void trace(JSTracer* trc);
+
   static inline size_t offsetOfMethod() {
     return offsetof(BaselineScript, method_);
   }
 
   void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
                               size_t* data) const {
     *data += mallocSizeOf(this);
   }
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -1027,18 +1027,16 @@ const OsiIndex* IonScript::getOsiIndex(u
   JitSpew(JitSpew_IonInvalidate, "IonScript %p has method %p raw %p",
           (void*)this, (void*)method(), method()->raw());
 
   MOZ_ASSERT(containsCodeAddress(retAddr));
   uint32_t disp = retAddr - method()->raw();
   return getOsiIndex(disp);
 }
 
-void IonScript::Trace(JSTracer* trc, IonScript* script) { script->trace(trc); }
-
 void IonScript::Destroy(JSFreeOp* fop, IonScript* script) {
   // This allocation is tracked by JSScript::setIonScriptImpl.
   fop->deleteUntracked(script);
 }
 
 void JS::DeletePolicy<js::jit::IonScript>::operator()(
     const js::jit::IonScript* script) {
   IonScript::Destroy(rt_->defaultFreeOp(), const_cast<IonScript*>(script));
@@ -3017,30 +3015,16 @@ void jit::DestroyJitScripts(JSFreeOp* fo
     BaselineScript* baseline = script->baselineScript();
     script->jitScript()->clearBaselineScript(fop, script);
     jit::BaselineScript::Destroy(fop, baseline);
   }
 
   script->releaseJitScript(fop);
 }
 
-void jit::TraceJitScripts(JSTracer* trc, JSScript* script) {
-  if (script->hasIonScript()) {
-    jit::IonScript::Trace(trc, script->ionScript());
-  }
-
-  if (script->hasBaselineScript()) {
-    jit::BaselineScript::Trace(trc, script->baselineScript());
-  }
-
-  if (script->hasJitScript()) {
-    script->jitScript()->trace(trc);
-  }
-}
-
 bool jit::JitSupportsSimd() { return js::jit::MacroAssembler::SupportsSimd(); }
 
 bool jit::JitSupportsAtomics() {
 #if defined(JS_CODEGEN_ARM)
   // Bug 1146902, bug 1077318: Enable Ion inlining of Atomics
   // operations on ARM only when the CPU has byte, halfword, and
   // doubleword load-exclusive and store-exclusive instructions,
   // until we can add support for systems that don't have those.
--- a/js/src/jit/Ion.h
+++ b/js/src/jit/Ion.h
@@ -250,17 +250,16 @@ class MOZ_RAII AutoEnterIonBackend {
 };
 
 bool OffThreadCompilationAvailable(JSContext* cx);
 
 void ForbidCompilation(JSContext* cx, JSScript* script);
 
 size_t SizeOfIonData(JSScript* script, mozilla::MallocSizeOf mallocSizeOf);
 void DestroyJitScripts(JSFreeOp* fop, JSScript* script);
-void TraceJitScripts(JSTracer* trc, JSScript* script);
 
 bool JitSupportsSimd();
 bool JitSupportsAtomics();
 
 }  // namespace jit
 }  // namespace js
 
 #endif /* jit_Ion_h */
--- a/js/src/jit/IonCode.h
+++ b/js/src/jit/IonCode.h
@@ -272,35 +272,34 @@ struct IonScript {
   }
   const OsiIndex* osiIndices() const {
     return const_cast<IonScript*>(this)->osiIndices();
   }
   OsiIndex* osiIndices() { return (OsiIndex*)&bottomBuffer()[osiIndexOffset_]; }
   uint32_t* icIndex() { return (uint32_t*)&bottomBuffer()[icIndex_]; }
   uint8_t* runtimeData() { return &bottomBuffer()[runtimeData_]; }
 
- private:
-  void trace(JSTracer* trc);
-
  public:
   // Do not call directly, use IonScript::New. This is public for cx->new_.
   explicit IonScript(IonCompilationId compilationId);
 
   static IonScript* New(JSContext* cx, IonCompilationId compilationId,
                         uint32_t frameSlots, uint32_t argumentSlots,
                         uint32_t frameSize, size_t snapshotsListSize,
                         size_t snapshotsRVATableSize, size_t recoversSize,
                         size_t bailoutEntries, size_t constants,
                         size_t safepointIndexEntries, size_t osiIndexEntries,
                         size_t icEntries, size_t runtimeSize,
                         size_t safepointsSize,
                         OptimizationLevel optimizationLevel);
-  static void Trace(JSTracer* trc, IonScript* script);
+
   static void Destroy(JSFreeOp* fop, IonScript* script);
 
+  void trace(JSTracer* trc);
+
   static inline size_t offsetOfMethod() { return offsetof(IonScript, method_); }
   static inline size_t offsetOfOsrEntryOffset() {
     return offsetof(IonScript, osrEntryOffset_);
   }
   static inline size_t offsetOfSkipArgCheckEntryOffset() {
     return offsetof(IonScript, skipArgCheckEntryOffset_);
   }
   static inline size_t offsetOfInvalidationCount() {
--- a/js/src/jit/JitFrames.cpp
+++ b/js/src/jit/JitFrames.cpp
@@ -836,17 +836,17 @@ static void TraceIonJSFrame(JSTracer* tr
 
   layout->replaceCalleeToken(TraceCalleeToken(trc, layout->calleeToken()));
 
   IonScript* ionScript = nullptr;
   if (frame.checkInvalidation(&ionScript)) {
     // This frame has been invalidated, meaning that its IonScript is no
     // longer reachable through the callee token (JSFunction/JSScript->ion
     // is now nullptr or recompiled). Manually trace it here.
-    IonScript::Trace(trc, ionScript);
+    ionScript->trace(trc);
   } else {
     ionScript = frame.ionScriptFromCalleeToken();
   }
 
   TraceThisAndArguments(trc, frame, frame.jsFrame());
 
   const SafepointIndex* si =
       ionScript->getSafepointIndex(frame.resumePCinCurrentFrame());
--- a/js/src/jit/JitScript.cpp
+++ b/js/src/jit/JitScript.cpp
@@ -193,16 +193,24 @@ void JSScript::releaseJitScript(JSFreeOp
   updateJitCodeRaw(fop->runtime());
 }
 
 void JitScript::CachedIonData::trace(JSTracer* trc) {
   TraceNullableEdge(trc, &templateEnv, "jitscript-iondata-template-env");
 }
 
 void JitScript::trace(JSTracer* trc) {
+  if (hasBaselineScript()) {
+    baselineScript()->trace(trc);
+  }
+
+  if (hasIonScript()) {
+    ionScript()->trace(trc);
+  }
+
   if (hasCachedIonData()) {
     cachedIonData().trace(trc);
   }
 
   // Mark all IC stub codes hanging off the IC stub entries.
   for (size_t i = 0; i < numICEntries(); i++) {
     ICEntry& ent = icEntry(i);
     ent.trace(trc);
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -4796,26 +4796,28 @@ void JSScript::traceChildren(JSTracer* t
   if (data_) {
     data_->trace(trc);
   }
 
   if (scriptData()) {
     scriptData()->traceChildren(trc);
   }
 
+  if (hasJitScript()) {
+    jitScript()->trace(trc);
+  }
+
   if (maybeLazyScript()) {
     TraceManuallyBarrieredEdge(trc, &lazyScript, "lazyScript");
   }
 
   JSObject* global = realm()->unsafeUnbarrieredMaybeGlobal();
   MOZ_ASSERT(global);
   TraceManuallyBarrieredEdge(trc, &global, "script_global");
 
-  jit::TraceJitScripts(trc, this);
-
   if (trc->isMarkingTracer()) {
     GCMarker::fromTracer(trc)->markImplicitEdges(this);
   }
 }
 
 void LazyScript::finalize(JSFreeOp* fop) {
   if (lazyData_) {
     fop->free_(this, lazyData_, lazyData_->allocationSize(),