So I hacked together a quick simulator of a system which tries to arrange data to minimize "long" references (ie. references to objects that are distant from the current object).
Here is an example run:
In this run, there are 16 "memory locations", each of which can contain pointers to other memory locations. The first line shows the number 10, which indicates that there are 10 references which cross between locations 0-7 and locations 8-15. Then it shows the 16 locations and the pointers each contains.
So far the initial configuration is created very naively. The code tries to start with a configuration where most references are to close-by memory locations, but occasionally there is a long reference, since this should mirror an allocation scheme that seeks to achieve this.
The next few lines show the algorithm doing its thing, swapping memory locations.
Again, this code is messy, and probably buggy (eg. line 9 should start with '9' now but it doesn't). I just wanted to push it out there so others could see what I'm up to.
Ian.