author | cjplummer |
Thu, 29 Oct 2015 12:04:04 -0700 | |
changeset 33730 | 30e064828045 |
parent 32740 | 6c550479932a |
child 35167 | 45801556e636 |
permissions | -rw-r--r-- |
32587
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
1 |
/* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
4 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
8 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
13 |
* accompanied this code). |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
14 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
18 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
21 |
* questions. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
22 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
23 |
*/ |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
24 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
25 |
package gc.g1.humongousObjects; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
26 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
27 |
import jdk.test.lib.Asserts; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
28 |
import sun.hotspot.WhiteBox; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
29 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
30 |
/** |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
31 |
* @test TestHumongousThreshold |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
32 |
* @summary Checks that objects larger than half a region are allocated as humongous |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
33 |
* @requires vm.gc=="G1" | vm.gc=="null" |
33730
30e064828045
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents:
32740
diff
changeset
|
34 |
* @library /testlibrary /test/lib |
32587
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
35 |
* @modules java.management |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
36 |
* @build sun.hotspot.WhiteBox |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
37 |
* gc.g1.humongousObjects.Helpers |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
38 |
* gc.g1.humongousObjects.TestHumongousThreshold |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
39 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
40 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
41 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
42 |
* @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
43 |
* -XX:G1HeapRegionSize=1M |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
44 |
* gc.g1.humongousObjects.TestHumongousThreshold |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
45 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
46 |
* @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
47 |
* -XX:G1HeapRegionSize=2M |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
48 |
* gc.g1.humongousObjects.TestHumongousThreshold |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
49 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
50 |
* @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
51 |
* -XX:G1HeapRegionSize=4M |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
52 |
* gc.g1.humongousObjects.TestHumongousThreshold |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
53 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
54 |
* @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
55 |
* -XX:G1HeapRegionSize=8M |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
56 |
* gc.g1.humongousObjects.TestHumongousThreshold |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
57 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
58 |
* @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. |
32740 | 59 |
* -Xms128M -XX:G1HeapRegionSize=16M |
32587
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
60 |
* gc.g1.humongousObjects.TestHumongousThreshold |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
61 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
62 |
* @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. |
32740 | 63 |
* -Xms200M -XX:G1HeapRegionSize=32M |
32587
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
64 |
* gc.g1.humongousObjects.TestHumongousThreshold |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
65 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
66 |
*/ |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
67 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
68 |
public class TestHumongousThreshold { |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
69 |
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
70 |
private static final int REGION_SIZE = WHITE_BOX.g1RegionSize(); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
71 |
private static final int MAX_CONTINUOUS_SIZE_CHECK = 129; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
72 |
private static final int NON_HUMONGOUS_DIVIDER = 10; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
73 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
74 |
/** |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
75 |
* The method allocates byte[] with specified size and checks that: |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
76 |
* 1. byte[] is allocated as we specified in expectedHumongous. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
77 |
* 2. byte[] is allocated as humongous if its size is large than a half of region and non-humongous otherwise. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
78 |
* It uses WB to obtain the size of created byte[]. Only objects larger than half of region are expected |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
79 |
* to be humongous. |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
80 |
* |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
81 |
* @param arraySize size of allocation |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
82 |
* @param expectedHumongous expected humongous/non-humongous allocation |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
83 |
* @return allocated byte array |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
84 |
*/ |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
85 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
86 |
private static byte[] allocateAndCheck(int arraySize, boolean expectedHumongous) { |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
87 |
byte[] storage = new byte[arraySize]; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
88 |
long objectSize = WHITE_BOX.getObjectSize(storage); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
89 |
boolean shouldBeHumongous = objectSize > (REGION_SIZE / 2); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
90 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
91 |
Asserts.assertEquals(expectedHumongous, shouldBeHumongous, "Despite we expected this object to be " |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
92 |
+ (expectedHumongous ? "humongous" : "non-humongous") + " it appeared otherwise when we checked " |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
93 |
+ "object size - likely test bug; Allocation size = " + arraySize + "; Object size = " + objectSize |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
94 |
+ "; region size = " + REGION_SIZE); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
95 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
96 |
Asserts.assertEquals(WHITE_BOX.g1IsHumongous(storage), shouldBeHumongous, |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
97 |
"Object should be allocated as " + (shouldBeHumongous ? "humongous" |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
98 |
: "non-humongous") + " but it wasn't; Allocation size = " + arraySize + "; Object size = " |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
99 |
+ objectSize + "; region size = " + REGION_SIZE); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
100 |
return storage; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
101 |
} |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
102 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
103 |
public static void main(String[] args) { |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
104 |
int byteArrayMemoryOverhead = Helpers.detectByteArrayAllocationOverhead(); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
105 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
106 |
// Largest non-humongous byte[] |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
107 |
int maxByteArrayNonHumongousSize = (REGION_SIZE / 2) - byteArrayMemoryOverhead; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
108 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
109 |
// Increment for non-humongous testing |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
110 |
int nonHumongousStep = maxByteArrayNonHumongousSize / NON_HUMONGOUS_DIVIDER; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
111 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
112 |
// Maximum byte[] that takes one region |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
113 |
int maxByteArrayOneRegionSize = REGION_SIZE - byteArrayMemoryOverhead; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
114 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
115 |
// Sizes in regions |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
116 |
// i,e, 1.0f means one region, 1.5f means one and half region etc |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
117 |
float[] humongousFactors = {0.8f, 1.0f, 1.2f, 1.5f, 1.7f, 2.0f, 2.5f}; |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
118 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
119 |
// Some diagnostic output |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
120 |
System.out.format("%s started%n", TestHumongousThreshold.class.getName()); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
121 |
System.out.format("Actual G1 region size %d%n", REGION_SIZE); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
122 |
System.out.format("byte[] memory overhead %d%n", byteArrayMemoryOverhead); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
123 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
124 |
// Non-humongous allocations |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
125 |
System.out.format("Doing non-humongous allocations%n"); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
126 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
127 |
// Testing allocations with byte[] with length from 0 to MAX_CONTINUOUS_SIZE_CHECK |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
128 |
System.out.format("Testing allocations with byte[] with length from 0 to %d%n", MAX_CONTINUOUS_SIZE_CHECK); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
129 |
for (int i = 0; i < MAX_CONTINUOUS_SIZE_CHECK; ++i) { |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
130 |
allocateAndCheck(i, false); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
131 |
} |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
132 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
133 |
// Testing allocations with byte[] with length from 0 to nonHumongousStep * NON_HUMONGOUS_DIVIDER |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
134 |
System.out.format("Testing allocations with byte[] with length from 0 to %d with step %d%n", |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
135 |
nonHumongousStep * NON_HUMONGOUS_DIVIDER, nonHumongousStep); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
136 |
for (int i = 0; i < NON_HUMONGOUS_DIVIDER; ++i) { |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
137 |
allocateAndCheck(i * nonHumongousStep, false); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
138 |
} |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
139 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
140 |
// Testing allocations with byte[] of maximum non-humongous length |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
141 |
System.out.format("Testing allocations with byte[] of maximum non-humongous length %d%n", |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
142 |
maxByteArrayNonHumongousSize); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
143 |
allocateAndCheck(maxByteArrayNonHumongousSize, false); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
144 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
145 |
// Humongous allocations |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
146 |
System.out.format("Doing humongous allocations%n"); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
147 |
// Testing with minimum humongous object |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
148 |
System.out.format("Testing with byte[] of minimum humongous object %d%n", maxByteArrayNonHumongousSize + 1); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
149 |
allocateAndCheck(maxByteArrayNonHumongousSize + 1, true); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
150 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
151 |
// Testing allocations with byte[] with length from (maxByteArrayNonHumongousSize + 1) to |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
152 |
// (maxByteArrayNonHumongousSize + 1 + MAX_CONTINUOUS_SIZE_CHECK) |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
153 |
System.out.format("Testing allocations with byte[] with length from %d to %d%n", |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
154 |
maxByteArrayNonHumongousSize + 1, maxByteArrayNonHumongousSize + 1 + MAX_CONTINUOUS_SIZE_CHECK); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
155 |
for (int i = 0; i < MAX_CONTINUOUS_SIZE_CHECK; ++i) { |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
156 |
allocateAndCheck(maxByteArrayNonHumongousSize + 1 + i, true); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
157 |
} |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
158 |
|
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
159 |
// Checking that large (more than a half of region size) objects are humongous |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
160 |
System.out.format("Checking that large (more than a half of region size) objects are humongous%n"); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
161 |
for (float factor : humongousFactors) { |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
162 |
allocateAndCheck((int) (maxByteArrayOneRegionSize * factor), true); |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
163 |
} |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
164 |
} |
397d087f7204
8132708: Add tests for Humongous objects allocation threshold
kzhaldyb
parents:
diff
changeset
|
165 |
} |