We have at least three copies of the logic for weak map marking (GC, plus two for the CC). It isn't that complex, but it is a little fiddly, so it would be nice if we had some way to let them all use the same core logic, via some template.
(In reply to Andrew McCreight [:mccr8] from comment #0) This is a great idea. I'm not sure exactly what form you had in mind though... like some kind of truth table? It might be difficult to make the implementation use this (the GC weak map marking code is a little convoluted) but the fixup code and any checks certainly could.
I'm not familiar with how the GC marking code works. Maybe this isn't practical.
I would guess that it's practical and a good idea for everything *but* the GC marking code. There's a major difference between the GC marking case and all others: the GC marking case doesn't know yet what maps are alive. All other cases do (well, they know a conservative estimate of what's alive, anyway). When doing GC marking, you can't just say eg "mark the value if both the map and the key are marked", because either you're doing this when marking the map (and the key may not have been marked *yet*), or when marking the key (and either the map may not have been marked yet, or you're doing the first fast marking phase which does not check whether some random object is a key).