< 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,11 +32,10 @@
 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;

@@ -282,15 +281,13 @@
                 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 computeArrayAllocationSize(length, headerSize, log2ElementSize);
                 }
                 return lookupJavaType.instanceSize();
             }
         } else {
             return constant.getJavaKind().getByteCount();

@@ -301,15 +298,17 @@
      * 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
+     * @return the size of the memory chunk
      */
-    public static int computeArrayAllocationSize(int length, int alignment, int headerSize, int log2ElementSize) {
+    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 >