mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-08 18:00:17 +02:00
Fixes #3675 This was the first time I've ever actually dived in to this code and this function melted my brain a bit while reading it. It was trying to be too smart in tracking VMA splits, but if it split right at the end of a VMA range it would then add a new range at the end where one already existed. This then caused us to have overlapping VMA ranges and it would completely break our SMC tracking since all tracking in the map must not overlap. Instead of being too smart, just break it down in to 4 merge strategies, three of which are one shot. This is significantly easier to reason about and each strategy is mostly self-contained. The fourth strategy in the list is the most complex since it requires multiple steps since it needs to walk multiple VMAs. To help test this I added some sanity checking code that proved invaluable to ensure everything was correct. That's not getting merged since the overhead is too much to run, but good to have available. Diff for this is at https://gist.github.com/Sonicadvance1/1ee60101ed0742b971a476fadbb51083