1 /*
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
54 "MaxTenuringThreshold")).orElse(15L);
55
56 /**
57 * Regexp used to parse memory size params, like 2G, 34m or 15k.
58 */
59 private static final Pattern SIZE_REGEX
60 = Pattern.compile("(?<size>[0-9]+)(?<multiplier>[GMKgmk])?");
61
62 // Names of different heap spaces.
63 private static final String DEF_NEW_EDEN = "Eden Space";
64 private static final String DEF_NEW_SURVIVOR = "Survivor Space";
65 private static final String PAR_NEW_EDEN = "Par Eden Space";
66 private static final String PAR_NEW_SURVIVOR = "Par Survivor Space";
67 private static final String PS_EDEN = "PS Eden Space";
68 private static final String PS_SURVIVOR = "PS Survivor Space";
69 private static final String G1_EDEN = "G1 Eden Space";
70 private static final String G1_SURVIVOR = "G1 Survivor Space";
71 private static final String SERIAL_TENURED = "Tenured Gen";
72 private static final String CMS_TENURED = "CMS Old Gen";
73 private static final String PS_TENURED = "PS Old Gen";
74 private static final String G1_TENURED = "G1 Old Gen";
75
76 private static final long G1_HEAP_REGION_SIZE = Optional.ofNullable(
77 SurvivorAlignmentTestMain.WHITE_BOX.getUintxVMFlag(
78 "G1HeapRegionSize")).orElse(-1L);
79
80 /**
81 * Min size of free chunk in CMS generation.
82 * An object allocated in CMS generation will at least occupy this amount
83 * of bytes.
84 */
85 private static final long CMS_MIN_FREE_CHUNK_SIZE
86 = 3L * Unsafe.ADDRESS_SIZE;
87
88 private static final AlignmentHelper EDEN_SPACE_HELPER;
89 private static final AlignmentHelper SURVIVOR_SPACE_HELPER;
90 private static final AlignmentHelper TENURED_SPACE_HELPER;
91 /**
92 * Amount of memory that should be filled during a test run.
93 */
94 private final long memoryToFill;
160 case SurvivorAlignmentTestMain.DEF_NEW_SURVIVOR:
161 case SurvivorAlignmentTestMain.PAR_NEW_SURVIVOR:
162 case SurvivorAlignmentTestMain.PS_SURVIVOR:
163 Asserts.assertNull(survivorHelper,
164 "Only one bean for survivor space is expected.");
165 survivorHelper = new AlignmentHelper(
166 AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
167 AlignmentHelper.SURVIVOR_ALIGNMENT_IN_BYTES,
168 AlignmentHelper.MIN_OBJECT_SIZE, pool);
169 break;
170 case SurvivorAlignmentTestMain.G1_SURVIVOR:
171 Asserts.assertNull(survivorHelper,
172 "Only one bean for survivor space is expected.");
173 survivorHelper = new AlignmentHelper(
174 SurvivorAlignmentTestMain.G1_HEAP_REGION_SIZE,
175 AlignmentHelper.SURVIVOR_ALIGNMENT_IN_BYTES,
176 AlignmentHelper.MIN_OBJECT_SIZE, pool);
177 break;
178 case SurvivorAlignmentTestMain.SERIAL_TENURED:
179 case SurvivorAlignmentTestMain.PS_TENURED:
180 case SurvivorAlignmentTestMain.G1_TENURED:
181 Asserts.assertNull(tenuredHelper,
182 "Only one bean for tenured space is expected.");
183 tenuredHelper = new AlignmentHelper(
184 AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
185 AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
186 AlignmentHelper.MIN_OBJECT_SIZE, pool);
187 break;
188 case SurvivorAlignmentTestMain.CMS_TENURED:
189 Asserts.assertNull(tenuredHelper,
190 "Only one bean for tenured space is expected.");
191 tenuredHelper = new AlignmentHelper(
192 AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
193 AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
194 SurvivorAlignmentTestMain.CMS_MIN_FREE_CHUNK_SIZE,
195 pool);
196 break;
197 }
198 }
199 EDEN_SPACE_HELPER = Objects.requireNonNull(edenHelper,
|
1 /*
2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
54 "MaxTenuringThreshold")).orElse(15L);
55
56 /**
57 * Regexp used to parse memory size params, like 2G, 34m or 15k.
58 */
59 private static final Pattern SIZE_REGEX
60 = Pattern.compile("(?<size>[0-9]+)(?<multiplier>[GMKgmk])?");
61
62 // Names of different heap spaces.
63 private static final String DEF_NEW_EDEN = "Eden Space";
64 private static final String DEF_NEW_SURVIVOR = "Survivor Space";
65 private static final String PAR_NEW_EDEN = "Par Eden Space";
66 private static final String PAR_NEW_SURVIVOR = "Par Survivor Space";
67 private static final String PS_EDEN = "PS Eden Space";
68 private static final String PS_SURVIVOR = "PS Survivor Space";
69 private static final String G1_EDEN = "G1 Eden Space";
70 private static final String G1_SURVIVOR = "G1 Survivor Space";
71 private static final String SERIAL_TENURED = "Tenured Gen";
72 private static final String CMS_TENURED = "CMS Old Gen";
73 private static final String PS_TENURED = "PS Old Gen";
74 private static final String G1_TENURED_LEGACY = "G1 Old Gen";
75 private static final String G1_TENURED = "G1 Old Space";
76
77 private static final long G1_HEAP_REGION_SIZE = Optional.ofNullable(
78 SurvivorAlignmentTestMain.WHITE_BOX.getUintxVMFlag(
79 "G1HeapRegionSize")).orElse(-1L);
80
81 /**
82 * Min size of free chunk in CMS generation.
83 * An object allocated in CMS generation will at least occupy this amount
84 * of bytes.
85 */
86 private static final long CMS_MIN_FREE_CHUNK_SIZE
87 = 3L * Unsafe.ADDRESS_SIZE;
88
89 private static final AlignmentHelper EDEN_SPACE_HELPER;
90 private static final AlignmentHelper SURVIVOR_SPACE_HELPER;
91 private static final AlignmentHelper TENURED_SPACE_HELPER;
92 /**
93 * Amount of memory that should be filled during a test run.
94 */
95 private final long memoryToFill;
161 case SurvivorAlignmentTestMain.DEF_NEW_SURVIVOR:
162 case SurvivorAlignmentTestMain.PAR_NEW_SURVIVOR:
163 case SurvivorAlignmentTestMain.PS_SURVIVOR:
164 Asserts.assertNull(survivorHelper,
165 "Only one bean for survivor space is expected.");
166 survivorHelper = new AlignmentHelper(
167 AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
168 AlignmentHelper.SURVIVOR_ALIGNMENT_IN_BYTES,
169 AlignmentHelper.MIN_OBJECT_SIZE, pool);
170 break;
171 case SurvivorAlignmentTestMain.G1_SURVIVOR:
172 Asserts.assertNull(survivorHelper,
173 "Only one bean for survivor space is expected.");
174 survivorHelper = new AlignmentHelper(
175 SurvivorAlignmentTestMain.G1_HEAP_REGION_SIZE,
176 AlignmentHelper.SURVIVOR_ALIGNMENT_IN_BYTES,
177 AlignmentHelper.MIN_OBJECT_SIZE, pool);
178 break;
179 case SurvivorAlignmentTestMain.SERIAL_TENURED:
180 case SurvivorAlignmentTestMain.PS_TENURED:
181 case SurvivorAlignmentTestMain.G1_TENURED_LEGACY:
182 case SurvivorAlignmentTestMain.G1_TENURED:
183 Asserts.assertNull(tenuredHelper,
184 "Only one bean for tenured space is expected.");
185 tenuredHelper = new AlignmentHelper(
186 AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
187 AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
188 AlignmentHelper.MIN_OBJECT_SIZE, pool);
189 break;
190 case SurvivorAlignmentTestMain.CMS_TENURED:
191 Asserts.assertNull(tenuredHelper,
192 "Only one bean for tenured space is expected.");
193 tenuredHelper = new AlignmentHelper(
194 AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
195 AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
196 SurvivorAlignmentTestMain.CMS_MIN_FREE_CHUNK_SIZE,
197 pool);
198 break;
199 }
200 }
201 EDEN_SPACE_HELPER = Objects.requireNonNull(edenHelper,
|