While working on bug 1865611 I found that we could simplify weak map marking by removing the incremental marking barriers if we changed the implicit edges (ephemerons) we create for weakmap entries. Currently when there is a weak map key with a delegate we create an ephemeron edge from the delegate to the key and from the delegate to the value. This means that if the association between the key and the delegate is removed we need to ensure the value gets marked if the key gets marked (the key originally contains a strong reference to the delegate). Instead, if we create an edge from the key to the delegate and from the key to the value it seems we don't require this barrier. Marking the key will mark the value. Marking the delegate will mark the value because it marks the key first. If the association between the key and the delegate is removed we will conservatively still mark key and value if the delegate gets marked, as the barrier does now. I may well be missing something here but I tested this and it and it seems to work.
Bug 1867220 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
While working on bug 1865611 I found that we could simplify weak map marking by removing the incremental marking barriers if we changed the implicit edges (ephemerons) we create for weakmap entries. Currently when there is a weak map key with a delegate we create an ephemeron edge from the delegate to the key and from the delegate to the value. This means that if the association between the key and the delegate is removed we need a barrier to ensure the value gets marked if the key gets marked (the key originally contains a strong reference to the delegate). Instead, if we create an edge from the delegate to the key and from the key to the value it seems we don't require this barrier. Marking the key will mark the value. Marking the delegate will mark the value because it marks the key first. If the association between the key and the delegate is removed we will conservatively still mark key and value if the delegate gets marked, as the barrier does now. I may well be missing something here but I tested this and it and it seems to work.