Merge
authoraph
Thu, 25 Feb 2016 14:47:08 +0000
changeset 36328 f627026bc04a
parent 36327 0df8bb4dc7d6 (current diff)
parent 36325 1330e79162ac (diff)
child 36329 06727ae6971e
child 36798 a00bc4ff7b23
Merge
--- a/hotspot/make/test/JtregNative.gmk	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/make/test/JtregNative.gmk	Thu Feb 25 14:47:08 2016 +0000
@@ -48,6 +48,7 @@
     $(HOTSPOT_TOPDIR)/test/runtime/SameObject \
     $(HOTSPOT_TOPDIR)/test/compiler/floatingpoint/ \
     $(HOTSPOT_TOPDIR)/test/compiler/calls \
+    $(HOTSPOT_TOPDIR)/test/compiler/native \
     #
 
 # Add conditional directories here when needed.
--- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Thu Feb 25 14:47:08 2016 +0000
@@ -1349,9 +1349,12 @@
     }
   } else if (dst.first()->is_stack()) {
     // reg to stack
-    __ st_ptr(src.first()->as_Register(), SP, reg2offset(dst.first()) + STACK_BIAS);
+    // Some compilers (gcc) expect a clean 32 bit value on function entry
+    __ signx(src.first()->as_Register(), L5);
+    __ st_ptr(L5, SP, reg2offset(dst.first()) + STACK_BIAS);
   } else {
-    __ mov(src.first()->as_Register(), dst.first()->as_Register());
+    // Some compilers (gcc) expect a clean 32 bit value on function entry
+    __ signx(src.first()->as_Register(), dst.first()->as_Register());
   }
 }
 
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp	Thu Feb 25 14:47:08 2016 +0000
@@ -224,6 +224,7 @@
 void Canonicalizer::do_ArrayLength    (ArrayLength*     x) {
   NewArray*  na;
   Constant*  ct;
+  LoadField* lf;
 
   if ((na = x->array()->as_NewArray()) != NULL) {
     // New arrays might have the known length.
@@ -239,14 +240,20 @@
 
   } else if ((ct = x->array()->as_Constant()) != NULL) {
     // Constant arrays have constant lengths.
-    set_constant(ct->type()->as_ArrayConstant()->value()->length());
+    ArrayConstant* cnst = ct->type()->as_ArrayConstant();
+    if (cnst != NULL) {
+      set_constant(cnst->value()->length());
+    }
 
-#ifdef ASSERT
-  } else {
-    LoadField* lf = x->array()->as_LoadField();
-    bool is_static_constant = (lf != NULL) && lf->field()->is_constant() && lf->field()->is_static();
-    assert(!is_static_constant, "Constant field loads are folded during parsing");
-#endif // ASSERT
+  } else if ((lf = x->array()->as_LoadField()) != NULL) {
+    ciField* field = lf->field();
+    if (field->is_constant() && field->is_static()) {
+      assert(PatchALot || ScavengeRootsInCode < 2, "Constant field loads are folded during parsing");
+      ciObject* c = field->constant_value().as_object();
+      if (!c->is_null_object()) {
+        set_constant(c->as_array()->length());
+      }
+    }
   }
 }
 
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Thu Feb 25 14:47:08 2016 +0000
@@ -469,7 +469,6 @@
 void CompileBroker::print_compile_queues(outputStream* st) {
   st->print_cr("Current compiles: ");
   MutexLocker locker(MethodCompileQueue_lock);
-  MutexLocker locker2(Threads_lock);
 
   char buf[2000];
   int buflen = sizeof(buf);
--- a/hotspot/src/share/vm/prims/whitebox.cpp	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/src/share/vm/prims/whitebox.cpp	Thu Feb 25 14:47:08 2016 +0000
@@ -644,12 +644,12 @@
   return (mh->queued_for_compilation() || nm != NULL);
 WB_END
 
-WB_ENTRY(jboolean, WB_ShouldPrintAssembly(JNIEnv* env, jobject o, jobject method))
+WB_ENTRY(jboolean, WB_ShouldPrintAssembly(JNIEnv* env, jobject o, jobject method, jint comp_level))
   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
 
   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
-  DirectiveSet* directive = DirectivesStack::getMatchingDirective(mh, CompileBroker::compiler(CompLevel_simple));
+  DirectiveSet* directive = DirectivesStack::getMatchingDirective(mh, CompileBroker::compiler(comp_level));
   bool result = directive->PrintAssemblyOption;
   DirectivesStack::release(directive);
 
@@ -1556,8 +1556,8 @@
 #endif // INCLUDE_NMT
   {CC"deoptimizeFrames",   CC"(Z)I",                  (void*)&WB_DeoptimizeFrames  },
   {CC"deoptimizeAll",      CC"()V",                   (void*)&WB_DeoptimizeAll     },
-    {CC"deoptimizeMethod0",   CC"(Ljava/lang/reflect/Executable;Z)I",
-                                                        (void*)&WB_DeoptimizeMethod  },
+  {CC"deoptimizeMethod0",   CC"(Ljava/lang/reflect/Executable;Z)I",
+                                                      (void*)&WB_DeoptimizeMethod  },
   {CC"isMethodCompiled0",   CC"(Ljava/lang/reflect/Executable;Z)Z",
                                                       (void*)&WB_IsMethodCompiled  },
   {CC"isMethodCompilable0", CC"(Ljava/lang/reflect/Executable;IZ)Z",
@@ -1592,7 +1592,7 @@
       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)I",
                                                       (void*)&WB_MatchesInline},
   {CC"shouldPrintAssembly",
-        CC"(Ljava/lang/reflect/Executable;)Z",
+        CC"(Ljava/lang/reflect/Executable;I)Z",
                                                         (void*)&WB_ShouldPrintAssembly},
 
   {CC"isConstantVMFlag",   CC"(Ljava/lang/String;)Z", (void*)&WB_IsConstantVMFlag},
--- a/hotspot/src/share/vm/runtime/vm_operations.cpp	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/src/share/vm/runtime/vm_operations.cpp	Thu Feb 25 14:47:08 2016 +0000
@@ -485,6 +485,10 @@
   }
 }
 
+void VM_PrintCompileQueue::doit() {
+  CompileBroker::print_compile_queues(_out);
+}
+
 #if INCLUDE_SERVICES
 void VM_PrintClassHierarchy::doit() {
   KlassHierarchy::print_class_hierarchy(_out, _print_interfaces, _print_subclasses, _classname);
--- a/hotspot/src/share/vm/runtime/vm_operations.hpp	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/src/share/vm/runtime/vm_operations.hpp	Thu Feb 25 14:47:08 2016 +0000
@@ -105,6 +105,7 @@
   template(DumpHashtable)                         \
   template(DumpTouchedMethods)                    \
   template(MarkActiveNMethods)                    \
+  template(PrintCompileQueue)                     \
   template(PrintClassHierarchy)                   \
 
 class VM_Operation: public CHeapObj<mtInternal> {
@@ -421,6 +422,17 @@
   void doit();
 };
 
+class VM_PrintCompileQueue: public VM_Operation {
+ private:
+  outputStream* _out;
+
+ public:
+  VM_PrintCompileQueue(outputStream* st) : _out(st) {}
+  VMOp_Type type() const { return VMOp_PrintCompileQueue; }
+  Mode evaluation_mode() const { return _safepoint; }
+  void doit();
+};
+
 #if INCLUDE_SERVICES
 class VM_PrintClassHierarchy: public VM_Operation {
  private:
--- a/hotspot/src/share/vm/services/diagnosticCommand.cpp	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp	Thu Feb 25 14:47:08 2016 +0000
@@ -832,7 +832,8 @@
 }
 
 void CompileQueueDCmd::execute(DCmdSource source, TRAPS) {
-  CompileBroker::print_compile_queues(output());
+  VM_PrintCompileQueue printCompileQueueOp(output());
+  VMThread::execute(&printCompileQueueOp);
 }
 
 void CodeListDCmd::execute(DCmdSource source, TRAPS) {
--- a/hotspot/src/share/vm/utilities/vmError.cpp	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/src/share/vm/utilities/vmError.cpp	Thu Feb 25 14:47:08 2016 +0000
@@ -1121,6 +1121,10 @@
   if (first_error_tid == -1 &&
       Atomic::cmpxchg_ptr(mytid, &first_error_tid, -1) == -1) {
 
+    // Initialize time stamps to use the same base.
+    out.time_stamp().update_to(1);
+    log.time_stamp().update_to(1);
+
     _id = id;
     _message = message;
     _thread = thread;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/c1/CanonicalizeArrayLength.java	Thu Feb 25 14:47:08 2016 +0000
@@ -0,0 +1,155 @@
+/*
+ * 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
+ * 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 8150102 8150514 8150534
+ * @summary C1 crashes in Canonicalizer::do_ArrayLength() after fix for JDK-8150102
+ * @run main/othervm -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation CanonicalizeArrayLength
+ * @run main/othervm -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:+PatchALot CanonicalizeArrayLength
+ * @run main/othervm -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:ScavengeRootsInCode=0 CanonicalizeArrayLength
+ * @run main/othervm -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:ScavengeRootsInCode=1 CanonicalizeArrayLength
+ */
+public class CanonicalizeArrayLength {
+    int[] arr = new int[42];
+    int[] arrNull = null;
+
+    final int[] finalArr = new int[42];
+    final int[] finalArrNull = null;
+
+    static int[] staticArr = new int[42];
+    static int[] staticArrNull = null;
+
+    static final int[] staticFinalArr = new int[42];
+    static final int[] staticFinalArrNull = null;
+
+    public static void main(String... args) {
+        CanonicalizeArrayLength t = new CanonicalizeArrayLength();
+        for (int i = 0; i < 20000; i++) {
+            if (t.testLocal() != 42)
+                throw new IllegalStateException();
+            if (t.testLocalNull() != 42)
+                throw new IllegalStateException();
+            if (t.testField() != 42)
+                throw new IllegalStateException();
+            if (t.testFieldNull() != 42)
+                throw new IllegalStateException();
+            if (t.testFinalField() != 42)
+                throw new IllegalStateException();
+            if (t.testFinalFieldNull() != 42)
+                throw new IllegalStateException();
+            if (t.testStaticField() != 42)
+                throw new IllegalStateException();
+            if (t.testStaticFieldNull() != 42)
+                throw new IllegalStateException();
+            if (t.testStaticFinalField() != 42)
+                throw new IllegalStateException();
+            if (t.testStaticFinalFieldNull() != 42)
+                throw new IllegalStateException();
+        }
+    }
+
+    int testField() {
+        try {
+            return arr.length;
+        } catch (Throwable t) {
+            return -1;
+        }
+    }
+
+    int testFieldNull() {
+        try {
+            return arrNull.length;
+        } catch (Throwable t) {
+            return 42;
+        }
+    }
+
+    int testFinalField() {
+        try {
+            return finalArr.length;
+        } catch (Throwable t) {
+            return -1;
+        }
+    }
+
+    int testFinalFieldNull() {
+        try {
+            return finalArrNull.length;
+        } catch (Throwable t) {
+            return 42;
+        }
+    }
+
+    int testStaticField() {
+        try {
+            return staticArr.length;
+        } catch (Throwable t) {
+            return -1;
+        }
+    }
+
+    int testStaticFieldNull() {
+        try {
+            return staticArrNull.length;
+        } catch (Throwable t) {
+            return 42;
+        }
+    }
+
+    int testStaticFinalField() {
+        try {
+            return staticFinalArr.length;
+        } catch (Throwable t) {
+            return -1;
+        }
+    }
+
+    int testStaticFinalFieldNull() {
+        try {
+            return staticFinalArrNull.length;
+        } catch (Throwable t) {
+            return 42;
+        }
+    }
+
+    int testLocal() {
+        int[] arr = new int[42];
+        try {
+            return arr.length;
+        } catch (Throwable t) {
+            return -1;
+        }
+    }
+
+    int testLocalNull() {
+        int[] arrNull = null;
+        try {
+            return arrNull.length;
+        } catch (Throwable t) {
+            return 42;
+        }
+    }
+
+
+}
--- a/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityBase.java	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityBase.java	Thu Feb 25 14:47:08 2016 +0000
@@ -24,25 +24,26 @@
 /*
  * @test TestCompilerDirectivesCompatibilityBase
  * @bug 8137167
- * @library /testlibrary /test/lib
+ * @library /testlibrary /test/lib /
  * @modules java.base/sun.misc
  *          java.compiler
  *          java.management
  * @build jdk.test.lib.*
- * @build jdk.test.lib.dcmd.*
- * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityBase
+ *        jdk.test.lib.dcmd.*
+ *        sun.hotspot.WhiteBox
+ *        compiler.testlibrary.CompilerUtils
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityBase
  * @summary Test compiler control compatibility with compile command
  */
 
+import compiler.testlibrary.CompilerUtils;
+import compiler.whitebox.CompilerWhiteBoxTest;
 import jdk.test.lib.dcmd.CommandExecutor;
 import jdk.test.lib.dcmd.JMXExecutor;
-
 import org.testng.annotations.Test;
 import org.testng.Assert;
-
 import sun.hotspot.WhiteBox;
 
 import java.io.BufferedReader;
@@ -64,32 +65,38 @@
         method  = getMethod(TestCompilerDirectivesCompatibilityBase.class, "helper");
         nomatch = getMethod(TestCompilerDirectivesCompatibilityBase.class, "another");
 
-        testCompatibility(executor);
+        int[] levels = CompilerUtils.getAvailableCompilationLevels();
+        for (int complevel : levels) {
+            // Only test the major compilers, ignore profiling levels
+            if (complevel == CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE || complevel == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION){
+                testCompatibility(executor, complevel);
+            }
+        }
     }
 
-    public void testCompatibility(CommandExecutor executor) throws Exception {
+    public void testCompatibility(CommandExecutor executor, int comp_level) throws Exception {
 
         // Call all validation twice to catch error when overwriting a directive
         // Flag is default off
         expect(!WB.getBooleanVMFlag("PrintAssembly"));
-        expect(!WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
-        expect(!WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
 
         // load directives that turn it on
         executor.execute("Compiler.directives_add " + control_on);
-        expect(WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
-        expect(WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
 
         // remove and see that it is true again
         executor.execute("Compiler.directives_remove");
-        expect(!WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
-        expect(!WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
     }
 
     public void expect(boolean test) throws Exception {
--- a/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOff.java	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOff.java	Thu Feb 25 14:47:08 2016 +0000
@@ -24,16 +24,17 @@
 /*
  * @test TestCompilerDirectivesCompatibilityCommandOff
  * @bug 8137167
- * @library /testlibrary /test/lib
+ * @library /testlibrary /test/lib /
  * @modules java.base/sun.misc
  *          java.compiler
  *          java.management
  * @build jdk.test.lib.*
- * @build jdk.test.lib.dcmd.*
- * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ *        jdk.test.lib.dcmd.*
+ *        sun.hotspot.WhiteBox
+ *        compiler.testlibrary.CompilerUtils
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions
  *      -XX:-PrintAssembly -XX:CompileCommand=option,*.helper,bool,PrintAssembly,false
  *      -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityCommandOff
  * @summary Test compiler control compatibility with compile command
@@ -55,27 +56,27 @@
 
 public class TestCompilerDirectivesCompatibilityCommandOff extends TestCompilerDirectivesCompatibilityBase {
 
-    public void testCompatibility(CommandExecutor executor) throws Exception {
+    public void testCompatibility(CommandExecutor executor, int comp_level) throws Exception {
 
         // Call all validation twice to catch error when overwriting a directive
         // Flag is default off
-        expect(!WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
-        expect(!WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
 
         // load directives that turn it on
         executor.execute("Compiler.directives_add " + control_on);
-        expect(WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
-        expect(WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
 
         // remove and see that it is false again
         executor.execute("Compiler.directives_remove");
-        expect(!WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
-        expect(!WB.shouldPrintAssembly(method));
-        expect(!WB.shouldPrintAssembly(nomatch));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(!WB.shouldPrintAssembly(nomatch, comp_level));
     }
 }
--- a/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOn.java	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityCommandOn.java	Thu Feb 25 14:47:08 2016 +0000
@@ -24,16 +24,17 @@
 /*
  * @test TestCompilerDirectivesCompatibilityCommandOn
  * @bug 8137167
- * @library /testlibrary /test/lib
+ * @library /testlibrary /test/lib /
  * @modules java.base/sun.misc
  *          java.compiler
  *          java.management
  * @build jdk.test.lib.*
- * @build jdk.test.lib.dcmd.*
- * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ *        jdk.test.lib.dcmd.*
+ *        sun.hotspot.WhiteBox
+ *        compiler.testlibrary.CompilerUtils
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions
  *      -XX:-PrintAssembly -XX:CompileCommand=print,*.* -XX:+WhiteBoxAPI
  *      TestCompilerDirectivesCompatibilityCommandOn
  * @summary Test compiler control compatibility with compile command
@@ -55,27 +56,27 @@
 
 public class TestCompilerDirectivesCompatibilityCommandOn extends TestCompilerDirectivesCompatibilityBase{
 
-    public void testCompatibility(CommandExecutor executor) throws Exception {
+    public void testCompatibility(CommandExecutor executor, int comp_level) throws Exception {
 
         // Call all validation twice to catch error when overwriting a directive
         // Flag is default on
-        expect(WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
-        expect(WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
 
         // load directives that turn it off
         executor.execute("Compiler.directives_add " + control_off);
-        expect(!WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
-        expect(!WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
 
         // remove and see that it is true again
         executor.execute("Compiler.directives_remove");
-        expect(WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
-        expect(WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
     }
 }
--- a/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityFlag.java	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/test/compiler/compilercontrol/TestCompilerDirectivesCompatibilityFlag.java	Thu Feb 25 14:47:08 2016 +0000
@@ -24,16 +24,17 @@
 /*
  * @test TestCompilerDirectivesCompatibilityFlag
  * @bug 8137167
- * @library /testlibrary /test/lib
+ * @library /testlibrary /test/lib /
  * @modules java.base/sun.misc
  *          java.compiler
  *          java.management
  * @build jdk.test.lib.*
- * @build jdk.test.lib.dcmd.*
- * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ *        jdk.test.lib.dcmd.*
+ *        sun.hotspot.WhiteBox
+ *        compiler.testlibrary.CompilerUtils
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run testng/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions
  *      -XX:+PrintAssembly -XX:+WhiteBoxAPI TestCompilerDirectivesCompatibilityFlag
  * @summary Test compiler control compatibility with compile command
  */
@@ -54,28 +55,28 @@
 
 public class TestCompilerDirectivesCompatibilityFlag extends TestCompilerDirectivesCompatibilityBase {
 
-    public void testCompatibility(CommandExecutor executor) throws Exception {
+    public void testCompatibility(CommandExecutor executor, int comp_level) throws Exception {
 
         // Call all validation twice to catch error when overwriting a directive
         // Flag is default on
         expect(WB.getBooleanVMFlag("PrintAssembly"));
-        expect(WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
-        expect(WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
 
         // load directives that turn it off
         executor.execute("Compiler.directives_add " + control_off);
-        expect(!WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
-        expect(!WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(!WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
 
         // remove and see that it is true again
         executor.execute("Compiler.directives_remove");
-        expect(WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
-        expect(WB.shouldPrintAssembly(method));
-        expect(WB.shouldPrintAssembly(nomatch));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
+        expect(WB.shouldPrintAssembly(method, comp_level));
+        expect(WB.shouldPrintAssembly(nomatch, comp_level));
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/native/TestDirtyInt.java	Thu Feb 25 14:47:08 2016 +0000
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * 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
+ * @run main/native TestDirtyInt
+ */
+public class TestDirtyInt {
+    static {
+        System.loadLibrary("TestDirtyInt");
+    }
+
+    native static int test(int v);
+
+    static int compiled(int v) {
+        return test(v<<2);
+    }
+
+    static public void main(String[] args) {
+        for (int i = 0; i < 20000; i++) {
+            int res = compiled(Integer.MAX_VALUE);
+            if (res != 0x42) {
+                throw new RuntimeException("Test failed");
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/native/libTestDirtyInt.c	Thu Feb 25 14:47:08 2016 +0000
@@ -0,0 +1,33 @@
+/*
+ * 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
+ * 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.
+ */
+
+#include "jni.h"
+#include <stdio.h>
+
+static int array = 0x42;
+
+JNIEXPORT jint JNICALL Java_TestDirtyInt_test(JNIEnv* env, jclass jclazz, jint v)
+{
+  int* ptr = &array + v + 4;
+  return *ptr;
+}
--- a/hotspot/test/serviceability/dcmd/compiler/CompilerQueueTest.java	Wed Feb 24 12:38:50 2016 +0000
+++ b/hotspot/test/serviceability/dcmd/compiler/CompilerQueueTest.java	Thu Feb 25 14:47:08 2016 +0000
@@ -24,25 +24,33 @@
 /*
  * @test CompilerQueueTest
  * @bug 8054889
- * @library /testlibrary
+ * @library /testlibrary /test/lib /
  * @modules java.base/sun.misc
  *          java.compiler
  *          java.management
  *          jdk.jvmstat/sun.jvmstat.monitor
- * @ignore 8069160
  * @build jdk.test.lib.*
- * @build jdk.test.lib.dcmd.*
- * @run testng CompilerQueueTest
- * @run testng/othervm -XX:-TieredCompilation CompilerQueueTest
- * @run testng/othervm -Xint CompilerQueueTest
+ *        jdk.test.lib.dcmd.*
+ *        sun.hotspot.WhiteBox
+ *        compiler.testlibrary.CompilerUtils
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmixed -XX:+WhiteBoxAPI CompilerQueueTest
+ * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmixed -XX:-TieredCompilation -XX:+WhiteBoxAPI CompilerQueueTest
+ * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xint -XX:+WhiteBoxAPI CompilerQueueTest
  * @summary Test of diagnostic command Compiler.queue
  */
 
+import compiler.testlibrary.CompilerUtils;
 import jdk.test.lib.OutputAnalyzer;
 import jdk.test.lib.dcmd.CommandExecutor;
 import jdk.test.lib.dcmd.JMXExecutor;
 import org.testng.annotations.Test;
+import org.testng.Assert;
+import sun.hotspot.WhiteBox;
 
+import java.lang.reflect.Executable;
+import java.lang.reflect.Method;
 import java.util.Iterator;
 
 public class CompilerQueueTest {
@@ -54,70 +62,123 @@
      *
      * Output example:
      *
-     * Contents of C1 compile queue
-     * ----------------------------
-     * 73       3       java.lang.AbstractStringBuilder::append (50 bytes)
-     * 74       1       java.util.TreeMap::size (5 bytes)
-     * 75       3       java.lang.StringBuilder::append (8 bytes)
-     * 83       3       java.util.TreeMap$ValueIterator::next (8 bytes)
-     * 84       1       javax.management.MBeanFeatureInfo::getName (5 bytes)
-     * ----------------------------
-     * Contents of C2 compile queue
-     * ----------------------------
+     * Current compiles:
+     * C1 CompilerThread14 267       3       java.net.URLStreamHandler::parseURL (1166 bytes)
+     * C1 CompilerThread13 760       3       javax.management.StandardMBean::getDescription (11 bytes)
+     * C1 CompilerThread12 757  s    3       com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory::getMapping (27 bytes)
+     * C1 CompilerThread11 756  s!   3       com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory::mappingForType (110 bytes)
+     * C1 CompilerThread10 761       3       java.lang.StringLatin1::indexOf (121 bytes)
+     * C2 CompilerThread7 769       4       CompilerQueueTest::testcaseMethod4 (1 bytes)
+     *
+     * C1 compile queue:
+     * 762       3       java.lang.invoke.MethodType::basicType (8 bytes)
+     * 763       3       java.util.ArrayList::rangeCheck (22 bytes)
+     * 764       3       java.util.ArrayList::elementData (7 bytes)
+     * 765       3       jdk.internal.org.objectweb.asm.MethodVisitor::<init> (35 bytes)
+     * 766       1       CompilerQueueTest::testcaseMethod1 (1 bytes)
+     * 767       2       CompilerQueueTest::testcaseMethod2 (1 bytes)
+     * 768       3       CompilerQueueTest::testcaseMethod3 (1 bytes)
+     * 770       3       java.util.Properties::getProperty (46 bytes)
+     *
+     * C2 compile queue:
      * Empty
-     * ----------------------------
      *
      **/
 
+    protected static final WhiteBox WB = WhiteBox.getWhiteBox();
+
     public void run(CommandExecutor executor) {
 
+        TestCase[] testcases = {
+                new TestCase(1, "testcaseMethod1"),
+                new TestCase(2, "testcaseMethod2"),
+                new TestCase(3, "testcaseMethod3"),
+                new TestCase(4, "testcaseMethod4"),
+        };
+
+        // Lock compilation makes all compiles stay in queue or compile thread before completion
+        WB.lockCompilation();
+
+        // Enqueue one test method for each available level
+        int[] complevels = CompilerUtils.getAvailableCompilationLevels();
+        for (int level : complevels) {
+            TestCase testcase = testcases[level - 1];
+
+            boolean added = WB.enqueueMethodForCompilation(testcase.method, testcase.level);
+            // Set results to false for those methods we must to find
+            // We will also assert if we find any test method we don't expect
+            Assert.assertTrue(WB.isMethodQueuedForCompilation(testcase.method));
+            testcase.check = false;
+        }
+
         // Get output from dcmd (diagnostic command)
         OutputAnalyzer output = executor.execute("Compiler.queue");
         Iterator<String> lines = output.asLines().iterator();
 
+        // Loop over output set result for all found methods
         while (lines.hasNext()) {
             String str = lines.next();
-            if (str.startsWith("Contents of C")) {
-                match(lines.next(), "----------------------------");
-                str = lines.next();
-                if (!str.equals("Empty")) {
-                    while (str.charAt(0) != '-') {
-                        validateMethodLine(str);
-                        str = lines.next();
+            // Fast check for common part of method name
+            if (str.contains("testcaseMethod")) {
+                for (TestCase testcase : testcases) {
+                    if (str.contains(testcase.methodName)) {
+                        Assert.assertFalse(testcase.check, "Must not be found or already found.");
+                        testcase.check = true;
                     }
-                } else {
-                    str = lines.next();
                 }
-                match(str,"----------------------------");
-            } else {
-                Assert.fail("Failed parsing dcmd queue, line: " + str);
             }
         }
-    }
 
-    private static void validateMethodLine(String str) {
-        // Skip until package/class name begins. Trim to remove whitespace that
-        // may differ.
-        String name = str.substring(14).trim();
-        int sep = name.indexOf("::");
-        if (sep == -1) {
-            Assert.fail("Failed dcmd queue, didn't find separator :: in: " + name);
+        for (TestCase testcase : testcases) {
+            if (!testcase.check) {
+                // If this method wasn't found it must have been removed by policy,
+                // verify that it is now removed from the queue
+                Assert.assertFalse(WB.isMethodQueuedForCompilation(testcase.method), "Must be found or not in queue");
+            }
+            // Otherwise all good.
         }
-        try {
-            Class.forName(name.substring(0, sep));
-        } catch (ClassNotFoundException e) {
-            Assert.fail("Failed dcmd queue, Class for name: " + str);
-        }
-    }
 
-    public static void match(String line, String str) {
-        if (!line.equals(str)) {
-            Assert.fail("String equals: " + line + ", " + str);
-        }
+        // Enable compilations again
+        WB.unlockCompilation();
     }
 
     @Test
     public void jmx() {
         run(new JMXExecutor());
     }
+
+    public void testcaseMethod1() {
+    }
+
+    public void testcaseMethod2() {
+    }
+
+    public void testcaseMethod3() {
+    }
+
+    public void testcaseMethod4() {
+    }
+
+    public static Method getMethod(Class klass, String name, Class<?>... parameterTypes) {
+        try {
+            return klass.getDeclaredMethod(name, parameterTypes);
+        } catch (NoSuchMethodException | SecurityException e) {
+            throw new RuntimeException("exception on getting method Helper." + name, e);
+        }
+    }
+
+    class TestCase {
+        Method method;
+        int level;
+        String methodName;
+        Boolean check;
+
+        public TestCase(int level, String methodName) {
+            this.method = getMethod(CompilerQueueTest.class, methodName);
+            this.level = level;
+            this.methodName = methodName;
+            this.check = true;
+        }
+    }
+
 }