< prev index next >

src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java

Print this page

        

*** 32,42 **** import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Objects; import jdk.vm.ci.code.CodeUtil; - import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.meta.DeoptimizationAction; import jdk.vm.ci.meta.DeoptimizationReason; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.JavaKind; --- 32,41 ----
*** 282,296 **** if (lookupJavaType.isArray()) { int length = Array.getLength(((HotSpotObjectConstantImpl) constant).object()); ResolvedJavaType elementType = lookupJavaType.getComponentType(); JavaKind elementKind = elementType.getJavaKind(); final int headerSize = getArrayBaseOffset(elementKind); - TargetDescription target = runtime.getHostJVMCIBackend().getTarget(); int sizeOfElement = getArrayIndexScale(elementKind); - int alignment = target.wordSize; int log2ElementSize = CodeUtil.log2(sizeOfElement); ! return computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); } return lookupJavaType.instanceSize(); } } else { return constant.getJavaKind().getByteCount(); --- 281,293 ---- if (lookupJavaType.isArray()) { int length = Array.getLength(((HotSpotObjectConstantImpl) constant).object()); ResolvedJavaType elementType = lookupJavaType.getComponentType(); JavaKind elementKind = elementType.getJavaKind(); final int headerSize = getArrayBaseOffset(elementKind); int sizeOfElement = getArrayIndexScale(elementKind); int log2ElementSize = CodeUtil.log2(sizeOfElement); ! return computeArrayAllocationSize(length, headerSize, log2ElementSize); } return lookupJavaType.instanceSize(); } } else { return constant.getJavaKind().getByteCount();
*** 301,315 **** * Computes the size of the memory chunk allocated for an array. This size accounts for the * array header size, body size and any padding after the last element to satisfy object * alignment requirements. * * @param length the number of elements in the array - * @param alignment the object alignment requirement * @param headerSize the size of the array header * @param log2ElementSize log2 of the size of an element in the array */ ! public static int computeArrayAllocationSize(int length, int alignment, int headerSize, int log2ElementSize) { int size = (length << log2ElementSize) + headerSize + (alignment - 1); int mask = ~(alignment - 1); return size & mask; } } --- 298,314 ---- * Computes the size of the memory chunk allocated for an array. This size accounts for the * array header size, body size and any padding after the last element to satisfy object * alignment requirements. * * @param length the number of elements in the array * @param headerSize the size of the array header * @param log2ElementSize log2 of the size of an element in the array + * @return the size of the memory chunk */ ! public int computeArrayAllocationSize(int length, int headerSize, int log2ElementSize) { ! HotSpotVMConfig config = runtime.getConfig(); ! int alignment = config.objectAlignment; int size = (length << log2ElementSize) + headerSize + (alignment - 1); int mask = ~(alignment - 1); return size & mask; } }
< prev index next >