From efab48c06554476eae7a7bd946dee033d16a9c38 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Fri, 14 Jun 2024 12:48:43 +0000 Subject: [PATCH 1/6] 8333714: Cleanup the usages of CHECK_EXCEPTION_NULL_FAIL macro in java launcher Reviewed-by: alanb --- src/java.base/share/native/libjli/java.c | 90 ++++++++++++++++-------- 1 file changed, 59 insertions(+), 31 deletions(-) diff --git a/src/java.base/share/native/libjli/java.c b/src/java.base/share/native/libjli/java.c index 1d506c3a6df70..1b4ece834d6e5 100644 --- a/src/java.base/share/native/libjli/java.c +++ b/src/java.base/share/native/libjli/java.c @@ -387,73 +387,92 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */ } \ } while (JNI_FALSE) -#define CHECK_EXCEPTION_NULL_FAIL(obj) \ - do { \ - if ((*env)->ExceptionOccurred(env)) { \ - return 0; \ - } else if (obj == NULL) { \ - return 0; \ - } \ - } while (JNI_FALSE) - /* - * Invoke a static main with arguments. Returns 1 (true) if successful otherwise - * processes the pending exception from GetStaticMethodID and returns 0 (false). + * Invokes static main(String[]) method if found. + * Returns 0 with a pending exception if not found. Returns 1 if invoked, maybe + * a pending exception if the method threw. */ int invokeStaticMainWithArgs(JNIEnv *env, jclass mainClass, jobjectArray mainArgs) { jmethodID mainID = (*env)->GetStaticMethodID(env, mainClass, "main", "([Ljava/lang/String;)V"); - CHECK_EXCEPTION_NULL_FAIL(mainID); + if (mainID == NULL) { + // static main(String[]) not found + return 0; + } (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); - return 1; + return 1; // method was invoked } /* - * Invoke an instance main with arguments. Returns 1 (true) if successful otherwise - * processes the pending exception from GetMethodID and returns 0 (false). + * Invokes instance main(String[]) method if found. + * Returns 0 with a pending exception if not found. Returns 1 if invoked, maybe + * a pending exception if the method threw. */ int invokeInstanceMainWithArgs(JNIEnv *env, jclass mainClass, jobjectArray mainArgs) { jmethodID constructor = (*env)->GetMethodID(env, mainClass, "", "()V"); - CHECK_EXCEPTION_NULL_FAIL(constructor); + if (constructor == NULL) { + // main class' no-arg constructor not found + return 0; + } jobject mainObject = (*env)->NewObject(env, mainClass, constructor); - CHECK_EXCEPTION_NULL_FAIL(mainObject); + if (mainObject == NULL) { + // main class instance couldn't be constructed + return 0; + } jmethodID mainID = (*env)->GetMethodID(env, mainClass, "main", "([Ljava/lang/String;)V"); - CHECK_EXCEPTION_NULL_FAIL(mainID); + if (mainID == NULL) { + // instance method main(String[]) method not found + return 0; + } (*env)->CallVoidMethod(env, mainObject, mainID, mainArgs); - return 1; + return 1; // method was invoked } /* - * Invoke a static main without arguments. Returns 1 (true) if successful otherwise - * processes the pending exception from GetStaticMethodID and returns 0 (false). + * Invokes no-arg static main() method if found. + * Returns 0 with a pending exception if not found. Returns 1 if invoked, maybe + * a pending exception if the method threw. */ int invokeStaticMainWithoutArgs(JNIEnv *env, jclass mainClass) { jmethodID mainID = (*env)->GetStaticMethodID(env, mainClass, "main", "()V"); - CHECK_EXCEPTION_NULL_FAIL(mainID); + if (mainID == NULL) { + // static main() method couldn't be located + return 0; + } (*env)->CallStaticVoidMethod(env, mainClass, mainID); - return 1; + return 1; // method was invoked } /* - * Invoke an instance main without arguments. Returns 1 (true) if successful otherwise - * processes the pending exception from GetMethodID and returns 0 (false). + * Invokes no-arg instance main() method if found. + * Returns 0 with a pending exception if not found. Returns 1 if invoked, maybe + * a pending exception if the method threw. */ int invokeInstanceMainWithoutArgs(JNIEnv *env, jclass mainClass) { jmethodID constructor = (*env)->GetMethodID(env, mainClass, "", "()V"); - CHECK_EXCEPTION_NULL_FAIL(constructor); + if (constructor == NULL) { + // main class' no-arg constructor not found + return 0; + } jobject mainObject = (*env)->NewObject(env, mainClass, constructor); - CHECK_EXCEPTION_NULL_FAIL(mainObject); + if (mainObject == NULL) { + // couldn't create instance of main class + return 0; + } jmethodID mainID = (*env)->GetMethodID(env, mainClass, "main", "()V"); - CHECK_EXCEPTION_NULL_FAIL(mainID); + if (mainID == NULL) { + // instance method main() not found + return 0; + } (*env)->CallVoidMethod(env, mainObject, mainID); - return 1; + return 1; // method was invoked } int @@ -639,6 +658,8 @@ JavaMain(void* _args) } } if (!ret) { + // An appropriate main method couldn't be located, check and report + // any exception and LEAVE() CHECK_EXCEPTION_LEAVE(1); } @@ -646,8 +667,15 @@ JavaMain(void* _args) * The launcher's exit code (in the absence of calls to * System.exit) will be non-zero if main threw an exception. */ - ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; - + if (ret && (*env)->ExceptionOccurred(env) == NULL) { + // main method was invoked and no exception was thrown from it, + // return success. + ret = 0; + } else { + // Either the main method couldn't be located or an exception occurred + // in the invoked main method, return failure. + ret = 1; + } LEAVE(); } From b5212d7bfe78b18c18e45c42c724a22365709328 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Fri, 14 Jun 2024 13:50:21 +0000 Subject: [PATCH 2/6] 8328107: Shenandoah/C2: TestVerifyLoopOptimizations test failure Reviewed-by: shade --- .../gc/shenandoah/c2/shenandoahSupport.cpp | 8 ++ .../compiler/TestBarrierOnLoopBackedge.java | 84 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 test/hotspot/jtreg/gc/shenandoah/compiler/TestBarrierOnLoopBackedge.java diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp index dbb45995698a6..8cd76dd3d6bc4 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp @@ -1333,6 +1333,14 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { OuterStripMinedLoopNode* outer = head->as_OuterStripMinedLoop(); hide_strip_mined_loop(outer, outer->unique_ctrl_out()->as_CountedLoop(), phase); } + if (head->is_BaseCountedLoop() && ctrl->is_IfProj() && ctrl->in(0)->is_BaseCountedLoopEnd() && + head->as_BaseCountedLoop()->loopexit() == ctrl->in(0)) { + Node* entry = head->in(LoopNode::EntryControl); + Node* backedge = head->in(LoopNode::LoopBackControl); + Node* new_head = new LoopNode(entry, backedge); + phase->register_control(new_head, phase->get_loop(entry), entry); + phase->lazy_replace(head, new_head); + } } // Expand load-reference-barriers diff --git a/test/hotspot/jtreg/gc/shenandoah/compiler/TestBarrierOnLoopBackedge.java b/test/hotspot/jtreg/gc/shenandoah/compiler/TestBarrierOnLoopBackedge.java new file mode 100644 index 0000000000000..a72c7d69d7f65 --- /dev/null +++ b/test/hotspot/jtreg/gc/shenandoah/compiler/TestBarrierOnLoopBackedge.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024, Red Hat, Inc. 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 8328107 + * @summary Barrier expanded on backedge break loop verification code + * @requires vm.gc.Shenandoah + * + * @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestBarrierOnLoopBackedge::notInlined + * -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyLoopOptimizations TestBarrierOnLoopBackedge + * @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestBarrierOnLoopBackedge::notInlined + * -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyLoopOptimizations -XX:-UseCountedLoopSafepoints TestBarrierOnLoopBackedge + */ + +public class TestBarrierOnLoopBackedge { + private static A field = new A(); + private static final A finalField = new A(); + private static float floatField; + + public static void main(String[] args) { + A[] array = new A[1]; + array[0] = finalField; + for (int i = 0; i < 20_000; i++) { + test1(); + test2(); + } + } + + private static void test1() { + floatField = field.f; + for (int i = 0; i < 1000; i++) { + notInlined(field); // load barrier split thru phi and ends up on back edge + if (i % 2 == 0) { + field = finalField; + } + } + } + + private static void test2() { + A[] array = new A[1]; + notInlined(array); + int i = 0; + A a = array[0]; + for (;;) { + synchronized (new Object()) { + } + notInlined(a); + i++; + if (i >= 1000) { + break; + } + a = array[0]; // load barrier pinned on backedge + } + } + + private static void notInlined(Object a) { + + } + + private static class A { + float f; + } +} From dae0bda9d0096c25d6378561ab2d09df05f381cf Mon Sep 17 00:00:00 2001 From: Archie Cobbs Date: Fri, 14 Jun 2024 14:53:05 +0000 Subject: [PATCH 3/6] 8334252: Verifier error for lambda declared in early construction context Reviewed-by: mcimadamore --- .../sun/tools/javac/comp/LambdaToMethod.java | 24 +++++----- .../javac/SuperInit/LambdaOuterCapture.java | 46 +++++++++++++++++++ 2 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 test/langtools/tools/javac/SuperInit/LambdaOuterCapture.java diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index 5b70a376f2a90..7e5dcee0e8d67 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -1239,7 +1239,7 @@ class LambdaAnalyzerPreprocessor extends TreeTranslator { private int lambdaCount = 0; /** - * List of types undergoing construction via explicit constructor chaining. + * List of types undergoing construction, i.e., in an early construction context. */ private List typesUnderConstruction; @@ -1280,15 +1280,10 @@ private JCClassDecl analyzeAndPreprocessClass(JCClassDecl tree) { @Override public void visitApply(JCMethodInvocation tree) { - List previousNascentTypes = typesUnderConstruction; - try { - Name methName = TreeInfo.name(tree.meth); - if (methName == names._this || methName == names._super) { - typesUnderConstruction = typesUnderConstruction.prepend(currentClass()); - } - super.visitApply(tree); - } finally { - typesUnderConstruction = previousNascentTypes; + super.visitApply(tree); + if (TreeInfo.isConstructorCall(tree)) { + Assert.check(typesUnderConstruction.head == currentClass()); + typesUnderConstruction = typesUnderConstruction.tail; // end of early construction context } } // where @@ -1439,13 +1434,16 @@ private LambdaTranslationContext analyzeLambda(JCLambda tree, String statKey) { @Override public void visitMethodDef(JCMethodDecl tree) { + List prevTypesUnderConstruction = typesUnderConstruction; List prevStack = frameStack; try { + if (TreeInfo.isConstructor(tree)) // start early construction context (Object() notwithstanding) + typesUnderConstruction = typesUnderConstruction.prepend(currentClass()); frameStack = frameStack.prepend(new Frame(tree)); super.visitMethodDef(tree); - } - finally { + } finally { frameStack = prevStack; + typesUnderConstruction = prevTypesUnderConstruction; } } diff --git a/test/langtools/tools/javac/SuperInit/LambdaOuterCapture.java b/test/langtools/tools/javac/SuperInit/LambdaOuterCapture.java new file mode 100644 index 0000000000000..092e2916c69d5 --- /dev/null +++ b/test/langtools/tools/javac/SuperInit/LambdaOuterCapture.java @@ -0,0 +1,46 @@ +/* + * 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 8194743 + * @summary Test lambda declared in early construction context + * @enablePreview + */ + +public class LambdaOuterCapture { + + public class Inner { + + public Inner() { + Runnable r = () -> System.out.println(LambdaOuterCapture.this); + this(r); + } + + public Inner(Runnable r) { + } + } + + public static void main(String[] args) { + new LambdaOuterCapture().new Inner(); + } +} From 548e95a689d63e97ddbdfe7dd7df3a2e3377046c Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Fri, 14 Jun 2024 15:32:04 +0000 Subject: [PATCH 4/6] 8330702: Update failure handler to don't generate Error message if cores actions are empty Reviewed-by: sspitsyn --- .../jdk/test/failurehandler/action/ActionSet.java | 9 ++++++--- test/failure_handler/src/share/conf/windows.properties | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/failure_handler/src/share/classes/jdk/test/failurehandler/action/ActionSet.java b/test/failure_handler/src/share/classes/jdk/test/failurehandler/action/ActionSet.java index d67611697bf64..46f1c5bc6f14b 100644 --- a/test/failure_handler/src/share/classes/jdk/test/failurehandler/action/ActionSet.java +++ b/test/failure_handler/src/share/classes/jdk/test/failurehandler/action/ActionSet.java @@ -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 @@ -104,8 +104,11 @@ private List getPatternActions(PrintWriter log, private String[] getTools(PrintWriter writer, Properties p, String key) { String value = p.getProperty(key); - if (value == null || value.isEmpty()) { - writer.printf("ERROR: '%s' property is empty%n", key); + if (value == null) { + writer.printf("ERROR: '%s' property is not set%n", key); + return new String[]{}; + } + if (value.isEmpty()) { return new String[]{}; } return value.split(" "); diff --git a/test/failure_handler/src/share/conf/windows.properties b/test/failure_handler/src/share/conf/windows.properties index e22c1a523d8a3..6d11553ebbf5d 100644 --- a/test/failure_handler/src/share/conf/windows.properties +++ b/test/failure_handler/src/share/conf/windows.properties @@ -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 @@ -59,6 +59,8 @@ native.stack.params.repeat=6 native.core.app=cdb native.core.args=-c ".dump /mA core.%p;qd" -p %p native.core.params.timeout=600000 + +cores= ################################################################################ # environment info to gather ################################################################################ From 8464ce6db5cbd5d50ac2a2bcba905b7255f510f5 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Fri, 14 Jun 2024 15:32:19 +0000 Subject: [PATCH 5/6] 8332113: Update nsk.share.Log to be always verbose Reviewed-by: sspitsyn, cjplummer --- test/hotspot/jtreg/vmTestbase/nsk/share/Log.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/Log.java b/test/hotspot/jtreg/vmTestbase/nsk/share/Log.java index 735f487f6c3c1..e575018249533 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/Log.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/Log.java @@ -74,15 +74,15 @@ public class Log { /** * Is log-mode verbose? - * Default value is false. + * Always enabled. */ - private boolean verbose = false; + private final boolean verbose = true; /** * Should log messages prefixed with timestamps? - * Default value is false. + * Always enabled. */ - private boolean timestamp = false; + private final boolean timestamp = true; /** * Names for trace levels @@ -193,7 +193,6 @@ public Log(PrintStream stream) { */ public Log(PrintStream stream, boolean verbose) { this(stream); - this.verbose = verbose; } /** @@ -204,7 +203,6 @@ public Log(PrintStream stream, boolean verbose) { public Log(PrintStream stream, ArgumentParser argsParser) { this(stream, argsParser.verbose()); traceLevel = argsParser.getTraceLevel(); - timestamp = argsParser.isTimestamp(); } ///////////////////////////////////////////////////////////////// @@ -220,10 +218,9 @@ public boolean verbose() { * Enable or disable verbose mode for printing messages. */ public void enableVerbose(boolean enable) { - if (!verbose) { - flushLogBuffer(); + if (!enable) { + throw new RuntimeException("The non-verbose logging is not supported."); } - verbose = enable; } public int getTraceLevel() { @@ -422,7 +419,6 @@ protected synchronized void logTo(PrintStream stream) { out.flush(); } out = stream; - verbose = true; } ///////////////////////////////////////////////////////////////// From 31e8debae63e008da79e403bcb870a7be631af2c Mon Sep 17 00:00:00 2001 From: Liming Liu Date: Mon, 17 Jun 2024 06:16:26 +0000 Subject: [PATCH 6/6] 8324781: runtime/Thread/TestAlwaysPreTouchStacks.java failed with Expected a higher ratio between stack committed and reserved 8325218: gc/parallel/TestAlwaysPreTouchBehavior.java fails Reviewed-by: stefank, jsjolen, stuefe --- test/hotspot/jtreg/ProblemList.txt | 2 -- .../gc/parallel/TestAlwaysPreTouchBehavior.java | 3 +-- .../runtime/Thread/TestAlwaysPreTouchStacks.java | 14 +++++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 5290a9bb6260e..4391357b70349 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -77,7 +77,6 @@ gc/epsilon/TestMemoryMXBeans.java 8206434 generic-all gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java 8156755 generic-all gc/g1/logging/TestG1LoggingFailure.java 8169634 generic-all gc/g1/humongousObjects/TestHeapCounters.java 8178918 generic-all -gc/parallel/TestAlwaysPreTouchBehavior.java 8325218 linux-all gc/TestAllocHumongousFragment.java#adaptive 8298781 generic-all gc/TestAllocHumongousFragment.java#aggressive 8298781 generic-all gc/TestAllocHumongousFragment.java#iu-aggressive 8298781 generic-all @@ -102,7 +101,6 @@ runtime/StackGuardPages/TestStackGuardPagesNative.java 8303612 linux-all runtime/ErrorHandling/TestDwarf.java#checkDecoder 8305489 linux-all runtime/ErrorHandling/MachCodeFramesInErrorFile.java 8313315 linux-ppc64le runtime/cds/appcds/customLoader/HelloCustom_JFR.java 8241075 linux-all,windows-x64 -runtime/Thread/TestAlwaysPreTouchStacks.java 8324781 linux-all applications/jcstress/copy.java 8229852 linux-all diff --git a/test/hotspot/jtreg/gc/parallel/TestAlwaysPreTouchBehavior.java b/test/hotspot/jtreg/gc/parallel/TestAlwaysPreTouchBehavior.java index 12c03661e0e22..3a5b2b557cc92 100644 --- a/test/hotspot/jtreg/gc/parallel/TestAlwaysPreTouchBehavior.java +++ b/test/hotspot/jtreg/gc/parallel/TestAlwaysPreTouchBehavior.java @@ -31,7 +31,7 @@ * @requires os.family == "linux" * @requires os.maxMemory > 2G * @library /test/lib - * @run main/othervm -Xmx1g -Xms1g -XX:+UseParallelGC -XX:+AlwaysPreTouch gc.parallel.TestAlwaysPreTouchBehavior + * @run main/othervm -Xmx1g -Xms1g -XX:+UseParallelGC -XX:+AlwaysPreTouch -XX:+UnlockDiagnosticVMOptions -XX:-UseMadvPopulateWrite gc.parallel.TestAlwaysPreTouchBehavior */ import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; @@ -77,4 +77,3 @@ public static void main(String [] args) { Asserts.assertGreaterThanOrEqual(rss, committedMemory, "RSS of this process(" + rss + "kb) should be bigger than or equal to committed heap mem(" + committedMemory + "kb)"); } } - diff --git a/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java b/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java index a10f41932348f..b12eff0cf8454 100644 --- a/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java +++ b/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.concurrent.CyclicBarrier; @@ -89,14 +90,17 @@ public static void main(String[] args) throws Exception { // should show up with fully - or almost fully - committed thread stacks. } else { - - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( + ArrayList vmArgs = new ArrayList<>(); + Collections.addAll(vmArgs, "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:+AlwaysPreTouchStacks", - "-XX:NativeMemoryTracking=summary", "-XX:+PrintNMTStatistics", - "TestAlwaysPreTouchStacks", - "test"); + "-XX:NativeMemoryTracking=summary", "-XX:+PrintNMTStatistics"); + if (System.getProperty("os.name").contains("Linux")) { + vmArgs.add("-XX:-UseMadvPopulateWrite"); + } + Collections.addAll(vmArgs, "TestAlwaysPreTouchStacks", "test"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(vmArgs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.reportDiagnosticSummary();