Re:Handles Are the Better Pointers
by hinkley on Wednesday June 21, 2023 @12:03PM
(#36420306)
Java started out with handles. It seemed to be useful for getting the compacting collector working right. Later on, around Java 5, those went away, improving branch prediction. Then sometime around Java 9 they came back with a twist. As part of concurrent GC work, they needed to be able to move an object while the app was still running. An object may have a handle living at the old location, forwarding access to the new one while the pointers are being updated.
That was about when I stopped paying attention to Java. I know there have been two major new collectors since so I don’t know if this is still true. I was also never clear how they clone the object atomically, since you would have to block all updates in order to move it. I think write barriers are involved for more recent GC’s but I’m fuzzy on whether it goes back that far or they used a different trick for the handles.
That was about when I stopped paying attention to Java. I know there have been two major new collectors since so I don’t know if this is still true. I was also never clear how they clone the object atomically, since you would have to block all updates in order to move it. I think write barriers are involved for more recent GC’s but I’m fuzzy on whether it goes back that far or they used a different trick for the handles.