This discussion is an attempt to compare the interface between Harmony's GC_Gen and Parrot's GC. The comparison is further divided into two sections, external and internal, based on Parrot's perception of GC API.

Title

Harmony (GC_Gen)

Parrot

Object Layout

Objects are laid out as chunks

Objects are laid out as, PMCs or Buffers

Pools

NOS, MOS and LOS

Yes

Copying/Compacting

Yes

Only for Buffers

Copy-on-Write

No

Yes

Pinning of Objects

Yes

No

Forcing GC

Yes

Yes

Scheduled GC

Yes

No

Wrapping-up

Yes

Partial

Weak-refs

Yes

No (Perhaps in the Future)

External Interface Methods

Acquiring/Releasing locks

Harmony: vm_gc_lock_init, vm_gc_lock_enum, vm_gc_unlock_enum

Parrot: Parrot_block_GC, Parrot_unblock_GC, Parrot_is_blocked_GC

Note:

  1. Parrot_is_blocked_GC is defined in dod.h but never used anywhere.
  2. Parrot_xx_DOD methods are deprecated

Handling Write Barriers

TBD

Freeing Objects

Harmony: Explicit Freeing is not supported

Parrot: Parrot_dod_free_pmc, Parrot_free_pmc_ext, Parrot_dod_free_sysmem, Parrot_dod_free_buffer, Parrot_dod_free_buffer_malloc

Note: We might not need to address buffers at all.

Invoking the GC

Harmony: gc_reclaim_heap,

Parrot: Parrot_dod_ms_run_init, Parrot_dod_ms_run

Note: GC invocation in Harmony is internal

Forcing the GC

Harmony: gc_force_gc

Parrot: Parrot_go_collect

Initializing the GC

Harmony: gc_init, gc_vm_initialized

Parrot: Parrot_gc_gms_init, Parrot_gc_ims_init

Note: Each GC type has an own init

Copy-on-Write (COW)

Harmony: unsupported

Parrot: clear_cow, used_cow

Note:

  1. Parrot might require a layer above Harmony GC to handle these.
  2. This is not mandatory

Allocations

Harmony: gc_alloc, gc_alloc_fast, gc_alloc_pinned

Parrot: handled by Arenas.

Note:

  1. This requires some wrapping I believe.
  2. gc_ms_alloc_objects is responsible for allocations

Tracing Objects

Harmony: vm_classloader_iterate_objects, vm_iterate_object

Parrot: Parrot_dod_trace_pmc_data, Parrot_dod_trace_root, Parrot_dod_trace_children, trace_mem_block

Root Set Enumeration

Harmony: vm_enumerate_root_set_all_threads, vm_resume_threads_after, vm_enumerate_thread_root_set, vm_enumerate_global_root_set

Parrot: trace_system_areas

Indication of Root Set Enumeration State

Harmony: safepoint_state.enumerate_the_universe

Parrot: CONSERVATIVE_POINTER_CHASING

Profiling

Harmony: implicit

Parrot: Parrot_dod_profile_start, Parrot_dod_profile_end

Note: We might not need to bother about Parrot's profiling at all

Wrapping Up

Harmony: gc_wrapup

Parrot: Parrot_block_GC, Parrot_block_DOD

Note: Parrot doesn't have any other explicit way to do this.

Internal Interface Methods

Marking Objects as Live

Harmony: vm_notify_obj_alive

Parrot: pobject_lives

Note: This changes object from White to Grey/Black in Parrot

Reclaiming Objects

Harmony: vm_reclaim_native_objs

Parrot: Parrot_dod_clear_live_bits

Sweeping Objects

Harmony: Called internally within the GC

Parrot: Parrot_dod_sweep

Note: I'm not sure whether Parrot will demand better control over separate Mark/Sweep processes.