mmtk / mmtk-core

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

Fix find_last_non_zero_bit, and align metadata address before converting to data address. #1188

Closed qinsoon closed 2 months ago

qinsoon commented 2 months ago

This PR fixes some bugs in finding base references for internal references. Prominently two bugs:

  1. The way we find the last non zero bit was wrong. We used to to use trailing_zeroes and compare the result with the given range of the starting and ending bits. This was simply wrong. Now we do a mask first to extract the value between the starting and the ending bits, and then use leading_zeroes. Performance-wise, the new code has similar performnace.
  2. When we convert a metadata bit (address + bit offset) back to the data address, the metadata bit needs to be the start of the metadata value. If it is the middle of the metadata value, then the computed data address will be incorrect. This PR adds align_metadata_address.

This PR skips some tests for LOS in plans that do not use LOS.