Bug 1320408 - Part 13: Change DebugEnvironmentProxy::getMaybeSentinelValue to static method. r=jandem
authorTooru Fujisawa <arai_a@mac.com>
Sat, 21 Jan 2017 17:25:45 +0900
changeset 330545 93ce2713f21dca17968d4080700a6eed22f75939
parent 330544 1c611312df295461159e240077c566ea4877dd43
child 330546 bdafc05f51e8164e3a8923637f7248f7c1124066
push id36330
push userphilringnalda@gmail.com
push dateSat, 21 Jan 2017 23:26:41 +0000
treeherderautoland@5f0652e323af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1320408
milestone53.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 1320408 - Part 13: Change DebugEnvironmentProxy::getMaybeSentinelValue to static method. r=jandem
js/src/jsobj.cpp
js/src/vm/Debugger.cpp
js/src/vm/EnvironmentObject.cpp
js/src/vm/EnvironmentObject.h
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -2211,17 +2211,18 @@ js::LookupNameUnqualified(JSContext* cx,
     if (pobj == env) {
         bool isTDZ = false;
         if (prop && name != cx->names().dotThis) {
             // Treat Debugger environments specially for TDZ checks, as they
             // look like non-native environments but in fact wrap native
             // environments.
             if (env->is<DebugEnvironmentProxy>()) {
                 RootedValue v(cx);
-                if (!env->as<DebugEnvironmentProxy>().getMaybeSentinelValue(cx, id, &v))
+                Rooted<DebugEnvironmentProxy*> envProxy(cx, &env->as<DebugEnvironmentProxy>());
+                if (!DebugEnvironmentProxy::getMaybeSentinelValue(cx, envProxy, id, &v))
                     return false;
                 isTDZ = IsUninitializedLexical(v);
             } else {
                 isTDZ = IsUninitializedLexicalSlot(env, prop);
             }
         }
 
         if (isTDZ) {
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -11029,17 +11029,18 @@ DebuggerEnvironment::getVariable(JSConte
             return true;
         }
 
         // For DebugEnvironmentProxys, we get sentinel values for optimized out
         // slots and arguments instead of throwing (the default behavior).
         //
         // See wrapDebuggeeValue for how the sentinel values are wrapped.
         if (referent->is<DebugEnvironmentProxy>()) {
-            if (!referent->as<DebugEnvironmentProxy>().getMaybeSentinelValue(cx, id, result))
+            Rooted<DebugEnvironmentProxy*> env(cx, &referent->as<DebugEnvironmentProxy>());
+            if (!DebugEnvironmentProxy::getMaybeSentinelValue(cx, env, id, result))
                 return false;
         } else {
             if (!GetProperty(cx, referent, referent, id, result))
                 return false;
         }
     }
 
     // When we've faked up scope chain objects for optimized-out scopes,
--- a/js/src/vm/EnvironmentObject.cpp
+++ b/js/src/vm/EnvironmentObject.cpp
@@ -2274,21 +2274,21 @@ DebugEnvironmentProxy::isForDeclarative(
     EnvironmentObject& e = environment();
     return e.is<CallObject>() ||
            e.is<VarEnvironmentObject>() ||
            e.is<ModuleEnvironmentObject>() ||
            e.is<WasmFunctionCallObject>() ||
            e.is<LexicalEnvironmentObject>();
 }
 
-bool
-DebugEnvironmentProxy::getMaybeSentinelValue(JSContext* cx, HandleId id, MutableHandleValue vp)
+/* static */ bool
+DebugEnvironmentProxy::getMaybeSentinelValue(JSContext* cx, Handle<DebugEnvironmentProxy*> env,
+                                             HandleId id, MutableHandleValue vp)
 {
-    Rooted<DebugEnvironmentProxy*> self(cx, this);
-    return DebugEnvironmentProxyHandler::singleton.getMaybeSentinelValue(cx, self, id, vp);
+    return DebugEnvironmentProxyHandler::singleton.getMaybeSentinelValue(cx, env, id, vp);
 }
 
 bool
 DebugEnvironmentProxy::isFunctionEnvironmentWithThis()
 {
     return DebugEnvironmentProxyHandler::isFunctionEnvironmentWithThis(environment());
 }
 
--- a/js/src/vm/EnvironmentObject.h
+++ b/js/src/vm/EnvironmentObject.h
@@ -890,17 +890,18 @@ class DebugEnvironmentProxy : public Pro
     void initSnapshot(ArrayObject& snapshot);
 
     // Currently, the 'declarative' environments are function, module, and
     // lexical environments.
     bool isForDeclarative() const;
 
     // Get a property by 'id', but returns sentinel values instead of throwing
     // on exceptional cases.
-    bool getMaybeSentinelValue(JSContext* cx, HandleId id, MutableHandleValue vp);
+    static bool getMaybeSentinelValue(JSContext* cx, Handle<DebugEnvironmentProxy*> env,
+                                      HandleId id, MutableHandleValue vp);
 
     // Returns true iff this is a function environment with its own this-binding
     // (all functions except arrow functions and generator expression lambdas).
     bool isFunctionEnvironmentWithThis();
 
     // Does this debug environment not have a real counterpart or was never
     // live (and thus does not have a synthesized EnvironmentObject or a
     // snapshot)?