Superword - Aligning arrays
James Walsh
groundskeeperwiley at yahoo.com
Wed Feb 4 20:47:02 PST 2009
Let's say the heap is at 0x1000. I have a 5 float array that I want strongly aligned. I create a dummy 20 byte array leaving the heap at 0x1014. I create the 5 float array with a 12 byte header. The data in the array oop is aligned on the 16byte boundary for SIMD and the whole oop is a nice round 32 bytes which is MinObjAlignment aligned. Unfortunately the heap is now at 0x1034 which will assert on the next allocation. I can detect this at the allocation of the second array and add an extra alignment word which will realign the heap and everything runs fine until GC. When GC hits the dummy array gets oop::size() called on it and says it's actually an MinObjAlignment aligned 24-bytes. The iterator will then index 4-bytes too far, read a bunch of garbage instead of a header resulting in the jvm crashing. I think this is the state of my code right now.
Is there a way around this without touching oop::size_given_klass? If I create a new heap parseable class I would still need some way of knowing that I should not honor the heap alignment for this oop. What if I set the length of the dummy array to the negative of it's actual length? That way in oop::size_given_klass I would know if I see a negative length that it is a alignment array that should ignore MinObjAlignment. For the strongly aligned array I could just check and see if the oop ends on 0x4 or 0xC and adjust the size up 4 bytes.
More information about the hotspot-dev
mailing list