mmtk / mmtk-core

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

Mark sweep free list allocates high address cells first #1164

Open qinsoon opened 4 months ago

qinsoon commented 4 months ago

When we allocate a new block or sweep a block, the free list for the block points to the last cell. https://github.com/mmtk/mmtk-core/blob/6cae51c40104d84bb74598ab3eba4f9ef8173e8e/src/util/alloc/free_list_allocator.rs#L360 https://github.com/mmtk/mmtk-core/blob/6cae51c40104d84bb74598ab3eba4f9ef8173e8e/src/policy/marksweepspace/native_ms/block.rs#L305

E.g. for a block starting at 0x10000 and ending at 0x20000, with the cell size of 8, the free list is like below: 0x1fff8 -> 0x1fff0 -> 0x1ffe8 -> ... -> 0x10000

So when we allocate, we will get the high address cell first, then the low address cell. I am not sure if this would cause any issue. But clearly we cannot assume that in two consecutively allocated objects, the second object has a higher address than the first object.