2018-10-28

Java 10 : Garbage Collector

The GC interface would be defined by the existing class CollectedHeap which every garbage collector needs to implement. The CollectedHeap class would drive most aspects of interaction between the garbage collector and the rest of HotSpot (there a few utility classes needed prior to a CollectedHeap being instantiated). More specifically, a garbage collector implementation will have to provide:
  • The heap, a subclass of CollectedHeap
  • The barrier set, a subclass of BarrierSet, which implements the various barriers for the runtime
  • An implementation of CollectorPolicy
  • An implementation of GCInterpreterSupport, which implements the various barriers for a GC for the interpreter (using assembler instructions)
  • An implementation of GCC1Support, which implements the various barriers for a GC for the C1 compiler
  • An implementation of GCC2Support, which implements the various barriers for a GC for the C2 compiler
  • Initialization of eventual GC specific arguments
  • Setup of a MemoryService, the related memory pools, memory managers, etc.
The code for implementation details that are shared between multiple garbage collectors should exist in a helper class. This way it can easily be used by the different GC implementations. For example, there could be a helper class that implements the various barriers for card table support, and any GC that requires card table post-barriers would call the corresponding methods of that helper class. This way the interface provides flexibility to implement completely new barriers, and at the same time allows for reuse of existing code in a mix-and-match style.

No comments:

Post a Comment