ReferenceProcessor::discover_reference tests the referent, rejecting deferred processing of the referent if it is already known to be stongly referenced. However, all calls to discover_reference are protected by their callers with a similar test of the reference's referent.
The callers can make use of collector-specific specialized liveness tests that might even be inlineable, whereas discover_reference has to use a more generic or indirect out of line approach.
All in all, this makes the referent test within discover_reference an expensive nop.
It would be better to remove that test from discover_reference and instead document discover_reference as benefitting from such a guard. Note that it isn't strictly a pre-condition, since nothing will actually fail if such a guard is not used. It would just result in a reference with a live referent being unnecessarily added to the discovery list and then later removed during the post-discovery phase.
The callers can make use of collector-specific specialized liveness tests that might even be inlineable, whereas discover_reference has to use a more generic or indirect out of line approach.
All in all, this makes the referent test within discover_reference an expensive nop.
It would be better to remove that test from discover_reference and instead document discover_reference as benefitting from such a guard. Note that it isn't strictly a pre-condition, since nothing will actually fail if such a guard is not used. It would just result in a reference with a live referent being unnecessarily added to the discovery list and then later removed during the post-discovery phase.