From 3cc558d2c293d62268c3075172277479002a0574 Mon Sep 17 00:00:00 2001 From: Emanuel Peter Date: Thu, 7 Mar 2024 07:48:38 +0000 Subject: [PATCH 1/6] 8327172: C2 SuperWord: data node in loop has no input in loop: replace assert with bailout Reviewed-by: chagedorn, kvn --- .../loopopts/superword/TestNoInputInLoop.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/loopopts/superword/TestNoInputInLoop.java diff --git a/test/hotspot/jtreg/compiler/loopopts/superword/TestNoInputInLoop.java b/test/hotspot/jtreg/compiler/loopopts/superword/TestNoInputInLoop.java new file mode 100644 index 00000000000..8790e7afa0a --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/superword/TestNoInputInLoop.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.loopopts.superword; + +/* + * @test id=Vanilla + * @bug 8327172 + * @summary Test bad loop ctrl: a node is in the loop, but has no input in the loop + * @run main/othervm compiler.loopopts.superword.TestNoInputInLoop + */ + +/* + * @test id=WithFlags + * @bug 8327172 + * @summary Test bad loop ctrl: a node is in the loop, but has no input in the loop + * @run main/othervm -Xbatch -XX:PerMethodTrapLimit=0 + * compiler.loopopts.superword.TestNoInputInLoop + */ + +/* + * @test id=WithMoreFlags + * @bug 8327172 + * @summary Test bad loop ctrl: a node is in the loop, but has no input in the loop + * @run main/othervm -Xbatch -XX:PerMethodTrapLimit=0 + * -XX:CompileCommand=compileonly,compiler.loopopts.superword.TestNoInputInLoop::test* + * compiler.loopopts.superword.TestNoInputInLoop + */ + +public class TestNoInputInLoop { + static long lFld; + static float fFld; + static int iArr[] = new int[400]; + + public static void main(String[] strArr) { + for (int i = 0; i < 100; i++) { + test1(); + } + for (int i = 0; i < 1_000; i++) { + test2(0); + } + } + + // It specifically reproduced with UseAVX=2 + // 1. PhaseIdealLoop::build_loop_early + // We have a Store in a loop, with a Load after it. + // Both have ctrl as the CountedLoopNode. + // 2. split_if_with_blocks -> PhaseIdealLoop::try_move_store_before_loop + // The Store is moved out of the loop, and its ctrl updated accordingly. + // But the Load has its ctrl not updated, even though it has now no input in the loop. + // 3. SuperWord (VLoopBody::construct) + // We detect a data node in the loop that has no input in the loop. + // This is not expected. + + // OSR failure + static void test1() { + for (int i = 0; i < 200; i++) { + fFld *= iArr[0] - lFld; + iArr[1] = (int) lFld; + for (int j = 0; j < 100_000; j++) {} // empty loop, trigger OSR + } + } + + // Normal compilation + static void test2(int start) { + for (int i = start; i < 200; i++) { + fFld *= iArr[0] - lFld; + iArr[1] = (int) lFld; + } + } +} From 6d89d851ccf26ec1a778add69e4ff95e161dddec Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Thu, 7 Mar 2024 09:44:35 +0000 Subject: [PATCH 2/6] 8327501: Common ForkJoinPool prevents class unloading in some cases Reviewed-by: alanb --- .../share/classes/java/util/concurrent/ForkJoinPool.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 4cdafb0a44f..98e3cd2917b 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -1140,9 +1140,12 @@ public final ForkJoinWorkerThread newThread(ForkJoinPool pool) { boolean isCommon = (pool.workerNamePrefix == null); @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); - if (sm == null) - return new ForkJoinWorkerThread(null, pool, true, false); - else if (isCommon) + if (sm == null) { + if (isCommon) + return new ForkJoinWorkerThread.InnocuousForkJoinWorkerThread(pool); + else + return new ForkJoinWorkerThread(null, pool, true, false); + } else if (isCommon) return newCommonWithACC(pool); else return newRegularWithACC(pool); From 15bc29259f1ff62cc66d6e250276d68254e239df Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Thu, 7 Mar 2024 12:21:23 +0000 Subject: [PATCH 3/6] 8320646: RISC-V: C2 VectorCastHF2F 8320647: RISC-V: C2 VectorCastF2HF Reviewed-by: luhenry, fyang --- .../TestFloatConversionsVector.java | 6 +- .../TestFloatConversionsVectorNaN.java | 202 ++++++++++++++++++ 2 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/vectorization/TestFloatConversionsVectorNaN.java diff --git a/test/hotspot/jtreg/compiler/vectorization/TestFloatConversionsVector.java b/test/hotspot/jtreg/compiler/vectorization/TestFloatConversionsVector.java index 49035332fa4..96324c62c32 100644 --- a/test/hotspot/jtreg/compiler/vectorization/TestFloatConversionsVector.java +++ b/test/hotspot/jtreg/compiler/vectorization/TestFloatConversionsVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,9 @@ * @bug 8294588 * @summary Auto-vectorize Float.floatToFloat16, Float.float16ToFloat APIs * @requires vm.compiler2.enabled - * @requires (os.simpleArch == "x64" & (vm.cpu.features ~= ".*avx512f.*" | vm.cpu.features ~= ".*f16c.*")) | os.arch == "aarch64" + * @requires (os.simpleArch == "x64" & (vm.cpu.features ~= ".*avx512f.*" | vm.cpu.features ~= ".*f16c.*")) | + * os.arch == "aarch64" | + * (os.arch == "riscv64" & vm.cpu.features ~= ".*zvfh.*") * @library /test/lib / * @run driver compiler.vectorization.TestFloatConversionsVector */ diff --git a/test/hotspot/jtreg/compiler/vectorization/TestFloatConversionsVectorNaN.java b/test/hotspot/jtreg/compiler/vectorization/TestFloatConversionsVectorNaN.java new file mode 100644 index 00000000000..26e42b92bad --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorization/TestFloatConversionsVectorNaN.java @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8320646 + * @summary Auto-vectorize Float.floatToFloat16, Float.float16ToFloat APIs, with NaN + * @requires vm.compiler2.enabled + * @requires (os.arch == "riscv64" & vm.cpu.features ~= ".*zvfh.*") + * @library /test/lib / + * @run driver compiler.vectorization.TestFloatConversionsVectorNaN + */ + +package compiler.vectorization; + +import java.util.HexFormat; + +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; + +public class TestFloatConversionsVectorNaN { + private static final int ARRLEN = 1024; + private static final int ITERS = 11000; + private static float [] finp; + private static short [] sout; + private static short [] sinp; + private static float [] fout; + + public static void main(String args[]) { + TestFramework.runWithFlags("-XX:-TieredCompilation", + "-XX:CompileThresholdScaling=0.3"); + System.out.println("PASSED"); + } + + @Test + @IR(counts = {IRNode.VECTOR_CAST_F2HF, IRNode.VECTOR_SIZE + "min(max_float, max_short)", "> 0"}) + public void test_float_float16(short[] sout, float[] finp) { + for (int i = 0; i < finp.length; i++) { + sout[i] = Float.floatToFloat16(finp[i]); + } + } + + @Run(test = {"test_float_float16"}, mode = RunMode.STANDALONE) + public void kernel_test_float_float16() { + int errno = 0; + finp = new float[ARRLEN]; + sout = new short[ARRLEN]; + + // Setup + for (int i = 0; i < ARRLEN; i++) { + if (i%39 == 0) { + int x = 0x7f800000 + ((i/39) << 13); + x = (i%2 == 0) ? x : (x | 0x80000000); + finp[i] = Float.intBitsToFloat(x); + } else { + finp[i] = (float) i * 1.4f; + } + } + int ranges[][] = { + {128, 64}, + {256, 19}, + {384-19, 19}, + {512-19, 17}, + {640+19, 19}, + {768+19, 32}, + {896-19, 32} + }; + for (int range[] : ranges) { + int start = range[0]; + int offset = range[1]; + for (int i = start; i < start+offset; i++) { + int x = 0x7f800000 + (i << 13); + finp[i] = Float.intBitsToFloat(x); + } + } + + // Test + for (int i = 0; i < ITERS; i++) { + test_float_float16(sout, finp); + } + + // Verifying the result + for (int i = 0; i < ARRLEN; i++) { + errno += assertEquals(i, finp[i], Float.floatToFloat16(finp[i]), sout[i]); + } + + if (errno > 0) { + throw new RuntimeException("errors occur"); + } + } + + static int assertEquals(int idx, float f, short expected, short actual) { + HexFormat hf = HexFormat.of(); + String msg = "floatToFloat16 wrong result: idx: " + idx + ", \t" + f + + ",\t expected: " + hf.toHexDigits(expected) + + ",\t actual: " + hf.toHexDigits(actual); + if ((expected & 0x7c00) != 0x7c00) { + if (expected != actual) { + System.err.println(msg); + return 1; + } + } else if ((expected & 0x3ff) != 0) { + if (((actual & 0x7c00) != 0x7c00) || (actual & 0x3ff) == 0) { + System.err.println(msg); + return 1; + } + } + return 0; + } + + @Test + @IR(counts = {IRNode.VECTOR_CAST_HF2F, IRNode.VECTOR_SIZE + "min(max_float, max_short)", "> 0"}) + public void test_float16_float(float[] fout, short[] sinp) { + for (int i = 0; i < sinp.length; i++) { + fout[i] = Float.float16ToFloat(sinp[i]); + } + } + + @Run(test = {"test_float16_float"}, mode = RunMode.STANDALONE) + public void kernel_test_float16_float() { + int errno = 0; + sinp = new short[ARRLEN]; + fout = new float[ARRLEN]; + + // Setup + for (int i = 0; i < ARRLEN; i++) { + if (i%39 == 0) { + int x = 0x7c00 + i; + x = (i%2 == 0) ? x : (x | 0x8000); + sinp[i] = (short)x; + } else { + sinp[i] = (short)i; + } + } + + int ranges[][] = { + {128, 64}, + {256, 19}, + {384-19, 19}, + {512-19, 17}, + {640+19, 19}, + {768+19, 32}, + {896-19, 32} + }; + for (int range[] : ranges) { + int start = range[0]; + int offset = range[1]; + for (int i = start; i < start+offset; i++) { + int x = 0x7c00 + i; + x = (i%2 == 0) ? x : (x | 0x8000); + sinp[i] = (short)x; + } + } + + // Test + for (int i = 0; i < ITERS; i++) { + test_float16_float(fout, sinp); + } + + // Verifying the result + for (int i = 0; i < ARRLEN; i++) { + errno += assertEquals(i, sinp[i], Float.float16ToFloat(sinp[i]), fout[i]); + } + + if (errno > 0) { + throw new RuntimeException("errors occur"); + } + } + + static int assertEquals(int idx, short s, float expected, float actual) { + String msg = "float16ToFloat wrong result: idx: " + idx + ", \t" + s + + ",\t expected: " + expected + ",\t" + Integer.toHexString(Float.floatToIntBits(expected)) + + ",\t actual: " + actual + ",\t" + Integer.toHexString(Float.floatToIntBits(actual)); + if (!Float.isNaN(expected) || !Float.isNaN(actual)) { + if (expected != actual) { + System.err.println(msg); + return 1; + } + } + return 0; + } +} From d59d6cebae4edb24671ecd9ca338ab89bc1dfccb Mon Sep 17 00:00:00 2001 From: Evgeny Nikitin Date: Thu, 7 Mar 2024 17:12:06 +0000 Subject: [PATCH 4/6] 8327390: JitTester: Implement temporary folder functionality Reviewed-by: gli, lmesnik --- .../jtreg/testlibrary/jittester/Makefile | 3 +- .../test/lib/jittester/JavaCodeGenerator.java | 6 +- .../src/jdk/test/lib/jittester/TempDir.java | 62 +++++++++++++++++++ .../test/lib/jittester/TestsGenerator.java | 14 ++--- 4 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TempDir.java diff --git a/test/hotspot/jtreg/testlibrary/jittester/Makefile b/test/hotspot/jtreg/testlibrary/jittester/Makefile index 32548e6cdba..16cb921304d 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/Makefile +++ b/test/hotspot/jtreg/testlibrary/jittester/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -80,6 +80,7 @@ TESTLIBRARY_SRC_FILES = $(TESTLIBRARY_SRC_DIR)/Asserts.java \ $(TESTLIBRARY_SRC_DIR)/process/OutputBuffer.java \ $(TESTLIBRARY_SRC_DIR)/process/ProcessTools.java \ $(TESTLIBRARY_SRC_DIR)/process/StreamPumper.java \ + $(TESTLIBRARY_SRC_DIR)/util/FileUtils.java \ $(TESTLIBRARY_SRC_DIR)/util/Pair.java .PHONY: cleantmp diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java index 02fb37d8072..7ca940fe531 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,13 +64,13 @@ private void generateSources(IRNode mainClass, IRNode privateClasses) { } private void compileJavaFile(String mainClassName) { - String classPath = tmpDir.toString(); + String classPath = tmpDir.path.toString(); ProcessBuilder pb = new ProcessBuilder(JAVAC, "-d", classPath, "-cp", classPath, generatorDir.resolve(mainClassName + ".java").toString()); try { - int r = runProcess(pb, tmpDir.resolve(mainClassName + ".javac").toString()); + int r = runProcess(pb, tmpDir.path.resolve(mainClassName + ".javac").toString()); if (r != 0) { throw new Error("Can't compile sources, exit code = " + r); } diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TempDir.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TempDir.java new file mode 100644 index 00000000000..b166315a332 --- /dev/null +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TempDir.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.jittester; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import jdk.test.lib.util.FileUtils; + +/** + * A temporary directory wrapper. + * Makes sure that the directory gets deleted after usage. + */ +public class TempDir { + public final Path path; + + /** + * Creates a temporary directory with a given suffix. + * The directory is deep deleted on VM shutdown using a ShutdownHook. + */ + public TempDir(String suffix) { + try { + path = Files.createTempDirectory(suffix).toAbsolutePath(); + Runtime.getRuntime().addShutdownHook(new Thread(this::delete)); + } catch (IOException e) { + throw new Error("Can't create a tmp dir for " + suffix, e); + } + + System.out.println("DBG: Temp folder created: '" + path + "'"); + } + + private void delete() { + try { + FileUtils.deleteFileTreeWithRetry(path); + System.out.println("DBG: Temp folder deleted: '" + path + "'"); + } catch (IOException exc) { + throw new Error("Could not deep delete '" + path + "'", exc); + } + } +} diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java index d8559398481..5d8ac107d6a 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public abstract class TestsGenerator implements BiConsumer { protected static final String JAVAC = Paths.get(JAVA_BIN, "javac").toString(); protected static final String JAVA = Paths.get(JAVA_BIN, "java").toString(); protected final Path generatorDir; - protected final Path tmpDir; + protected final TempDir tmpDir; protected final Function preRunActions; protected final String jtDriverOptions; private static final String DISABLE_WARNINGS = "-XX:-PrintWarnings"; @@ -54,17 +54,13 @@ protected TestsGenerator(String suffix) { protected TestsGenerator(String suffix, Function preRunActions, String jtDriverOptions) { generatorDir = getRoot().resolve(suffix).toAbsolutePath(); - try { - tmpDir = Files.createTempDirectory(suffix).toAbsolutePath(); - } catch (IOException e) { - throw new Error("Can't get a tmp dir for " + suffix, e); - } + tmpDir = new TempDir(suffix); this.preRunActions = preRunActions; this.jtDriverOptions = jtDriverOptions; } protected void generateGoldenOut(String mainClassName) { - String classPath = tmpDir.toString() + File.pathSeparator + String classPath = tmpDir.path.toString() + File.pathSeparator + generatorDir.toString(); ProcessBuilder pb = new ProcessBuilder(JAVA, "-Xint", DISABLE_WARNINGS, "-Xverify", "-cp", classPath, mainClassName); @@ -97,7 +93,7 @@ protected static int runProcess(ProcessBuilder pb, String name) protected void compilePrinter() { Path root = getRoot(); ProcessBuilder pbPrinter = new ProcessBuilder(JAVAC, - "-d", tmpDir.toString(), + "-d", tmpDir.path.toString(), root.resolve("jdk") .resolve("test") .resolve("lib") From 65e98788a71bc1037a96e8b2292c41e1b082e186 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Thu, 7 Mar 2024 20:09:13 +0000 Subject: [PATCH 5/6] 8326611: Clean up vmTestbase/nsk/stress/stack tests Reviewed-by: coleenp, mseledtsov --- test/hotspot/jtreg/TEST.groups | 3 +- .../stack/Stack001.java} | 30 +-- .../stack/Stack002.java} | 38 ++-- .../stack/Stack003.java} | 37 ++-- .../stack/Stack004.java} | 43 ++--- .../stack/Stack005.java} | 40 ++-- .../stack/Stack006.java} | 42 ++--- .../stack/Stack007.java} | 42 ++--- .../stack/Stack008.java} | 47 ++--- .../stack/Stack009.java} | 41 ++--- .../stack/Stack010.java} | 73 +++----- .../stack/Stack011.java} | 66 +++---- .../stack/Stack012.java} | 68 +++---- .../stack/Stack013.java} | 70 +++---- .../stack/Stack014.java} | 70 +++---- .../stack/Stack015.java} | 81 ++++----- .../stack/Stack016.java} | 88 ++------- .../stack/Stack017.java} | 93 +++------- .../stack/Stack018.java} | 86 +++------ .../stack/Stack019.java} | 58 ++---- .../hotspot/jtreg/vmTestbase/nsk/share/README | 2 +- .../vmTestbase/nsk/share/Terminator.java | 172 ------------------ 22 files changed, 362 insertions(+), 928 deletions(-) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack001.java => runtime/stack/Stack001.java} (79%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack002.java => runtime/stack/Stack002.java} (80%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack003.java => runtime/stack/Stack003.java} (75%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack004.java => runtime/stack/Stack004.java} (73%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack005.java => runtime/stack/Stack005.java} (74%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack006.java => runtime/stack/Stack006.java} (74%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack007.java => runtime/stack/Stack007.java} (74%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack008.java => runtime/stack/Stack008.java} (80%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack009.java => runtime/stack/Stack009.java} (70%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack010.java => runtime/stack/Stack010.java} (67%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack011.java => runtime/stack/Stack011.java} (70%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack012.java => runtime/stack/Stack012.java} (70%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack013.java => runtime/stack/Stack013.java} (70%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack014.java => runtime/stack/Stack014.java} (71%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack015.java => runtime/stack/Stack015.java} (70%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack016.java => runtime/stack/Stack016.java} (67%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack017.java => runtime/stack/Stack017.java} (61%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack018.java => runtime/stack/Stack018.java} (73%) rename test/hotspot/jtreg/{vmTestbase/nsk/stress/stack/stack019.java => runtime/stack/Stack019.java} (65%) delete mode 100644 test/hotspot/jtreg/vmTestbase/nsk/share/Terminator.java diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index 22ce64b9801..0456b3ec69a 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -415,7 +415,8 @@ tier1_runtime = \ -runtime/Unsafe/RangeCheck.java \ sanity/ \ -:tier1_runtime_appcds_exclude \ - -runtime/signal + -runtime/signal \ + -runtime/stack hotspot_cds = \ runtime/cds/ \ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack001.java b/test/hotspot/jtreg/runtime/stack/Stack001.java similarity index 79% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack001.java rename to test/hotspot/jtreg/runtime/stack/Stack001.java index 3ded4d236a3..b344e177499 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack001.java +++ b/test/hotspot/jtreg/runtime/stack/Stack001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,25 +52,14 @@ * 4302288 the second stack overflow causes Classic VM to exit on win32 * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack001 + * @run main/othervm/timeout=900 Stack001 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack001 { +public class Stack001 { public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - stack001 test = new stack001(); + Stack001 test = new Stack001(); test.recurse(0); - out.println("Maximal depth: " + test.maxdepth); - return 0; + System.out.println("Maximal depth: " + test.maxdepth); } private int maxdepth; @@ -79,13 +68,10 @@ private void recurse(int depth) { maxdepth = depth; try { recurse(depth + 1); - } catch (Error error) { - if (!(error instanceof StackOverflowError) && - !(error instanceof OutOfMemoryError)) - throw error; - - if (maxdepth == depth) + } catch (StackOverflowError | OutOfMemoryError e) { + if (maxdepth == depth) { recurse(depth + 1); + } } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack002.java b/test/hotspot/jtreg/runtime/stack/Stack002.java similarity index 80% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack002.java rename to test/hotspot/jtreg/runtime/stack/Stack002.java index 3844c88a322..320e74512fa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack002.java +++ b/test/hotspot/jtreg/runtime/stack/Stack002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,24 +53,14 @@ * 4302288 the second stack overflow causes Classic VM to exit on win32 * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack002 + * @run main/othervm/timeout=900 Stack002 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack002 { +public class Stack002 { static final long timeout = 10000; // 10 seconds public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - Tester tester = new Tester(out); + Tester tester = new Tester(); Timer timer = new Timer(tester); timer.start(); tester.start(); @@ -78,21 +68,18 @@ public static int run(String args[], PrintStream out) { try { timer.join(); } catch (InterruptedException e) { - e.printStackTrace(out); - return 2; + e.printStackTrace(); + throw new RuntimeException(e); } } - out.println("Maximal depth: " + tester.maxdepth); - return 0; + System.out.println("Maximal depth: " + tester.maxdepth); } private static class Tester extends Thread { int maxdepth; - PrintStream out; public volatile boolean stop; - public Tester(PrintStream out) { - this.out = out; + public Tester() { maxdepth = 0; stop = false; } @@ -108,10 +95,7 @@ void recurse(int depth) { return; } recurse(depth + 1); - } catch (Error error) { - if (!(error instanceof StackOverflowError) && - !(error instanceof OutOfMemoryError)) - throw error; + } catch (StackOverflowError | OutOfMemoryError e) { recurse(depth + 1); } } @@ -129,9 +113,9 @@ public void run() { started = System.currentTimeMillis(); while (System.currentTimeMillis() - started < timeout) { try { - this.sleep(1000); + Thread.sleep(1000); } catch (InterruptedException e) { - e.printStackTrace(tester.out); + e.printStackTrace(); return; }; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack003.java b/test/hotspot/jtreg/runtime/stack/Stack003.java similarity index 75% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack003.java rename to test/hotspot/jtreg/runtime/stack/Stack003.java index f8a122c2b67..260344456c9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack003.java +++ b/test/hotspot/jtreg/runtime/stack/Stack003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,48 +47,37 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack003 + * @run main/othervm/timeout=900 Stack003 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack003 { +public class Stack003 { final static int ITERATIONS = 100; final static int INCREMENT = 100; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - public static int run(String args[], PrintStream out) { int depth; - for (depth = 1; ; depth += INCREMENT) + for (depth = 1; ; depth += INCREMENT) { try { recurse(depth); - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { break; } - out.println("Max. depth: " + depth); - for (int i = 0; i < ITERATIONS; i++) + } + System.out.println("Max. depth: " + depth); + for (int i = 0; i < ITERATIONS; i++) { try { recurse(2 * depth); - out.println("?"); - } catch (StackOverflowError soe) { + System.out.println("?"); + } catch (StackOverflowError | OutOfMemoryError err) { // OK. - } catch (OutOfMemoryError oome) { - // Also OK. } - return 0; + } } static void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack004.java b/test/hotspot/jtreg/runtime/stack/Stack004.java similarity index 73% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack004.java rename to test/hotspot/jtreg/runtime/stack/Stack004.java index b7bff2aedb5..fb9b594421b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack004.java +++ b/test/hotspot/jtreg/runtime/stack/Stack004.java @@ -47,51 +47,38 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack004 + * @run main/othervm/timeout=900 Stack004 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack004 { +public class Stack004 { public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); + Stack004 test = new Stack004(); + test.doRun(); } - public static int run(String args[], PrintStream out) { - stack004 test = new stack004(); - int exitCode = test.doRun(args, out); - return exitCode; - } - - public int doRun(String args[], PrintStream out) { + public void doRun() { int depth; - for (depth = 100; ; depth += 100) + for (depth = 100; ; depth += 100) { try { recurse(depth); - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { break; } - out.println("Max. depth: " + depth); - for (int i = 0; i < 100; i++) + } + System.out.println("Max. depth: " + depth); + for (int i = 0; i < 100; i++) { try { recurse(2 * depth); - out.println("?"); - } catch (StackOverflowError soe) { + System.out.println("?"); + } catch (StackOverflowError | OutOfMemoryError err) { // OK. - } catch (OutOfMemoryError oome) { - // Also OK. } - return 0; + } } final static void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack005.java b/test/hotspot/jtreg/runtime/stack/Stack005.java similarity index 74% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack005.java rename to test/hotspot/jtreg/runtime/stack/Stack005.java index a5bd10595fc..35963e03bc8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack005.java +++ b/test/hotspot/jtreg/runtime/stack/Stack005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,46 +47,34 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack005 + * @run main/othervm/timeout=900 Stack005 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack005 { +public class Stack005 { public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - stack005 test = new stack005(); + Stack005 test = new Stack005(); int depth; - for (depth = 100; ; depth += 100) + for (depth = 100; ; depth += 100) { try { test.recurse(depth); - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError soe) { break; } - out.println("Max. depth: " + depth); - for (int i = 0; i < 100; i++) + } + System.out.println("Max. depth: " + depth); + for (int i = 0; i < 100; i++) { try { test.recurse(2 * depth); - out.println("?"); - } catch (StackOverflowError soe) { + System.out.println("?"); + } catch (StackOverflowError | OutOfMemoryError err) { // OK. - } catch (OutOfMemoryError oome) { - // Also OK. } - return 0; + } } final void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack006.java b/test/hotspot/jtreg/runtime/stack/Stack006.java similarity index 74% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack006.java rename to test/hotspot/jtreg/runtime/stack/Stack006.java index 2b8754dd2ae..313fdd02c6a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack006.java +++ b/test/hotspot/jtreg/runtime/stack/Stack006.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,50 +47,38 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack006 + * @run main/othervm/timeout=900 Stack006 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack006 implements stack006i { +public class Stack006 implements Stack006i { public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - stack006i test = new stack006(); + Stack006i test = new Stack006(); int depth; - for (depth = 100; ; depth += 100) + for (depth = 100; ; depth += 100) { try { test.recurse(depth); - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { break; } - out.println("Max. depth: " + depth); - for (int i = 0; i < 100; i++) + } + System.out.println("Max. depth: " + depth); + for (int i = 0; i < 100; i++) { try { test.recurse(2 * depth); - out.println("?"); - } catch (StackOverflowError soe) { + System.out.println("?"); + } catch (StackOverflowError | OutOfMemoryError err) { // OK. - } catch (OutOfMemoryError oome) { - // Also OK. } - return 0; + } } public void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } -interface stack006i { +interface Stack006i { void recurse(int depth); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack007.java b/test/hotspot/jtreg/runtime/stack/Stack007.java similarity index 74% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack007.java rename to test/hotspot/jtreg/runtime/stack/Stack007.java index 1a9b7f0d392..d8849dd847c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack007.java +++ b/test/hotspot/jtreg/runtime/stack/Stack007.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,53 +46,41 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack007 + * @run main/othervm/timeout=900 Stack007 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack007 implements stack007i { +public class Stack007 implements Stack007i { final static int ITERATIONS = 1000; final static int INCREMENT = 100; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - stack007i test = new stack007(); + Stack007i test = new Stack007(); int depth; - for (depth = 100; ; depth += INCREMENT) + for (depth = 100; ; depth += INCREMENT) { try { test.recurse(depth); - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { break; } - out.println("Max. depth: " + depth); - for (int i = 0; i < ITERATIONS; i++) + } + System.out.println("Max. depth: " + depth); + for (int i = 0; i < ITERATIONS; i++) { try { test.recurse(10 * depth); - out.println("?"); - } catch (StackOverflowError soe) { + System.out.println("?"); + } catch (StackOverflowError | OutOfMemoryError err) { // OK. - } catch (OutOfMemoryError oome) { - // Also OK. } - return 0; + } } public synchronized void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } -interface stack007i { +interface Stack007i { void recurse(int depth); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack008.java b/test/hotspot/jtreg/runtime/stack/Stack008.java similarity index 80% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack008.java rename to test/hotspot/jtreg/runtime/stack/Stack008.java index a90f237aa76..e1776a0bcb7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack008.java +++ b/test/hotspot/jtreg/runtime/stack/Stack008.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,28 +48,19 @@ * Making it bigger could cause timeouts on other platform. * * @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096) - * @run main/othervm/timeout=900 -Xss200K nsk.stress.stack.stack008 + * @run main/othervm/timeout=900 -Xss200K Stack008 */ -package nsk.stress.stack; - - -import java.io.PrintStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -public class stack008 { +public class Stack008 { public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { int depth; // // Measure maximal recursion depth until stack overflow: // - for (depth = 100; ; depth += 100) + for (depth = 100; ; depth += 100) { try { invokeRecurse(depth); } catch (Throwable exception) { @@ -77,30 +68,27 @@ public static int run(String args[], PrintStream out) { if ((target instanceof StackOverflowError) || (target instanceof OutOfMemoryError)) break; // OK. - target.printStackTrace(out); - if (target instanceof ThreadDeath) - throw (ThreadDeath) target; - return 2; + target.printStackTrace(); + throw new RuntimeException(exception); } - out.println("Max. depth: " + depth); + } + System.out.println("Max. depth: " + depth); // // Provoke stack overflow multiple times: // - for (int i = 0; i < 100; i++) + for (int i = 0; i < 100; i++) { try { invokeRecurse(2 * depth); -// out.println("?"); +// System.out.println("?"); } catch (Throwable exception) { Throwable target = getTargetException(exception); if ((target instanceof StackOverflowError) || (target instanceof OutOfMemoryError)) continue; // OK. - target.printStackTrace(out); - if (target instanceof ThreadDeath) - throw (ThreadDeath) target; - return 2; + target.printStackTrace(); + throw new RuntimeException(exception); } - return 0; + } } private static Throwable getTargetException(Throwable exception) { @@ -118,7 +106,7 @@ private static Throwable getTargetException(Throwable exception) { } static Method method = null; - static stack008 instance = null; + static Stack008 instance = null; static Object params[] = null; private static void invokeRecurse(int depth) throws Exception { @@ -126,8 +114,8 @@ private static void invokeRecurse(int depth) throws Exception { // // Optimization trick: allocate once, use everywhere. // - instance = new stack008(); - method = stack008.class.getMethod("recurse"); + instance = new Stack008(); + method = Stack008.class.getMethod("recurse"); params = new Object[]{}; } // @@ -140,10 +128,11 @@ private static void invokeRecurse(int depth) throws Exception { int depth = 0; public void recurse() throws Exception { - if (depth > 0) + if (depth > 0) { // // Self-invoke via reflection: // invokeRecurse(depth - 1); + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack009.java b/test/hotspot/jtreg/runtime/stack/Stack009.java similarity index 70% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack009.java rename to test/hotspot/jtreg/runtime/stack/Stack009.java index b8f52d0a3f2..f2cbb51b304 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack009.java +++ b/test/hotspot/jtreg/runtime/stack/Stack009.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,49 +47,32 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack009 + * @run main/othervm/timeout=900 Stack009 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack009 { +public class Stack009 { public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - for (int depth = 100; ; depth += 100) + for (int depth = 100; ; depth += 100) { try { recurse(depth); - } catch (Error error1) { - if (!(error1 instanceof StackOverflowError) && - !(error1 instanceof OutOfMemoryError)) - throw error1; + } catch (StackOverflowError | OutOfMemoryError error1) { - out.println("Max. depth: " + depth); + System.out.println("Max. depth: " + depth); try { recurse(10 * depth); - out.println("?"); - } catch (Error error2) { - if (!(error2 instanceof StackOverflowError) && - !(error2 instanceof OutOfMemoryError)) - throw error2; - - // Stack overflow is OK here. + System.out.println("?"); + } catch (StackOverflowError | OutOfMemoryError error2) { + // ignore } - break; } - return 0; + } } static void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack010.java b/test/hotspot/jtreg/runtime/stack/Stack010.java similarity index 67% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack010.java rename to test/hotspot/jtreg/runtime/stack/Stack010.java index 6c4c159b58f..142c7ab6cb2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack010.java +++ b/test/hotspot/jtreg/runtime/stack/Stack010.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,99 +47,82 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack010 + * @run main/othervm/timeout=900 Stack010 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack010 extends Thread { - final static int THREADS = 10; - final static int CYCLES = 10; +public class Stack010 extends Thread { + final static int THREADS = 1; + final static int CYCLES = 1; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { // // Measure maximal recursion depth until stack overflow: // int maxDepth = 0; - for (int depth = 10; ; depth += 10) + for (int depth = 10; ; depth += 10) { try { recurse(depth); maxDepth = depth; - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { break; } - out.println("Max. depth: " + maxDepth); + } + System.out.println("Max. depth: " + maxDepth); // // Execute multiple threads repeatedly provoking stack overflows: // - stack010 threads[] = new stack010[THREADS]; + Stack010 threads[] = new Stack010[THREADS]; for (int i = 0; i < threads.length; i++) { - threads[i] = new stack010(); - threads[i].depthToTry = 10 * maxDepth; + threads[i] = new Stack010(); + threads[i].depthToTry = 100 * maxDepth; threads[i].start(); } - for (int i = 0; i < threads.length; i++) - if (threads[i].isAlive()) + for (int i = 0; i < threads.length; i++) { + if (threads[i].isAlive()) { try { threads[i].join(); } catch (InterruptedException exception) { - exception.printStackTrace(out); - return 2; + throw new RuntimeException(exception); } - + } + } // // Check if unexpected exceptions were not thrown: // - int exitCode = 0; - for (int i = 0; i < threads.length; i++) + for (int i = 0; i < threads.length; i++) { if (threads[i].thrown != null) { - threads[i].thrown.printStackTrace(out); - exitCode = 2; + threads[i].thrown.printStackTrace(); + throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown); } - - if (exitCode != 0) - out.println("# TEST FAILED"); - return exitCode; + } } int depthToTry = 0; Throwable thrown = null; public void run() { - for (int i = 0; i < CYCLES; i++) + for (int i = 0; i < CYCLES; i++) { try { + System.out.println("depth = " +depthToTry); recurse(depthToTry); throw new Exception( "TEST_RFE: no stack overflow thrown" + ", need to try deeper recursion?"); - } catch (StackOverflowError soe) { - // It's OK: stack overflow was expected. - } catch (OutOfMemoryError oome) { - // Also OK: out of memory may indacate stack overflow. - + } catch (StackOverflowError | OutOfMemoryError err) { + // It's OK } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) - throw (ThreadDeath) throwable; // It isn't OK! thrown = throwable; break; } + } } static void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack011.java b/test/hotspot/jtreg/runtime/stack/Stack011.java similarity index 70% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack011.java rename to test/hotspot/jtreg/runtime/stack/Stack011.java index 81e26f575d7..423e009c912 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack011.java +++ b/test/hotspot/jtreg/runtime/stack/Stack011.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,99 +47,81 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack011 + * @run main/othervm/timeout=900 Stack011 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack011 extends Thread { +public class Stack011 extends Thread { final static int THREADS = 10; final static int CYCLES = 10; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { // // Measure maximal recursion depth until stack overflow: // int maxDepth = 0; - for (int depth = 10; ; depth += 10) + for (int depth = 10; ; depth += 10) { try { recurse(depth); maxDepth = depth; - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError soe) { break; } - out.println("Max. depth: " + maxDepth); + } + System.out.println("Max. depth: " + maxDepth); // // Execute multiple threads repeatedly provoking stack overflows: // - stack011 threads[] = new stack011[THREADS]; + Stack011 threads[] = new Stack011[THREADS]; for (int i = 0; i < threads.length; i++) { - threads[i] = new stack011(); + threads[i] = new Stack011(); threads[i].depthToTry = 10 * maxDepth; threads[i].start(); } - for (int i = 0; i < threads.length; i++) - if (threads[i].isAlive()) + for (int i = 0; i < threads.length; i++) { + if (threads[i].isAlive()) { try { threads[i].join(); } catch (InterruptedException exception) { - exception.printStackTrace(out); - return 2; + throw new RuntimeException(exception); } - + } + } // // Check if unexpected exceptions were not thrown: // - int exitCode = 0; - for (int i = 0; i < threads.length; i++) + for (int i = 0; i < threads.length; i++) { if (threads[i].thrown != null) { - threads[i].thrown.printStackTrace(out); - exitCode = 2; + threads[i].thrown.printStackTrace(); + throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown); } - - if (exitCode != 0) - out.println("# TEST FAILED"); - return exitCode; + } } int depthToTry = 0; Throwable thrown = null; public void run() { - for (int i = 0; i < CYCLES; i++) + for (int i = 0; i < CYCLES; i++) { try { recurse(depthToTry); throw new Exception( "TEST_RFE: no stack overflow thrown" + ", need to try deeper recursion?"); - } catch (StackOverflowError error) { - // It's OK: stack overflow was expected. - } catch (OutOfMemoryError oome) { - // Also OK: recursion may result in memory lack. - + } catch (StackOverflowError | OutOfMemoryError err) { + // It's OK } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) - throw (ThreadDeath) throwable; // It isn't OK! thrown = throwable; break; } + } } final static void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack012.java b/test/hotspot/jtreg/runtime/stack/Stack012.java similarity index 70% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack012.java rename to test/hotspot/jtreg/runtime/stack/Stack012.java index 6dc33a83cc8..1edbe215043 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack012.java +++ b/test/hotspot/jtreg/runtime/stack/Stack012.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,100 +48,82 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack012 + * @run main/othervm/timeout=900 Stack012 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack012 extends Thread { +public class Stack012 extends Thread { final static int THREADS = 10; final static int CYCLES = 10; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - stack012 test = new stack012(); + Stack012 test = new Stack012(); // // Measure maximal recursion depth until stack overflow: // int maxDepth = 0; - for (int depth = 10; ; depth += 10) + for (int depth = 10; ; depth += 10) { try { test.recurse(depth); maxDepth = depth; - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { break; } - out.println("Max. depth: " + maxDepth); + } + System.out.println("Max. depth: " + maxDepth); // // Execute multiple threads repeatedly provoking stack overflows: // - stack012 threads[] = new stack012[THREADS]; + Stack012 threads[] = new Stack012[THREADS]; for (int i = 0; i < threads.length; i++) { - threads[i] = new stack012(); + threads[i] = new Stack012(); threads[i].depthToTry = 10 * maxDepth; threads[i].start(); } - for (int i = 0; i < threads.length; i++) - if (threads[i].isAlive()) + for (int i = 0; i < threads.length; i++) { + if (threads[i].isAlive()) { try { threads[i].join(); } catch (InterruptedException exception) { - exception.printStackTrace(out); - return 2; + throw new RuntimeException(exception); } - + } + } // // Check if unexpected exceptions were not thrown: // - int exitCode = 0; - for (int i = 0; i < threads.length; i++) + for (int i = 0; i < threads.length; i++) { if (threads[i].thrown != null) { - threads[i].thrown.printStackTrace(out); - exitCode = 2; + threads[i].thrown.printStackTrace(); + throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown); } - - if (exitCode != 0) - out.println("# TEST FAILED"); - return exitCode; + } } int depthToTry = 0; Throwable thrown = null; public void run() { - for (int i = 0; i < CYCLES; i++) + for (int i = 0; i < CYCLES; i++) { try { this.recurse(depthToTry); throw new Exception( "TEST_RFE: no stack overflow thrown" + ", need to try deeper recursion?"); - } catch (StackOverflowError error) { - // It's OK: stack overflow was expected. - } catch (OutOfMemoryError oome) { - // Also OK: invocation may result in out of memory. - + } catch (StackOverflowError | OutOfMemoryError err) { + // It's OK } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) - throw (ThreadDeath) throwable; // It isn't OK! thrown = throwable; break; } + } } final void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack013.java b/test/hotspot/jtreg/runtime/stack/Stack013.java similarity index 70% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack013.java rename to test/hotspot/jtreg/runtime/stack/Stack013.java index 94a3ef622ef..6c17b780d0e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack013.java +++ b/test/hotspot/jtreg/runtime/stack/Stack013.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,81 +47,67 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack013 + * @run main/othervm/timeout=900 Stack013 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack013 extends stack013i { +public class Stack013 extends Stack013i { final static int THREADS = 10; final static int CYCLES = 10; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - stack013i test = new stack013(); + Stack013i test = new Stack013(); // // Measure maximal recursion depth until stack overflow: // int maxDepth = 0; - for (int depth = 10; ; depth += 10) + for (int depth = 10; ; depth += 10) { try { test.recurse(depth); maxDepth = depth; - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { break; } - out.println("Max. depth: " + maxDepth); + } + System.out.println("Max. depth: " + maxDepth); // // Execute multiple threads repeatedly provoking stack overflows: // - stack013i threads[] = new stack013i[THREADS]; + Stack013i threads[] = new Stack013i[THREADS]; for (int i = 0; i < threads.length; i++) { - threads[i] = new stack013(); + threads[i] = new Stack013(); threads[i].depthToTry = 10 * maxDepth; threads[i].cycles = CYCLES; threads[i].start(); } - for (int i = 0; i < threads.length; i++) - if (threads[i].isAlive()) + for (int i = 0; i < threads.length; i++) { + if (threads[i].isAlive()) { try { threads[i].join(); } catch (InterruptedException exception) { - exception.printStackTrace(out); - return 2; + throw new RuntimeException(exception); } - + } + } // // Check if unexpected exceptions were thrown: // - int exitCode = 0; - for (int i = 0; i < threads.length; i++) + for (int i = 0; i < threads.length; i++) { if (threads[i].thrown != null) { - threads[i].thrown.printStackTrace(out); - exitCode = 2; + threads[i].thrown.printStackTrace(); + throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown); } - - if (exitCode != 0) - out.println("# TEST FAILED"); - return exitCode; + } } void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } -abstract class stack013i extends Thread { +abstract class Stack013i extends Thread { // // Pure virtual method: // @@ -135,24 +121,20 @@ public void run() { // // Provoke multiple stack overflows: // - for (int i = 0; i < cycles; i++) + for (int i = 0; i < cycles; i++) { try { recurse(depthToTry); throw new Exception( "TEST_RFE: no stack overflow thrown" + ", need to try deeper recursion?"); - } catch (StackOverflowError error) { - // It's OK: stack overflow was expected. - } catch (OutOfMemoryError oome) { - // Also OK: out of memory is eligible here. - + } catch (StackOverflowError | OutOfMemoryError err) { + // It's OK } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) - throw (ThreadDeath) throwable; // It isn't OK! thrown = throwable; break; } + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack014.java b/test/hotspot/jtreg/runtime/stack/Stack014.java similarity index 71% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack014.java rename to test/hotspot/jtreg/runtime/stack/Stack014.java index 2f7f79331e2..972f386c1f1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack014.java +++ b/test/hotspot/jtreg/runtime/stack/Stack014.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,81 +50,67 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack014 + * @run main/othervm/timeout=900 Stack014 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack014 extends stack014i { +public class Stack014 extends Stack014i { final static int THREADS = 10; final static int CYCLES = 10; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - stack014i test = new stack014(); + Stack014i test = new Stack014(); // // Measure maximal recursion depth until stack overflow: // int maxDepth = 0; - for (int depth = 10; ; depth += 10) + for (int depth = 10; ; depth += 10) { try { test.recurse(depth); maxDepth = depth; - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { break; } - out.println("Max. depth: " + maxDepth); + } + System.out.println("Max. depth: " + maxDepth); // // Execute multiple threads repeatedly provoking stack overflows: // - stack014i threads[] = new stack014i[THREADS]; + Stack014i threads[] = new Stack014i[THREADS]; for (int i = 0; i < threads.length; i++) { - threads[i] = new stack014(); + threads[i] = new Stack014(); threads[i].depthToTry = 10 * maxDepth; threads[i].cycles = CYCLES; threads[i].start(); } - for (int i = 0; i < threads.length; i++) - if (threads[i].isAlive()) + for (int i = 0; i < threads.length; i++) { + if (threads[i].isAlive()) { try { threads[i].join(); } catch (InterruptedException exception) { - exception.printStackTrace(out); - return 2; + throw new RuntimeException(exception); } - + } + } // // Check if unexpected exceptions were thrown: // - int exitCode = 0; - for (int i = 0; i < threads.length; i++) + for (int i = 0; i < threads.length; i++) { if (threads[i].thrown != null) { - threads[i].thrown.printStackTrace(out); - exitCode = 2; + threads[i].thrown.printStackTrace(); + throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown); } - - if (exitCode != 0) - out.println("# TEST FAILED"); - return exitCode; + } } synchronized void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } } -abstract class stack014i extends Thread { +abstract class Stack014i extends Thread { // // Pure virtual method: // @@ -138,24 +124,20 @@ public void run() { // // Provoke multiple stack overflows: // - for (int i = 0; i < cycles; i++) + for (int i = 0; i < cycles; i++) { try { recurse(depthToTry); throw new Exception( "TEST_RFE: no stack overflow thrown" + ", need to try deeper recursion?"); - } catch (StackOverflowError error) { - // It's OK: stack overflow was expected. - } catch (OutOfMemoryError oome) { - // Also OK: if there is no memory for stack expansion. - + } catch (StackOverflowError | OutOfMemoryError err) { + // It's OK } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) - throw (ThreadDeath) throwable; // It isn't OK! thrown = throwable; break; } + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack015.java b/test/hotspot/jtreg/runtime/stack/Stack015.java similarity index 70% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack015.java rename to test/hotspot/jtreg/runtime/stack/Stack015.java index 0a2d108af9d..3bceca2119b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack015.java +++ b/test/hotspot/jtreg/runtime/stack/Stack015.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,88 +48,74 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires vm.opt.DeoptimizeALot != true - * @run main/othervm/timeout=900 nsk.stress.stack.stack015 + * @run main/othervm/timeout=900 Stack015 */ -package nsk.stress.stack; - - -import java.io.PrintStream; - -public class stack015 extends stack015i { +public class Stack015 extends Stack015i { final static int THREADS = 10; final static int CYCLES = 10; final static int STEP = 10; final static int RESERVE = 10; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { // - // The test will invoke the particular stack015.recurse() + // The test will invoke the particular Stack015.recurse() // method via abstract test.recurse() invocations. // - stack015i test = new stack015(); - stack015i.test = test; + Stack015i test = new Stack015(); + Stack015i.test = test; // // Measure maximal recursion depth until stack overflow: // int maxDepth = 0; - for (int depth = 0; ; depth += STEP) + for (int depth = 0; ; depth += STEP) { try { test.recurse(depth); maxDepth = depth; - } catch (StackOverflowError soe) { - break; - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { break; } - out.println("Max. depth: " + maxDepth); + } + System.out.println("Max. depth: " + maxDepth); // // Execute multiple threads repeatedly provoking stack overflows: // - stack015i threads[] = new stack015i[THREADS]; + Stack015i threads[] = new Stack015i[THREADS]; for (int i = 0; i < threads.length; i++) { - threads[i] = new stack015(); + threads[i] = new Stack015(); threads[i].depthToTry = RESERVE * maxDepth; threads[i].start(); } - for (int i = 0; i < threads.length; i++) - if (threads[i].isAlive()) + for (int i = 0; i < threads.length; i++) { + if (threads[i].isAlive()) { try { threads[i].join(); } catch (InterruptedException exception) { - exception.printStackTrace(out); - return 2; + throw new RuntimeException(exception); } - + } + } // // Check if unexpected exceptions were thrown: // - int exitCode = 0; - for (int i = 0; i < threads.length; i++) + for (int i = 0; i < threads.length; i++) { if (threads[i].thrown != null) { - threads[i].thrown.printStackTrace(out); - exitCode = 2; + threads[i].thrown.printStackTrace(); + throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown); } - - if (exitCode != 0) - out.println("# TEST FAILED"); - return exitCode; + } } synchronized void syncRecurse(int depth) { - if (depth > 0) + if (depth > 0) { syncRecurse(depth - 1); + } } } -abstract class stack015i extends Thread { +abstract class Stack015i extends Thread { // // Pure virtual method: // @@ -139,24 +125,25 @@ void recurse(int depth) { // // Stack overflow must occur here: // - syncRecurse(stack015.STEP); + syncRecurse(Stack015.STEP); // // If no stack overflow occured, try again with deeper stack: // - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } Throwable thrown = null; int depthToTry; - static stack015i test; + static Stack015i test; public void run() { // // Provoke multiple stack overflows: // - for (int i = 0; i < stack015.CYCLES; i++) + for (int i = 0; i < Stack015.CYCLES; i++) { try { // // All threads invoke the same synchronized method: @@ -167,17 +154,13 @@ public void run() { "TEST_RFE: no stack overflow thrown" + ", need to try deeper recursion?"); - } catch (StackOverflowError error) { - // It's OK: stack overflow was expected. - } catch (OutOfMemoryError oome) { - // Also OK: there may be no memory for stack expansion. - + } catch (StackOverflowError | OutOfMemoryError err) { + // It's OK } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) - throw (ThreadDeath) throwable; // It isn't OK! thrown = throwable; break; } + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack016.java b/test/hotspot/jtreg/runtime/stack/Stack016.java similarity index 67% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack016.java rename to test/hotspot/jtreg/runtime/stack/Stack016.java index dd33dd5e02c..dc2dbe7d105 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack016.java +++ b/test/hotspot/jtreg/runtime/stack/Stack016.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,21 +49,12 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp") - * @library /vmTestbase - * @build nsk.share.Terminator - * @run main/othervm/timeout=900 -Xint -Xss448K nsk.stress.stack.stack016 -eager - * @run main/othervm/timeout=900 -Xcomp -Xss448K nsk.stress.stack.stack016 -eager - * @run main/othervm/timeout=900 -Xcomp -XX:-TieredCompilation -Xss448K nsk.stress.stack.stack016 -eager + * @run main/othervm/timeout=900 -Xint -Xss448K Stack016 + * @run main/othervm/timeout=900 -Xcomp -Xss448K Stack016 + * @run main/othervm/timeout=900 -Xcomp -XX:-TieredCompilation -Xss448K Stack016 */ -package nsk.stress.stack; - - -import nsk.share.Terminator; - -import java.io.PrintStream; - -public class stack016 extends Thread { +public class Stack016 extends Thread { private final static int THREADS = 10; private final static int CYCLES = 10; private final static int STEP = 10; @@ -71,37 +62,11 @@ public class stack016 extends Thread { private final static int PROBES = STEP * RESERVE; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); + Stack016 test = new Stack016(); + test.doRun(); } - public static int run(String args[], PrintStream out) { - verbose = false; - boolean eager = false; - for (int i = 0; i < args.length; i++) - if (args[i].toLowerCase().equals("-verbose")) - verbose = true; - else if (args[i].toLowerCase().equals("-eager")) - eager = true; - if (!eager) - Terminator.appoint(Terminator.parseAppointment(args)); - stack016.out = out; - stack016 test = new stack016(); - return test.doRun(); - } - - private static boolean verbose; - private static PrintStream out; - - private void display(Object message) { - if (!verbose) - return; - synchronized (out) { - out.println(message.toString()); - } - } - - private int doRun() { + private void doRun() { // // Measure recursive depth before stack overflow: // @@ -114,14 +79,14 @@ private int doRun() { break; } } - out.println("Maximal recursion depth: " + maxDepth); + System.out.println("Maximal recursion depth: " + maxDepth); // // Run the tested threads: // - stack016 threads[] = new stack016[THREADS]; + Stack016 threads[] = new Stack016[THREADS]; for (int i = 0; i < threads.length; i++) { - threads[i] = new stack016(); + threads[i] = new Stack016(); threads[i].setName("Thread: " + (i + 1) + "/" + THREADS); threads[i].depthToTry = RESERVE * maxDepth; threads[i].start(); @@ -131,8 +96,7 @@ private int doRun() { try { threads[i].join(); } catch (InterruptedException exception) { - exception.printStackTrace(out); - return 2; + throw new RuntimeException(exception); } } } @@ -140,16 +104,12 @@ private int doRun() { // // Check if unexpected exceptions were thrown: // - int exitCode = 0; for (int i = 0; i < threads.length; i++) { if (threads[i].thrown != null) { - threads[i].thrown.printStackTrace(out); - exitCode = 2; + threads[i].thrown.printStackTrace(); + throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown); } } - if (exitCode != 0) - out.println("# TEST FAILED"); - return exitCode; } private int stackTop = 0; @@ -161,11 +121,7 @@ private void trickyRecurse(int depth) { if (depth > 0) { try { trickyRecurse(depth - 1); - } catch (Error error) { - if (!(error instanceof StackOverflowError) && - !(error instanceof OutOfMemoryError)) - throw error; - + } catch (StackOverflowError | OutOfMemoryError error) { // // Provoke more stack overflow, // if current stack is deep enough: @@ -180,28 +136,24 @@ private void trickyRecurse(int depth) { } private static void recurse(int depth) { - if (depth > 0) + if (depth > 0) { recurse(depth - 1); + } } public void run() { String threadName = Thread.currentThread().getName(); for (int i = 1; i <= CYCLES; i++) { try { - display(threadName + ", iteration: " + i + "/" + CYCLES + + System.out.println(threadName + ", iteration: " + i + "/" + CYCLES + ", depthToTry: " + depthToTry); trickyRecurse(depthToTry); throw new Error( "TEST_BUG: trickyRecursion() must throw an error anyway!"); - } catch (StackOverflowError error) { - // It's OK: stack overflow was expected. - } catch (OutOfMemoryError oome) { - // Also OK, if there is no memory for stack expansion. - + } catch (StackOverflowError | OutOfMemoryError err) { + // It's OK } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) - throw (ThreadDeath) throwable; thrown = throwable; break; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack017.java b/test/hotspot/jtreg/runtime/stack/Stack017.java similarity index 61% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack017.java rename to test/hotspot/jtreg/runtime/stack/Stack017.java index fcb18ed216e..47db5886a00 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack017.java +++ b/test/hotspot/jtreg/runtime/stack/Stack017.java @@ -42,99 +42,59 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096) - * @library /vmTestbase - * @build nsk.share.Terminator - * @run main/othervm/timeout=900 -Xss220K nsk.stress.stack.stack017 -eager + * @run main/othervm/timeout=900 -Xss220K Stack017 */ -package nsk.stress.stack; - - -import nsk.share.Terminator; - -import java.io.PrintStream; - -public class stack017 extends Thread { +public class Stack017 extends Thread { private final static int THREADS = 10; private final static int CYCLES = 10; private final static int PROBES = 100; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - verbose = false; - boolean eager = false; - for (int i = 0; i < args.length; i++) - if (args[i].toLowerCase().equals("-verbose")) - verbose = true; - else if (args[i].toLowerCase().equals("-eager")) - eager = true; - if (!eager) - Terminator.appoint(Terminator.parseAppointment(args)); - stack017.out = out; - stack017 test = new stack017(); - return test.doRun(); - } - - private static boolean verbose; - private static PrintStream out; - - private void display(Object message) { - if (!verbose) - return; - synchronized (out) { - out.println(message.toString()); - } + Stack017 test = new Stack017(); + test.doRun(); } private static int depthToTry; - private int doRun() { + private void doRun() { // // Measure recursive depth before stack overflow: // try { recurse(0); - } catch (StackOverflowError soe) { - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { } - out.println("Maximal recursion depth: " + maxDepth); + System.out.println("Maximal recursion depth: " + maxDepth); depthToTry = maxDepth; // // Run the tested threads: // - stack017 threads[] = new stack017[THREADS]; + Stack017 threads[] = new Stack017[THREADS]; for (int i = 0; i < threads.length; i++) { - threads[i] = new stack017(); + threads[i] = new Stack017(); threads[i].setName("Thread: " + (i + 1) + "/" + THREADS); threads[i].start(); } - for (int i = 0; i < threads.length; i++) - if (threads[i].isAlive()) + for (int i = 0; i < threads.length; i++) { + if (threads[i].isAlive()) { try { threads[i].join(); } catch (InterruptedException exception) { - exception.printStackTrace(out); - return 2; + throw new RuntimeException(exception); } - + } + } // // Check if unexpected exceptions were thrown: // - int exitCode = 0; - for (int i = 0; i < threads.length; i++) + for (int i = 0; i < threads.length; i++) { if (threads[i].thrown != null) { - threads[i].thrown.printStackTrace(out); - exitCode = 2; + threads[i].thrown.printStackTrace(); + throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown); } - - if (exitCode != 0) - out.println("# TEST FAILED"); - return exitCode; + } } private int maxDepth = 0; @@ -148,11 +108,7 @@ private void trickyRecurse(int depth) { try { maxDepth = depth; trickyRecurse(depth + 1); - } catch (Error error) { - if (!(error instanceof StackOverflowError) && - !(error instanceof OutOfMemoryError)) - throw error; - + } catch (StackOverflowError | OutOfMemoryError error) { // // Stack problem caught: provoke it again, // if current stack is enough deep: @@ -169,19 +125,14 @@ public void run() { String threadName = Thread.currentThread().getName(); for (int i = 1; i <= CYCLES; i++) try { - display(threadName + ", iteration: " + i + "/" + CYCLES); + System.out.println(threadName + ", iteration: " + i + "/" + CYCLES); trickyRecurse(0); throw new Exception( "TEST_BUG: stack overflow was expected!"); - } catch (StackOverflowError oome) { - // It's OK: stack overflow was expected. - } catch (OutOfMemoryError oome) { - // Also OK, if there is no memory for stack expansion. - + } catch (StackOverflowError | OutOfMemoryError err) { + // It's OK } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) - throw (ThreadDeath) throwable; // It isn't OK! thrown = throwable; break; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack018.java b/test/hotspot/jtreg/runtime/stack/Stack018.java similarity index 73% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack018.java rename to test/hotspot/jtreg/runtime/stack/Stack018.java index b60309cc98f..a54ffff6e6c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack018.java +++ b/test/hotspot/jtreg/runtime/stack/Stack018.java @@ -47,58 +47,24 @@ * 4366625 (P4/S4) multiple stack overflow causes HS crash * * @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096) - * @library /vmTestbase - * @build nsk.share.Terminator - * @run main/othervm/timeout=900 -Xss220K nsk.stress.stack.stack018 -eager + * @run main/othervm/timeout=900 -Xss220K Stack018 */ -package nsk.stress.stack; - - -import nsk.share.Terminator; - -import java.io.PrintStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -public class stack018 extends Thread { +public class Stack018 extends Thread { private final static int THREADS = 10; private final static int CYCLES = 10; private final static int STEP = 100; private final static int RESERVE = 100; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - verbose = false; - boolean eager = false; - for (int i = 0; i < args.length; i++) - if (args[i].toLowerCase().equals("-verbose")) - verbose = true; - else if (args[i].toLowerCase().equals("-eager")) - eager = true; - if (!eager) - Terminator.appoint(Terminator.parseAppointment(args)); - stack018.out = out; - stack018 test = new stack018(); - return test.doRun(); - } - - private static boolean verbose; - private static PrintStream out; - - private void display(Object message) { - if (!verbose) - return; - synchronized (out) { - out.println(message.toString()); - } + Stack018 test = new Stack018(); + test.doRun(); } - private int doRun() { + private void doRun() { // // Measure maximal recursion depth until stack overflow: // @@ -112,10 +78,8 @@ private int doRun() { if ((target instanceof StackOverflowError) || (target instanceof OutOfMemoryError)) break; // OK. - target.printStackTrace(out); - if (target instanceof ThreadDeath) - throw (ThreadDeath) target; - return 2; + target.printStackTrace(); + throw new RuntimeException(exception); } } @@ -123,41 +87,38 @@ private int doRun() { // The depth STEP was enough to cause StackOverflowError or OutOfMemoryError. maxDepth = STEP; } - out.println("Maximal recursion depth: " + maxDepth); + System.out.println("Maximal recursion depth: " + maxDepth); // // Run the tested threads: // - stack018 threads[] = new stack018[THREADS]; + Stack018 threads[] = new Stack018[THREADS]; for (int i = 0; i < threads.length; i++) { - threads[i] = new stack018(); + threads[i] = new Stack018(); threads[i].setName("Thread: " + (i + 1) + "/" + THREADS); threads[i].depthToTry = RESERVE * maxDepth; threads[i].start(); } - for (int i = 0; i < threads.length; i++) - if (threads[i].isAlive()) + for (int i = 0; i < threads.length; i++) { + if (threads[i].isAlive()) { try { threads[i].join(); } catch (InterruptedException exception) { - exception.printStackTrace(out); - return 2; + throw new RuntimeException(exception); } - + } + } // // Check if unexpected exceptions were thrown: // int exitCode = 0; - for (int i = 0; i < threads.length; i++) + for (int i = 0; i < threads.length; i++) { if (threads[i].thrown != null) { - out.println("# " + threads[i].getName() + System.out.println("# " + threads[i].getName() + ": " + threads[i].thrown); - exitCode = 2; + throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown); } - - if (exitCode != 0) - out.println("# TEST FAILED"); - return exitCode; + } } private int depthToTry = 0; @@ -167,7 +128,7 @@ public void run() { String threadName = Thread.currentThread().getName(); for (int i = 1; i <= CYCLES; i++) try { - display(threadName + ", iteration: " + i + "/" + CYCLES); + System.out.println(threadName + ", iteration: " + i + "/" + CYCLES); invokeRecurse(depthToTry); throw new Error("TEST_RFE: try deeper invocations!"); @@ -176,8 +137,6 @@ public void run() { if ((target instanceof StackOverflowError) || (target instanceof OutOfMemoryError)) continue; // OK. - if (target instanceof ThreadDeath) - throw (ThreadDeath) target; thrown = target; break; } @@ -205,7 +164,7 @@ private void invokeRecurse(int depth) throws Exception { // // Optimization trick: allocate once, use everywhere. // - method = stack018.class.getMethod("recurse"); + method = Stack018.class.getMethod("recurse"); params = new Object[]{}; } this.depth = depth; // actual parameter @@ -215,10 +174,11 @@ private void invokeRecurse(int depth) throws Exception { private int depth = 0; // actual parameter for recurse() public void recurse() throws Exception { - if (depth > 0) + if (depth > 0) { // // Self-invoke via reflection: // invokeRecurse(depth - 1); + } } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack019.java b/test/hotspot/jtreg/runtime/stack/Stack019.java similarity index 65% rename from test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack019.java rename to test/hotspot/jtreg/runtime/stack/Stack019.java index c6c5efbb36f..7a20ae3e6a2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack019.java +++ b/test/hotspot/jtreg/runtime/stack/Stack019.java @@ -43,45 +43,22 @@ * * @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096) * @requires os.family != "windows" - * @library /vmTestbase - * @build nsk.share.Terminator - * @run main/othervm/timeout=900 -Xss200K nsk.stress.stack.stack019 -eager + * @run main/othervm/timeout=900 -Xss200K Stack019 */ -package nsk.stress.stack; - - -import nsk.share.Terminator; - -import java.io.PrintStream; - -public class stack019 { +public class Stack019 { private final static int CYCLES = 50; private final static int PROBES = 50; public static void main(String[] args) { - int exitCode = run(args, System.out); - System.exit(exitCode + 95); - } - - public static int run(String args[], PrintStream out) { - boolean verbose = false, eager = false; - for (int i = 0; i < args.length; i++) - if (args[i].toLowerCase().equals("-verbose")) - verbose = true; - else if (args[i].toLowerCase().equals("-eager")) - eager = true; - if (!eager) - Terminator.appoint(Terminator.parseAppointment(args)); // // Measure recursive depth before stack overflow: // try { recurse(0); - } catch (StackOverflowError soe) { - } catch (OutOfMemoryError oome) { + } catch (StackOverflowError | OutOfMemoryError err) { } - out.println("Maximal recursion depth: " + maxDepth); + System.out.println("Maximal recursion depth: " + maxDepth); depthToTry = maxDepth; // @@ -89,23 +66,15 @@ else if (args[i].toLowerCase().equals("-eager")) // for (int i = 0; i < CYCLES; i++) { try { - out.println("Iteration: " + i + "/" + CYCLES); + System.out.println("Iteration: " + i + "/" + CYCLES); trickyRecurse(0); - out.println("# TEST_BUG: stack overflow was expected!"); - return 2; - - } catch (StackOverflowError error) { - } catch (OutOfMemoryError oome) { - // It's OK: stack overflow was expected. - + throw new RuntimeException("# TEST_BUG: stack overflow was expected!"); + } catch (StackOverflowError | OutOfMemoryError error) { + // It's OK } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) - throw (ThreadDeath) throwable; - throwable.printStackTrace(out); - return 2; + throw new RuntimeException(throwable); } } - return 0; } private static int maxDepth; @@ -120,17 +89,14 @@ private static void trickyRecurse(int depth) { try { maxDepth = depth; trickyRecurse(depth + 1); - } catch (Error error) { - if (!(error instanceof StackOverflowError) && - !(error instanceof OutOfMemoryError)) - throw error; - + } catch (StackOverflowError | OutOfMemoryError error){ // // Stack problem caught: provoke it again, // if current stack is enough deep: // - if (depth < depthToTry - PROBES) + if (depth < depthToTry - PROBES) { throw error; + } recurse(depth + 1); } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/README b/test/hotspot/jtreg/vmTestbase/nsk/share/README index d36f955659b..a696a90d516 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/README +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/README @@ -54,7 +54,7 @@ Short description of files: text processing: Grep.java, Paragrep.java timeouts handling: - Terminator.java, TimeoutHandler.java + TimeoutHandler.java tree structures support: Denotation.java, TreeNodesDenotation.java RAS mode support: diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/Terminator.java b/test/hotspot/jtreg/vmTestbase/nsk/share/Terminator.java deleted file mode 100644 index dbf26d5a8fd..00000000000 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/Terminator.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package nsk.share; - -/** - * Terminator is used to terminate a stress test with PASS exit status - * before the test is terminated as timed out (and so failed). - * - *

Terminator class holds a thread which sleeps for the given amount - * of time, and then wakes up and executes System.exit() - * with the given exit status. That thread is daemon, so it doesn't - * prevent application from exiting once all its threads finish - * before it's time for termination. Appointing terminator in zero - * delay implies immediate exit(). - * - *

There is a limitation: you may appoint no more than one terminator - * per application. - */ -public class Terminator { - /** - * Use specific appoint() method to appoint terminator. - * - * @see #appoint(int) - * @see #appoint(int,int) - */ - protected Terminator() {} - - /** - * One terminator per application, or null (by default). - */ - private static Thread terminator = null; - - /** - *

Return timeout (or waittime) value munus the margin - * value (which is assumed 1 minute by default). - * - *

Treat args[0] as $TIMEOUT value, or seek for - * -waittime=$WAITTIME value. If both parameters - * (or either none of them) are assigned, throw an exception to - * report parameters inconsistency. - * - *

Also, seek for -margin=... assignment, or assume margin - * is 1 minute. - * - * @param args Is usually obtained via the application's command-line. - * - * @throws IllegalArgumentException If args[] is inconsistent. - * - * @see #appoint(int) - * @see #appoint(int,int) - */ - public static int parseAppointment(String args[]) { - int timeout=-1, margin=1; - int timeouts=0, waittimes=0, margins=0; - for (int i=0; i 1) - throw new IllegalArgumentException( - "more than one -waittime=... is set"); - if (margins > 1) - throw new IllegalArgumentException( - "more than one -margin=... is set"); - - int result = timeout - margin; - if (result <= 0) - throw new IllegalArgumentException( - "delay appointment must be greater than "+margin+" minutes"); - return result; - } - - /** - * Appoint terminator after the given amount of minutes, - * so that exit status would be 95 (to simulate JCK-like PASS - * status). - * - * @throws IllegalStateException If terminator is already appointed. - * - * @see #appoint(int,int) - * @see #parseAppointment(String[]) - */ - public static void appoint(int minutes) { - appoint(minutes,95); // JCK-like PASS status - } - - /** - * Appoint Terminator for the given amount of minutes, - * so that the given status would be exited when time - * is over. - * - * @throws IllegalStateException If terminator is already appointed. - * - * @see #appoint(int) - * @see #parseAppointment(String[]) - */ - public static void appoint(int minutes, int status) { - if (terminator != null) - throw new IllegalStateException("Terminator is already appointed."); - - final long timeToExit = System.currentTimeMillis() + 60*1000L*minutes; - final int exitStatus = status; - - terminator = new Thread(Terminator.class.getName()) { - public void run() { - long timeToSleep = timeToExit - System.currentTimeMillis(); - if (timeToSleep > 0) - try { - // - // Use wait() instead of sleep(), because Java 2 - // specification doesn't guarantee the method - // sleep() to yield to other threads. - // - Object someDummyObject = new Object(); - synchronized (someDummyObject) { - someDummyObject.wait(timeToSleep); - } - } catch (InterruptedException exception) { - exception.printStackTrace(System.err); - return; - }; - // - // OK, lets do it now: - // - System.err.println( - "#\n# Terminator: prescheduled program termination.\n#"); - System.exit(exitStatus); // terminator to all threads - } - }; - - terminator.setPriority(Thread.MAX_PRIORITY); - terminator.setDaemon(true); - terminator.start(); - } -} From c4dfef8657705f34bb50afdbd417cbc03482e41a Mon Sep 17 00:00:00 2001 From: vamsi-parasa Date: Thu, 7 Mar 2024 21:44:46 +0000 Subject: [PATCH 6/6] 8327147: Improve performance of Math ceil, floor, and rint for x86 Reviewed-by: jbhateja, sviswanathan, dlong --- test/micro/org/openjdk/bench/java/lang/MathBench.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/micro/org/openjdk/bench/java/lang/MathBench.java b/test/micro/org/openjdk/bench/java/lang/MathBench.java index c7dde019154..fe461ee3f9c 100644 --- a/test/micro/org/openjdk/bench/java/lang/MathBench.java +++ b/test/micro/org/openjdk/bench/java/lang/MathBench.java @@ -141,6 +141,11 @@ public double ceilDouble() { return Math.ceil(double4Dot1); } + @Benchmark + public double addCeilFloorDouble() { + return Math.ceil(double4Dot1) + Math.floor(double4Dot1); + } + @Benchmark public double copySignDouble() { return Math.copySign(double81, doubleNegative12);