Bug 836985 - Remove ScriptSourceHolder::rt. r=benjamin.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 03 Feb 2013 19:55:09 -0800
changeset 120714 f24b93663ea95a4252e38be6e4f0cdf7ebe5c211
parent 120713 0c6f78d3f0a498ff2222139ca157f65a3db294c5
child 120715 c966159d269920d0cfb08666b95e9d7337448e74
push id24262
push userryanvm@gmail.com
push dateMon, 04 Feb 2013 11:52:04 +0000
treeherdermozilla-central@2a8e243711a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenjamin
bugs836985
milestone21.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 836985 - Remove ScriptSourceHolder::rt. r=benjamin.
js/src/frontend/BytecodeCompiler.cpp
js/src/jsapi.cpp
js/src/jsscript.cpp
js/src/jsscript.h
js/src/vm/GlobalObject.cpp
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -76,17 +76,17 @@ frontend::CompileScript(JSContext *cx, H
     JS_ASSERT_IF(staticLevel != 0, callerFrame);
 
     if (!CheckLength(cx, length))
         return UnrootedScript(NULL);
     JS_ASSERT_IF(staticLevel != 0, options.sourcePolicy != CompileOptions::LAZY_SOURCE);
     ScriptSource *ss = cx->new_<ScriptSource>();
     if (!ss)
         return UnrootedScript(NULL);
-    ScriptSourceHolder ssh(cx->runtime, ss);
+    ScriptSourceHolder ssh(ss);
     SourceCompressionToken sct(cx);
     switch (options.sourcePolicy) {
       case CompileOptions::SAVE_SOURCE:
         if (!ss->setSourceCopy(cx, chars, length, false, &sct))
             return UnrootedScript(NULL);
         break;
       case CompileOptions::LAZY_SOURCE:
         ss->setSourceRetrievable();
@@ -227,17 +227,17 @@ bool
 frontend::CompileFunctionBody(JSContext *cx, HandleFunction fun, CompileOptions options,
                               const AutoNameVector &formals, StableCharPtr chars, size_t length)
 {
     if (!CheckLength(cx, length))
         return false;
     ScriptSource *ss = cx->new_<ScriptSource>();
     if (!ss)
         return false;
-    ScriptSourceHolder ssh(cx->runtime, ss);
+    ScriptSourceHolder ssh(ss);
     SourceCompressionToken sct(cx);
     JS_ASSERT(options.sourcePolicy != CompileOptions::LAZY_SOURCE);
     if (options.sourcePolicy == CompileOptions::SAVE_SOURCE) {
         if (!ss->setSourceCopy(cx, chars, length, true, &sct))
             return false;
     }
 
     options.setCompileAndGo(false);
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -846,17 +846,17 @@ JSRuntime::JSRuntime(JSUseHelperThreads 
     hadOutOfMemory(false),
     data(NULL),
     gcLock(NULL),
     gcHelperThread(thisFromCtor()),
 #ifdef JS_THREADSAFE
 #ifdef JS_ION
     workerThreadState(NULL),
 #endif
-    sourceCompressorThread(thisFromCtor()),
+    sourceCompressorThread(),
 #endif
     defaultFreeOp_(thisFromCtor(), false),
     debuggerMutations(0),
     securityCallbacks(const_cast<JSSecurityCallbacks *>(&NullSecurityCallbacks)),
     DOMcallbacks(NULL),
     destroyPrincipals(NULL),
     structuredCloneCallbacks(NULL),
     telemetryCallback(NULL),
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -546,17 +546,17 @@ js::XDRScript(XDRState<mode> *xdr, Handl
         if (scriptBits & (1 << OwnSource)) {
             ss = cx->new_<ScriptSource>();
             if (!ss)
                 return false;
         } else {
             JS_ASSERT(enclosingScript);
             ss = enclosingScript->scriptSource();
         }
-        ScriptSourceHolder ssh(cx->runtime, ss);
+        ScriptSourceHolder ssh(ss);
         script = JSScript::Create(cx, enclosingScope, !!(scriptBits & (1 << SavedCallerFun)),
                                   options, /* staticLevel = */ 0, ss, 0, 0);
         if (!script)
             return false;
     }
 
     /* JSScript::partiallyInit assumes script->bindings is fully initialized. */
     LifoAllocScope las(&cx->tempLifoAlloc());
@@ -1287,17 +1287,17 @@ SourceCompressionToken::abort()
 {
     JS_ASSERT(active());
 #ifdef JS_THREADSAFE
     cx->runtime->sourceCompressorThread.abort(this);
 #endif
 }
 
 void
-ScriptSource::destroy(JSRuntime *rt)
+ScriptSource::destroy()
 {
     JS_ASSERT(ready());
     adjustDataSize(0);
     js_free(sourceMap_);
     ready_ = false;
     js_free(this);
 }
 
@@ -1935,17 +1935,17 @@ JSScript::finalize(FreeOp *fop)
     mjit::ReleaseScriptCode(fop, this);
 # ifdef JS_ION
     ion::DestroyIonScripts(fop, this);
 # endif
 #endif
 
     destroyScriptCounts(fop);
     destroyDebugScript(fop);
-    scriptSource_->decref(fop->runtime());
+    scriptSource_->decref();
 
     if (data) {
         JS_POISON(data, 0xdb, computedSizeOfData());
         fop->free_(data);
     }
 }
 
 static const uint32_t GSN_CACHE_THRESHOLD = 100;
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -1050,20 +1050,20 @@ struct ScriptSource
         sourceMap_(NULL),
         sourceRetrievable_(false),
         argumentsNotIncluded_(false),
         ready_(true)
     {
         data.source = NULL;
     }
     void incref() { refs++; }
-    void decref(JSRuntime *rt) {
+    void decref() {
         JS_ASSERT(refs != 0);
         if (--refs == 0)
-            destroy(rt);
+            destroy();
     }
     bool setSourceCopy(JSContext *cx,
                        StableCharPtr src,
                        uint32_t length,
                        bool argumentsNotIncluded,
                        SourceCompressionToken *tok);
     void setSource(const jschar *src, uint32_t length);
     bool ready() const { return ready_; }
@@ -1086,38 +1086,36 @@ struct ScriptSource
     bool performXDR(XDRState<mode> *xdr);
 
     // Source maps
     bool setSourceMap(JSContext *cx, jschar *sourceMapURL, const char *filename);
     const jschar *sourceMap();
     bool hasSourceMap() const { return sourceMap_ != NULL; }
 
   private:
-    void destroy(JSRuntime *rt);
+    void destroy();
     bool compressed() const { return compressedLength_ != 0; }
     size_t computedSizeOfData() const {
         return compressed() ? compressedLength_ : sizeof(jschar) * length_;
     }
     bool adjustDataSize(size_t nbytes);
 };
 
 class ScriptSourceHolder
 {
-    JSRuntime *rt;
     ScriptSource *ss;
   public:
-    ScriptSourceHolder(JSRuntime *rt, ScriptSource *ss)
-      : rt(rt),
-        ss(ss)
+    ScriptSourceHolder(ScriptSource *ss)
+      : ss(ss)
     {
         ss->incref();
     }
     ~ScriptSourceHolder()
     {
-        ss->decref(rt);
+        ss->decref();
     }
 };
 
 #ifdef JS_THREADSAFE
 /*
  * Background thread to compress JS source code. This happens only while parsing
  * and bytecode generation is happening in the main thread. If needed, the
  * compiler waits for compression to complete before returning.
@@ -1154,17 +1152,17 @@ class SourceCompressorThread
     // Flag which can be set by the main thread to ask compression to abort.
     volatile bool stop;
 
     bool internalCompress();
     void threadLoop();
     static void compressorThread(void *arg);
 
   public:
-    explicit SourceCompressorThread(JSRuntime *rt)
+    explicit SourceCompressorThread()
     : state(IDLE),
       tok(NULL),
       thread(NULL),
       lock(NULL),
       wakeup(NULL),
       done(NULL) {}
     void finish();
     bool init();
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -229,17 +229,17 @@ GlobalObject::initFunctionAndObjectClass
         jschar *source = InflateString(cx, rawSource, &sourceLen);
         if (!source)
             return NULL;
         ScriptSource *ss = cx->new_<ScriptSource>();
         if (!ss) {
             js_free(source);
             return NULL;
         }
-        ScriptSourceHolder ssh(cx->runtime, ss);
+        ScriptSourceHolder ssh(ss);
         ss->setSource(source, sourceLen);
 
         CompileOptions options(cx);
         options.setNoScriptRval(true)
                .setVersion(JSVERSION_DEFAULT);
         RootedScript script(cx, JSScript::Create(cx,
                                                  /* enclosingScope = */ NullPtr(),
                                                  /* savedCallerFun = */ false,