Bug 1145781 - Unlazify functions when getting their debug scopes. r=jimb, a=lizzard
authorShu-yu Guo <shu@rfrn.org>
Mon, 30 Mar 2015 22:26:43 -0700
changeset 266149 9d21268e218c
parent 266148 1f0092bc321a
child 266150 a2f619521d74
push id4766
push userryanvm@gmail.com
push date2015-06-01 16:39 +0000
treeherdermozilla-beta@a2f619521d74 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb, lizzard
bugs1145781
milestone39.0
Bug 1145781 - Unlazify functions when getting their debug scopes. r=jimb, a=lizzard
js/src/jit-test/tests/debug/Environment-03.js
js/src/vm/ScopeObject.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Environment-03.js
@@ -0,0 +1,10 @@
+// Test that getting a function's environment can unlazify scripts.
+
+var g = newGlobal();
+g.eval('function f() { }');
+var dbg = new Debugger;
+var gw = dbg.makeGlobalObjectReference(g);
+var fw = gw.getOwnPropertyDescriptor('f').value;
+gc();
+dbg.addDebuggee(g);
+var fenv = fw.environment;
--- a/js/src/vm/ScopeObject.cpp
+++ b/js/src/vm/ScopeObject.cpp
@@ -1241,28 +1241,28 @@ class DebugScopeProxy : public BaseProxy
      *       scope, then the unaliased values are lost and not recoverable.
      *
      * Callers should check accessResult for non-failure results:
      *  - ACCESS_UNALIASED if the access was unaliased and completed
      *  - ACCESS_GENERIC   if the access was aliased or the property not found
      *  - ACCESS_LOST      if the value has been lost to the debugger
      */
     bool handleUnaliasedAccess(JSContext* cx, Handle<DebugScopeObject*> debugScope,
-                               Handle<ScopeObject*> scope, jsid id, Action action,
+                               Handle<ScopeObject*> scope, HandleId id, Action action,
                                MutableHandleValue vp, AccessResult* accessResult) const
     {
         MOZ_ASSERT(&debugScope->scope() == scope);
         MOZ_ASSERT_IF(action == SET, !debugScope->isOptimizedOut());
         *accessResult = ACCESS_GENERIC;
         LiveScopeVal* maybeLiveScope = DebugScopes::hasLiveScope(*scope);
 
         /* Handle unaliased formals, vars, lets, and consts at function scope. */
         if (scope->is<CallObject>() && !scope->as<CallObject>().isForEval()) {
             CallObject& callobj = scope->as<CallObject>();
-            RootedScript script(cx, callobj.callee().nonLazyScript());
+            RootedScript script(cx, callobj.callee().getOrCreateScript(cx));
             if (!script->ensureHasTypes(cx) || !script->ensureHasAnalyzedArgsUsage(cx))
                 return false;
 
             Bindings& bindings = script->bindings;
             BindingIter bi(script);
             while (bi && NameToId(bi->name()) != id)
                 bi++;
             if (!bi)
@@ -2463,17 +2463,20 @@ GetDebugScope(JSContext* cx, const Scope
 
 JSObject*
 js::GetDebugScopeForFunction(JSContext* cx, HandleFunction fun)
 {
     assertSameCompartment(cx, fun);
     MOZ_ASSERT(CanUseDebugScopeMaps(cx));
     if (!DebugScopes::updateLiveScopes(cx))
         return nullptr;
-    ScopeIter si(cx, fun->environment(), fun->nonLazyScript()->enclosingStaticScope());
+    JSScript* script = fun->getOrCreateScript(cx);
+    if (!script)
+        return nullptr;
+    ScopeIter si(cx, fun->environment(), script->enclosingStaticScope());
     return GetDebugScope(cx, si);
 }
 
 JSObject*
 js::GetDebugScopeForFrame(JSContext* cx, AbstractFramePtr frame, jsbytecode* pc)
 {
     assertSameCompartment(cx, frame);
     if (CanUseDebugScopeMaps(cx) && !DebugScopes::updateLiveScopes(cx))