It would be interesting to experiment with object collocation where when two object are allocated at a similar time we replace the allocation with a single collocated allocation. Consider:
String {
char[] value;
String(char[] _value) {
value = new char[_value.length];
for (int i=0; i<_value.length; i++) {
value[i]=_value[i];
}
}
char charAt(int offset) {
return value[offset];
}
}
if the String and char[] were collocated then we could turn charAt into:
char charAt(int offset) {
if (collocated()) return load(this+offset_of_value+offset*2)
return value[offset];
}
ie we've saved a load. The collocated test could be either a bit in the object header, or that the String has been allocated in the nursery (and the region between the allocation of String to the allocation of the array for value is uninterruptible). Once we have a test case like this we can experiment with MMTk, specializing on the collocated case, enforcing collocation (so the collocation test result just becomes true), etc.. We can also consider automating the transformation to collocated objects with the opt compiler.