Bug 940317 - Move the varObjFix flag from ContextOptions to RuntimeOptions. r=bholley
authorEddy Bruel <ejpbruel@mozilla.com>
Tue, 15 Jul 2014 09:04:20 -0700
changeset 216098 db5ffe95df00a07cbb8e9fe58764190539270821
parent 216097 3b0111ca90e21ec9fc7774d462b8c30fd6caaacd
child 216099 7441f4dde492536449823c3e1a6f5ee441b7775e
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs940317
milestone33.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 940317 - Move the varObjFix flag from ContextOptions to RuntimeOptions. r=bholley
js/src/jsapi-tests/testJSEvaluateScript.cpp
js/src/jsapi-tests/tests.h
js/src/jsapi.h
js/src/vm/Interpreter.cpp
--- a/js/src/jsapi-tests/testJSEvaluateScript.cpp
+++ b/js/src/jsapi-tests/testJSEvaluateScript.cpp
@@ -4,33 +4,33 @@
 
 #include "jsapi-tests/tests.h"
 
 BEGIN_TEST(testJSEvaluateScript)
 {
     JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), global));
     CHECK(obj);
 
-    CHECK(JS::ContextOptionsRef(cx).varObjFix());
+    CHECK(JS::RuntimeOptionsRef(cx).varObjFix());
 
     static const char src[] = "var x = 5;";
 
     JS::RootedValue retval(cx);
     CHECK(JS_EvaluateScript(cx, obj, src, sizeof(src) - 1, __FILE__, __LINE__, &retval));
 
     bool hasProp = true;
     CHECK(JS_AlreadyHasOwnProperty(cx, obj, "x", &hasProp));
     CHECK(!hasProp);
 
     hasProp = false;
     CHECK(JS_HasProperty(cx, global, "x", &hasProp));
     CHECK(hasProp);
 
     // Now do the same thing, but without JSOPTION_VAROBJFIX
-    JS::ContextOptionsRef(cx).setVarObjFix(false);
+    JS::RuntimeOptionsRef(cx).setVarObjFix(false);
 
     static const char src2[] = "var y = 5;";
 
     CHECK(JS_EvaluateScript(cx, obj, src2, sizeof(src2) - 1, __FILE__, __LINE__, &retval));
 
     hasProp = false;
     CHECK(JS_AlreadyHasOwnProperty(cx, obj, "y", &hasProp));
     CHECK(hasProp);
--- a/js/src/jsapi-tests/tests.h
+++ b/js/src/jsapi-tests/tests.h
@@ -293,16 +293,17 @@ class JSAPITest
         JS_SetNativeStackQuota(rt, MAX_STACK_SIZE);
     }
 
     virtual JSRuntime * createRuntime() {
         JSRuntime *rt = JS_NewRuntime(8L * 1024 * 1024);
         if (!rt)
             return nullptr;
         setNativeStackQuota(rt);
+        JS::RuntimeOptionsRef(rt).setVarObjFix(true);
         return rt;
     }
 
     virtual void destroyRuntime() {
         JS_ASSERT(!cx);
         JS_ASSERT(rt);
         JS_DestroyRuntime(rt);
     }
@@ -313,17 +314,16 @@ class JSAPITest
                 (unsigned int) report->lineno,
                 message);
     }
 
     virtual JSContext * createContext() {
         JSContext *cx = JS_NewContext(rt, 8192);
         if (!cx)
             return nullptr;
-        JS::ContextOptionsRef(cx).setVarObjFix(true);
         JS_SetErrorReporter(cx, &reportError);
         return cx;
     }
 
     virtual const JSClass * getGlobalClass() {
         return basicGlobalClass();
     }
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1418,17 +1418,18 @@ namespace JS {
 class JS_PUBLIC_API(RuntimeOptions) {
   public:
     RuntimeOptions()
       : baseline_(false),
         ion_(false),
         asmJS_(false),
         nativeRegExp_(false),
         werror_(false),
-        strictMode_(false)
+        strictMode_(false),
+        varObjFix_(false)
     {
     }
 
     bool baseline() const { return baseline_; }
     RuntimeOptions &setBaseline(bool flag) {
         baseline_ = flag;
         return *this;
     }
@@ -1478,36 +1479,46 @@ class JS_PUBLIC_API(RuntimeOptions) {
         strictMode_ = flag;
         return *this;
     }
     RuntimeOptions &toggleStrictMode() {
         strictMode_ = !strictMode_;
         return *this;
     }
 
+    bool varObjFix() const { return varObjFix_; }
+    RuntimeOptions &setVarObjFix(bool flag) {
+        varObjFix_ = flag;
+        return *this;
+    }
+    RuntimeOptions &toggleVarObjFix() {
+        varObjFix_ = !varObjFix_;
+        return *this;
+    }
+
   private:
     bool baseline_ : 1;
     bool ion_ : 1;
     bool asmJS_ : 1;
     bool nativeRegExp_ : 1;
     bool werror_ : 1;
     bool strictMode_ : 1;
+    bool varObjFix_ : 1;
 };
 
 JS_PUBLIC_API(RuntimeOptions &)
 RuntimeOptionsRef(JSRuntime *rt);
 
 JS_PUBLIC_API(RuntimeOptions &)
 RuntimeOptionsRef(JSContext *cx);
 
 class JS_PUBLIC_API(ContextOptions) {
   public:
     ContextOptions()
       : extraWarnings_(false),
-        varObjFix_(false),
         privateIsNSISupports_(false),
         dontReportUncaught_(false),
         noDefaultCompartmentObject_(false),
         noScriptRval_(false)
     {
     }
 
     bool extraWarnings() const { return extraWarnings_; }
@@ -1515,26 +1526,16 @@ class JS_PUBLIC_API(ContextOptions) {
         extraWarnings_ = flag;
         return *this;
     }
     ContextOptions &toggleExtraWarnings() {
         extraWarnings_ = !extraWarnings_;
         return *this;
     }
 
-    bool varObjFix() const { return varObjFix_; }
-    ContextOptions &setVarObjFix(bool flag) {
-        varObjFix_ = flag;
-        return *this;
-    }
-    ContextOptions &toggleVarObjFix() {
-        varObjFix_ = !varObjFix_;
-        return *this;
-    }
-
     bool privateIsNSISupports() const { return privateIsNSISupports_; }
     ContextOptions &setPrivateIsNSISupports(bool flag) {
         privateIsNSISupports_ = flag;
         return *this;
     }
     ContextOptions &togglePrivateIsNSISupports() {
         privateIsNSISupports_ = !privateIsNSISupports_;
         return *this;
@@ -1567,17 +1568,16 @@ class JS_PUBLIC_API(ContextOptions) {
     }
     ContextOptions &toggleNoScriptRval() {
         noScriptRval_ = !noScriptRval_;
         return *this;
     }
 
   private:
     bool extraWarnings_ : 1;
-    bool varObjFix_ : 1;
     bool privateIsNSISupports_ : 1;
     bool dontReportUncaught_ : 1;
     bool noDefaultCompartmentObject_ : 1;
     bool noScriptRval_ : 1;
 };
 
 JS_PUBLIC_API(ContextOptions &)
 ContextOptionsRef(JSContext *cx);
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -633,17 +633,17 @@ js::Execute(JSContext *cx, HandleScript 
     JSObject *s = scopeChain;
     do {
         assertSameCompartment(cx, s);
         JS_ASSERT_IF(!s->enclosingScope(), s->is<GlobalObject>());
     } while ((s = s->enclosingScope()));
 #endif
 
     /* The VAROBJFIX option makes varObj == globalObj in global code. */
-    if (!cx->options().varObjFix()) {
+    if (!cx->runtime()->options().varObjFix()) {
         if (!scopeChain->setVarObj(cx))
             return false;
     }
 
     /* Use the scope chain as 'this', modulo outerization. */
     JSObject *thisObj = JSObject::thisObject(cx, scopeChain);
     if (!thisObj)
         return false;