Module vm

Module vm 

Source
Expand description

MMTk-to-VM interface: the VMBinding trait.

This module provides VM-specific traits that serve as MMTK-to-VM interfaces. Each VM binding needs to provide an implementation for each of the traits. MMTk requires the interfaces to be efficient, as some of the methods are called frequently during collection (e.g. the methods for ObjectModel). We rely on cross-crate link-time-optimization to remove the overhead of MMTk invoking methods on those traits.

It is recommended for a VM binding that uses mmtk-core to do the following to ensure LTO is enabled for performance.

  1. Add the following section in the manifest file of a VM binding (Cargo.toml). This enables LTO for the release build:
    [profile.release]
    lto = true
  2. Make sure that the crate type for a VM binding supports LTO. To our knowledge, staticlib and cdylib support LTO, and rlib does not support LTO.

Modulesยง

active_plan ๐Ÿ”’
collection ๐Ÿ”’
object_model ๐Ÿ”’
reference_glue ๐Ÿ”’
scanning ๐Ÿ”’
slot
This module provides the trait Slot and related traits and types which allow VMs to customize the layout of slots and the behavior of loading and updating object references in slots.

Structsยง

VMGlobalLogBitSpec
1-bit global metadata to log an object.
VMLocalForwardingBitsSpec
2-bit local metadata for spaces that store a forwarding state for objects. If this spec is defined in the header, it can be defined with a position of the lowest 2 bits in the forwarding pointer.
VMLocalForwardingPointerSpec
1-word local metadata for spaces that may copy objects. This metadata has to be stored in the header. This metadata can be defined at a position within the object payload. As a forwarding pointer is only stored in dead objects which is not accessible by the language, it is okay that store a forwarding pointer overwrites object payload
VMLocalLOSMarkNurserySpec
2-bits local metadata for the large object space. The two bits serve as the mark bit and the nursery bit.
VMLocalMarkBitSpec
1-bit local metadata for spaces that need to mark an object.
VMLocalPinningBitSpec
1-bit local metadata for spaces that support pinning.

Enumsยง

GCThreadContext
Thread context for the spawned GC thread. It is used by spawn_gc_thread. Currently, GCWorker is the only kind of thread that mmtk-core will create.

Constantsยง

DEFAULT_LOG_MAX_ALIGNMENT ๐Ÿ”’
Default max alignment 8 bytes
DEFAULT_LOG_MIN_ALIGNMENT ๐Ÿ”’
Default min alignment 4 bytes

Traitsยง

ActivePlan
VM-specific methods for the current plan.
Collection
VM-specific methods for garbage collection.
Finalizable
A finalizable object for MMTk. MMTk needs to know the actual object reference in the type, while a binding can use this type to store some runtime information about finalizable objects. For example, for bindings that allows multiple finalizer methods with one object, they can define the type as a tuple of (object, finalize method), and register different finalizer methods to MMTk for the same object. The implementation should mark theird method implementations as inline for performance.
ObjectModel
VM-specific methods for object model.
ObjectTracer
Callback trait of scanning functions that directly trace through object graph edges.
ObjectTracerContext
An ObjectTracerContext gives a GC worker temporary access to an ObjectTracer, allowing the GC worker to trace objects. This trait is intended to abstract out the implementation details of tracing objects, enqueuing objects, and creating work packets that expand the transitive closure, allowing the VM binding to focus on VM-specific parts.
ReferenceGlue
VM-specific methods for reference processing, including weak references, and finalizers. We handle weak references and finalizers differently:
RootsWorkFactory
Root-scanning methods use this trait to create work packets for processing roots.
Scanning
VM-specific methods for scanning roots/objects.
SlotVisitor
Callback trait of scanning functions that report slots.
VMBinding
The VMBinding trait associates with each trait, and provides VM-specific constants.