Bug 928507: Properly hide JS::Handle's assignment operator; add 'repoint' method to deal with the fallout; fix C1Spewer, IonSpewer, and CompileOptions. r=terrence
authorJim Blandy <jimb@mozilla.com>
Mon, 21 Oct 2013 12:56:44 -0700
changeset 151595 a92ac47a8ba759ff99379ddad1f45323b9707d2e
parent 151594 55d36871fbd853fe35b3084ed740eeed881352d7
child 151596 5709e2db35ff8484b695befd64a26224ef6eaff7
push id25503
push userkwierso@gmail.com
push dateTue, 22 Oct 2013 22:12:07 +0000
treeherdermozilla-central@31382b5fa51e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs928507
milestone27.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 928507: Properly hide JS::Handle's assignment operator; add 'repoint' method to deal with the fallout; fix C1Spewer, IonSpewer, and CompileOptions. r=terrence
js/public/RootingAPI.h
js/src/jit/C1Spewer.cpp
js/src/jit/IonSpewer.cpp
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -450,23 +450,26 @@ class MOZ_NONHEAP_CLASS Handle : public 
      * takes a |const T&| is not a GC hazard.
      */
     operator const T&() const { return get(); }
     T operator->() const { return get(); }
 
     bool operator!=(const T &other) const { return *ptr != other; }
     bool operator==(const T &other) const { return *ptr == other; }
 
+    /* Change this handle to point to the same rooted location RHS does. */
+    void repoint(const Handle &rhs) { ptr = rhs.address(); }
+
   private:
     Handle() {}
 
     const T *ptr;
 
-    template <typename S>
-    void operator=(S v) MOZ_DELETE;
+    template <typename S> void operator=(S) MOZ_DELETE;
+    void operator=(Handle) MOZ_DELETE;
 };
 
 /*
  * Similar to a handle, but the underlying storage can be changed. This is
  * useful for outparams.
  *
  * If you want to add additional methods to MutableHandle for a specific
  * specialization, define a MutableHandleBase<T> specialization containing
--- a/js/src/jit/C1Spewer.cpp
+++ b/js/src/jit/C1Spewer.cpp
@@ -26,17 +26,17 @@ C1Spewer::init(const char *path)
 
 void
 C1Spewer::beginFunction(MIRGraph *graph, HandleScript script)
 {
     if (!spewout_)
         return;
 
     this->graph  = graph;
-    this->script = script;
+    this->script.repoint(script);
 
     fprintf(spewout_, "begin_compilation\n");
     if (script) {
         fprintf(spewout_, "  name \"%s:%d\"\n", script->filename(), script->lineno);
         fprintf(spewout_, "  method \"%s:%d\"\n", script->filename(), script->lineno);
     } else {
         fprintf(spewout_, "  name \"asm.js compilation\"\n");
         fprintf(spewout_, "  method \"asm.js compilation\"\n");
--- a/js/src/jit/IonSpewer.cpp
+++ b/js/src/jit/IonSpewer.cpp
@@ -156,17 +156,17 @@ IonSpewer::beginFunction(MIRGraph *graph
     if (!FilterContainsLocation(function)) {
         JS_ASSERT(!this->graph);
         // filter out logs during the compilation.
         filteredOutCompilations++;
         return;
     }
 
     this->graph = graph;
-    this->function = function;
+    this->function.repoint(function);
 
     c1Spewer.beginFunction(graph, function);
     jsonSpewer.beginFunction(function);
 }
 
 void
 IonSpewer::spewPass(const char *pass)
 {
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4461,17 +4461,17 @@ JS::Compile(JSContext *cx, HandleObject 
 }
 
 JSScript *
 JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options, const char *filename)
 {
     AutoFile file;
     if (!file.open(cx, filename))
         return nullptr;
-    options = options.setFileAndLine(filename, 1);
+    options.setFileAndLine(filename, 1);
     JSScript *script = Compile(cx, obj, options, file.fp());
     return script;
 }
 
 JS_PUBLIC_API(bool)
 JS::CanCompileOffThread(JSContext *cx, const CompileOptions &options)
 {
 #ifdef JS_WORKER_THREADS
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -3464,17 +3464,17 @@ class JS_PUBLIC_API(CompileOptions)
     CompileOptions &setOriginPrincipals(JSPrincipals *p) { originPrincipals_ = p; return *this; }
     CompileOptions &setVersion(JSVersion v) { version = v; versionSet = true; return *this; }
     CompileOptions &setUTF8(bool u) { utf8 = u; return *this; }
     CompileOptions &setFileAndLine(const char *f, unsigned l) {
         filename = f; lineno = l; return *this;
     }
     CompileOptions &setSourceMapURL(const jschar *s) { sourceMapURL = s; return *this; }
     CompileOptions &setColumn(unsigned c) { column = c; return *this; }
-    CompileOptions &setElement(Handle<JSObject*> e) { element = e; return *this; }
+    CompileOptions &setElement(Handle<JSObject*> e) { element.repoint(e); return *this; }
     CompileOptions &setCompileAndGo(bool cng) { compileAndGo = cng; return *this; }
     CompileOptions &setForEval(bool eval) { forEval = eval; return *this; }
     CompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; }
     CompileOptions &setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; }
     CompileOptions &setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; }
     CompileOptions &setSourcePolicy(SourcePolicy sp) { sourcePolicy = sp; return *this; }
 };