Address review comments from billm (bug 672829 comment 15).
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 21 Jul 2011 18:14:33 -0500
changeset 75226 8998a25f3887f8038426aaa4a050368d75dd499b
parent 75225 46a7638aeb4d9132dc416bda95605347f0070857
child 75227 8c3a259cccf38ff521ae78f2f044e00ec701db85
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs672829
milestone8.0a1
Address review comments from billm (bug 672829 comment 15).
js/src/jsweakmap.h
--- a/js/src/jsweakmap.h
+++ b/js/src/jsweakmap.h
@@ -277,49 +277,24 @@ class DefaultMarkPolicy<JSObject *, JSOb
         return false;
     }
     void markEntry(JSObject *k, JSObject *v) {
         js::gc::MarkObject(tracer, *k, "WeakMap entry key");
         js::gc::MarkObject(tracer, *v, "WeakMap entry value");
     }
 };
 
-// A MarkPolicy for WeakMaps whose Keys and values may be objects in arbitrary
+// A MarkPolicy for WeakMaps whose keys and values may be objects in arbitrary
 // compartments within a runtime.
-class CrossCompartmentMarkPolicy {
-  private:
-    JSTracer *tracer;
-    JSCompartment *comp;
-
-    // During per-compartment GC, if a key or value object is outside the gc
-    // compartment, consider it marked.
-    bool isMarked(JSObject *obj) {
-        return (comp && obj->compartment() != comp) || !IsAboutToBeFinalized(tracer->context, obj);
-    }
-
-  public:
-    CrossCompartmentMarkPolicy(JSTracer *t)
-        : tracer(t), comp(t->context->runtime->gcCurrentCompartment) {}
-    bool keyMarked(JSObject *k) { return isMarked(k); }
-    bool valueMarked(JSObject *v) { return isMarked(v); }
-
-    bool markEntryIfLive(JSObject *k, JSObject *v) {
-        if (keyMarked(k) && !valueMarked(v)) {
-            js::gc::MarkObject(tracer, *v, "WeakMap entry value");
-            return true;
-        }
-        return false;
-    }
-    void markEntry(JSObject *k, JSObject *v) {
-        if (!comp || k->compartment() == comp)
-            js::gc::MarkObject(tracer, *k, "WeakMap entry key");
-        if (!comp || v->compartment() == comp)
-            js::gc::MarkObject(tracer, *v, "WeakMap entry value");
-    }
-};
+//
+// With the current GC, the implementation turns out to be identical to the
+// default mark policy. We give it a distinct name anyway, in case this ever
+// changes.
+//
+typedef DefaultMarkPolicy<JSObject *, JSObject *> CrossCompartmentMarkPolicy;
 
 // The class of JavaScript WeakMap objects.
 extern Class WeakMapClass;
 
 }
 
 extern JSObject *
 js_InitWeakMapClass(JSContext *cx, JSObject *obj);