Uninitialized Fields
In GitLab by @qinsoon on Jan 26, 2020, 11:44
A lot of structs in Rust MMTk are initialized with some uninitialized fields. We are using empty values (such as 0, OpaquePointer::EMPTY), mem::uninitialized(), or Option::None for the uninitialized fields.
The reasons why those uninitialized fields exist are:
- Rust MMTk used to create some structs as static variables, some fields are uninitialized. Rust MMTk relies on an extra
init()step to properly set values for those fields. - Initialize circular references.
I suggest we do these:
- As we are removing global states, we should remove the extra
init()so that all the fields are initialized properly innew(). We should do this wherever possible. - If we cannot remove
init(), we should use a wrapper to properly indicate that this field might be uninitialized such asMaybeUninit<T>. - Remove circular references if we can.
This issue is raised in code reviews for both https://gitlab.anu.edu.au/mmtk/mmtk/merge_requests/20 and https://gitlab.anu.edu.au/mmtk/mmtk/merge_requests/22.
In GitLab by @qinsoon on Jan 26, 2020, 11:45
mentioned in merge request !22
In GitLab by @qinsoon on Jan 26, 2020, 19:10
mentioned in merge request !23
We have gradually removed the pattern. I am not aware of any unnecessary two-step initialisation in our code base. I feel we can close this issue now. If you find anything that is related with this issue and hasn't been addressed, please reply to this issue. Otherwise, I will close this issue soon.
Closed as above