--- old/test/runtime/ReservedStack/ReservedStackTest.java 2017-03-21 18:12:26.993045174 -0700 +++ new/test/runtime/ReservedStack/ReservedStackTest.java 2017-03-21 18:12:26.917044950 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -112,6 +112,8 @@ import java.util.concurrent.locks.ReentrantLock; import jdk.test.lib.Platform; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; public class ReservedStackTest { @@ -197,14 +199,7 @@ String result = test.getResult(); // The feature is not fully implemented on all platforms, // corruptions are still possible. - boolean supportedPlatform = - Platform.isAix() || - (Platform.isLinux() && - (Platform.isPPC() || Platform.isS390x() || Platform.isX64() || - Platform.isX86() || Platform.isAArch64())) || - Platform.isOSX() || - Platform.isSolaris(); - if (supportedPlatform && !result.contains("PASSED")) { + if (isSupportedPlatform && !result.contains("PASSED")) { System.out.println(result); throw new Error(result); } else { @@ -237,7 +232,63 @@ } } - public static void main(String[] args) { + public static boolean isAlwaysSupportedPlatform() { + // Note: To date Aarch64 is the only platform that we don't statically + // know if it supports the reserved stack area. This is because the + // open Aarch64 port supports it and the Oracle arm64 port does not. + return Platform.isAix() || + (Platform.isLinux() && + (Platform.isPPC() || Platform.isS390x() || Platform.isX64() || + Platform.isX86())) || + Platform.isOSX() || + Platform.isSolaris(); + } + + public static boolean isNeverSupportedPlatform() { + return !isAlwaysSupportedPlatform() && !Platform.isAArch64(); + } + + public static boolean isSupportedPlatform; + + public static void initIsSupportedPlatform() throws Exception { + // In order to dynamicaly determine if the platform supports the reserved + // stack area, run with -XX:StackReservedPages=1 and see if we get the + // expected warning message for platforms that don't support it. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:StackReservedPages=1", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + System.out.println("StackReservedPages=1 log: [" + output.getOutput() + "]"); + if (output.getExitValue() != 0) { + String msg = "Could not launch with -XX:StackReservedPages=1: exit " + output.getExitValue(); + System.err.println("FAILED: " + msg); + throw new RuntimeException(msg); + } + + boolean isSupportedPlatform = true; + String matchStr = "Reserved Stack Area not supported on this platform"; + int match_idx = output.getOutput().indexOf(matchStr); + if (match_idx >= 0) { + isSupportedPlatform = false; + } + + // Do a sanity check. Some platforms we know are always supported. Make sure + // we didn't determine that one of those platforms is not supported. + if (!isSupportedPlatform && isAlwaysSupportedPlatform()) { + String msg = "This platform should be supported: " + Platform.getOsArch(); + System.err.println("FAILED: " + msg); + throw new RuntimeException(msg); + } + + // And some platforms we know are never supported. Make sure + // we didn't determine that one of those platforms is supported. + if (isSupportedPlatform && isNeverSupportedPlatform()) { + String msg = "This platform should not be supported: " + Platform.getOsArch(); + System.err.println("FAILED: " + msg); + throw new RuntimeException(msg); + } + } + + public static void main(String[] args) throws Exception { + initIsSupportedPlatform(); for (int i = 0; i < 1000; i++) { // Each iteration has to be executed by a new thread. The test // relies on the random size area pushed by the VM at the beginning