Closed Bug 1340499 Opened 7 years ago Closed 7 years ago

Add test code for watchpoint marking

Categories

(Core :: JavaScript: GC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla54
Tracking Status
firefox54 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

Details

Attachments

(1 file)

We currently have this watchpoint feature (js::WatchGuts/UnwatchGuts).  The idea is that you can watch an object property and have a closure called when it changes.  While the watchpoint is active, the closure is marked if the object is marked (in WatchpointMap::markIteratively).  

These edges are reported to the CC was weak edges (despite really being strong edges) so that the gray fixup can call unmark gray on the closure if the object is black, because UnmarkGray doesn't trace through watchpoints.  We could make this work, but at the moment it's handled by the fixup.

This adds some testcode to check the current behaviour and also removes some unused functionality where we can get the closure and handler back out when we remove a watchpoint.
Attachment #8838487 - Flags: review?(sphink)
Comment on attachment 8838487 [details] [diff] [review]
test-watchpoint-marking

Review of attachment 8838487 [details] [diff] [review]:
-----------------------------------------------------------------

What does it mean to report something to the CC as a weak edge?

::: js/src/jsapi-tests/testGCGrayMarking.cpp
@@ +295,5 @@
> +    JSObject* key = AllocPlainObject();
> +    CHECK(key);
> +
> +    JSObject* value = AllocPlainObject();
> +    CHECK(value);

Why "key" and "value"? Could "key" be "watchedObject" (or just "watched"), and "value" be "callback" or "handler" or "watchHandler" or "watcher"?
Attachment #8838487 - Flags: review?(sphink) → review+
(In reply to Steve Fink [:sfink] [:s:] from comment #1)
> What does it mean to report something to the CC as a weak edge?

This is a good question.  I think the CC does some iterative marking via weak edges but I don't understand the exact implications of this.

These are reported via TraceWeakMaps with a null JSObject*.  I also wonder how the CC's handling differs when the object is null or not.
Flags: needinfo?(continuation)
(In reply to Steve Fink [:sfink] [:s:] from comment #1)
> Why "key" and "value"?

Another good question.  I'm going with "watched" and "closure".
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3df979582555
Add test code for watchpoint marking r=sfink
https://hg.mozilla.org/mozilla-central/rev/3df979582555
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
(In reply to Jon Coppeard (:jonco) from comment #2)
> (In reply to Steve Fink [:sfink] [:s:] from comment #1)
> > What does it mean to report something to the CC as a weak edge?
> 
> This is a good question.  I think the CC does some iterative marking via
> weak edges but I don't understand the exact implications of this.
> 
> These are reported via TraceWeakMaps with a null JSObject*.  I also wonder
> how the CC's handling differs when the object is null or not.

The idea here is that the CC needs to handle grey cycles passing through watchpoints. Rather than implement some new way to report these to the CC, I treat a watchpoint as a weak map where the map is known black. (Or maybe the key it sounds like?) The CC gets passed null for something when the underlying thing is black. Does that answer your question?
Flags: needinfo?(continuation)
(In reply to Andrew McCreight [:mccr8] from comment #6)

That makes sense, thanks.
It does answer the question, though the naming is a little bit shaky -- "weak" is being used here to mean something else. I was considering changing the adjective for this purpose in the weakmap code to "implicit", though I only ended up using it in a single comment.

There's nothing weak going on -- if the source of the edge is live, then the destination must also be live. (Sorry, that's GC terminology. For the CC, I think it's that if the source is dead and the destination is not otherwise live, then the destination is dead?) But tracing the source will not trace the edge to the destination, so the edge is implicit. Or indirect? Hm, maybe indirect is better.

Sorry, just trying to work this out in my head. I think you could say "weak as in weakmap", because weakmaps aren't weak either except insofar as you could have a live key mapping to a dead value, which otherwise only happens with (true) weak references. But weakmaps are really bundles of strong conjunction edges.
You need to log in before you can comment on or make changes to this bug.