This change implements four basic optimizations:
- If a relocated value isn't used, it doesn't need to be relocated.
- If the value being relocated is null, relocation doesn't change that. (Technically, this might be collector specific. I don't know of one which it doesn't work for though.)
- If the value being relocated is undef, the relocation is meaningless.
- If the value being relocated was known nonnull, the relocated pointer also isn't null. (Since it points to the same source language object.)
I outlined other planned work in comments.
While I'm okay with keeping in this clause for now, I'm not comfortable with it.
What you're effectively saying here is that given any bit pattern P, there a source pattern Q such that P = relocate(Q). But there may be collectors that do not map to specific address patterns. For example, in x86-64, I think most collectors won't map any address to, say, ((void *) -1) because that is outside the 48 bit range.