Bug 1507322 - Mark implicit edges via mark stack instead of eagerly. r=jonco, a=RyanVM
authorSteve Fink <sfink@mozilla.com>
Fri, 11 Jan 2019 15:43:56 -0800
changeset 509527 e758e8df7f9a1cd53bc6ca5b670e9c1fa23e6b4c
parent 509526 9299c74c0459c8faeb2ebaab093db8a9a12ee11b
child 509528 69143a6c191dd9d8742568548fcf7981a0ceb91d
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco, RyanVM
bugs1507322
milestone65.0
Bug 1507322 - Mark implicit edges via mark stack instead of eagerly. r=jonco, a=RyanVM
js/src/gc/GCMarker.h
js/src/gc/Marking.cpp
js/src/vm/JSScript.cpp
--- a/js/src/gc/GCMarker.h
+++ b/js/src/gc/GCMarker.h
@@ -298,16 +298,19 @@ class GCMarker : public JSTracer {
 
   void markEphemeronValues(gc::Cell* markedCell, gc::WeakEntryVector& entry);
 
   static GCMarker* fromTracer(JSTracer* trc) {
     MOZ_ASSERT(trc->isMarkingTracer());
     return static_cast<GCMarker*>(trc);
   }
 
+  template <typename T>
+  void markImplicitEdges(T* oldThing);
+
  private:
 #ifdef DEBUG
   void checkZone(void* p);
 #else
   void checkZone(void* p) {}
 #endif
 
   // Push an object onto the stack for later tracing and assert that it has
@@ -317,18 +320,16 @@ class GCMarker : public JSTracer {
   template <typename T>
   void markAndTraceChildren(T* thing);
   template <typename T>
   void markAndPush(T* thing);
   template <typename T>
   void markAndScan(T* thing);
   template <typename T>
   void markImplicitEdgesHelper(T oldThing);
-  template <typename T>
-  void markImplicitEdges(T* oldThing);
   void eagerlyMarkChildren(JSLinearString* str);
   void eagerlyMarkChildren(JSRope* rope);
   void eagerlyMarkChildren(JSString* str);
   void eagerlyMarkChildren(LazyScript* thing);
   void eagerlyMarkChildren(Shape* shape);
   void eagerlyMarkChildren(Scope* scope);
   void lazilyMarkChildren(ObjectGroup* group);
 
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -641,16 +641,20 @@ void GCMarker::markImplicitEdgesHelper(T
 template <>
 void GCMarker::markImplicitEdgesHelper(HasNoImplicitEdgesType) {}
 
 template <typename T>
 void GCMarker::markImplicitEdges(T* thing) {
   markImplicitEdgesHelper<typename ImplicitEdgeHolderType<T*>::Type>(thing);
 }
 
+template void GCMarker::markImplicitEdges(JSObject*);
+template void GCMarker::markImplicitEdges(JSScript*);
+template void GCMarker::markImplicitEdges(LazyScript*);
+
 }  // namespace js
 
 template <typename T>
 static inline bool ShouldMark(GCMarker* gcmarker, T thing) {
   // Don't trace things that are owned by another runtime.
   if (IsOwnedByOtherRuntime(gcmarker->runtime(), thing)) {
     return false;
   }
@@ -829,17 +833,16 @@ void GCMarker::traverse(js::Scope* thing
 // included for historical reasons. JSScript normally cannot recurse, but may
 // be used as a weakmap key and thereby recurse into weakmapped values.
 template <typename T>
 void js::GCMarker::markAndPush(T* thing) {
   if (!mark(thing)) {
     return;
   }
   pushTaggedPtr(thing);
-  markImplicitEdges(thing);
 }
 namespace js {
 template <>
 void GCMarker::traverse(JSObject* thing) {
   markAndPush(thing);
 }
 template <>
 void GCMarker::traverse(ObjectGroup* thing) {
@@ -987,16 +990,20 @@ void LazyScript::traceChildren(JSTracer*
                                  "closedOverBinding");
     }
   }
 
   GCPtrFunction* innerFunctions = this->innerFunctions();
   for (auto i : IntegerRange(numInnerFunctions())) {
     TraceEdge(trc, &innerFunctions[i], "lazyScriptInnerFunction");
   }
+
+  if (trc->isMarkingTracer()) {
+    return GCMarker::fromTracer(trc)->markImplicitEdges(this);
+  }
 }
 inline void js::GCMarker::eagerlyMarkChildren(LazyScript* thing) {
   if (thing->script_) {
     noteWeakEdge(thing->script_.unsafeUnbarrieredForTracing());
   }
 
   if (thing->function_) {
     traverseEdge(thing, static_cast<JSObject*>(thing->function_));
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -4331,16 +4331,20 @@ void JSScript::traceChildren(JSTracer* t
     TraceManuallyBarrieredEdge(trc, &lazyScript, "lazyScript");
   }
 
   if (trc->isMarkingTracer()) {
     realm()->mark();
   }
 
   jit::TraceJitScripts(trc, this);
+
+  if (trc->isMarkingTracer()) {
+    return GCMarker::fromTracer(trc)->markImplicitEdges(this);
+  }
 }
 
 void LazyScript::finalize(FreeOp* fop) { fop->free_(table_); }
 
 size_t JSScript::calculateLiveFixed(jsbytecode* pc) {
   size_t nlivefixed = numAlwaysLiveFixedSlots();
 
   if (nfixed() != nlivefixed) {