Bug 784706 - clear proxiedScopes in DebugScopes::onCompartmentLeaveDebugMode (r=jimb)
authorLuke Wagner <luke@mozilla.com>
Thu, 23 Aug 2012 10:58:24 -0700
changeset 105346 88d90921b34838c4d4e880f80b987ebf819a3c20
parent 105345 8618d9956e869630165c7e2def703010fd3bf1e2
child 105347 786f414ea72681508af57225d8b2082332cdc758
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersjimb
bugs784706
milestone17.0a1
Bug 784706 - clear proxiedScopes in DebugScopes::onCompartmentLeaveDebugMode (r=jimb)
js/src/jsweakmap.h
js/src/vm/ScopeObject.cpp
--- a/js/src/jsweakmap.h
+++ b/js/src/jsweakmap.h
@@ -145,19 +145,19 @@ class WeakMapBase {
     WeakMapBase *next;
 };
 
 template <class Key, class Value,
           class HashPolicy = DefaultHasher<Key> >
 class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, public WeakMapBase {
   private:
     typedef HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy> Base;
-    typedef typename Base::Enum Enum;
 
   public:
+    typedef typename Base::Enum Enum;
     typedef typename Base::Range Range;
 
     explicit WeakMap(JSRuntime *rt, JSObject *memOf=NULL) : Base(rt), WeakMapBase(memOf) { }
     explicit WeakMap(JSContext *cx, JSObject *memOf=NULL) : Base(cx), WeakMapBase(memOf) { }
 
     /* Use with caution, as result can be affected by garbage collection. */
     Range nondeterministicAll() {
         return Base::all();
--- a/js/src/vm/ScopeObject.cpp
+++ b/js/src/vm/ScopeObject.cpp
@@ -1658,17 +1658,17 @@ DebugScopes::onPopCall(StackFrame *fp, J
             liveScopes.remove(&debugScope->scope().asCall());
             missingScopes.remove(p);
         }
     }
 
     /*
      * When the StackFrame is popped, the values of unaliased variables
      * are lost. If there is any debug scope referring to this scope, save a
-     * copy of the unaliased variables' values in an array for latter debugger
+     * copy of the unaliased variables' values in an array for later debugger
      * access via DebugScopeProxy::handleUnaliasedAccess.
      *
      * Note: since it is simplest for this function to be infallible, failure
      * in this code will be silently ignored. This does not break any
      * invariants since DebugScopeObject::maybeSnapshot can already be NULL.
      */
     if (debugScope) {
         /*
@@ -1771,16 +1771,20 @@ DebugScopes::onGeneratorFrameChange(Stac
             }
         }
     }
 }
 
 void
 DebugScopes::onCompartmentLeaveDebugMode(JSCompartment *c)
 {
+    for (ObjectWeakMap::Enum e(proxiedScopes); !e.empty(); e.popFront()) {
+        if (e.front().key->compartment() == c)
+            e.removeFront();
+    }
     for (MissingScopeMap::Enum e(missingScopes); !e.empty(); e.popFront()) {
         if (e.front().key.fp()->compartment() == c)
             e.removeFront();
     }
     for (LiveScopeMap::Enum e(liveScopes); !e.empty(); e.popFront()) {
         if (e.front().key->compartment() == c)
             e.removeFront();
     }