This commit is contained in:
Rickard Bäckman 2014-07-24 14:38:26 +02:00
commit 84271f1c96
31 changed files with 458 additions and 356 deletions

@ -9728,7 +9728,7 @@ instruct cmpN_reg_branch_short(cmpOp cmp, iRegN op1, iRegN op2, label labl, flag
size(4); size(4);
ins_cost(BRANCH_COST); ins_cost(BRANCH_COST);
format %{ "CWB$cmp $op1,op2,$labl\t! compressed ptr" %} format %{ "CWB$cmp $op1,$op2,$labl\t! compressed ptr" %}
ins_encode %{ ins_encode %{
Label* L = $labl$$label; Label* L = $labl$$label;
assert(__ use_cbcond(*L), "back to back cbcond"); assert(__ use_cbcond(*L), "back to back cbcond");

@ -138,6 +138,17 @@ ciField::ciField(ciInstanceKlass* klass, int index): _known_to_link_with_put(NUL
return; return;
} }
// Access check based on declared_holder. canonical_holder should not be used
// to check access because it can erroneously succeed. If this check fails,
// propagate the declared holder to will_link() which in turn will bail out
// compilation for this field access.
if (!Reflection::verify_field_access(klass->get_Klass(), declared_holder->get_Klass(), canonical_holder, field_desc.access_flags(), true)) {
_holder = declared_holder;
_offset = -1;
_is_constant = false;
return;
}
assert(canonical_holder == field_desc.field_holder(), "just checking"); assert(canonical_holder == field_desc.field_holder(), "just checking");
initialize_from(&field_desc); initialize_from(&field_desc);
} }

@ -69,7 +69,12 @@ class PcDescCache VALUE_OBJ_CLASS_SPEC {
friend class VMStructs; friend class VMStructs;
private: private:
enum { cache_size = 4 }; enum { cache_size = 4 };
PcDesc* _pc_descs[cache_size]; // last cache_size pc_descs found // The array elements MUST be volatile! Several threads may modify
// and read from the cache concurrently. find_pc_desc_internal has
// returned wrong results. C++ compiler (namely xlC12) may duplicate
// C++ field accesses if the elements are not volatile.
typedef PcDesc* PcDescPtr;
volatile PcDescPtr _pc_descs[cache_size]; // last cache_size pc_descs found
public: public:
PcDescCache() { debug_only(_pc_descs[0] = NULL); } PcDescCache() { debug_only(_pc_descs[0] = NULL); }
void reset_to(PcDesc* initial_pc_desc); void reset_to(PcDesc* initial_pc_desc);

@ -1089,7 +1089,7 @@ Node *PhaseIterGVN::transform_old(Node* n) {
#endif #endif
while (i != NULL) { while (i != NULL) {
#ifndef PRODUCT #ifdef ASSERT
if (loop_count >= K) { if (loop_count >= K) {
dump_infinite_loop_info(i); dump_infinite_loop_info(i);
} }

@ -117,15 +117,6 @@ compact3 = \
# Tests that require compact3 API's # Tests that require compact3 API's
# #
needs_compact3 = \ needs_compact3 = \
compiler/8009761/Test8009761.java \
compiler/whitebox/DeoptimizeMethodTest.java \
compiler/whitebox/SetForceInlineMethodTest.java \
compiler/whitebox/SetDontInlineMethodTest.java \
compiler/whitebox/DeoptimizeAllTest.java \
compiler/whitebox/MakeMethodNotCompilableTest.java \
compiler/whitebox/ClearMethodStateTest.java \
compiler/whitebox/EnqueueMethodForCompilationTest.java \
compiler/whitebox/IsMethodCompilableTest.java \
gc/6581734/Test6581734.java \ gc/6581734/Test6581734.java \
gc/7072527/TestFullGCCount.java \ gc/7072527/TestFullGCCount.java \
gc/g1/TestHumongousAllocInitialMark.java \ gc/g1/TestHumongousAllocInitialMark.java \
@ -138,11 +129,7 @@ needs_compact3 = \
runtime/InternalApi/ThreadCpuTimesDeadlock.java \ runtime/InternalApi/ThreadCpuTimesDeadlock.java \
serviceability/threads/TestFalseDeadLock.java \ serviceability/threads/TestFalseDeadLock.java \
serviceability/jvmti/GetObjectSizeOverflow.java \ serviceability/jvmti/GetObjectSizeOverflow.java \
serviceability/jvmti/TestRedefineWithUnresolvedClass.java \ serviceability/jvmti/TestRedefineWithUnresolvedClass.java
compiler/tiered/NonTieredLevelsTest.java \
compiler/tiered/TieredLevelsTest.java \
compiler/intrinsics/bmi/verifycode \
runtime/whitebox/WBStackSize.java
# Compact 2 adds full VM tests # Compact 2 adds full VM tests
compact2 = \ compact2 = \
@ -199,8 +186,7 @@ compact2_minimal = \
# Tests that require compact2 API's # Tests that require compact2 API's
# #
needs_compact2 = \ needs_compact2 =
compiler/6589834/Test_ia32.java
# All tests that run on the most minimal configuration: Minimal VM on Compact 1 # All tests that run on the most minimal configuration: Minimal VM on Compact 1
compact1_minimal = \ compact1_minimal = \

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,163 +27,195 @@
* @bug 6890943 * @bug 6890943
* @summary JVM mysteriously gives wrong result on 64-bit 1.6 VMs in hotspot mode. * @summary JVM mysteriously gives wrong result on 64-bit 1.6 VMs in hotspot mode.
* *
* @run shell/timeout=240 Test6890943.sh * @run main/othervm/timeout=240 Test6890943
*/ */
import java.util.*;
import java.io.*; import java.io.*;
import java.util.regex.*; import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Test6890943 { public class Test6890943 {
public static final boolean AIR = true, ROCK = false; public static final boolean AIR = true, ROCK = false;
public static void main(String[] args) { private static final Path PATH = Paths.get(System.getProperty("test.src", "."));
new Test6890943().go(); private static final Path INPUT_FILE = PATH.resolve("input6890943.txt");
} private static final Path GOLDEN_FILE = PATH.resolve("output6890943.txt");
int r, c, f, t; public static void main(String[] args) {
boolean[][] grid; new Test6890943().go();
public void go() {
Scanner s = new Scanner(System.in);
s.useDelimiter("\\s+");
int T = s.nextInt();
for (t = 0 ; t < T ; t++) {
r = s.nextInt(); c = s.nextInt(); f = s.nextInt();
grid = new boolean[r][c];
for (int x = 0 ; x < r ; x++) {
String line = s.next();
for (int y = 0 ; y < c ; y++) grid[x][y] = line.charAt(y) == '.';
}
int digs = solve();
String res = digs == -1 ? "No" : "Yes " + digs;
System.out.printf("Case #%d: %s\n", t+1, res);
} }
}
Map<Integer, Integer> M = new HashMap<Integer, Integer>(); int r, c, f, t;
boolean[][] grid;
private int solve() { public void go() {
M = new HashMap<Integer, Integer>(); Scanner in, golden;
M.put(calcWalkingRange(0, 0), 0); try {
for (int digDown = 0 ; digDown < r ; digDown++) { in = new Scanner(new FileInputStream(INPUT_FILE.toFile()));
Map<Integer, Integer> tries = new HashMap<Integer, Integer>(); golden = new Scanner(new FileInputStream(GOLDEN_FILE.toFile()));
for (Map.Entry<Integer, Integer> m : M.entrySet()) { } catch (FileNotFoundException e) {
int q = m.getKey(); throw new RuntimeException("TEST failure: can't open test file", e);
if (depth(q) != (digDown)) continue;
if (stuck(q)) continue;
tries.put(q, m.getValue());
}
for (Map.Entry<Integer, Integer> m : tries.entrySet()) {
int q = m.getKey();
int fallLeftDelta = 0, fallRightDelta = 0;
//fall left
int fallLeft = fall(digDown, start(q));
if (fallLeft > 0) {
fallLeftDelta = 1;
if (fallLeft <= f) addToM(calcWalkingRange(digDown+fallLeft, start(q)), m.getValue());
} }
in.useDelimiter("\\s+");
golden.useDelimiter("\\s+");
//fall right int T = in.nextInt();
int fallRight = fall(digDown, end(q)); for (t = 0; t < T; t++) {
if (fallRight > 0) { r = in.nextInt();
fallRightDelta = 1; c = in.nextInt();
f = in.nextInt();
if (fallRight <= f) addToM(calcWalkingRange(digDown+fallRight, end(q)), m.getValue()); grid = new boolean[r][c];
} for (int x = 0; x < r; x++) {
String line = in.next();
for (int p = start(q) + fallLeftDelta ; p <= end(q) - fallRightDelta ; p++) { for (int y = 0; y < c; y++) {
//goLeft grid[x][y] = line.charAt(y) == '.';
for (int digSpot = p ; digSpot > start(q) +fallLeftDelta ; digSpot--) { }
int fallDown = 1+fall(digDown+1, digSpot);
if (fallDown <= f) {
if (fallDown == 1) {
addToM(calcWalkingRange(digDown + 1, digSpot, digSpot, p), m.getValue() + Math.abs(digSpot-p)+1);
} else {
addToM(calcWalkingRange(digDown + fallDown, digSpot), m.getValue() + Math.abs(digSpot-p)+1);
}
} }
} int digs = solve();
String result = "Case #" + (t + 1) + ": " + (digs == -1 ? "No" : "Yes " + digs);
//goRight System.out.println(result);
for (int digSpot = p ; digSpot < end(q)-fallRightDelta ;digSpot++) { // Compare with golden string from the file
int fallDown = 1+fall(digDown+1, digSpot); String goldenStr = golden.nextLine();
if (fallDown <= f) { if (!result.equals(goldenStr)) {
if (fallDown == 1) { System.err.println("FAIL: strings are not equal\n"
addToM(calcWalkingRange(digDown + 1, digSpot, p, digSpot), m.getValue() + Math.abs(digSpot-p)+1); + "-- Result: " + result + "\n"
} else { + "-- Golden: " + goldenStr);
addToM(calcWalkingRange(digDown + fallDown, digSpot), m.getValue() + Math.abs(digSpot-p)+1); throw new RuntimeException("FAIL: Result string is not equal to the golden");
}
} }
}
} }
}
} }
int result = Integer.MAX_VALUE; Map<Integer, Integer> M = new HashMap<Integer, Integer>();
for (Map.Entry<Integer, Integer> m : M.entrySet()) {
if (depth(m.getKey()) == r-1) result = Math.min(m.getValue(), result); private int solve() {
M = new HashMap<Integer, Integer>();
M.put(calcWalkingRange(0, 0), 0);
for (int digDown = 0; digDown < r; digDown++) {
Map<Integer, Integer> tries = new HashMap<Integer, Integer>();
for (Map.Entry<Integer, Integer> m : M.entrySet()) {
int q = m.getKey();
if (depth(q) != (digDown)) continue;
if (stuck(q)) continue;
tries.put(q, m.getValue());
}
for (Map.Entry<Integer, Integer> m : tries.entrySet()) {
int q = m.getKey();
int fallLeftDelta = 0, fallRightDelta = 0;
//fall left
int fallLeft = fall(digDown, start(q));
if (fallLeft > 0) {
fallLeftDelta = 1;
if (fallLeft <= f) addToM(calcWalkingRange(digDown + fallLeft, start(q)), m.getValue());
}
//fall right
int fallRight = fall(digDown, end(q));
if (fallRight > 0) {
fallRightDelta = 1;
if (fallRight <= f) addToM(calcWalkingRange(digDown + fallRight, end(q)), m.getValue());
}
for (int p = start(q) + fallLeftDelta; p <= end(q) - fallRightDelta; p++) {
//goLeft
for (int digSpot = p; digSpot > start(q) + fallLeftDelta; digSpot--) {
int fallDown = 1 + fall(digDown + 1, digSpot);
if (fallDown <= f) {
if (fallDown == 1) {
addToM(calcWalkingRange(digDown + 1, digSpot, digSpot, p),
m.getValue() + Math.abs(digSpot - p) + 1);
} else {
addToM(calcWalkingRange(digDown + fallDown, digSpot),
m.getValue() + Math.abs(digSpot - p) + 1);
}
}
}
//goRight
for (int digSpot = p; digSpot < end(q) - fallRightDelta; digSpot++) {
int fallDown = 1 + fall(digDown + 1, digSpot);
if (fallDown <= f) {
if (fallDown == 1) {
addToM(calcWalkingRange(digDown + 1, digSpot, p, digSpot),
m.getValue() + Math.abs(digSpot - p) + 1);
} else {
addToM(calcWalkingRange(digDown + fallDown, digSpot),
m.getValue() + Math.abs(digSpot - p) + 1);
}
}
}
}
}
}
int result = Integer.MAX_VALUE;
for (Map.Entry<Integer, Integer> m : M.entrySet()) {
if (depth(m.getKey()) == r - 1) result = Math.min(m.getValue(), result);
}
if (result == Integer.MAX_VALUE) return -1;
return result;
} }
if (result == Integer.MAX_VALUE) return -1; private void addToM(int q, int i) {
return result; Integer original = M.get(q);
} if (original == null) M.put(q, i);
else M.put(q, Math.min(original, i));
private void addToM(int q, int i) {
Integer original = M.get(q);
if ( original == null ) M.put(q, i);
else M.put(q, Math.min(original, i));
}
private int fall(int row, int column) {
int res = 0;
for ( int p = row+1 ; p < r ; p++) {
if (grid[p][column] == AIR) res++;
else break;
}
return res;
}
private boolean stuck(int q) {
return start(q) == end(q);
}
private int depth(int q) {
return q % 50;
}
private int start(int q) {
return q / (50*50);
}
private int end(int q) {
return (q / 50) % 50;
}
private int calcWalkingRange(int depth, int pos) {
return calcWalkingRange(depth, pos, Integer.MAX_VALUE, Integer.MIN_VALUE);
}
private int calcWalkingRange(int depth, int pos, int airOverrideStart, int airOverrideEnd) {
int left = pos, right = pos;
if (depth >= r) return (c-1)*50 + depth;
while (left > 0) {
if (grid[depth][left-1] == ROCK && (left-1 < airOverrideStart || left-1 > airOverrideEnd)) break;
if (depth < r-1 && grid[depth+1][left-1] == AIR) {
left--;
break;
}
left--;
}
while (right < c-1) {
if (grid[depth][right+1] == ROCK && (right+1 < airOverrideStart || right+1 > airOverrideEnd)) break;
if (depth < r-1 && grid[depth+1][right+1] == AIR) {
right++;
break;
}
right++;
} }
return left *50*50 + right*50 + depth; private int fall(int row, int column) {
} int res = 0;
for (int p = row + 1; p < r; p++) {
if (grid[p][column] == AIR) res++;
else break;
}
return res;
}
private boolean stuck(int q) {
return start(q) == end(q);
}
private int depth(int q) {
return q % 50;
}
private int start(int q) {
return q / (50 * 50);
}
private int end(int q) {
return (q / 50) % 50;
}
private int calcWalkingRange(int depth, int pos) {
return calcWalkingRange(depth, pos, Integer.MAX_VALUE, Integer.MIN_VALUE);
}
private int calcWalkingRange(int depth, int pos, int airOverrideStart, int airOverrideEnd) {
int left = pos, right = pos;
if (depth >= r) return (c - 1) * 50 + depth;
while (left > 0) {
if (grid[depth][left - 1] == ROCK && (left - 1 < airOverrideStart || left - 1 > airOverrideEnd)) break;
if (depth < r - 1 && grid[depth + 1][left - 1] == AIR) {
left--;
break;
}
left--;
}
while (right < c - 1) {
if (grid[depth][right + 1] == ROCK && (right + 1 < airOverrideStart || right + 1 > airOverrideEnd)) break;
if (depth < r - 1 && grid[depth + 1][right + 1] == AIR) {
right++;
break;
}
right++;
}
return left * 50 * 50 + right * 50 + depth;
}
} }

@ -1,60 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2011, 2013, 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.
#
#
## some tests require path to find test source dir
if [ "${TESTSRC}" = "" ]
then
TESTSRC=${PWD}
echo "TESTSRC not set. Using "${TESTSRC}" as default"
fi
echo "TESTSRC=${TESTSRC}"
## Adding common setup Variables for running shell tests.
. ${TESTSRC}/../../test_env.sh
set -x
cp ${TESTSRC}/Test6890943.java .
cp ${TESTSRC}/input6890943.txt .
cp ${TESTSRC}/output6890943.txt .
cp ${TESTSRC}/Test6890943.sh .
${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} -d . Test6890943.java
${TESTJAVA}/bin/java -XX:-PrintVMOptions -XX:+IgnoreUnrecognizedVMOptions ${TESTVMOPTS} Test6890943 < input6890943.txt > pretest.out 2>&1
# This test sometimes tickles an unrelated performance warning that interferes with diff.
grep -v 'warning: Performance bug: SystemDictionary' pretest.out > test.out
diff output6890943.txt test.out
result=$?
if [ $result -eq 0 ]
then
echo "Passed"
exit 0
else
echo "Failed"
exit 1
fi

@ -0,0 +1,86 @@
/*
* Copyright (c) 2014, 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.
*/
public class InlinedArrayCloneTestCase implements Runnable {
private Test_ia32 executionController;
public InlinedArrayCloneTestCase(Test_ia32 executionController) {
this.executionController = executionController;
}
/*
* Please leave following two methods (invokeArrayClone and verifyArguments)
* static.
*
* It does not really matter if these methods are static or instance,
* original issue could be reproduced in both cases, but if these methods
* are static then it is much easier to understand that reproduced issue
* is actually interpreter's stack corruption.
*
* If these methods are non-static, then interpreter's stack will contain
* invalid 'this' pointer required for instance's method call and
* verifyArguments' call may throw NullPointerException. There was another
* issue w/ NPE after deoptimization addressed by JDK-6833129, so NPE looks
* a little bit confusing.
*
* If these methods are static then after deptimization we'll get incorrect
* arguments values in verifyArguments.
* Something like "2, -1289936896, 3, 4" instead of "1, 2, 3, 4".
* This information tells much more about actual issue comparing to NPE,
* so it's preferable to leave these methods static.
*/
private static int verifyArguments(int i1, int i2, LoadedClass[] arr,
int i3, int i4) {
if (!(i1==1 && i2==2 && i3==3 && i4==4)) {
throw new RuntimeException(String.format(
"Arguments have unexpected values: %d, %d, %d, %d",
i1, i2, i3, i4));
}
return arr.length;
}
private static int invokeArrayClone(LoadedClass[] a) {
return InlinedArrayCloneTestCase.verifyArguments(1, 2, a.clone(), 3, 4);
}
@Override
public void run() {
LoadedClass[] array = executionController.getArray();
int length;
while (executionController.continueExecution()) {
try {
length = InlinedArrayCloneTestCase.invokeArrayClone(array);
} catch (Throwable e) {
e.printStackTrace();
executionController.setTestFailed();
return;
}
if (length != array.length) {
System.out.println(String.format("f(array) returned %d "
+ "instead of %d.", length, array.length));
executionController.setTestFailed();
}
}
}
}

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,103 +24,116 @@
/** /**
* @test * @test
* @bug 6589834 * @bug 6589834
* @summary deoptimization problem with -XX:+DeoptimizeALot * @summary Safepoint placed between stack pointer increment and decrement leads
* * to interpreter's stack corruption after deoptimization.
* @run main Test_ia32 * @library /testlibrary /testlibrary/whitebox
* @build ClassFileInstaller sun.hotspot.WhiteBox com.oracle.java.testlibrary.*
* Test_ia32 InlinedArrayCloneTestCase
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:+WhiteBoxAPI -XX:CompileOnly=InlinedArrayCloneTestCase
* -XX:CompileCommand=dontinline,InlinedArrayCloneTestCase.invokeArrayClone
* -XX:CompileCommand=inline,InlinedArrayCloneTestCase.verifyArguments
* -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack Test_ia32
*/ */
/*************************************************************************************** import java.lang.reflect.Method;
NOTE: The bug shows up (with several "Bug!" message) even without the
flag -XX:+DeoptimizeALot. In a debug build, you may want to try import com.oracle.java.testlibrary.Asserts;
the flags -XX:+VerifyStack and -XX:+DeoptimizeALot to get more information. import sun.hotspot.WhiteBox;
****************************************************************************************/
import java.lang.reflect.Constructor;
public class Test_ia32 { public class Test_ia32 {
private static final int NUM_THREADS
= Math.min(100, 2 * Runtime.getRuntime().availableProcessors());
private static final int CLONE_LENGTH = 1000;
public static int NUM_THREADS = 100; private static WhiteBox wb = WhiteBox.getWhiteBox();
public static int CLONE_LENGTH = 1000; private final LoadedClass[] ARRAY = new LoadedClass[Test_ia32.CLONE_LENGTH];
private volatile boolean doSpin = true;
private volatile boolean testFailed = false;
public static void main(String[] args) throws InterruptedException, ClassNotFoundException { public boolean continueExecution() {
return doSpin;
}
public void stopExecution() {
doSpin = false;
}
public boolean isTestFailed() {
return testFailed;
}
public void setTestFailed() {
this.testFailed = true;
stopExecution();
}
public LoadedClass[] getArray() {
return ARRAY;
}
public void runTest() {
Thread[] threads = new Thread[Test_ia32.NUM_THREADS];
Method method;
try {
method = InlinedArrayCloneTestCase.class.getDeclaredMethod(
"invokeArrayClone", LoadedClass[].class);
} catch (NoSuchMethodException e) {
throw new Error("Tested method not found", e);
}
Asserts.assertTrue(wb.isMethodCompilable(method),
"Method " + method.getName() + " should be compilable.");
Reflector[] threads = new Reflector[NUM_THREADS];
for (int i = 0; i < threads.length; i++) { for (int i = 0; i < threads.length; i++) {
threads[i] = new Reflector(); threads[i] = new Thread(new InlinedArrayCloneTestCase(this));
threads[i].start(); threads[i].start();
} }
System.out.println("Give Reflector.run() some time to compile..."); /*
Thread.sleep(5000); * Wait until InlinedArrayCloneTestCase::invokeArrayClone is compiled.
*/
while (!wb.isMethodCompiled(method)) {
Thread.yield();
}
System.out.println("Load RMISecurityException causing run() deoptimization"); /*
ClassLoader.getSystemClassLoader().loadClass("java.rmi.RMISecurityException"); * Load NotLoadedClass to cause deoptimization of
* InlinedArrayCloneTestCase::invokeArrayClone due to invalidated
* dependency.
*/
try {
Class.forName("NotLoadedClass");
} catch (ClassNotFoundException e) {
throw new Error("Unable to load class that invalidates "
+ "CHA-dependency for method " + method.getName(), e);
}
for (Reflector thread : threads) stopExecution();
thread.requestStop();
for (Reflector thread : threads) for (Thread thread : threads) {
try { try {
thread.join(); thread.join();
} catch (InterruptedException e) { } catch (InterruptedException e) {
System.out.println(e); throw new Error("Fail to join thread " + thread, e);
} }
}
Asserts.assertFalse(isTestFailed(), "Test failed.");
} }
public static void main(String[] args) {
new Test_ia32().runTest();
}
} }
class Reflector extends Thread { class LoadedClass {
}
volatile boolean _doSpin = true;
@SuppressWarnings("unused")
Test_ia32[] _tests; class NotLoadedClass extends LoadedClass {
Reflector() {
_tests = new Test_ia32[Test_ia32.CLONE_LENGTH];
for (int i = 0; i < _tests.length; i++) {
_tests[i] = new Test_ia32();
}
}
static int g(int i1, int i2, Test_ia32[] arr, int i3, int i4) {
if (!(i1==1 && i2==2 && i3==3 && i4==4)) {
System.out.println("Bug!");
}
return arr.length;
}
static int f(Test_ia32[] arr) {
return g(1, 2, arr.clone(), 3, 4);
}
@Override
public void run() {
Constructor[] ctrs = null;
Class<Test_ia32> klass = Test_ia32.class;
try {
ctrs = klass.getConstructors();
} catch (SecurityException e) {
System.out.println(e);
}
try {
while (_doSpin) {
if (f(_tests) < 0)
System.out.println("return value usage");
}
} catch (NullPointerException e) {
e.printStackTrace();
}
System.out.println(this + " - stopped.");
}
public void requestStop() {
System.out.println(this + " - stop requested.");
_doSpin = false;
}
} }

@ -28,7 +28,7 @@
* @bug 8005722 * @bug 8005722
* @summary assert(_oprs_len[mode] < maxNumberOfOperands) failed: array overflow * @summary assert(_oprs_len[mode] < maxNumberOfOperands) failed: array overflow
* *
* @run main/othervm -Xcomp -client Test8004051 * @run main/othervm -Xcomp Test8004051
*/ */
public class Test8004051 { public class Test8004051 {

@ -26,7 +26,7 @@
## ##
## @test ## @test
## @bug 8011675 ## @bug 8011675
## @ignore 8032226, 8031978 ## @ignore 8031978
## @summary testing of ciReplay with using generated by SA replay.txt ## @summary testing of ciReplay with using generated by SA replay.txt
## @author igor.ignatyev@oracle.com ## @author igor.ignatyev@oracle.com
## @run shell TestSA.sh ## @run shell TestSA.sh

@ -26,7 +26,6 @@
## ##
## @test ## @test
## @bug 8011675 ## @bug 8011675
## @ignore 8031978
## @summary testing of ciReplay with using generated by VM replay.txt ## @summary testing of ciReplay with using generated by VM replay.txt
## @author igor.ignatyev@oracle.com ## @author igor.ignatyev@oracle.com
## @run shell TestVM.sh ## @run shell TestVM.sh

@ -26,7 +26,6 @@
## ##
## @test ## @test
## @bug 8011675 ## @bug 8011675
## @ignore 8031978
## @summary testing of ciReplay with using generated by VM replay.txt w/o comp_level ## @summary testing of ciReplay with using generated by VM replay.txt w/o comp_level
## @author igor.ignatyev@oracle.com ## @author igor.ignatyev@oracle.com
## @run shell TestVM_no_comp_level.sh ## @run shell TestVM_no_comp_level.sh

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -223,21 +223,29 @@ generate_replay() {
-XX:CICrashAt=1 \ -XX:CICrashAt=1 \
-XX:+CreateMinidumpOnCrash \ -XX:+CreateMinidumpOnCrash \
-XX:+DumpReplayDataOnError \ -XX:+DumpReplayDataOnError \
-XX:-TransmitErrorReport \
-XX:+PreferInterpreterNativeStubs \
-XX:+PrintCompilation \
-XX:ReplayDataFile=${replay_data} \ -XX:ReplayDataFile=${replay_data} \
-version" -version"
echo GENERATION OF REPLAY.TXT: echo GENERATION OF REPLAY.TXT:
echo $cmd echo $cmd
${cmd} > crash.out 2>&1 ${cmd} > crash.out 2>&1
exit_code=$?
if [ ${exit_code} -eq 0 ]
then
cat crash.out
test_fail 3 "CHECK :: CRASH" "JVM exits gracefully"
fi
core_locations=`grep -i core crash.out | grep "location:" | \ core_locations=`grep -i core crash.out | grep "location:" | \
sed -e 's/.*location: //'` sed -e 's/.*location: //'`
echo CRASH OUTPUT:
cat crash.out if [ -z "${core_locations}" ]
if [ "${core_locations}" = "" ]
then then
test_fail 2 "CHECK :: CORE_LOCATION" "output doesn't contain the location of core file, see crash.out" test_fail 4 "CHECK :: CORE_LOCATION" "output doesn't contain the location of core file, see crash.out"
fi fi
rm crash.out rm crash.out
@ -245,16 +253,19 @@ generate_replay() {
# processing core locations for *nix # processing core locations for *nix
if [ $VM_OS != "windows" ] if [ $VM_OS != "windows" ]
then then
# remove 'or' between '/core.<pid>' and 'core' # remove 'or' between '<core_path>/core.<pid>' and 'core'
# and the rest of line -- ' (max size ...) . To ensure a full core ...'
core_locations=`echo $core_locations | \ core_locations=`echo $core_locations | \
sed -e 's/\([^ ]*\) or \([^ ]*\)/\1 \2/'` sed -e 's/\([^ ]*\) or \([^ ]*\).*/\1 \2/'`
# add <core_path>/core.<pid> core.<pid>
core_with_dir=`echo $core_locations | awk '{print $1}'` core_with_dir=`echo $core_locations | awk '{print $1}'`
dir=`dirname $core_with_dir`
core_with_pid=`echo $core_locations | awk '{print $2}'` core_with_pid=`echo $core_locations | awk '{print $2}'`
if [ -n ${core_with_pid} ] dir=`dirname $core_with_dir`
file=`basename $core_with_dir`
# add <core_path>/core.<pid> core
core_locations="'$core_with_dir' '$file'"
if [ -n "${core_with_pid}" ]
then then
core_locations="$core_locations $dir${FS}$core_with_pid $core_with_pid" core_locations="$core_locations '$core_with_pid' '$dir${FS}$core_with_pid'"
fi fi
fi fi

@ -146,6 +146,10 @@ public class BmiIntrinsicBase extends CompilerWhiteBoxTest {
} }
protected int countCpuInstructions(byte[] nativeCode) { protected int countCpuInstructions(byte[] nativeCode) {
return countCpuInstructions(nativeCode, instrMask, instrPattern);
}
public static int countCpuInstructions(byte[] nativeCode, byte[] instrMask, byte[] instrPattern) {
int count = 0; int count = 0;
int patternSize = Math.min(instrMask.length, instrPattern.length); int patternSize = Math.min(instrMask.length, instrPattern.length);
boolean found; boolean found;
@ -183,4 +187,21 @@ public class BmiIntrinsicBase extends CompilerWhiteBoxTest {
return "UseBMI1Instructions"; return "UseBMI1Instructions";
} }
} }
abstract static class BmiTestCase_x64 extends BmiTestCase {
protected byte[] instrMask_x64;
protected byte[] instrPattern_x64;
protected BmiTestCase_x64(Method method) {
super(method);
}
protected int countCpuInstructions(byte[] nativeCode) {
int cnt = super.countCpuInstructions(nativeCode);
if (Platform.isX64()) { // on x64 platform the instruction we search for can be encoded in 2 different ways
cnt += countCpuInstructions(nativeCode, instrMask_x64, instrPattern_x64);
}
return cnt;
}
}
} }

@ -33,12 +33,15 @@
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class LZcntTestI extends BmiIntrinsicBase.BmiTestCase { public class LZcntTestI extends BmiIntrinsicBase.BmiTestCase_x64 {
protected LZcntTestI(Method method) { protected LZcntTestI(Method method) {
super(method); super(method);
instrMask = new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; instrMask = new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
instrPattern = new byte[]{(byte) 0xF3, (byte) 0x0F, (byte) 0xBD}; instrPattern = new byte[]{(byte) 0xF3, (byte) 0x0F, (byte) 0xBD};
instrMask_x64 = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF};
instrPattern_x64 = new byte[]{(byte) 0xF3, (byte) 0x00, (byte) 0x0F, (byte) 0xBD};
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

@ -31,8 +31,6 @@
* -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCountLeadingZerosInstruction LZcntTestL * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCountLeadingZerosInstruction LZcntTestL
*/ */
import com.oracle.java.testlibrary.Platform;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class LZcntTestL extends LZcntTestI { public class LZcntTestL extends LZcntTestI {
@ -40,10 +38,6 @@ public class LZcntTestL extends LZcntTestI {
protected LZcntTestL(Method method) { protected LZcntTestL(Method method) {
super(method); super(method);
isLongOperation = true; isLongOperation = true;
if (Platform.isX64()) {
instrMask = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF};
instrPattern = new byte[]{(byte) 0xF3, (byte) 0x00, (byte) 0x0F, (byte) 0xBD};
}
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

@ -33,12 +33,15 @@
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class TZcntTestI extends BmiIntrinsicBase.BmiTestCase { public class TZcntTestI extends BmiIntrinsicBase.BmiTestCase_x64 {
protected TZcntTestI(Method method) { protected TZcntTestI(Method method) {
super(method); super(method);
instrMask = new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; instrMask = new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
instrPattern = new byte[]{(byte) 0xF3, (byte) 0x0F, (byte) 0xBC}; instrPattern = new byte[]{(byte) 0xF3, (byte) 0x0F, (byte) 0xBC};
instrMask_x64 = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF};
instrPattern_x64 = new byte[]{(byte) 0xF3, (byte) 0x00, (byte) 0x0F, (byte) 0xBC};
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

@ -31,8 +31,6 @@
* -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCountTrailingZerosInstruction TZcntTestL * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCountTrailingZerosInstruction TZcntTestL
*/ */
import com.oracle.java.testlibrary.Platform;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class TZcntTestL extends TZcntTestI { public class TZcntTestL extends TZcntTestI {
@ -40,11 +38,6 @@ public class TZcntTestL extends TZcntTestI {
protected TZcntTestL(Method method) { protected TZcntTestL(Method method) {
super(method); super(method);
isLongOperation = true; isLongOperation = true;
if (Platform.isX64()) {
instrMask = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF};
instrPattern = new byte[]{(byte) 0xF3, (byte) 0x00, (byte) 0x0F, (byte) 0xBC};
}
isLongOperation = true;
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

@ -25,8 +25,8 @@ import java.util.function.IntPredicate;
/** /**
* @test NonTieredLevelsTest * @test NonTieredLevelsTest
* @ignore 8046268
* @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
* @ignore 8046268
* @build NonTieredLevelsTest * @build NonTieredLevelsTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:-TieredCompilation * @run main/othervm -Xbootclasspath/a:. -XX:-TieredCompilation

@ -23,8 +23,8 @@
/** /**
* @test TieredLevelsTest * @test TieredLevelsTest
* @ignore 8046268
* @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @library /testlibrary /testlibrary/whitebox /compiler/whitebox
* @ignore 8046268
* @build TieredLevelsTest * @build TieredLevelsTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation * @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,9 +25,9 @@ import java.util.function.Function;
/* /*
* @test ClearMethodStateTest * @test ClearMethodStateTest
* @ignore 8046268
* @bug 8006683 8007288 8022832 * @bug 8006683 8007288 8022832
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @ignore 8046268
* @build ClearMethodStateTest * @build ClearMethodStateTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* ClearMethodStateTest * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* ClearMethodStateTest

@ -21,11 +21,8 @@
* questions. * questions.
*/ */
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
import sun.hotspot.WhiteBox; import sun.hotspot.WhiteBox;
import sun.hotspot.code.NMethod; import sun.hotspot.code.NMethod;
import sun.management.ManagementFactoryHelper;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Executable; import java.lang.reflect.Executable;
@ -98,15 +95,7 @@ public abstract class CompilerWhiteBoxTest {
*/ */
protected static String getVMOption(String name) { protected static String getVMOption(String name) {
Objects.requireNonNull(name); Objects.requireNonNull(name);
HotSpotDiagnosticMXBean diagnostic return Objects.toString(WHITE_BOX.getVMFlag(name), null);
= ManagementFactoryHelper.getDiagnosticMXBean();
VMOption tmp;
try {
tmp = diagnostic.getVMOption(name);
} catch (IllegalArgumentException e) {
tmp = null;
}
return (tmp == null ? null : tmp.getValue());
} }
/** /**
@ -174,7 +163,7 @@ public abstract class CompilerWhiteBoxTest {
* @see #test() * @see #test()
*/ */
protected final void runTest() { protected final void runTest() {
if (ManagementFactoryHelper.getCompilationMXBean() == null) { if (CompilerWhiteBoxTest.MODE.startsWith("interpreted ")) {
System.err.println( System.err.println(
"Warning: test is not applicable in interpreted mode"); "Warning: test is not applicable in interpreted mode");
return; return;

@ -23,9 +23,9 @@
/* /*
* @test DeoptimizeAllTest * @test DeoptimizeAllTest
* @ignore 8046268
* @bug 8006683 8007288 8022832 * @bug 8006683 8007288 8022832
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @ignore 8046268
* @build DeoptimizeAllTest * @build DeoptimizeAllTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* DeoptimizeAllTest * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* DeoptimizeAllTest

@ -23,9 +23,9 @@
/* /*
* @test DeoptimizeMethodTest * @test DeoptimizeMethodTest
* @ignore 8046268
* @bug 8006683 8007288 8022832 * @bug 8006683 8007288 8022832
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @ignore 8046268
* @build DeoptimizeMethodTest * @build DeoptimizeMethodTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* DeoptimizeMethodTest * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* DeoptimizeMethodTest

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,9 +23,9 @@
/* /*
* @test EnqueueMethodForCompilationTest * @test EnqueueMethodForCompilationTest
* @ignore 8046268
* @bug 8006683 8007288 8022832 * @bug 8006683 8007288 8022832
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @ignore 8046268
* @build EnqueueMethodForCompilationTest * @build EnqueueMethodForCompilationTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm/timeout=600 -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* EnqueueMethodForCompilationTest * @run main/othervm/timeout=600 -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* EnqueueMethodForCompilationTest

@ -26,9 +26,9 @@ import sun.hotspot.code.NMethod;
/* /*
* @test GetNMethodTest * @test GetNMethodTest
* @ignore 8046268
* @bug 8038240 * @bug 8038240
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @ignore 8046268
* @build GetNMethodTest * @build GetNMethodTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* GetNMethodTest * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* GetNMethodTest

@ -23,9 +23,9 @@
/* /*
* @test MakeMethodNotCompilableTest * @test MakeMethodNotCompilableTest
* @ignore 8046268
* @bug 8012322 8006683 8007288 8022832 * @bug 8012322 8006683 8007288 8022832
* @library /testlibrary /testlibrary/whitebox * @library /testlibrary /testlibrary/whitebox
* @ignore 8046268
* @build MakeMethodNotCompilableTest * @build MakeMethodNotCompilableTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* MakeMethodNotCompilableTest * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* MakeMethodNotCompilableTest

@ -39,7 +39,6 @@
* Please file a test bug, if this is a problem. * Please file a test bug, if this is a problem.
*/ */
import com.sun.management.HotSpotDiagnosticMXBean;
import sun.hotspot.WhiteBox; import sun.hotspot.WhiteBox;
public class WBStackSize { public class WBStackSize {
@ -81,8 +80,7 @@ public class WBStackSize {
} }
public static void main(String[] args) { public static void main(String[] args) {
HotSpotDiagnosticMXBean bean = sun.management.ManagementFactoryHelper.getDiagnosticMXBean(); long configStackSize = wb.getIntxVMFlag("ThreadStackSize") * K;
long configStackSize = Long.valueOf(bean.getVMOption("ThreadStackSize").getValue()) * K;
System.out.println("ThreadStackSize VM option: " + configStackSize); System.out.println("ThreadStackSize VM option: " + configStackSize);

@ -25,6 +25,10 @@
package sun.hotspot; package sun.hotspot;
import java.lang.reflect.Executable; import java.lang.reflect.Executable;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;
import java.security.BasicPermission; import java.security.BasicPermission;
import sun.hotspot.parser.DiagnosticCommand; import sun.hotspot.parser.DiagnosticCommand;
@ -171,4 +175,15 @@ public class WhiteBox {
public native Long getUint64VMFlag(String name); public native Long getUint64VMFlag(String name);
public native String getStringVMFlag(String name); public native String getStringVMFlag(String name);
public native Double getDoubleVMFlag(String name); public native Double getDoubleVMFlag(String name);
private final List<Function<String,Object>> flagsGetters = Arrays.asList(
this::getBooleanVMFlag, this::getIntxVMFlag, this::getUintxVMFlag,
this::getUint64VMFlag, this::getStringVMFlag, this::getDoubleVMFlag);
public Object getVMFlag(String name) {
return flagsGetters.stream()
.map(f -> f.apply(name))
.filter(x -> x != null)
.findAny()
.orElse(null);
}
} }

@ -91,16 +91,20 @@ public final class VmFlagTest<T> {
} }
private void testPositive(T value, T expected) { private void testPositive(T value, T expected) {
Asserts.assertEQ(getVMOptionAsString(), asString(getValue())); String oldValue = getVMOptionAsString();
Asserts.assertEQ(oldValue, asString(getValue()));
Asserts.assertEQ(oldValue, asString(WHITE_BOX.getVMFlag(flagName)));
setNewValue(value); setNewValue(value);
String newValue = getVMOptionAsString(); String newValue = getVMOptionAsString();
Asserts.assertEQ(newValue, asString(expected)); Asserts.assertEQ(newValue, asString(expected));
Asserts.assertEQ(getVMOptionAsString(), asString(getValue())); Asserts.assertEQ(newValue, asString(getValue()));
Asserts.assertEQ(newValue, asString(WHITE_BOX.getVMFlag(flagName)));
} }
private void testNegative(T value, T expected) { private void testNegative(T value, T expected) {
String oldValue = getVMOptionAsString(); String oldValue = getVMOptionAsString();
Asserts.assertEQ(oldValue, asString(getValue())); Asserts.assertEQ(oldValue, asString(getValue()));
Asserts.assertEQ(oldValue, asString(WHITE_BOX.getVMFlag(flagName)));
setNewValue(value); setNewValue(value);
String newValue = getVMOptionAsString(); String newValue = getVMOptionAsString();
Asserts.assertEQ(oldValue, newValue); Asserts.assertEQ(oldValue, newValue);