annotate test/gc/survivorAlignment/AlignmentHelper.java @ 20915:916aac9fe6f7

LinearScan: use RegisterAllocationConfig.
author Josef Eisl <josef.eisl@jku.at>
date Mon, 13 Apr 2015 15:10:55 +0200
parents 4b7c96fba3d8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20717
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
1 /*
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
4 *
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
7 * published by the Free Software Foundation.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
8 *
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
13 * accompanied this code).
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
14 *
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
18 *
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
21 * questions.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
22 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
23
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
24 import java.lang.management.MemoryPoolMXBean;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
25 import java.util.Optional;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
26
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
27 import sun.hotspot.WhiteBox;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
28
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
29 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
30 * Helper class aimed to provide information about alignment of objects in
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
31 * particular heap space, expected memory usage after objects' allocation so on.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
32 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
33 public class AlignmentHelper {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
34 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
35
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
36 private static final long OBJECT_ALIGNMENT_IN_BYTES_FOR_32_VM = 8L;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
37
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
38 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
39 * Max relative allowed actual memory usage deviation from expected memory
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
40 * usage.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
41 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
42 private static final float MAX_RELATIVE_DEVIATION = 0.05f; // 5%
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
43
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
44 public static final long OBJECT_ALIGNMENT_IN_BYTES = Optional.ofNullable(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
45 AlignmentHelper.WHITE_BOX.getIntxVMFlag("ObjectAlignmentInBytes"))
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
46 .orElse(AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES_FOR_32_VM);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
47
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
48 public static final long SURVIVOR_ALIGNMENT_IN_BYTES = Optional.ofNullable(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
49 AlignmentHelper.WHITE_BOX.getIntxVMFlag("SurvivorAlignmentInBytes"))
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
50 .orElseThrow(() ->new AssertionError(
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
51 "Unable to get SurvivorAlignmentInBytes value"));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
52 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
53 * Min amount of memory that will be occupied by an object.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
54 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
55 public static final long MIN_OBJECT_SIZE
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
56 = AlignmentHelper.WHITE_BOX.getObjectSize(new Object());
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
57 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
58 * Min amount of memory that will be occupied by an empty byte array.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
59 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
60 public static final long MIN_ARRAY_SIZE
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
61 = AlignmentHelper.WHITE_BOX.getObjectSize(new byte[0]);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
62
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
63 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
64 * Precision at which actual memory usage in a heap space represented by
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
65 * this sizing helper could be measured.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
66 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
67 private final long memoryUsageMeasurementPrecision;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
68 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
69 * Min amount of memory that will be occupied by an object allocated in a
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
70 * heap space represented by this sizing helper.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
71 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
72 private final long minObjectSizeInThisSpace;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
73 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
74 * Object's alignment in a heap space represented by this sizing helper.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
75 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
76 private final long objectAlignmentInThisRegion;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
77 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
78 * MemoryPoolMXBean associated with a heap space represented by this sizing
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
79 * helper.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
80 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
81 private final MemoryPoolMXBean poolMXBean;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
82
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
83 private static long alignUp(long value, long alignment) {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
84 return ((value - 1) / alignment + 1) * alignment;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
85 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
86
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
87 protected AlignmentHelper(long memoryUsageMeasurementPrecision,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
88 long objectAlignmentInThisRegion, long minObjectSizeInThisSpace,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
89 MemoryPoolMXBean poolMXBean) {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
90 this.memoryUsageMeasurementPrecision = memoryUsageMeasurementPrecision;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
91 this.minObjectSizeInThisSpace = minObjectSizeInThisSpace;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
92 this.objectAlignmentInThisRegion = objectAlignmentInThisRegion;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
93 this.poolMXBean = poolMXBean;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
94 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
95
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
96 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
97 * Returns how many objects have to be allocated to fill
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
98 * {@code memoryToFill} bytes in this heap space using objects of size
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
99 * {@code objectSize}.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
100 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
101 public int getObjectsCount(long memoryToFill, long objectSize) {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
102 return (int) (memoryToFill / getObjectSizeInThisSpace(objectSize));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
103 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
104
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
105 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
106 * Returns amount of memory that {@code objectsCount} of objects with size
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
107 * {@code objectSize} will occupy this this space after allocation.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
108 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
109 public long getExpectedMemoryUsage(long objectSize, int objectsCount) {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
110 long correctedObjectSize = getObjectSizeInThisSpace(objectSize);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
111 return AlignmentHelper.alignUp(correctedObjectSize * objectsCount,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
112 memoryUsageMeasurementPrecision);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
113 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
114
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
115 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
116 * Returns current memory usage in this heap space.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
117 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
118 public long getActualMemoryUsage() {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
119 return poolMXBean.getUsage().getUsed();
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
120 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
121
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
122 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
123 * Returns maximum memory usage deviation from {@code expectedMemoryUsage}
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
124 * given the max allowed relative deviation equal to
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
125 * {@code relativeDeviation}.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
126 *
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
127 * Note that value returned by this method is aligned according to
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
128 * memory measurement precision for this heap space.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
129 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
130 public long getAllowedMemoryUsageDeviation(long expectedMemoryUsage) {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
131 long unalignedDeviation = (long) (expectedMemoryUsage *
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
132 AlignmentHelper.MAX_RELATIVE_DEVIATION);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
133 return AlignmentHelper.alignUp(unalignedDeviation,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
134 memoryUsageMeasurementPrecision);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
135 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
136
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
137 /**
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
138 * Returns amount of memory that will be occupied by an object with size
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
139 * {@code objectSize} in this heap space.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
140 */
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
141 public long getObjectSizeInThisSpace(long objectSize) {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
142 objectSize = Math.max(objectSize, minObjectSizeInThisSpace);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
143
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
144 long alignedObjectSize = AlignmentHelper.alignUp(objectSize,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
145 objectAlignmentInThisRegion);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
146 long sizeDiff = alignedObjectSize - objectSize;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
147
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
148 // If there is not enough space to fit padding object, then object will
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
149 // be aligned to {@code 2 * objectAlignmentInThisRegion}.
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
150 if (sizeDiff >= AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
151 && sizeDiff < AlignmentHelper.MIN_OBJECT_SIZE) {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
152 alignedObjectSize += AlignmentHelper.MIN_OBJECT_SIZE;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
153 alignedObjectSize = AlignmentHelper.alignUp(alignedObjectSize,
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
154 objectAlignmentInThisRegion);
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
155 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
156
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
157 return alignedObjectSize;
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
158 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
159 @Override
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
160 public String toString() {
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
161 StringBuilder builder = new StringBuilder();
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
162
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
163 builder.append(String.format("AlignmentHelper for memory pool '%s':%n",
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
164 poolMXBean.getName()));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
165 builder.append(String.format("Memory usage measurement precision: %d%n",
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
166 memoryUsageMeasurementPrecision));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
167 builder.append(String.format("Min object size in this space: %d%n",
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
168 minObjectSizeInThisSpace));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
169 builder.append(String.format("Object alignment in this space: %d%n",
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
170 objectAlignmentInThisRegion));
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
171
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
172 return builder.toString();
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
173 }
4b7c96fba3d8 8037968: Add tests on alignment of objects copied to survivor space
fzhinkin
parents:
diff changeset
174 }