8154073: Several compiler tests fail when are executed with C1 only
Summary: Added missing flag checks to the tests and Whitebox API.
Reviewed-by: kvn
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp Tue Apr 12 17:12:51 2016 -0700
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp Thu Apr 14 08:32:39 2016 +0200
@@ -1060,6 +1060,7 @@
assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range");
assert(!method->is_abstract() && (osr_bci == InvocationEntryBci || !method->is_native()), "cannot compile abstract/native methods");
assert(!method->method_holder()->is_not_initialized(), "method holder must be initialized");
+ assert(!TieredCompilation || comp_level <= TieredStopAtLevel, "Invalid compilation level");
// allow any levels for WhiteBox
assert(WhiteBoxAPI || TieredCompilation || comp_level == CompLevel_highest_tier, "only CompLevel_highest_tier must be used in non-tiered");
// return quickly if possible
--- a/hotspot/src/share/vm/prims/whitebox.cpp Tue Apr 12 17:12:51 2016 -0700
+++ b/hotspot/src/share/vm/prims/whitebox.cpp Thu Apr 14 08:32:39 2016 +0200
@@ -641,7 +641,8 @@
bool WhiteBox::compile_method(Method* method, int comp_level, int bci, Thread* THREAD) {
// Screen for unavailable/bad comp level or null method
- if (method == NULL || CompileBroker::compiler(comp_level) == NULL) {
+ if (method == NULL || comp_level > TieredStopAtLevel ||
+ CompileBroker::compiler(comp_level) == NULL) {
return false;
}
methodHandle mh(THREAD, method);
--- a/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java Tue Apr 12 17:12:51 2016 -0700
+++ b/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java Thu Apr 14 08:32:39 2016 +0200
@@ -72,6 +72,7 @@
}
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+ private static final int TIERED_STOP_AT_LEVEL = WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue();
static boolean deoptimize(Method method, Object src_obj) throws Exception {
for (int i = 0; i < 10; i++) {
@@ -84,7 +85,9 @@
}
static public void main(String[] args) throws Exception {
- if (Platform.isServer()) {
+ // Only execute if C2 is available
+ if (Platform.isServer() &&
+ TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) {
int[] src = new int[10];
Object src_obj = new Object();
Method method_m1 = TestArrayCopyNoInitDeopt.class.getMethod("m1", Object.class);
--- a/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java Tue Apr 12 17:12:51 2016 -0700
+++ b/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java Thu Apr 14 08:32:39 2016 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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,7 @@
* @bug 8073480
* @summary explicit range checks should be recognized by C2
* @library /testlibrary /test/lib /compiler/whitebox /
- * @build TestExplicitRangeChecks
+ * @build TestExplicitRangeChecks
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main ClassFileInstaller jdk.test.lib.Platform
* @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
@@ -44,8 +44,10 @@
import compiler.whitebox.CompilerWhiteBoxTest;
public class TestExplicitRangeChecks {
-
- static int[] array = new int[10];
+ private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+ private static final int TIERED_STOP_AT_LEVEL = WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue();
+ private static int[] array = new int[10];
+ private static boolean success = true;
@Retention(RetentionPolicy.RUNTIME)
@interface Args {
@@ -366,10 +368,6 @@
return true;
}
- static boolean success = true;
-
- private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
-
final HashMap<String,Method> tests = new HashMap<>();
{
for (Method m : this.getClass().getDeclaredMethods()) {
@@ -439,7 +437,9 @@
System.out.println(name + " bad result for bad input " + bad[i]);
success = false;
}
- if (Platform.isServer()) {
+ // Only perform these additional checks if C2 is available
+ if (Platform.isServer() &&
+ TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) {
if (deoptimize && WHITE_BOX.isMethodCompiled(m)) {
System.out.println(name + " not deoptimized on invalid access");
success = false;