Bug 1189112 - Part 1: Use TraceableVector to simplify tracing of ScriptsAndCountsVector; r=nbp
authorTerrence Cole <terrence@mozilla.com>
Wed, 29 Jul 2015 14:59:49 -0700
changeset 287607 abc018892155463bfee51a1cc3d72454904a0bf0
parent 287606 d1288e84b4a039332a52ba194877100b0b6ec598
child 287608 027800a23ccb63ac3b0b1f493de197e8cfefbd3b
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1189112
milestone42.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 1189112 - Part 1: Use TraceableVector to simplify tracing of ScriptsAndCountsVector; r=nbp
js/src/gc/RootMarking.cpp
js/src/jsscript.h
js/src/vm/Runtime.h
--- a/js/src/gc/RootMarking.cpp
+++ b/js/src/gc/RootMarking.cpp
@@ -360,21 +360,18 @@ js::gc::GCRuntime::markRuntime(JSTracer*
         for (RootRange r = rootsHash.all(); !r.empty(); r.popFront()) {
             const RootEntry& entry = r.front();
             TraceRoot(trc, entry.key(), entry.value());
         }
 
         MarkPersistentRootedChains(trc);
     }
 
-    if (rt->scriptAndCountsVector) {
-        ScriptAndCountsVector& vec = *rt->scriptAndCountsVector;
-        for (size_t i = 0; i < vec.length(); i++)
-            TraceRoot(trc, &vec[i].script, "scriptAndCountsVector");
-    }
+    if (rt->scriptAndCountsVector)
+        rt->scriptAndCountsVector->trace(trc);
 
     if (!rt->isBeingDestroyed() && !rt->isHeapMinorCollecting()) {
         gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_RUNTIME_DATA);
 
         if (traceOrMark == TraceRuntime || rt->atomsCompartment()->zone()->isCollecting()) {
             MarkPermanentAtoms(trc);
             MarkAtoms(trc);
             MarkWellKnownSymbols(trc);
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -2360,16 +2360,20 @@ struct ScriptAndCounts
 
     PCCounts& getPCCounts(jsbytecode* pc) const {
         return scriptCounts.pcCountsVector[script->pcToOffset(pc)];
     }
 
     jit::IonScriptCounts* getIonCounts() const {
         return scriptCounts.ionCounts;
     }
+
+    void trace(JSTracer* trc) {
+        TraceRoot(trc, &script, "ScriptAndCounts::script");
+    }
 };
 
 struct GSNCache;
 
 jssrcnote*
 GetSrcNote(GSNCache& cache, JSScript* script, jsbytecode* pc);
 
 extern jssrcnote*
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -31,16 +31,17 @@
 #include "gc/GCRuntime.h"
 #include "gc/Tracer.h"
 #include "irregexp/RegExpStack.h"
 #include "js/Debug.h"
 #include "js/HashTable.h"
 #ifdef DEBUG
 # include "js/Proxy.h" // For AutoEnterPolicy
 #endif
+#include "js/TraceableVector.h"
 #include "js/Vector.h"
 #include "vm/CommonPropertyNames.h"
 #include "vm/DateTime.h"
 #include "vm/MallocProvider.h"
 #include "vm/SPSProfiler.h"
 #include "vm/Stack.h"
 #include "vm/Symbol.h"
 
@@ -134,17 +135,17 @@ struct ScopeCoordinateNameCache {
 
     Shape* shape;
     Map map;
 
     ScopeCoordinateNameCache() : shape(nullptr) {}
     void purge();
 };
 
-typedef Vector<ScriptAndCounts, 0, SystemAllocPolicy> ScriptAndCountsVector;
+using ScriptAndCountsVector = TraceableVector<ScriptAndCounts, 0, SystemAllocPolicy>;
 
 struct EvalCacheEntry
 {
     JSLinearString* str;
     JSScript* script;
     JSScript* callerScript;
     jsbytecode* pc;
 };