Skip to content

Conversation

@wks
Copy link
Collaborator

@wks wks commented Oct 13, 2022

This PR does the following:

  • Rename "alloc bit" to "valid-object bit" (VO-bit)
    • Rename the file alloc_bit.rs to vo_bit.rs and move it under src/util/metadata.
    • Rename constants and methods.
    • Change comments so they mention "VO-bit" when they used to mention "alloc bit".
  • Do refactoring related to VO-bit
    • All functions that accesses the VO-bit metadata now take ObjectReference as parameter instead of Address.
    • Remove the "is_mmtk_object" Cargo feature in favour for the "vo_bit" feature.
    • Merge the util::is_mmtk_object module into util::metadata::vo_bit.
    • Rename memory_manager::is_mmtk_object to util::metadata::vo_bit::is_valid_mmtk_object, and it takes ObjectReference parameter.
  • Add TODO comments to MallocSpace and MarkCompactSpace about switching to local meatdata.

We currently have a so-called "allocation bit", or "alloc bit" metadata. This name is misleading, because the name suggests it is used to identify allocated units in spaces, which is not true. It actually identifies valid objects (not allocation units) at any address, regardless of space. It is primarily designed to help conservative GC to filter potential object references on the stack or in objects. This PR renames it to valid-object bit, or VO-bit for short.

Some existing spaces use VO-bit to identify allocated units. Currently they are MallocSpace and MarkCompactSpace.

  • MallocSpace uses VO-bit to record all the memory returned by malloc.
  • MarkCompactSpace uses VO-bit to iterate through all allocation units in the space.

These two spaces should switch to local metadata, and such metadata should only exist if the corresponding spaces MallocSpace or MarkCompactSpace exist. It should be independent from the VO-bit.

This PR also does some minor refactoring related to things related to VO-bit. Particularly, the Cargo feature "is_mmtk_object" is removed. The is_mmtk_object function was designed to support conservative GC, but that is actually what VO-bit is designed for. So that function (now renamed util::metadata::vo_bit::is_valid_mmtk_object) is enabled whenever the "vo_bit" feature is enabled.

Things that are NOT done in this PR:

  • Refactor MallocSpace and MarkCompactSpace to use local metadata. I'll do them in separate PRs. Those changes may affect performance.
  • Refactor VO-bit access functions to use fecth_and and fetch_or. See Fix fetch_and_atomic and fetch_or_atomic #684
  • Enable the util::metadata::invalidate_object function. It should simply clear the VO-bit of an object, but it (1) interferes with the way MallocSpace currently works, and (2) requires the tracing code to skip objects without VO-bits. This change may affect performance.

wks added 12 commits October 12, 2022 16:09
I did not rename comments and functions in malloc space and mark-compact
space because when they mention "alloc bit", they do mean a
one-bit-per-allocation metadata.  They should have used their own local
metadata for that purpose.
It is how it is intended to be used.  It is set at addresses pointed by
`ObjectReference`, not the beginning of an object.
vo_bit is designed for the very purpose of is_mmtk_object, so we don't
need another feature for that.
bzero should be unsafe because of potential races.
@wks wks force-pushed the rename-to-vo-bit branch from 2879b3a to e929f83 Compare October 17, 2022 05:41
wks added 2 commits October 17, 2022 15:04
There is a bug with fetch_and and fetch_or.
@wks
Copy link
Collaborator Author

wks commented Apr 13, 2023

This PR tries to do too many things in one go. I think it is taking way too long. I'll do it in smaller steps. See: #791

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant