int instanceSize = base + cd.arrayLength() * scale;
instanceSize = VMSupport.align(instanceSize, autoAlign ? Math.max(4, scale) : 8);
base = VMSupport.align(base, Math.max(4, scale));
result.add(new FieldLayout(FieldData.create(cd.arrayClass(), "length", "int"), model.headerSize(), model.sizeOf("int")));
result.add(new FieldLayout(FieldData.create(cd.arrayClass(), "<elements>", cd.arrayComponentType()), base, scale * cd.arrayLength()));
return new ClassLayout(cd, result, model.headerSize(), instanceSize, false);
}
List<String> hierarchy = cd.classHierarchy();
BitSet claimed = new BitSet();
claimed.set(0, model.headerSize());
for (String k : hierarchy) {
Collection<FieldData> fields = cd.fieldsFor(k);
SortedSet<FieldLayout> current = new TreeSet<FieldLayout>();
for (int size : new int[]{8, 4, 2, 1}) {
for (FieldData f : fields) {
int fSize = model.sizeOf(f.typeClass());
if (fSize != size) continue;
for (int t = 0; t < Integer.MAX_VALUE; t++) {
if (claimed.get(t * size, (t + 1) * size).isEmpty()) {
claimed.set(t * size, (t + 1) * size);
current.add(new FieldLayout(f, t * size, size));
break;
}
}
}
}