Path: blob/master/test/hotspot/jtreg/gc/epsilon/TestElasticTLAB.java
40942 views
/*1* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package gc.epsilon;2425/**26* @test TestElasticTLAB27* @key randomness28* @requires vm.gc.Epsilon & os.maxMemory > 1G29* @summary Epsilon is able to work with/without elastic TLABs30* @library /test/lib31*32* @run main/othervm -Xmx1g -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-EpsilonElasticTLAB gc.epsilon.TestElasticTLAB33* @run main/othervm -Xmx1g -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:+EpsilonElasticTLAB -XX:EpsilonTLABElasticity=1 gc.epsilon.TestElasticTLAB34* @run main/othervm -Xmx1g -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:+EpsilonElasticTLAB -XX:EpsilonTLABElasticity=1.1 gc.epsilon.TestElasticTLAB35* @run main/othervm -Xmx1g -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:+EpsilonElasticTLAB -XX:EpsilonTLABElasticity=2.0 gc.epsilon.TestElasticTLAB36* @run main/othervm -Xmx1g -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:+EpsilonElasticTLAB -XX:EpsilonTLABElasticity=42 gc.epsilon.TestElasticTLAB37* @run main/othervm -Xmx1g -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:+EpsilonElasticTLAB -XX:EpsilonTLABElasticity=100 gc.epsilon.TestElasticTLAB38*/3940import java.util.Random;41import jdk.test.lib.Utils;4243public class TestElasticTLAB {44static int COUNT = Integer.getInteger("count", 3000); // ~500 MB allocation4546static byte[][] arr;4748public static void main(String[] args) throws Exception {49Random r = Utils.getRandomInstance();5051arr = new byte[COUNT * 100][];52for (int c = 0; c < COUNT; c++) {53arr[c] = new byte[c * 100];54for (int v = 0; v < c; v++) {55arr[c][v] = (byte)(r.nextInt(255) & 0xFF);56}57}5859r = new Random(Utils.SEED);60for (int c = 0; c < COUNT; c++) {61byte[] b = arr[c];62if (b.length != (c * 100)) {63throw new IllegalStateException("Failure: length = " + b.length + ", need = " + (c*100));64}65for (int v = 0; v < c; v++) {66byte actual = b[v];67byte expected = (byte)(r.nextInt(255) & 0xFF);68if (actual != expected) {69throw new IllegalStateException("Failure: expected = " + expected + ", actual = " + actual);70}71}72}73}74}757677