mmtk / mmtk-core

Memory Management ToolKit
https://www.mmtk.io
Other
379 stars 69 forks source link

Expose VO bit functions #1157

Open udesou opened 4 months ago

udesou commented 4 months ago

Currently Julia needs to bulk set the VO bit for boot image regions of code. While hacky, this solution seems to work and shouldn't be too problematic given we only do that for permalloc-ed objects. This PR makes the functions bzero_vo_bit and bset_vo_bit public via util/metadata/side_metadata/global.rs so that it can be called by the Julia binding.

qinsoon commented 4 months ago

I am not sure if it is a good idea to bulk set vo bit. VO bit means a valid object. Bulk setting vo bits clearly violates the contract. Addresses with vo bits set may not be an object.

For example, when we have internal pointers and we try to find the base pointer, MMTk will give incorrect results, as the contract about VO bits is broken.

However, I dont know what we should do for Julia's boot image. Is it possible to find each object in the boot image? I looked at https://github.com/mmtk/julia/blob/d907a0630b4551cfbb321366da6e96242ada25d1/src/staticdata.c#L2844, and it doesn't look like an easy thing to do.

udesou commented 4 months ago

I am not sure if it is a good idea to bulk set vo bit. VO bit means a valid object. Bulk setting vo bits clearly violates the contract. Addresses with vo bits set may not be an object.

For example, when we have internal pointers and we try to find the base pointer, MMTk will give incorrect results, as the contract about VO bits is broken.

However, I dont know what we should do for Julia's boot image. Is it possible to find each object in the boot image? I looked at https://github.com/mmtk/julia/blob/d907a0630b4551cfbb321366da6e96242ada25d1/src/staticdata.c#L2844, and it doesn't look like an easy thing to do.

I guess the other option is to ignore immortal objects altogether. ~Would that make sense?~ I guess it wouldn't be a problem for Julia since we use the conservative stack scanning only for pinning (and immortal objects don't move), but if we do need them as roots, then it would definitely be a problem.