From 53a9ab4dc3075a666742e2f2dcc1e246c2e29020 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 21 Oct 2013 12:56:44 -0700 Subject: [PATCH] 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 | 7 +++++-- js/src/jit/C1Spewer.cpp | 2 +- js/src/jit/IonSpewer.cpp | 2 +- js/src/jsapi.cpp | 2 +- js/src/jsapi.h | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h index 6e02daecbb2a..3c5bd6ec3a69 100644 --- a/js/public/RootingAPI.h +++ b/js/public/RootingAPI.h @@ -455,13 +455,16 @@ class MOZ_NONHEAP_CLASS Handle : public js::HandleBase 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 - void operator=(S v) MOZ_DELETE; + template void operator=(S) MOZ_DELETE; + void operator=(Handle) MOZ_DELETE; }; /* diff --git a/js/src/jit/C1Spewer.cpp b/js/src/jit/C1Spewer.cpp index 01cd2caa4fd6..a021ce6a9d73 100644 --- a/js/src/jit/C1Spewer.cpp +++ b/js/src/jit/C1Spewer.cpp @@ -31,7 +31,7 @@ C1Spewer::beginFunction(MIRGraph *graph, HandleScript script) return; this->graph = graph; - this->script = script; + this->script.repoint(script); fprintf(spewout_, "begin_compilation\n"); if (script) { diff --git a/js/src/jit/IonSpewer.cpp b/js/src/jit/IonSpewer.cpp index bb58d00cdb38..6fd646422e58 100644 --- a/js/src/jit/IonSpewer.cpp +++ b/js/src/jit/IonSpewer.cpp @@ -161,7 +161,7 @@ IonSpewer::beginFunction(MIRGraph *graph, HandleScript function) } this->graph = graph; - this->function = function; + this->function.repoint(function); c1Spewer.beginFunction(graph, function); jsonSpewer.beginFunction(function); diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index d97609f0b8c0..2ca3af141b10 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -4466,7 +4466,7 @@ JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options, const char 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; } diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 87cc9c29fa54..96b3f0ae0493 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3469,7 +3469,7 @@ class JS_PUBLIC_API(CompileOptions) } CompileOptions &setSourceMapURL(const jschar *s) { sourceMapURL = s; return *this; } CompileOptions &setColumn(unsigned c) { column = c; return *this; } - CompileOptions &setElement(Handle e) { element = e; return *this; } + CompileOptions &setElement(Handle 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; }