pub fn is_in_mmtk_spaces(object: ObjectReference) -> bool
Expand description

Return true if the object lies in a region of memory where

  • only MMTk can allocate into, or
  • only MMTk’s delegated memory allocator (such as a malloc implementation) can allocate into for allocation requests from MMTk.

Return false otherwise. This function never panics.

Particularly, if this function returns true, object cannot be an object allocated by the VM itself.

If this function returns true, the object cannot be allocate by the malloc function called by the VM, either. In other words, if the MallocSpace of MMTk called malloc to allocate the object for the VM in response to memory_manager::alloc, this function will return true; but if the VM directly called malloc to allocate the object, this function will return false.

If is_mmtk_object(object.to_raw_address()) returns true, is_in_mmtk_spaces(object) must also return true.

This function is useful if an object reference in the VM can be either a pointer into the MMTk heap, or a pointer to non-MMTk objects. If the VM has a pre-built boot image that contains primordial objects, or if the VM has its own allocator or uses any third-party allocators, or if the VM allows an object reference to point to native objects such as C++ objects, this function can distinguish between MMTk-allocated objects and other objects.

Note: This function has special behaviors if the VM space (enabled by the vm_space feature) is present. See crate::plan::global::BasePlan::vm_space.

Arguments:

  • object: The object reference to query.