Garbage Collection Points
JIT Code
GC Points are an essential part of an exact (and moving) GarbageCollector. A collection can only take place if all threads are stopped at such points. The following things have to be assured at these points:
- The collector knows about "stack frame maps": That means we know which registers and stack slots actually contain references.
- The thread actually suspends itself at the GC point: This will be achieved by code patching (delay slots can be a problem here). The collector has to patch all (some) GC points so they become GC traps, then resume the thread, and wait for the thread to suspend itself.
The number and placement of GC points has to make sure there are no blocking methods running in the thread. Once the GC wants to do a collection, all the threads need to suspend "quickly". So we chose the following JIT instructions to be GC points:
- invocations: This assures that all the calling methods are at GC points as well we can walk through the calling stack.
- return instructions: So that the method is not able to escape before firing a trap.
- exceptions: See above! This can also be moved to exceptions_throw_exception()
- all back-branches: This eliminates blocking loops.
Problems in native code
TODO