changeset 12247:9ce79aaf2e0b

Merge
author rprotacio
date Wed, 26 Oct 2016 20:13:29 +0000
parents 46c8f9b67187 1ca21e468b1b
children d9aa9adb7dd2
files src/share/vm/utilities/quickSort.cpp test/compiler/ciReplay/TestSA.sh test/compiler/ciReplay/TestVM.sh test/compiler/ciReplay/TestVM_no_comp_level.sh test/compiler/ciReplay/common.sh
diffstat 156 files changed, 5515 insertions(+), 2172 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Oct 26 15:46:13 2016 -0400
+++ b/.hgtags	Wed Oct 26 20:13:29 2016 +0000
@@ -542,3 +542,5 @@
 dfcbf839e299e7e2bba1da69bdb347617ea4c7e8 jdk-9+137
 fc0956308c7a586267c5dd35dff74f773aa9c3eb jdk-9+138
 08492e67bf3226784dab3bf9ae967382ddbc1af5 jdk-9+139
+fec31089c2ef5a12dd64f401b0bf2e00f56ee0d0 jdk-9+140
+160a00bc6ed0af1fdf8418fc65e6bddbbc0c536d jdk-9+141
--- a/.mx.jvmci/.pydevproject	Wed Oct 26 15:46:13 2016 -0400
+++ b/.mx.jvmci/.pydevproject	Wed Oct 26 20:13:29 2016 +0000
@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?eclipse-pydev version="1.0"?>
-
-<pydev_project>
+<?eclipse-pydev version="1.0"?><pydev_project>
 <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
 <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
 <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
-<path>/mx.jvmci</path>
+<path>/.mx.jvmci</path>
 </pydev_pathproperty>
 <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
 <path>/mx</path>
--- a/make/lib/Lib-jdk.hotspot.agent.gmk	Wed Oct 26 15:46:13 2016 -0400
+++ b/make/lib/Lib-jdk.hotspot.agent.gmk	Wed Oct 26 20:13:29 2016 +0000
@@ -61,9 +61,8 @@
 
 else ifeq ($(OPENJDK_TARGET_OS), solaris)
   SA_TOOLCHAIN := TOOLCHAIN_LINK_CXX
-  COMMON_CFLAGS := -DSOLARIS_11_B159_OR_LATER
-  SA_CFLAGS := $(CFLAGS_JDKLIB) $(COMMON_CFLAGS)
-  SA_CXXFLAGS := $(CXXFLAGS_JDKLIB) $(COMMON_CFLAGS)
+  SA_CFLAGS := $(CFLAGS_JDKLIB)
+  SA_CXXFLAGS := $(CXXFLAGS_JDKLIB)
   SA_LDFLAGS := $(subst -Wl$(COMMA)-z$(COMMA)defs,, $(LDFLAGS_JDKLIB)) \
       -mt $(LDFLAGS_CXX_JDK)
   SA_LIBS := -ldl -ldemangle -lthread -lc
@@ -75,7 +74,7 @@
       -mstack-alignment=16 -fPIC
   SA_LDFLAGS := $(LDFLAGS_JDKLIB)
   SA_LIBS := -framework Foundation -framework JavaNativeFoundation \
-      -framework Security -framework CoreFoundation
+      -framework JavaRuntimeSupport -framework Security -framework CoreFoundation
 
 else ifeq ($(OPENJDK_TARGET_OS), windows)
   SA_NAME := sawindbg
--- a/src/cpu/aarch64/vm/frame_aarch64.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/aarch64/vm/frame_aarch64.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -142,6 +142,10 @@
       }
 
       sender_sp = _unextended_sp + _cb->frame_size();
+      // Is sender_sp safe?
+      if ((address)sender_sp >= thread->stack_base()) {
+        return false;
+      }
       sender_unextended_sp = sender_sp;
       sender_pc = (address) *(sender_sp-1);
       // Note: frame::sender_sp_offset is only valid for compiled frame
@@ -200,8 +204,15 @@
       }
 
       // construct the potential sender
+
       frame sender(sender_sp, sender_unextended_sp, saved_fp, sender_pc);
-      return sender.is_entry_frame_valid(thread);
+
+      // Validate the JavaCallWrapper an entry frame must have
+      address jcw = (address)sender.entry_frame_call_wrapper();
+
+      bool jcw_safe = (jcw < thread->stack_base()) && (jcw > (address)sender.fp());
+
+      return jcw_safe;
     }
 
     CompiledMethod* nm = sender_blob->as_compiled_method_or_null();
--- a/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1962,6 +1962,8 @@
       // due to cache line collision.
       __ serialize_memory(rthread, r2);
     }
+  } else {
+    __ strw(rscratch1, Address(rthread, JavaThread::thread_state_offset()));
   }
 
   // check for safepoint operation in progress and/or pending suspend requests
--- a/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -454,8 +454,9 @@
   __ str(zr, Address(rfp, frame::interpreter_frame_last_sp_offset * wordSize));
 
 #if INCLUDE_JVMCI
-  // Check if we need to take lock at entry of synchronized method.
-  if (UseJVMCICompiler) {
+  // Check if we need to take lock at entry of synchronized method.  This can
+  // only occur on method entry so emit it only for vtos with step 0.
+  if (UseJVMCICompiler && state == vtos && step == 0) {
     Label L;
     __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
     __ cbz(rscratch1, L);
@@ -464,6 +465,16 @@
     // Take lock.
     lock_method();
     __ bind(L);
+  } else {
+#ifdef ASSERT
+    if (UseJVMCICompiler) {
+      Label L;
+      __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
+      __ cbz(rscratch1, L);
+      __ stop("unexpected pending monitor in deopt entry");
+      __ bind(L);
+    }
+#endif
   }
 #endif
   // handle exceptions
--- a/src/cpu/ppc/vm/assembler_ppc.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/ppc/vm/assembler_ppc.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -2102,7 +2102,9 @@
   inline void mfvscr(   VectorRegister d);
 
   // Vector-Scalar (VSX) instructions.
+  inline void lxvd2x(   VectorSRegister d, Register a);
   inline void lxvd2x(   VectorSRegister d, Register a, Register b);
+  inline void stxvd2x(  VectorSRegister d, Register a);
   inline void stxvd2x(  VectorSRegister d, Register a, Register b);
   inline void mtvrd(    VectorRegister  d, Register a);
   inline void mfvrd(    Register        a, VectorRegister d);
--- a/src/cpu/ppc/vm/assembler_ppc.inline.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/ppc/vm/assembler_ppc.inline.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -734,8 +734,10 @@
 inline void Assembler::lvsr(  VectorRegister d, Register s1, Register s2) { emit_int32( LVSR_OPCODE   | vrt(d) | ra0mem(s1) | rb(s2)); }
 
 // Vector-Scalar (VSX) instructions.
-inline void Assembler::lxvd2x (VectorSRegister d, Register s1, Register s2) { emit_int32( LXVD2X_OPCODE  | vsrt(d) | ra(s1) | rb(s2)); }
-inline void Assembler::stxvd2x(VectorSRegister d, Register s1, Register s2) { emit_int32( STXVD2X_OPCODE | vsrt(d) | ra(s1) | rb(s2)); }
+inline void Assembler::lxvd2x (VectorSRegister d, Register s1) { emit_int32( LXVD2X_OPCODE  | vsrt(d) | ra(0) | rb(s1)); }
+inline void Assembler::lxvd2x (VectorSRegister d, Register s1, Register s2) { emit_int32( LXVD2X_OPCODE  | vsrt(d) | ra0mem(s1) | rb(s2)); }
+inline void Assembler::stxvd2x(VectorSRegister d, Register s1) { emit_int32( STXVD2X_OPCODE | vsrt(d) | ra(0) | rb(s1)); }
+inline void Assembler::stxvd2x(VectorSRegister d, Register s1, Register s2) { emit_int32( STXVD2X_OPCODE | vsrt(d) | ra0mem(s1) | rb(s2)); }
 inline void Assembler::mtvrd(  VectorRegister  d, Register a)               { emit_int32( MTVSRD_OPCODE  | vrt(d)  | ra(a)  | 1u); } // 1u: d is treated as Vector (VMX/Altivec).
 inline void Assembler::mfvrd(  Register        a, VectorRegister d)         { emit_int32( MFVSRD_OPCODE  | vrt(d)  | ra(a)  | 1u); } // 1u: d is treated as Vector (VMX/Altivec).
 
--- a/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1894,6 +1894,22 @@
     __ beq(combined_check, slow);
   }
 
+  if (flags & LIR_OpArrayCopy::type_check) {
+    if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) {
+      __ load_klass(tmp, dst);
+      __ lwz(tmp2, in_bytes(Klass::layout_helper_offset()), tmp);
+      __ cmpwi(CCR0, tmp2, Klass::_lh_neutral_value);
+      __ bge(CCR0, slow);
+    }
+
+    if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) {
+      __ load_klass(tmp, src);
+      __ lwz(tmp2, in_bytes(Klass::layout_helper_offset()), tmp);
+      __ cmpwi(CCR0, tmp2, Klass::_lh_neutral_value);
+      __ bge(CCR0, slow);
+    }
+  }
+
   // Higher 32bits must be null.
   __ extsw(length, length);
 
--- a/src/cpu/ppc/vm/stubGenerator_ppc.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/ppc/vm/stubGenerator_ppc.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1220,8 +1220,8 @@
       __ bind(l_10);
       // Use loop with VSX load/store instructions to
       // copy 32 elements a time.
-      __ lxvd2x(tmp_vsr1, 0, R3_ARG1);     // Load src
-      __ stxvd2x(tmp_vsr1, 0, R4_ARG2);    // Store to dst
+      __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load src
+      __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst
       __ lxvd2x(tmp_vsr2, tmp1, R3_ARG1);  // Load src + 16
       __ stxvd2x(tmp_vsr2, tmp1, R4_ARG2); // Store to dst + 16
       __ addi(R3_ARG1, R3_ARG1, 32);       // Update src+=32
@@ -1486,8 +1486,8 @@
         __ bind(l_9);
         // Use loop with VSX load/store instructions to
         // copy 16 elements a time.
-        __ lxvd2x(tmp_vsr1, 0, R3_ARG1);     // Load from src.
-        __ stxvd2x(tmp_vsr1, 0, R4_ARG2);    // Store to dst.
+        __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load from src.
+        __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst.
         __ lxvd2x(tmp_vsr2, R3_ARG1, tmp1);  // Load from src + 16.
         __ stxvd2x(tmp_vsr2, R4_ARG2, tmp1); // Store to dst + 16.
         __ addi(R3_ARG1, R3_ARG1, 32);       // Update src+=32.
@@ -1677,8 +1677,8 @@
       __ bind(l_7);
       // Use loop with VSX load/store instructions to
       // copy 8 elements a time.
-      __ lxvd2x(tmp_vsr1, 0, R3_ARG1);     // Load src
-      __ stxvd2x(tmp_vsr1, 0, R4_ARG2);    // Store to dst
+      __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load src
+      __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst
       __ lxvd2x(tmp_vsr2, tmp1, R3_ARG1);  // Load src + 16
       __ stxvd2x(tmp_vsr2, tmp1, R4_ARG2); // Store to dst + 16
       __ addi(R3_ARG1, R3_ARG1, 32);       // Update src+=32
@@ -1745,13 +1745,16 @@
     // Do reverse copy.  We assume the case of actual overlap is rare enough
     // that we don't have to optimize it.
 
-    Label l_1, l_2, l_3, l_4, l_5, l_6;
+    Label l_1, l_2, l_3, l_4, l_5, l_6, l_7;
 
     Register tmp1 = R6_ARG4;
     Register tmp2 = R7_ARG5;
     Register tmp3 = R8_ARG6;
     Register tmp4 = R0;
 
+    VectorSRegister tmp_vsr1  = VSR1;
+    VectorSRegister tmp_vsr2  = VSR2;
+
     { // FasterArrayCopy
       __ cmpwi(CCR0, R5_ARG3, 0);
       __ beq(CCR0, l_6);
@@ -1761,6 +1764,25 @@
       __ add(R4_ARG2, R4_ARG2, R5_ARG3);
       __ srdi(R5_ARG3, R5_ARG3, 2);
 
+      if (!aligned) {
+        // check if arrays have same alignment mod 8.
+        __ xorr(tmp1, R3_ARG1, R4_ARG2);
+        __ andi_(R0, tmp1, 7);
+        // Not the same alignment, but ld and std just need to be 4 byte aligned.
+        __ bne(CCR0, l_7); // to OR from is 8 byte aligned -> copy 2 at a time
+
+        // copy 1 element to align to and from on an 8 byte boundary
+        __ andi_(R0, R3_ARG1, 7);
+        __ beq(CCR0, l_7);
+
+        __ addi(R3_ARG1, R3_ARG1, -4);
+        __ addi(R4_ARG2, R4_ARG2, -4);
+        __ addi(R5_ARG3, R5_ARG3, -1);
+        __ lwzx(tmp2, R3_ARG1);
+        __ stwx(tmp2, R4_ARG2);
+        __ bind(l_7);
+      }
+
       __ cmpwi(CCR0, R5_ARG3, 7);
       __ ble(CCR0, l_5); // copy 1 at a time if less than 8 elements remain
 
@@ -1768,6 +1790,7 @@
       __ andi(R5_ARG3, R5_ARG3, 7);
       __ mtctr(tmp1);
 
+     if (!VM_Version::has_vsx()) {
       __ bind(l_4);
       // Use unrolled version for mass copying (copy 4 elements a time).
       // Load feeding store gets zero latency on Power6, however not on Power5.
@@ -1783,6 +1806,40 @@
       __ std(tmp2, 8, R4_ARG2);
       __ std(tmp1, 0, R4_ARG2);
       __ bdnz(l_4);
+     } else {  // Processor supports VSX, so use it to mass copy.
+      // Prefetch the data into the L2 cache.
+      __ dcbt(R3_ARG1, 0);
+
+      // If supported set DSCR pre-fetch to deepest.
+      if (VM_Version::has_mfdscr()) {
+        __ load_const_optimized(tmp2, VM_Version::_dscr_val | 7);
+        __ mtdscr(tmp2);
+      }
+
+      __ li(tmp1, 16);
+
+      // Backbranch target aligned to 32-byte. Not 16-byte align as
+      // loop contains < 8 instructions that fit inside a single
+      // i-cache sector.
+      __ align(32);
+
+      __ bind(l_4);
+      // Use loop with VSX load/store instructions to
+      // copy 8 elements a time.
+      __ addi(R3_ARG1, R3_ARG1, -32);      // Update src-=32
+      __ addi(R4_ARG2, R4_ARG2, -32);      // Update dsc-=32
+      __ lxvd2x(tmp_vsr2, tmp1, R3_ARG1);  // Load src+16
+      __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load src
+      __ stxvd2x(tmp_vsr2, tmp1, R4_ARG2); // Store to dst+16
+      __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst
+      __ bdnz(l_4);
+
+      // Restore DSCR pre-fetch value.
+      if (VM_Version::has_mfdscr()) {
+        __ load_const_optimized(tmp2, VM_Version::_dscr_val);
+        __ mtdscr(tmp2);
+      }
+     }
 
       __ cmpwi(CCR0, R5_ARG3, 0);
       __ beq(CCR0, l_6);
@@ -1892,8 +1949,8 @@
       __ bind(l_5);
       // Use loop with VSX load/store instructions to
       // copy 4 elements a time.
-      __ lxvd2x(tmp_vsr1, 0, R3_ARG1);     // Load src
-      __ stxvd2x(tmp_vsr1, 0, R4_ARG2);    // Store to dst
+      __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load src
+      __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst
       __ lxvd2x(tmp_vsr2, tmp1, R3_ARG1);  // Load src + 16
       __ stxvd2x(tmp_vsr2, tmp1, R4_ARG2); // Store to dst + 16
       __ addi(R3_ARG1, R3_ARG1, 32);       // Update src+=32
@@ -1962,6 +2019,9 @@
     Register tmp3 = R8_ARG6;
     Register tmp4 = R0;
 
+    VectorSRegister tmp_vsr1  = VSR1;
+    VectorSRegister tmp_vsr2  = VSR2;
+
     Label l_1, l_2, l_3, l_4, l_5;
 
     __ cmpwi(CCR0, R5_ARG3, 0);
@@ -1980,6 +2040,7 @@
       __ andi(R5_ARG3, R5_ARG3, 3);
       __ mtctr(tmp1);
 
+     if (!VM_Version::has_vsx()) {
       __ bind(l_4);
       // Use unrolled version for mass copying (copy 4 elements a time).
       // Load feeding store gets zero latency on Power6, however not on Power5.
@@ -1995,6 +2056,40 @@
       __ std(tmp2, 8, R4_ARG2);
       __ std(tmp1, 0, R4_ARG2);
       __ bdnz(l_4);
+     } else { // Processor supports VSX, so use it to mass copy.
+      // Prefetch the data into the L2 cache.
+      __ dcbt(R3_ARG1, 0);
+
+      // If supported set DSCR pre-fetch to deepest.
+      if (VM_Version::has_mfdscr()) {
+        __ load_const_optimized(tmp2, VM_Version::_dscr_val | 7);
+        __ mtdscr(tmp2);
+      }
+
+      __ li(tmp1, 16);
+
+      // Backbranch target aligned to 32-byte. Not 16-byte align as
+      // loop contains < 8 instructions that fit inside a single
+      // i-cache sector.
+      __ align(32);
+
+      __ bind(l_4);
+      // Use loop with VSX load/store instructions to
+      // copy 4 elements a time.
+      __ addi(R3_ARG1, R3_ARG1, -32);      // Update src-=32
+      __ addi(R4_ARG2, R4_ARG2, -32);      // Update dsc-=32
+      __ lxvd2x(tmp_vsr2, tmp1, R3_ARG1);  // Load src+16
+      __ lxvd2x(tmp_vsr1, R3_ARG1);        // Load src
+      __ stxvd2x(tmp_vsr2, tmp1, R4_ARG2); // Store to dst+16
+      __ stxvd2x(tmp_vsr1, R4_ARG2);       // Store to dst
+      __ bdnz(l_4);
+
+      // Restore DSCR pre-fetch value.
+      if (VM_Version::has_mfdscr()) {
+        __ load_const_optimized(tmp2, VM_Version::_dscr_val);
+        __ mtdscr(tmp2);
+      }
+     }
 
       __ cmpwi(CCR0, R5_ARG3, 0);
       __ beq(CCR0, l_1);
--- a/src/cpu/ppc/vm/vm_version_ppc.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/ppc/vm/vm_version_ppc.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -656,7 +656,7 @@
   a->vpmsumb(VR0, VR1, VR2);                   // code[11] -> vpmsumb
   a->tcheck(0);                                // code[12] -> tcheck
   a->mfdscr(R0);                               // code[13] -> mfdscr
-  a->lxvd2x(VSR0, 0, R3_ARG1);                 // code[14] -> vsx
+  a->lxvd2x(VSR0, R3_ARG1);                    // code[14] -> vsx
   a->blr();
 
   // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it.
--- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -2034,6 +2034,27 @@
     __ delayed()->nop();
   }
 
+  // If the compiler was not able to prove that exact type of the source or the destination
+  // of the arraycopy is an array type, check at runtime if the source or the destination is
+  // an instance type.
+  if (flags & LIR_OpArrayCopy::type_check) {
+    if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) {
+      __ load_klass(dst, tmp);
+      __ lduw(tmp, in_bytes(Klass::layout_helper_offset()), tmp2);
+      __ cmp(tmp2, Klass::_lh_neutral_value);
+      __ br(Assembler::greaterEqual, false, Assembler::pn, *stub->entry());
+      __ delayed()->nop();
+    }
+
+    if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) {
+      __ load_klass(src, tmp);
+      __ lduw(tmp, in_bytes(Klass::layout_helper_offset()), tmp2);
+      __ cmp(tmp2, Klass::_lh_neutral_value);
+      __ br(Assembler::greaterEqual, false, Assembler::pn, *stub->entry());
+      __ delayed()->nop();
+    }
+  }
+
   if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
     // test src_pos register
     __ cmp_zero_and_br(Assembler::less, src_pos, *stub->entry());
--- a/src/cpu/sparc/vm/frame_sparc.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/sparc/vm/frame_sparc.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -279,7 +279,13 @@
     }
 
     if (sender.is_entry_frame()) {
-      return sender.is_entry_frame_valid(thread);
+      // Validate the JavaCallWrapper an entry frame must have
+
+      address jcw = (address)sender.entry_frame_call_wrapper();
+
+      bool jcw_safe = (jcw <= thread->stack_base()) && (jcw > sender_fp);
+
+      return jcw_safe;
     }
 
     // If the frame size is 0 something (or less) is bad because every nmethod has a non-zero frame size
--- a/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -384,8 +384,9 @@
   address entry = __ pc();
   __ get_constant_pool_cache(LcpoolCache); // load LcpoolCache
 #if INCLUDE_JVMCI
-  // Check if we need to take lock at entry of synchronized method.
-  if (UseJVMCICompiler) {
+  // Check if we need to take lock at entry of synchronized method.  This can
+  // only occur on method entry so emit it only for vtos with step 0.
+  if (UseJVMCICompiler && state == vtos && step == 0) {
     Label L;
     Address pending_monitor_enter_addr(G2_thread, JavaThread::pending_monitorenter_offset());
     __ ldbool(pending_monitor_enter_addr, Gtemp);  // Load if pending monitor enter
@@ -395,6 +396,17 @@
     // Take lock.
     lock_method();
     __ bind(L);
+  } else {
+#ifdef ASSERT
+    if (UseJVMCICompiler) {
+      Label L;
+      Address pending_monitor_enter_addr(G2_thread, JavaThread::pending_monitorenter_offset());
+      __ ldbool(pending_monitor_enter_addr, Gtemp);  // Load if pending monitor enter
+      __ cmp_and_br_short(Gtemp, G0, Assembler::equal, Assembler::pn, L);
+      __ stop("unexpected pending monitor in deopt entry");
+      __ bind(L);
+    }
+#endif
   }
 #endif
   { Label L;
--- a/src/cpu/sparc/vm/vm_version_sparc.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/sparc/vm/vm_version_sparc.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -457,9 +457,10 @@
 
 unsigned int VM_Version::calc_parallel_worker_threads() {
   unsigned int result;
-  if (is_M_series()) {
-    // for now, use same gc thread calculation for M-series as for niagara-plus
-    // in future, we may want to tweak parameters for nof_parallel_worker_thread
+  if (is_M_series() || is_S_series()) {
+    // for now, use same gc thread calculation for M-series and S-series as for
+    // niagara-plus. In future, we may want to tweak parameters for
+    // nof_parallel_worker_thread
     result = nof_parallel_worker_threads(5, 16, 8);
   } else if (is_niagara_plus()) {
     result = nof_parallel_worker_threads(5, 16, 8);
@@ -483,6 +484,9 @@
   } else if (strstr(impl, "SPARC-M") != NULL) {
     // M-series SPARC is based on T-series.
     features |= (M_family_m | T_family_m);
+  } else if (strstr(impl, "SPARC-S") != NULL) {
+    // S-series SPARC is based on T-series.
+    features |= (S_family_m | T_family_m);
   } else if (strstr(impl, "SPARC-T") != NULL) {
     features |= T_family_m;
     if (strstr(impl, "SPARC-T1") != NULL) {
--- a/src/cpu/sparc/vm/vm_version_sparc.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/sparc/vm/vm_version_sparc.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -49,14 +49,15 @@
     cbcond_instructions   = 12,
     sparc64_family        = 13,
     M_family              = 14,
-    T_family              = 15,
-    T1_model              = 16,
-    sparc5_instructions   = 17,
-    aes_instructions      = 18,
-    sha1_instruction      = 19,
-    sha256_instruction    = 20,
-    sha512_instruction    = 21,
-    crc32c_instruction    = 22
+    S_family              = 15,
+    T_family              = 16,
+    T1_model              = 17,
+    sparc5_instructions   = 18,
+    aes_instructions      = 19,
+    sha1_instruction      = 20,
+    sha256_instruction    = 21,
+    sha512_instruction    = 22,
+    crc32c_instruction    = 23
   };
 
   enum Feature_Flag_Set {
@@ -78,6 +79,7 @@
     cbcond_instructions_m   = 1 << cbcond_instructions,
     sparc64_family_m        = 1 << sparc64_family,
     M_family_m              = 1 << M_family,
+    S_family_m              = 1 << S_family,
     T_family_m              = 1 << T_family,
     T1_model_m              = 1 << T1_model,
     sparc5_instructions_m   = 1 << sparc5_instructions,
@@ -105,6 +107,7 @@
 
   // Returns true if the platform is in the niagara line (T series)
   static bool is_M_family(int features) { return (features & M_family_m) != 0; }
+  static bool is_S_family(int features) { return (features & S_family_m) != 0; }
   static bool is_T_family(int features) { return (features & T_family_m) != 0; }
   static bool is_niagara() { return is_T_family(_features); }
 #ifdef ASSERT
@@ -153,6 +156,7 @@
   static bool is_niagara_plus()         { return is_T_family(_features) && !is_T1_model(_features); }
 
   static bool is_M_series()             { return is_M_family(_features); }
+  static bool is_S_series()             { return is_S_family(_features); }
   static bool is_T4()                   { return is_T_family(_features) && has_cbcond(); }
   static bool is_T7()                   { return is_T_family(_features) && has_sparc5_instr(); }
 
--- a/src/cpu/x86/vm/assembler_x86.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/assembler_x86.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -2461,6 +2461,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.reset_is_clear_context();
   simd_prefix(src, xnoreg, dst, VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
   emit_int8(0x7F);
   emit_operand(src, dst);
@@ -2490,6 +2491,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_256bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.reset_is_clear_context();
   // swap src<->dst for encoding
   assert(src != xnoreg, "sanity");
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
@@ -2590,6 +2592,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.reset_is_clear_context();
   attributes.set_embedded_opmask_register_specifier(mask);
   attributes.set_is_evex_instruction();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
@@ -2623,6 +2626,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.reset_is_clear_context();
   attributes.set_is_evex_instruction();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
   emit_int8(0x7F);
@@ -2655,6 +2659,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.reset_is_clear_context();
   attributes.set_is_evex_instruction();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
   emit_int8(0x7F);
@@ -2794,6 +2799,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit);
+  attributes.reset_is_clear_context();
   attributes.set_rex_vex_w_reverted();
   simd_prefix(src, xnoreg, dst, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes);
   emit_int8(0x11);
@@ -2823,6 +2829,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_32bit);
+  attributes.reset_is_clear_context();
   simd_prefix(src, xnoreg, dst, VEX_SIMD_F3, VEX_OPCODE_0F, &attributes);
   emit_int8(0x11);
   emit_operand(src, dst);
@@ -3291,6 +3298,15 @@
   emit_int8(imm8);
 }
 
+void Assembler::vperm2f128(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8) {
+  assert(VM_Version::supports_avx(), "");
+  InstructionAttr attributes(AVX_256bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8(0x06);
+  emit_int8(0xC0 | encode);
+  emit_int8(imm8);
+}
+
 
 void Assembler::pause() {
   emit_int8((unsigned char)0xF3);
@@ -3362,6 +3378,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.reset_is_clear_context();
   attributes.set_embedded_opmask_register_specifier(mask);
   attributes.set_is_evex_instruction();
   int dst_enc = kdst->encoding();
@@ -3384,6 +3401,7 @@
   assert(is_vector_masking(), "");
   assert(VM_Version::supports_avx512vlbw(), "");
   InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  attributes.reset_is_clear_context();
   attributes.set_embedded_opmask_register_specifier(mask);
   attributes.set_is_evex_instruction();
   int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
@@ -3423,6 +3441,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_reg_mask */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.reset_is_clear_context();
   attributes.set_embedded_opmask_register_specifier(mask);
   attributes.set_is_evex_instruction();
   vex_prefix(src, nds->encoding(), kdst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
@@ -3493,6 +3512,7 @@
   assert(VM_Version::supports_evex(), "");
   InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_is_evex_instruction();
+  attributes.reset_is_clear_context();
   int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
   emit_int8(0x76);
   emit_int8((unsigned char)(0xC0 | encode));
@@ -3503,6 +3523,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_32bit);
+  attributes.reset_is_clear_context();
   attributes.set_is_evex_instruction();
   int dst_enc = kdst->encoding();
   vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
@@ -3532,6 +3553,7 @@
 void Assembler::evpcmpeqq(KRegister kdst, XMMRegister nds, XMMRegister src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
   InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.reset_is_clear_context();
   attributes.set_is_evex_instruction();
   int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
   emit_int8(0x29);
@@ -3543,6 +3565,7 @@
   assert(VM_Version::supports_evex(), "");
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  attributes.reset_is_clear_context();
   attributes.set_is_evex_instruction();
   attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit);
   int dst_enc = kdst->encoding();
@@ -3763,6 +3786,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_HVM, /* input_size_in_bits */ EVEX_NObit);
+  attributes.reset_is_clear_context();
   attributes.set_embedded_opmask_register_specifier(mask);
   attributes.set_is_evex_instruction();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes);
@@ -6208,6 +6232,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4, /* input_size_in_bits */ EVEX_32bit);
+  attributes.reset_is_clear_context();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x39);
   emit_operand(src, dst);
@@ -6238,6 +6263,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4, /* input_size_in_bits */ EVEX_32bit);
+  attributes.reset_is_clear_context();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x39);
   emit_operand(src, dst);
@@ -6298,6 +6324,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4, /* input_size_in_bits */ EVEX_32bit);
+  attributes.reset_is_clear_context();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x19);
   emit_operand(src, dst);
@@ -6328,6 +6355,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4, /* input_size_in_bits */ EVEX_32bit);
+  attributes.reset_is_clear_context();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x19);
   emit_operand(src, dst);
@@ -6371,6 +6399,7 @@
   InstructionMark im(this);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4,/* input_size_in_bits */  EVEX_64bit);
+  attributes.reset_is_clear_context();
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x1B);
   emit_operand(src, dst);
@@ -7181,7 +7210,9 @@
   // fourth EVEX.L'L for vector length : 0 is 128, 1 is 256, 2 is 512, currently we do not support 1024
   byte4 |= ((_attributes->get_vector_len())& 0x3) << 5;
   // last is EVEX.z for zero/merge actions
-  byte4 |= (_attributes->is_clear_context() ? EVEX_Z : 0);
+  if (_attributes->is_no_reg_mask() == false) {
+    byte4 |= (_attributes->is_clear_context() ? EVEX_Z : 0);
+  }
   emit_int8(byte4);
 }
 
@@ -7337,7 +7368,7 @@
   emit_int8((unsigned char)(0xF & cop));
 }
 
-void Assembler::vpblendd(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len) {
+void Assembler::blendvpd(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len) {
   assert(VM_Version::supports_avx(), "");
   assert(!VM_Version::supports_evex(), "");
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
@@ -7348,6 +7379,15 @@
   emit_int8((unsigned char)(0xF0 & src2_enc<<4));
 }
 
+void Assembler::vpblendd(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8, int vector_len) {
+  assert(VM_Version::supports_avx2(), "");
+  InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8((unsigned char)0x02);
+  emit_int8((unsigned char)(0xC0 | encode));
+  emit_int8((unsigned char)imm8);
+}
+
 void Assembler::shlxl(Register dst, Register src1, Register src2) {
   assert(VM_Version::supports_bmi2(), "");
   InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
--- a/src/cpu/x86/vm/assembler_x86.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/assembler_x86.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1550,6 +1550,7 @@
   void vpermq(XMMRegister dst, XMMRegister src, int imm8, int vector_len);
   void vpermq(XMMRegister dst, XMMRegister src, int imm8);
   void vperm2i128(XMMRegister dst,  XMMRegister nds, XMMRegister src, int imm8);
+  void vperm2f128(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8);
 
   void pause();
 
@@ -2105,7 +2106,8 @@
 
   // AVX support for vectorized conditional move (double). The following two instructions used only coupled.
   void cmppd(XMMRegister dst, XMMRegister nds, XMMRegister src, int cop, int vector_len);
-  void vpblendd(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len);
+  void blendvpd(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len);
+  void vpblendd(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8, int vector_len);
 
  protected:
   // Next instructions require address alignment 16 bytes SSE mode.
@@ -2139,7 +2141,7 @@
       _input_size_in_bits(Assembler::EVEX_NObit),
       _is_evex_instruction(false),
       _evex_encoding(0),
-      _is_clear_context(false),
+      _is_clear_context(true),
       _is_extended_context(false),
       _current_assembler(NULL),
       _embedded_opmask_register_specifier(1) { // hard code k1, it will be initialized for now
@@ -2205,7 +2207,7 @@
   void set_evex_encoding(int value) { _evex_encoding = value; }
 
   // Set the Evex.Z field to be used to clear all non directed XMM/YMM/ZMM components
-  void set_is_clear_context(void) { _is_clear_context = true; }
+  void reset_is_clear_context(void) { _is_clear_context = false; }
 
   // Map back to current asembler so that we can manage object level assocation
   void set_current_assembler(Assembler *current_assembler) { _current_assembler = current_assembler; }
--- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -3146,6 +3146,23 @@
     __ jcc(Assembler::zero, *stub->entry());
   }
 
+  // If the compiler was not able to prove that exact type of the source or the destination
+  // of the arraycopy is an array type, check at runtime if the source or the destination is
+  // an instance type.
+  if (flags & LIR_OpArrayCopy::type_check) {
+    if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
+      __ load_klass(tmp, dst);
+      __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value);
+      __ jcc(Assembler::greaterEqual, *stub->entry());
+    }
+
+    if (!(flags & LIR_OpArrayCopy::src_objarray)) {
+      __ load_klass(tmp, src);
+      __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value);
+      __ jcc(Assembler::greaterEqual, *stub->entry());
+    }
+  }
+
   // check if negative
   if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
     __ testl(src_pos, src_pos);
--- a/src/cpu/x86/vm/frame_x86.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/frame_x86.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -140,6 +140,10 @@
       }
 
       sender_sp = _unextended_sp + _cb->frame_size();
+      // Is sender_sp safe?
+      if ((address)sender_sp >= thread->stack_base()) {
+        return false;
+      }
       sender_unextended_sp = sender_sp;
       // On Intel the return_address is always the word on the stack
       sender_pc = (address) *(sender_sp-1);
@@ -199,8 +203,15 @@
       }
 
       // construct the potential sender
+
       frame sender(sender_sp, sender_unextended_sp, saved_fp, sender_pc);
-      return sender.is_entry_frame_valid(thread);
+
+      // Validate the JavaCallWrapper an entry frame must have
+      address jcw = (address)sender.entry_frame_call_wrapper();
+
+      bool jcw_safe = (jcw < thread->stack_base()) && (jcw > (address)sender.fp());
+
+      return jcw_safe;
     }
 
     CompiledMethod* nm = sender_blob->as_compiled_method_or_null();
--- a/src/cpu/x86/vm/macroAssembler_x86.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/macroAssembler_x86.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -4309,6 +4309,15 @@
   }
 }
 
+void MacroAssembler::vpand(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len) {
+  if (reachable(src)) {
+    Assembler::vpand(dst, nds, as_Address(src), vector_len);
+  } else {
+    lea(rscratch1, src);
+    Assembler::vpand(dst, nds, Address(rscratch1, 0), vector_len);
+  }
+}
+
 void MacroAssembler::vpbroadcastw(XMMRegister dst, XMMRegister src) {
   int dst_enc = dst->encoding();
   int src_enc = src->encoding();
--- a/src/cpu/x86/vm/macroAssembler_x86.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/macroAssembler_x86.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -943,6 +943,23 @@
                    bool multi_block, XMMRegister shuf_mask);
 #endif
 
+#ifdef _LP64
+ private:
+  void sha512_AVX2_one_round_compute(Register old_h, Register a, Register b, Register c, Register d,
+                                     Register e, Register f, Register g, Register h, int iteration);
+
+  void sha512_AVX2_one_round_and_schedule(XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
+                                          Register a, Register b, Register c, Register d, Register e, Register f,
+                                          Register g, Register h, int iteration);
+
+  void addmq(int disp, Register r1, Register r2);
+ public:
+  void sha512_AVX2(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0,
+                   XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4,
+                   Register buf, Register state, Register ofs, Register limit, Register rsp, bool multi_block,
+                   XMMRegister shuf_mask);
+#endif
+
   void fast_sha1(XMMRegister abcd, XMMRegister e0, XMMRegister e1, XMMRegister msg0,
                  XMMRegister msg1, XMMRegister msg2, XMMRegister msg3, XMMRegister shuf_mask,
                  Register buf, Register state, Register ofs, Register limit, Register rsp,
@@ -1177,6 +1194,10 @@
   void vpaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
   void vpaddw(XMMRegister dst, XMMRegister nds, Address src, int vector_len);
 
+  void vpand(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { Assembler::vpand(dst, nds, src, vector_len); }
+  void vpand(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { Assembler::vpand(dst, nds, src, vector_len); }
+  void vpand(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len);
+
   void vpbroadcastw(XMMRegister dst, XMMRegister src);
 
   void vpcmpeqb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
--- a/src/cpu/x86/vm/macroAssembler_x86_sha.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/macroAssembler_x86_sha.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -674,6 +674,11 @@
   movl(Address(r1, disp), r2);
 }
 
+void MacroAssembler::addmq(int disp, Register r1, Register r2) {
+  addq(r2, Address(r1, disp));
+  movq(Address(r1, disp), r2);
+}
+
 void MacroAssembler::sha256_AVX2(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0,
   XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4,
   Register buf, Register state, Register ofs, Register limit, Register rsp,
@@ -1026,4 +1031,488 @@
 bind(compute_size_end1);
   }
 }
+
+void MacroAssembler::sha512_AVX2_one_round_compute(Register  old_h, Register a, Register b, Register c,
+                                                   Register d, Register e, Register f, Register g, Register h,
+                                                   int iteration)
+{
+
+    const Register& y0 = r13;
+    const Register& y1 = r14;
+    const Register& y2 = r15;
+#ifdef _WIN64
+    const Register& y3 = rcx;
+#else
+    const Register& y3 = rdi;
+#endif
+    const Register& T1 = r12;
+
+    if (iteration % 4 > 0) {
+      addq(old_h, y2); //h = k + w + h + S0 + S1 + CH = t1 + S0;
+    }
+    movq(y2, f); //y2 = f; CH
+    rorxq(y0, e, 41); //y0 = e >> 41; S1A
+    rorxq(y1, e, 18); //y1 = e >> 18; S1B
+    xorq(y2, g); //y2 = f^g; CH
+
+    xorq(y0, y1); //y0 = (e >> 41) ^ (e >> 18); S1
+    rorxq(y1, e, 14); //y1 = (e >> 14); S1
+    andq(y2, e); //y2 = (f^g)&e; CH
+
+    if (iteration % 4 > 0 ) {
+      addq(old_h, y3); //h = t1 + S0 + MAJ
+    }
+    xorq(y0, y1); //y0 = (e >> 41) ^ (e >> 18) ^ (e >> 14); S1
+    rorxq(T1, a, 34); //T1 = a >> 34; S0B
+    xorq(y2, g); //y2 = CH = ((f^g)&e) ^g; CH
+    rorxq(y1, a, 39); //y1 = a >> 39; S0A
+    movq(y3, a); //y3 = a; MAJA
+
+    xorq(y1, T1); //y1 = (a >> 39) ^ (a >> 34); S0
+    rorxq(T1, a, 28); //T1 = (a >> 28); S0
+    addq(h, Address(rsp, (8 * iteration))); //h = k + w + h; --
+    orq(y3, c); //y3 = a | c; MAJA
+
+    xorq(y1, T1); //y1 = (a >> 39) ^ (a >> 34) ^ (a >> 28); S0
+    movq(T1, a); //T1 = a; MAJB
+    andq(y3, b); //y3 = (a | c)&b; MAJA
+    andq(T1, c); //T1 = a&c; MAJB
+    addq(y2, y0); //y2 = S1 + CH; --
+
+    addq(d, h); //d = k + w + h + d; --
+    orq(y3, T1); //y3 = MAJ = (a | c)&b) | (a&c); MAJ
+    addq(h, y1); //h = k + w + h + S0; --
+
+    addq(d, y2); //d = k + w + h + d + S1 + CH = d + t1; --
+
+    if (iteration % 4 == 3) {
+      addq(h, y2); //h = k + w + h + S0 + S1 + CH = t1 + S0; --
+      addq(h, y3); //h = t1 + S0 + MAJ; --
+    }
+}
+
+void MacroAssembler::sha512_AVX2_one_round_and_schedule(
+    XMMRegister xmm4, // ymm4
+    XMMRegister xmm5, // ymm5
+    XMMRegister xmm6, // ymm6
+    XMMRegister xmm7, // ymm7
+    Register a, //rax
+    Register b, //rbx
+    Register c, //rdi
+    Register d, //rsi
+    Register e, //r8
+    Register f, //r9
+    Register g, //r10
+    Register h, //r11
+    int iteration)
+{
+
+    const Register& y0 = r13;
+    const Register& y1 = r14;
+    const Register& y2 = r15;
+#ifdef _WIN64
+    const Register& y3 = rcx;
+#else
+    const Register& y3 = rdi;
+#endif
+    const Register& T1 = r12;
+
+    if (iteration % 4 == 0) {
+      // Extract w[t - 7]
+      // xmm0 = W[-7]
+      vperm2f128(xmm0, xmm7, xmm6, 3);
+      vpalignr(xmm0, xmm0, xmm6, 8, AVX_256bit);
+
+      // Calculate w[t - 16] + w[t - 7]
+      vpaddq(xmm0, xmm0, xmm4, AVX_256bit); //xmm0 = W[-7] + W[-16]
+      // Extract w[t - 15]
+      //xmm1 = W[-15]
+      vperm2f128(xmm1, xmm5, xmm4, 3);
+      vpalignr(xmm1, xmm1, xmm4, 8, AVX_256bit);
+
+      // Calculate sigma0
+      // Calculate w[t - 15] ror 1
+      vpsrlq(xmm2, xmm1, 1, AVX_256bit);
+      vpsllq(xmm3, xmm1, (64 - 1), AVX_256bit);
+      vpor(xmm3, xmm3, xmm2, AVX_256bit); //xmm3 = W[-15] ror 1
+      // Calculate w[t - 15] shr 7
+      vpsrlq(xmm8, xmm1, 7, AVX_256bit); //xmm8 = W[-15] >> 7
+
+    } else if (iteration % 4 == 1) {
+      //Calculate w[t - 15] ror 8
+      vpsrlq(xmm2, xmm1, 8, AVX_256bit);
+      vpsllq(xmm1, xmm1, (64 - 8), AVX_256bit);
+      vpor(xmm1, xmm1, xmm2, AVX_256bit); //xmm1 = W[-15] ror 8
+
+      //XOR the three components
+      vpxor(xmm3, xmm3, xmm8, AVX_256bit); //xmm3 = W[-15] ror 1 ^ W[-15] >> 7
+      vpxor(xmm1, xmm3, xmm1, AVX_256bit); //xmm1 = s0
+
+      //Add three components, w[t - 16], w[t - 7] and sigma0
+      vpaddq(xmm0, xmm0, xmm1, AVX_256bit); //xmm0 = W[-16] + W[-7] + s0
+
+      // Move to appropriate lanes for calculating w[16] and w[17]
+      vperm2f128(xmm4, xmm0, xmm0, 0); //xmm4 = W[-16] + W[-7] + s0{ BABA }
+
+      address MASK_YMM_LO = StubRoutines::x86::pshuffle_byte_flip_mask_addr_sha512();
+      //Move to appropriate lanes for calculating w[18] and w[19]
+      vpand(xmm0, xmm0, ExternalAddress(MASK_YMM_LO + 32), AVX_256bit); //xmm0 = W[-16] + W[-7] + s0{ DC00 }
+      //Calculate w[16] and w[17] in both 128 bit lanes
+      //Calculate sigma1 for w[16] and w[17] on both 128 bit lanes
+      vperm2f128(xmm2, xmm7, xmm7, 17); //xmm2 = W[-2] {BABA}
+      vpsrlq(xmm8, xmm2, 6, AVX_256bit); //xmm8 = W[-2] >> 6 {BABA}
+
+    } else if (iteration % 4 == 2) {
+      vpsrlq(xmm3, xmm2, 19, AVX_256bit); //xmm3 = W[-2] >> 19 {BABA}
+      vpsllq(xmm1, xmm2, (64 - 19), AVX_256bit); //xmm1 = W[-2] << 19 {BABA}
+      vpor(xmm3, xmm3, xmm1, AVX_256bit); //xmm3 = W[-2] ror 19 {BABA}
+      vpxor(xmm8, xmm8, xmm3, AVX_256bit);// xmm8 = W[-2] ror 19 ^ W[-2] >> 6 {BABA}
+      vpsrlq(xmm3, xmm2, 61, AVX_256bit); //xmm3 = W[-2] >> 61 {BABA}
+      vpsllq(xmm1, xmm2, (64 - 61), AVX_256bit); //xmm1 = W[-2] << 61 {BABA}
+      vpor(xmm3, xmm3, xmm1, AVX_256bit); //xmm3 = W[-2] ror 61 {BABA}
+      vpxor(xmm8, xmm8, xmm3, AVX_256bit); //xmm8 = s1 = (W[-2] ror 19) ^ (W[-2] ror 61) ^ (W[-2] >> 6) { BABA }
+
+      //Add sigma1 to the other components to get w[16] and w[17]
+      vpaddq(xmm4, xmm4, xmm8, AVX_256bit); //xmm4 = { W[1], W[0], W[1], W[0] }
+
+      //Calculate sigma1 for w[18] and w[19] for upper 128 bit lane
+      vpsrlq(xmm8, xmm4, 6, AVX_256bit); //xmm8 = W[-2] >> 6 {DC--}
+
+    } else if (iteration % 4 == 3){
+      vpsrlq(xmm3, xmm4, 19, AVX_256bit); //xmm3 = W[-2] >> 19 {DC--}
+      vpsllq(xmm1, xmm4, (64 - 19), AVX_256bit); //xmm1 = W[-2] << 19 {DC--}
+      vpor(xmm3, xmm3, xmm1, AVX_256bit); //xmm3 = W[-2] ror 19 {DC--}
+      vpxor(xmm8, xmm8, xmm3, AVX_256bit); //xmm8 = W[-2] ror 19 ^ W[-2] >> 6 {DC--}
+      vpsrlq(xmm3, xmm4, 61, AVX_256bit); //xmm3 = W[-2] >> 61 {DC--}
+      vpsllq(xmm1, xmm4, (64 - 61), AVX_256bit); //xmm1 = W[-2] << 61 {DC--}
+      vpor(xmm3, xmm3, xmm1, AVX_256bit); //xmm3 = W[-2] ror 61 {DC--}
+      vpxor(xmm8, xmm8, xmm3, AVX_256bit); //xmm8 = s1 = (W[-2] ror 19) ^ (W[-2] ror 61) ^ (W[-2] >> 6) { DC-- }
+
+      //Add the sigma0 + w[t - 7] + w[t - 16] for w[18] and w[19] to newly calculated sigma1 to get w[18] and w[19]
+      vpaddq(xmm2, xmm0, xmm8, AVX_256bit); //xmm2 = { W[3], W[2], --, -- }
+
+      //Form w[19, w[18], w17], w[16]
+      vpblendd(xmm4, xmm4, xmm2, 0xF0, AVX_256bit); //xmm4 = { W[3], W[2], W[1], W[0] }
+    }
+
+    movq(y3, a); //y3 = a; MAJA
+    rorxq(y0, e, 41); // y0 = e >> 41; S1A
+    rorxq(y1, e, 18); //y1 = e >> 18; S1B
+    addq(h, Address(rsp, (iteration * 8))); //h = k + w + h; --
+    orq(y3, c); //y3 = a | c; MAJA
+    movq(y2, f); //y2 = f; CH
+
+    xorq(y2, g); //y2 = f^g; CH
+
+    rorxq(T1, a, 34); //T1 = a >> 34; S0B
+    xorq(y0, y1); //y0 = (e >> 41) ^ (e >> 18); S1
+
+    rorxq(y1, e, 14); //y1 = (e >> 14); S1
+
+    andq(y2, e); //y2 = (f^g) & e; CH
+    addq(d, h); //d = k + w + h + d; --
+
+    andq(y3, b); //y3 = (a | c)&b; MAJA
+    xorq(y0, y1); //y0 = (e >> 41) ^ (e >> 18) ^ (e >> 14); S1
+    rorxq(y1, a, 39); //y1 = a >> 39; S0A
+
+    xorq(y1, T1); //y1 = (a >> 39) ^ (a >> 34); S0
+    rorxq(T1, a, 28); //T1 = (a >> 28); S0
+    xorq(y2, g); //y2 = CH = ((f^g)&e) ^ g; CH
+
+    xorq(y1, T1); //y1 = (a >> 39) ^ (a >> 34) ^ (a >> 28); S0
+    movq(T1, a); //T1 = a; MAJB
+
+    andq(T1, c); //T1 = a&c; MAJB
+    addq(y2, y0); //y2 = S1 + CH; --
+
+    orq(y3, T1); //y3 = MAJ = (a | c)&b) | (a&c); MAJ
+    addq(h, y1); //h = k + w + h + S0; --
+
+    addq(d, y2); //d = k + w + h + d + S1 + CH = d + t1; --
+    addq(h, y2); //h = k + w + h + S0 + S1 + CH = t1 + S0; --
+    addq(h, y3); //h = t1 + S0 + MAJ; --
+}
+
+void MacroAssembler::sha512_AVX2(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0,
+                                 XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4,
+                                 Register buf, Register state, Register ofs, Register limit, Register rsp,
+                                 bool multi_block, XMMRegister shuf_mask)
+{
+
+    Label loop0, loop1, loop2, done_hash,
+    compute_block_size, compute_size,
+    compute_block_size_end, compute_size_end;
+
+    address K512_W = StubRoutines::x86::k512_W_addr();
+    address pshuffle_byte_flip_mask_sha512 = StubRoutines::x86::pshuffle_byte_flip_mask_addr_sha512();
+    address pshuffle_byte_flip_mask_addr = 0;
+
+    const XMMRegister& XFER = xmm0; // YTMP0
+    const XMMRegister& BYTE_FLIP_MASK = xmm9; // ymm9
+#ifdef _WIN64
+    const Register& INP = rcx; //1st arg
+    const Register& CTX = rdx; //2nd arg
+    const Register& NUM_BLKS = r8; //3rd arg
+    const Register& c = rdi;
+    const Register& d = rsi;
+    const Register& e = r8;
+    const Register& y3 = rcx;
+    const Register& offset = r8;
+    const Register& input_limit = r9;
+#else
+    const Register& INP = rdi; //1st arg
+    const Register& CTX = rsi; //2nd arg
+    const Register& NUM_BLKS = rdx; //3rd arg
+    const Register& c  = rcx;
+    const Register& d  = r8;
+    const Register& e  = rdx;
+    const Register& y3 = rdi;
+    const Register& offset = rdx;
+    const Register& input_limit = rcx;
+#endif
+
+    const Register& TBL = rbp;
+
+    const Register& a = rax;
+    const Register& b = rbx;
+
+    const Register& f = r9;
+    const Register& g = r10;
+    const Register& h = r11;
+
+    //Local variables as defined in assembly file.
+    enum
+    {
+      _XFER_SIZE = 4 * 8, // resq 4 => reserve 4 quadwords. Hence 4 * 8
+      _SRND_SIZE = 8, // resq 1
+      _INP_SIZE = 8,
+      _INP_END_SIZE = 8,
+      _RSP_SAVE_SIZE = 8,  // defined as resq 1
+
+#ifdef _WIN64
+      _GPR_SAVE_SIZE = 8 * 8, // defined as resq 8
+#else
+      _GPR_SAVE_SIZE = 6 * 8 // resq 6
+#endif
+    };
+
+    enum
+    {
+      _XFER = 0,
+      _SRND = _XFER + _XFER_SIZE, // 32
+      _INP = _SRND + _SRND_SIZE, // 40
+      _INP_END = _INP + _INP_SIZE, // 48
+      _RSP = _INP_END + _INP_END_SIZE, // 56
+      _GPR = _RSP + _RSP_SAVE_SIZE, // 64
+      _STACK_SIZE = _GPR + _GPR_SAVE_SIZE // 128 for windows and 112 for linux.
+    };
+
+//Saving offset and limit as it will help with blocksize calculation for multiblock SHA512.
+#ifdef _WIN64
+    push(r8);    // win64: this is ofs
+    push(r9);    // win64: this is limit, we need them again at the very end.
+#else
+    push(rdx);   // linux : this is ofs, need at the end for multiblock calculation
+    push(rcx);   // linux: This is the limit.
+#endif
+
+    //Allocate Stack Space
+    movq(rax, rsp);
+    subq(rsp, _STACK_SIZE);
+    andq(rsp, -32);
+    movq(Address(rsp, _RSP), rax);
+
+    //Save GPRs
+    movq(Address(rsp, _GPR), rbp);
+    movq(Address(rsp, (_GPR + 8)), rbx);
+    movq(Address(rsp, (_GPR + 16)), r12);
+    movq(Address(rsp, (_GPR + 24)), r13);
+    movq(Address(rsp, (_GPR + 32)), r14);
+    movq(Address(rsp, (_GPR + 40)), r15);
+
+#ifdef _WIN64
+    movq(Address(rsp, (_GPR + 48)), rsi);
+    movq(Address(rsp, (_GPR + 56)), rdi);
+#endif
+
+    vpblendd(xmm0, xmm0, xmm1, 0xF0, AVX_128bit);
+    vpblendd(xmm0, xmm0, xmm1, 0xF0, AVX_256bit);
+
+    if (multi_block) {
+      xorq(rax, rax);
+      bind(compute_block_size);
+      cmpptr(offset, input_limit); // Assuming that offset is less than limit.
+      jccb(Assembler::aboveEqual, compute_block_size_end);
+      addq(offset, 128);
+      addq(rax, 128);
+      jmpb(compute_block_size);
+
+      bind(compute_block_size_end);
+      movq(NUM_BLKS, rax);
+
+      cmpq(NUM_BLKS, 0);
+      jcc(Assembler::equal, done_hash);
+    } else {
+      xorq(NUM_BLKS, NUM_BLKS); //If single block.
+      addq(NUM_BLKS, 128);
+    }
+
+    addq(NUM_BLKS, INP); //pointer to end of data
+    movq(Address(rsp, _INP_END), NUM_BLKS);
+
+    //load initial digest
+    movq(a, Address(CTX, 8 * 0));
+    movq(b, Address(CTX, 8 * 1));
+    movq(c, Address(CTX, 8 * 2));
+    movq(d, Address(CTX, 8 * 3));
+    movq(e, Address(CTX, 8 * 4));
+    movq(f, Address(CTX, 8 * 5));
+    movq(g, Address(CTX, 8 * 6));
+    movq(h, Address(CTX, 8 * 7));
+
+    pshuffle_byte_flip_mask_addr = pshuffle_byte_flip_mask_sha512;
+    vmovdqu(BYTE_FLIP_MASK, ExternalAddress(pshuffle_byte_flip_mask_addr + 0)); //PSHUFFLE_BYTE_FLIP_MASK wrt rip
+
+    bind(loop0);
+    lea(TBL, ExternalAddress(K512_W));
+
+    //byte swap first 16 dwords
+    vmovdqu(xmm4, Address(INP, 32 * 0));
+    vpshufb(xmm4, xmm4, BYTE_FLIP_MASK, AVX_256bit);
+    vmovdqu(xmm5, Address(INP, 32 * 1));
+    vpshufb(xmm5, xmm5, BYTE_FLIP_MASK, AVX_256bit);
+    vmovdqu(xmm6, Address(INP, 32 * 2));
+    vpshufb(xmm6, xmm6, BYTE_FLIP_MASK, AVX_256bit);
+    vmovdqu(xmm7, Address(INP, 32 * 3));
+    vpshufb(xmm7, xmm7, BYTE_FLIP_MASK, AVX_256bit);
+
+    movq(Address(rsp, _INP), INP);
+
+    movslq(Address(rsp, _SRND), 4);
+    align(16);
+
+    //Schedule 64 input dwords, by calling sha512_AVX2_one_round_and_schedule
+    bind(loop1);
+    vpaddq(xmm0, xmm4, Address(TBL, 0 * 32), AVX_256bit);
+    vmovdqu(Address(rsp, _XFER), xmm0);
+    //four rounds and schedule
+    sha512_AVX2_one_round_and_schedule(xmm4, xmm5, xmm6, xmm7, a, b, c, d, e, f, g, h, 0);
+    sha512_AVX2_one_round_and_schedule(xmm4, xmm5, xmm6, xmm7, h, a, b, c, d, e, f, g, 1);
+    sha512_AVX2_one_round_and_schedule(xmm4, xmm5, xmm6, xmm7, g, h, a, b, c, d, e, f, 2);
+    sha512_AVX2_one_round_and_schedule(xmm4, xmm5, xmm6, xmm7, f, g, h, a, b, c, d, e, 3);
+
+    vpaddq(xmm0, xmm5, Address(TBL, 1 * 32), AVX_256bit);
+    vmovdqu(Address(rsp, _XFER), xmm0);
+    //four rounds and schedule
+    sha512_AVX2_one_round_and_schedule(xmm5, xmm6, xmm7, xmm4, e, f, g, h, a, b, c, d, 0);
+    sha512_AVX2_one_round_and_schedule(xmm5, xmm6, xmm7, xmm4, d, e, f, g, h, a, b, c, 1);
+    sha512_AVX2_one_round_and_schedule(xmm5, xmm6, xmm7, xmm4, c, d, e, f, g, h, a, b, 2);
+    sha512_AVX2_one_round_and_schedule(xmm5, xmm6, xmm7, xmm4, b, c, d, e, f, g, h, a, 3);
+
+    vpaddq(xmm0, xmm6, Address(TBL, 2 * 32), AVX_256bit);
+    vmovdqu(Address(rsp, _XFER), xmm0);
+    //four rounds and schedule
+    sha512_AVX2_one_round_and_schedule(xmm6, xmm7, xmm4, xmm5, a, b, c, d, e, f, g, h, 0);
+    sha512_AVX2_one_round_and_schedule(xmm6, xmm7, xmm4, xmm5, h, a, b, c, d, e, f, g, 1);
+    sha512_AVX2_one_round_and_schedule(xmm6, xmm7, xmm4, xmm5, g, h, a, b, c, d, e, f, 2);
+    sha512_AVX2_one_round_and_schedule(xmm6, xmm7, xmm4, xmm5, f, g, h, a, b, c, d, e, 3);
+
+    vpaddq(xmm0, xmm7, Address(TBL, 3 * 32), AVX_256bit);
+    vmovdqu(Address(rsp, _XFER), xmm0);
+    addq(TBL, 4 * 32);
+    //four rounds and schedule
+    sha512_AVX2_one_round_and_schedule(xmm7, xmm4, xmm5, xmm6, e, f, g, h, a, b, c, d, 0);
+    sha512_AVX2_one_round_and_schedule(xmm7, xmm4, xmm5, xmm6, d, e, f, g, h, a, b, c, 1);
+    sha512_AVX2_one_round_and_schedule(xmm7, xmm4, xmm5, xmm6, c, d, e, f, g, h, a, b, 2);
+    sha512_AVX2_one_round_and_schedule(xmm7, xmm4, xmm5, xmm6, b, c, d, e, f, g, h, a, 3);
+
+    subq(Address(rsp, _SRND), 1);
+    jcc(Assembler::notEqual, loop1);
+
+    movslq(Address(rsp, _SRND), 2);
+
+    bind(loop2);
+    vpaddq(xmm0, xmm4, Address(TBL, 0 * 32), AVX_256bit);
+    vmovdqu(Address(rsp, _XFER), xmm0);
+    //four rounds and compute.
+    sha512_AVX2_one_round_compute(a, a, b, c, d, e, f, g, h, 0);
+    sha512_AVX2_one_round_compute(h, h, a, b, c, d, e, f, g, 1);
+    sha512_AVX2_one_round_compute(g, g, h, a, b, c, d, e, f, 2);
+    sha512_AVX2_one_round_compute(f, f, g, h, a, b, c, d, e, 3);
+
+    vpaddq(xmm0, xmm5, Address(TBL, 1 * 32), AVX_256bit);
+    vmovdqu(Address(rsp, _XFER), xmm0);
+    addq(TBL, 2 * 32);
+    // four rounds and compute.
+    sha512_AVX2_one_round_compute(e, e, f, g, h, a, b, c, d, 0);
+    sha512_AVX2_one_round_compute(d, d, e, f, g, h, a, b, c, 1);
+    sha512_AVX2_one_round_compute(c, c, d, e, f, g, h, a, b, 2);
+    sha512_AVX2_one_round_compute(b, b, c, d, e, f, g, h, a, 3);
+
+    vmovdqu(xmm4, xmm6);
+    vmovdqu(xmm5, xmm7);
+
+    subq(Address(rsp, _SRND), 1);
+    jcc(Assembler::notEqual, loop2);
+
+    addmq(8 * 0, CTX, a);
+    addmq(8 * 1, CTX, b);
+    addmq(8 * 2, CTX, c);
+    addmq(8 * 3, CTX, d);
+    addmq(8 * 4, CTX, e);
+    addmq(8 * 5, CTX, f);
+    addmq(8 * 6, CTX, g);
+    addmq(8 * 7, CTX, h);
+
+    movq(INP, Address(rsp, _INP));
+    addq(INP, 128);
+    cmpq(INP, Address(rsp, _INP_END));
+    jcc(Assembler::notEqual, loop0);
+
+    bind(done_hash);
+
+    //Restore GPRs
+    movq(rbp, Address(rsp, (_GPR + 0)));
+    movq(rbx, Address(rsp, (_GPR + 8)));
+    movq(r12, Address(rsp, (_GPR + 16)));
+    movq(r13, Address(rsp, (_GPR + 24)));
+    movq(r14, Address(rsp, (_GPR + 32)));
+    movq(r15, Address(rsp, (_GPR + 40)));
+
+#ifdef _WIN64
+    movq(rsi, Address(rsp, (_GPR + 48)));
+    movq(rdi, Address(rsp, (_GPR + 56)));
+#endif
+
+    //Restore Stack Pointer
+    movq(rsp, Address(rsp, _RSP));
+
+#ifdef _WIN64
+    pop(r9);
+    pop(r8);
+#else
+    pop(rcx);
+    pop(rdx);
+#endif
+
+    if (multi_block) {
+#ifdef _WIN64
+      const Register& limit_end = r9;
+      const Register& ofs_end = r8;
+#else
+      const Register& limit_end = rcx;
+      const Register& ofs_end   = rdx;
+#endif
+      movq(rax, ofs_end);
+      bind(compute_size);
+      cmpptr(rax, limit_end);
+      jccb(Assembler::aboveEqual, compute_size_end);
+      addq(rax, 128);
+      jmpb(compute_size);
+      bind(compute_size_end);
+    }
+}
+
 #endif //#ifdef _LP64
+
--- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -3718,6 +3718,25 @@
     return start;
   }
 
+  //Mask for byte-swapping a couple of qwords in an XMM register using (v)pshufb.
+  address generate_pshuffle_byte_flip_mask_sha512() {
+    __ align(32);
+    StubCodeMark mark(this, "StubRoutines", "pshuffle_byte_flip_mask_sha512");
+    address start = __ pc();
+    if (VM_Version::supports_avx2()) {
+      __ emit_data64(0x0001020304050607, relocInfo::none); // PSHUFFLE_BYTE_FLIP_MASK
+      __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none);
+      __ emit_data64(0x1011121314151617, relocInfo::none);
+      __ emit_data64(0x18191a1b1c1d1e1f, relocInfo::none);
+      __ emit_data64(0x0000000000000000, relocInfo::none); //MASK_YMM_LO
+      __ emit_data64(0x0000000000000000, relocInfo::none);
+      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
+      __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none);
+    }
+
+    return start;
+  }
+
 // ofs and limit are use for multi-block byte array.
 // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
   address generate_sha256_implCompress(bool multi_block, const char *name) {
@@ -3761,6 +3780,39 @@
     return start;
   }
 
+  address generate_sha512_implCompress(bool multi_block, const char *name) {
+    assert(VM_Version::supports_avx2(), "");
+    assert(VM_Version::supports_bmi2(), "");
+    __ align(CodeEntryAlignment);
+    StubCodeMark mark(this, "StubRoutines", name);
+    address start = __ pc();
+
+    Register buf = c_rarg0;
+    Register state = c_rarg1;
+    Register ofs = c_rarg2;
+    Register limit = c_rarg3;
+
+    const XMMRegister msg = xmm0;
+    const XMMRegister state0 = xmm1;
+    const XMMRegister state1 = xmm2;
+    const XMMRegister msgtmp0 = xmm3;
+    const XMMRegister msgtmp1 = xmm4;
+    const XMMRegister msgtmp2 = xmm5;
+    const XMMRegister msgtmp3 = xmm6;
+    const XMMRegister msgtmp4 = xmm7;
+
+    const XMMRegister shuf_mask = xmm8;
+
+    __ enter();
+
+    __ sha512_AVX2(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4,
+    buf, state, ofs, limit, rsp, multi_block, shuf_mask);
+
+    __ leave();
+    __ ret(0);
+    return start;
+  }
+
   // This is a version of CTR/AES crypt which does 6 blocks in a loop at a time
   // to hide instruction latency
   //
@@ -5081,6 +5133,12 @@
       StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress");
       StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB");
     }
+    if (UseSHA512Intrinsics) {
+      StubRoutines::x86::_k512_W_addr = (address)StubRoutines::x86::_k512_W;
+      StubRoutines::x86::_pshuffle_byte_flip_mask_addr_sha512 = generate_pshuffle_byte_flip_mask_sha512();
+      StubRoutines::_sha512_implCompress = generate_sha512_implCompress(false, "sha512_implCompress");
+      StubRoutines::_sha512_implCompressMB = generate_sha512_implCompress(true, "sha512_implCompressMB");
+    }
 
     // Generate GHASH intrinsics code
     if (UseGHASHIntrinsics) {
--- a/src/cpu/x86/vm/stubRoutines_x86.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/stubRoutines_x86.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -48,6 +48,8 @@
 address StubRoutines::x86::_k256_adr = NULL;
 #ifdef _LP64
 address StubRoutines::x86::_k256_W_adr = NULL;
+address StubRoutines::x86::_k512_W_addr = NULL;
+address StubRoutines::x86::_pshuffle_byte_flip_mask_addr_sha512 = NULL;
 #endif
 address StubRoutines::x86::_pshuffle_byte_flip_mask_addr = NULL;
 
@@ -297,4 +299,49 @@
 // used in MacroAssembler::sha256_AVX2
 // dynamically built from _k256
 ALIGNED_(64) juint StubRoutines::x86::_k256_W[2*sizeof(StubRoutines::x86::_k256)];
+
+// used in MacroAssembler::sha512_AVX2
+ALIGNED_(64) julong StubRoutines::x86::_k512_W[] =
+{
+    0x428a2f98d728ae22LL, 0x7137449123ef65cdLL,
+    0xb5c0fbcfec4d3b2fLL, 0xe9b5dba58189dbbcLL,
+    0x3956c25bf348b538LL, 0x59f111f1b605d019LL,
+    0x923f82a4af194f9bLL, 0xab1c5ed5da6d8118LL,
+    0xd807aa98a3030242LL, 0x12835b0145706fbeLL,
+    0x243185be4ee4b28cLL, 0x550c7dc3d5ffb4e2LL,
+    0x72be5d74f27b896fLL, 0x80deb1fe3b1696b1LL,
+    0x9bdc06a725c71235LL, 0xc19bf174cf692694LL,
+    0xe49b69c19ef14ad2LL, 0xefbe4786384f25e3LL,
+    0x0fc19dc68b8cd5b5LL, 0x240ca1cc77ac9c65LL,
+    0x2de92c6f592b0275LL, 0x4a7484aa6ea6e483LL,
+    0x5cb0a9dcbd41fbd4LL, 0x76f988da831153b5LL,
+    0x983e5152ee66dfabLL, 0xa831c66d2db43210LL,
+    0xb00327c898fb213fLL, 0xbf597fc7beef0ee4LL,
+    0xc6e00bf33da88fc2LL, 0xd5a79147930aa725LL,
+    0x06ca6351e003826fLL, 0x142929670a0e6e70LL,
+    0x27b70a8546d22ffcLL, 0x2e1b21385c26c926LL,
+    0x4d2c6dfc5ac42aedLL, 0x53380d139d95b3dfLL,
+    0x650a73548baf63deLL, 0x766a0abb3c77b2a8LL,
+    0x81c2c92e47edaee6LL, 0x92722c851482353bLL,
+    0xa2bfe8a14cf10364LL, 0xa81a664bbc423001LL,
+    0xc24b8b70d0f89791LL, 0xc76c51a30654be30LL,
+    0xd192e819d6ef5218LL, 0xd69906245565a910LL,
+    0xf40e35855771202aLL, 0x106aa07032bbd1b8LL,
+    0x19a4c116b8d2d0c8LL, 0x1e376c085141ab53LL,
+    0x2748774cdf8eeb99LL, 0x34b0bcb5e19b48a8LL,
+    0x391c0cb3c5c95a63LL, 0x4ed8aa4ae3418acbLL,
+    0x5b9cca4f7763e373LL, 0x682e6ff3d6b2b8a3LL,
+    0x748f82ee5defb2fcLL, 0x78a5636f43172f60LL,
+    0x84c87814a1f0ab72LL, 0x8cc702081a6439ecLL,
+    0x90befffa23631e28LL, 0xa4506cebde82bde9LL,
+    0xbef9a3f7b2c67915LL, 0xc67178f2e372532bLL,
+    0xca273eceea26619cLL, 0xd186b8c721c0c207LL,
+    0xeada7dd6cde0eb1eLL, 0xf57d4f7fee6ed178LL,
+    0x06f067aa72176fbaLL, 0x0a637dc5a2c898a6LL,
+    0x113f9804bef90daeLL, 0x1b710b35131c471bLL,
+    0x28db77f523047d84LL, 0x32caab7b40c72493LL,
+    0x3c9ebe0a15c9bebcLL, 0x431d67c49c100d4cLL,
+    0x4cc5d4becb3e42b6LL, 0x597f299cfc657e2aLL,
+    0x5fcb6fab3ad6faecLL, 0x6c44198c4a475817LL,
+};
 #endif
--- a/src/cpu/x86/vm/stubRoutines_x86.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/stubRoutines_x86.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -33,7 +33,7 @@
 
 enum platform_dependent_constants {
   code_size1 = 20000 LP64_ONLY(+10000),         // simply increase if too small (assembler will crash if too small)
-  code_size2 = 33800 LP64_ONLY(+1200)           // simply increase if too small (assembler will crash if too small)
+  code_size2 = 33800 LP64_ONLY(+10000)           // simply increase if too small (assembler will crash if too small)
 };
 
 class x86 {
@@ -134,6 +134,10 @@
 #ifdef _LP64
   static juint _k256_W[];
   static address _k256_W_adr;
+  static julong _k512_W[];
+  static address _k512_W_addr;
+  // byte flip mask for sha512
+  static address _pshuffle_byte_flip_mask_addr_sha512;
 #endif
   // byte flip mask for sha256
   static address _pshuffle_byte_flip_mask_addr;
@@ -192,6 +196,8 @@
   static address k256_addr()      { return _k256_adr; }
 #ifdef _LP64
   static address k256_W_addr()    { return _k256_W_adr; }
+  static address k512_W_addr()    { return _k512_W_addr; }
+  static address pshuffle_byte_flip_mask_addr_sha512() { return _pshuffle_byte_flip_mask_addr_sha512; }
 #endif
   static address pshuffle_byte_flip_mask_addr() { return _pshuffle_byte_flip_mask_addr; }
   static void generate_CRC32C_table(bool is_pclmulqdq_supported);
--- a/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -254,8 +254,9 @@
   const Register thread = NOT_LP64(rcx) LP64_ONLY(r15_thread);
   NOT_LP64(__ get_thread(thread));
 #if INCLUDE_JVMCI
-  // Check if we need to take lock at entry of synchronized method.
-  if (UseJVMCICompiler) {
+  // Check if we need to take lock at entry of synchronized method.  This can
+  // only occur on method entry so emit it only for vtos with step 0.
+  if (UseJVMCICompiler && state == vtos && step == 0) {
     Label L;
     __ cmpb(Address(thread, JavaThread::pending_monitorenter_offset()), 0);
     __ jcc(Assembler::zero, L);
@@ -266,6 +267,16 @@
     // Take lock.
     lock_method();
     __ bind(L);
+  } else {
+#ifdef ASSERT
+    if (UseJVMCICompiler) {
+      Label L;
+      __ cmpb(Address(r15_thread, JavaThread::pending_monitorenter_offset()), 0);
+      __ jccb(Assembler::zero, L);
+      __ stop("unexpected pending monitor in deopt entry");
+      __ bind(L);
+    }
+#endif
   }
 #endif
   // handle exceptions
--- a/src/cpu/x86/vm/vm_version_x86.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/vm_version_x86.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -769,7 +769,11 @@
     FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
   }
 
-  if (UseSHA512Intrinsics) {
+  if (UseSHA) {
+    if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) {
+      FLAG_SET_DEFAULT(UseSHA512Intrinsics, true);
+    }
+  } else if (UseSHA512Intrinsics) {
     warning("Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU.");
     FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
   }
--- a/src/cpu/x86/vm/x86.ad	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/cpu/x86/vm/x86.ad	Wed Oct 26 20:13:29 2016 +0000
@@ -8173,13 +8173,13 @@
   match(Set dst (CMoveVD (Binary copnd cop) (Binary src1 src2)));
   effect(TEMP dst, USE src1, USE src2);
   format %{ "cmppd.$copnd  $dst, $src1, $src2  ! vcmovevd, cond=$cop\n\t"
-            "vpblendd $dst,$src1,$src2,$dst ! vcmovevd\n\t"
+            "blendvpd $dst,$src1,$src2,$dst ! vcmovevd\n\t"
          %}
   ins_encode %{
     int vector_len = 1;
     int cond = (Assembler::Condition)($copnd$$cmpcode);
     __ cmppd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, cond, vector_len);
-    __ vpblendd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, $dst$$XMMRegister, vector_len);
+    __ blendvpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, $dst$$XMMRegister, vector_len);
   %}
   ins_pipe( pipe_slow );
 %}
--- a/src/jdk.hotspot.agent/macosx/native/libsaproc/MacosxDebuggerLocal.m	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/jdk.hotspot.agent/macosx/native/libsaproc/MacosxDebuggerLocal.m	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -25,6 +25,7 @@
 #include <objc/objc-runtime.h>
 #import <Foundation/Foundation.h>
 #import <JavaNativeFoundation/JavaNativeFoundation.h>
+#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
 
 #include <jni.h>
 
--- a/src/jdk.hotspot.agent/solaris/native/libsaproc/libproc.h	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/jdk.hotspot.agent/solaris/native/libsaproc/libproc.h	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -420,8 +420,6 @@
 /*
  * Stack frame iteration interface.
  */
-#ifdef SOLARIS_11_B159_OR_LATER
-/* building on Nevada-B159 or later so define the new callback */
 typedef int proc_stack_f(
     void *,             /* the cookie given to Pstack_iter() */
     const prgregset_t,  /* the frame's registers */
@@ -432,10 +430,6 @@
 
 #define PR_SIGNAL_FRAME    1    /* called by a signal handler */
 #define PR_FOUND_SIGNAL    2    /* we found the corresponding signal number */
-#else
-/* building on Nevada-B158 or earlier so define the old callback */
-typedef int proc_stack_f(void *, const prgregset_t, uint_t, const long *);
-#endif
 
 extern int Pstack_iter(struct ps_prochandle *,
     const prgregset_t, proc_stack_f *, void *);
--- a/src/jdk.hotspot.agent/solaris/native/libsaproc/salibproc.h	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/jdk.hotspot.agent/solaris/native/libsaproc/salibproc.h	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -46,6 +46,17 @@
 extern "C" {
 #endif
 
+/* extended symbol table information */
+typedef struct {
+        const char      *prs_object;            /* object name */
+        const char      *prs_name;              /* symbol name */
+        Lmid_t          prs_lmid;               /* link map id */
+        uint_t          prs_id;                 /* symbol id */
+        uint_t          prs_table;              /* symbol table id */
+} prsyminfo_t;
+
+typedef struct ps_prochandle ps_prochandle_t;
+
 /*
  * 'object_name' is the name of a load object obtained from an
  * iteration over the process's address space mappings (Pmapping_iter),
@@ -53,8 +64,10 @@
  * or else it is one of the special PR_OBJ_* values above.
  */
 
-extern int Plookup_by_addr(struct ps_prochandle *,
-    uintptr_t, char *, size_t, GElf_Sym *);
+extern int Plookup_by_addr(ps_prochandle_t *, uintptr_t, char *,
+                           size_t, GElf_Sym *, prsyminfo_t *);
+extern ps_prochandle_t *proc_arg_grab(const char *, int, int,
+                                      int *, const char **);
 
 typedef int proc_map_f(void *, const prmap_t *, const char *);
 extern int Pobject_iter(struct ps_prochandle *, proc_map_f *, void *);
@@ -88,7 +101,6 @@
 #define G_ELF           13      /* Libelf error, elf_errno() is meaningful */
 #define G_NOTE          14      /* Required PT_NOTE Phdr not present in core */
 
-extern struct ps_prochandle *proc_arg_grab(const char *, int, int, int *);
 extern  const pstatus_t *Pstatus(struct ps_prochandle *);
 
 /* Flags accepted by Prelease (partial) */
@@ -101,8 +113,6 @@
 /*
  * Stack frame iteration interface.
  */
-#ifdef SOLARIS_11_B159_OR_LATER
-/* building on Nevada-B159 or later so define the new callback */
 typedef int proc_stack_f(
     void *,             /* the cookie given to Pstack_iter() */
     const prgregset_t,  /* the frame's registers */
@@ -113,10 +123,6 @@
 
 #define PR_SIGNAL_FRAME    1    /* called by a signal handler */
 #define PR_FOUND_SIGNAL    2    /* we found the corresponding signal number */
-#else
-/* building on Nevada-B158 or earlier so define the old callback */
-typedef int proc_stack_f(void *, const prgregset_t, uint_t, const long *);
-#endif
 
 extern int Pstack_iter(struct ps_prochandle *,
     const prgregset_t, proc_stack_f *, void *);
--- a/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -24,9 +24,6 @@
 
 #include "salibproc.h"
 #include "sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal.h"
-#ifndef SOLARIS_11_B159_OR_LATER
-#include <sys/utsname.h>
-#endif
 #include <thread_db.h>
 #include <strings.h>
 #include <limits.h>
@@ -45,20 +42,6 @@
 
 // debug modes
 static int _libsaproc_debug = 0;
-#ifndef SOLARIS_11_B159_OR_LATER
-static bool _Pstack_iter_debug = false;
-
-static void dprintf_2(const char* format,...) {
-  if (_Pstack_iter_debug) {
-    va_list alist;
-
-    va_start(alist, format);
-    fputs("Pstack_iter DEBUG: ", stderr);
-    vfprintf(stderr, format, alist);
-    va_end(alist);
-  }
-}
-#endif // !SOLARIS_11_B159_OR_LATER
 
 static void print_debug(const char* format,...) {
   if (_libsaproc_debug) {
@@ -757,7 +740,8 @@
 #endif
 
   // connect to process/core
-  struct ps_prochandle* ph = proc_arg_grab(cmdLine_cstr, (isProcess? PR_ARG_PIDS : PR_ARG_CORES), PGRAB_FORCE, &gcode);
+  ps_prochandle_t* ph = proc_arg_grab(cmdLine_cstr, (isProcess? PR_ARG_PIDS : PR_ARG_CORES), PGRAB_FORCE, &gcode, NULL);
+
   env->ReleaseStringUTFChars(cmdLine, cmdLine_cstr);
   if (! ph) {
      if (gcode > 0 && gcode < sizeof(proc_arg_grab_errmsgs)/sizeof(const char*)) {
@@ -997,11 +981,6 @@
                    TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
 }
 
-#ifndef SOLARIS_11_B159_OR_LATER
-// building on Nevada-B158 or earlier so more hoops to jump through
-static bool has_newer_Pstack_iter = false;  // older version by default
-#endif
-
 /*
  * Class:       sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
  * Method:      fillCFrameList0
@@ -1030,23 +1009,8 @@
   env->ReleaseLongArrayElements(regsArray, ptr, JNI_ABORT);
   CHECK_EXCEPTION_(0);
 
-#ifdef SOLARIS_11_B159_OR_LATER
-  // building on Nevada-B159 or later so use the new callback
   Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
               wrapper_fill_cframe_list, &dbgo2);
-#else
-  // building on Nevada-B158 or earlier so figure out which callback to use
-
-  if (has_newer_Pstack_iter) {
-    // Since we're building on Nevada-B158 or earlier, we have to
-    // cast wrapper_fill_cframe_list to make the compiler happy.
-    Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
-                (proc_stack_f *)wrapper_fill_cframe_list, &dbgo2);
-  } else {
-    Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
-                fill_cframe_list, &dbgo2);
-  }
-#endif // SOLARIS_11_B159_OR_LATER
   return dbgo2.obj;
 }
 
@@ -1236,7 +1200,8 @@
    char nameBuf[SYMBOL_BUF_SIZE + 1];
    GElf_Sym sym;
    int res = Plookup_by_addr((struct ps_prochandle*) p_ps_prochandle, (uintptr_t) address,
-                                 nameBuf, sizeof(nameBuf), &sym);
+                             nameBuf, sizeof(nameBuf), &sym, NULL);
+
    if (res != 0) { // failed
       return 0;
    }
@@ -1268,102 +1233,6 @@
   return res;
 }
 
-#ifndef SOLARIS_11_B159_OR_LATER
-// Determine if the OS we're running on has the newer version
-// of libproc's Pstack_iter.
-//
-// Set env var PSTACK_ITER_DEBUG=true to debug this logic.
-// Set env var PSTACK_ITER_DEBUG_RELEASE to simulate a 'release' value.
-// Set env var PSTACK_ITER_DEBUG_VERSION to simulate a 'version' value.
-//
-// frankenputer 'uname -r -v': 5.10 Generic_141445-09
-// jurassic 'uname -r -v':     5.11 snv_164
-// lonepeak 'uname -r -v':     5.11 snv_127
-//
-static void set_has_newer_Pstack_iter(JNIEnv *env) {
-  static bool done_set = false;
-
-  if (done_set) {
-    // already set has_newer_Pstack_iter
-    return;
-  }
-
-  struct utsname name;
-  if (uname(&name) == -1) {
-    THROW_NEW_DEBUGGER_EXCEPTION("uname() failed!");
-  }
-  dprintf_2("release='%s'  version='%s'\n", name.release, name.version);
-
-  if (_Pstack_iter_debug) {
-    char *override = getenv("PSTACK_ITER_DEBUG_RELEASE");
-    if (override != NULL) {
-      strncpy(name.release, override, SYS_NMLN - 1);
-      name.release[SYS_NMLN - 2] = '\0';
-      dprintf_2("overriding with release='%s'\n", name.release);
-    }
-    override = getenv("PSTACK_ITER_DEBUG_VERSION");
-    if (override != NULL) {
-      strncpy(name.version, override, SYS_NMLN - 1);
-      name.version[SYS_NMLN - 2] = '\0';
-      dprintf_2("overriding with version='%s'\n", name.version);
-    }
-  }
-
-  // the major number corresponds to the old SunOS major number
-  int major = atoi(name.release);
-  if (major >= 6) {
-    dprintf_2("release is SunOS 6 or later\n");
-    has_newer_Pstack_iter = true;
-    done_set = true;
-    return;
-  }
-  if (major < 5) {
-    dprintf_2("release is SunOS 4 or earlier\n");
-    done_set = true;
-    return;
-  }
-
-  // some SunOS 5.* build so now check for Solaris versions
-  char *dot = strchr(name.release, '.');
-  int minor = 0;
-  if (dot != NULL) {
-    // release is major.minor format
-    *dot = NULL;
-    minor = atoi(dot + 1);
-  }
-
-  if (minor <= 10) {
-    dprintf_2("release is Solaris 10 or earlier\n");
-    done_set = true;
-    return;
-  } else if (minor >= 12) {
-    dprintf_2("release is Solaris 12 or later\n");
-    has_newer_Pstack_iter = true;
-    done_set = true;
-    return;
-  }
-
-  // some Solaris 11 build so now check for internal build numbers
-  if (strncmp(name.version, "snv_", 4) != 0) {
-    dprintf_2("release is Solaris 11 post-GA or later\n");
-    has_newer_Pstack_iter = true;
-    done_set = true;
-    return;
-  }
-
-  // version begins with "snv_" so a pre-GA build of Solaris 11
-  int build = atoi(&name.version[4]);
-  if (build >= 159) {
-    dprintf_2("release is Nevada-B159 or later\n");
-    has_newer_Pstack_iter = true;
-  } else {
-    dprintf_2("release is Nevada-B158 or earlier\n");
-  }
-
-  done_set = true;
-}
-#endif // !SOLARIS_11_B159_OR_LATER
-
 /*
  * Class:       sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
  * Method:      initIDs
@@ -1383,14 +1252,6 @@
   if (libproc_handle == 0)
      THROW_NEW_DEBUGGER_EXCEPTION("can't load libproc.so, if you are using Solaris 5.7 or below, copy libproc.so from 5.8!");
 
-#ifndef SOLARIS_11_B159_OR_LATER
-  _Pstack_iter_debug = getenv("PSTACK_ITER_DEBUG") != NULL;
-
-  set_has_newer_Pstack_iter(env);
-  CHECK_EXCEPTION;
-  dprintf_2("has_newer_Pstack_iter=%d\n", has_newer_Pstack_iter);
-#endif
-
   p_ps_prochandle_ID = env->GetFieldID(clazz, "p_ps_prochandle", "J");
   CHECK_EXCEPTION;
 
--- a/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Wed Oct 26 20:13:29 2016 +0000
@@ -171,6 +171,9 @@
             return (String) getValue();
         }
 
+        private static final int PROPERTY_LINE_WIDTH = 80;
+        private static final int PROPERTY_HELP_INDENT = 10;
+
         /**
          * Prints a description of the properties used to configure shared JVMCI code.
          *
@@ -178,24 +181,26 @@
          */
         public static void printProperties(PrintStream out) {
             out.println("[JVMCI properties]");
-            int typeWidth = 0;
-            int nameWidth = 0;
             Option[] values = values();
             for (Option option : values) {
-                typeWidth = Math.max(typeWidth, option.type.getSimpleName().length());
-                nameWidth = Math.max(nameWidth, option.getPropertyName().length());
-            }
-            for (Option option : values) {
                 Object value = option.getValue();
                 if (value instanceof String) {
                     value = '"' + String.valueOf(value) + '"';
                 }
-                String assign = option.isDefault ? " =" : ":=";
-                String format = "%" + (typeWidth + 1) + "s %-" + (nameWidth + 1) + "s %s %s%n";
-                out.printf(format, option.type.getSimpleName(), option.getPropertyName(), assign, value);
-                String helpFormat = "%" + (typeWidth + 1) + "s %s%n";
+
+                String name = option.getPropertyName();
+                String assign = option.isDefault ? "=" : ":=";
+                String typeName = option.type.getSimpleName();
+                String linePrefix = String.format("%s %s %s ", name, assign, value);
+                int typeStartPos = PROPERTY_LINE_WIDTH - typeName.length();
+                int linePad = typeStartPos - linePrefix.length();
+                if (linePad > 0) {
+                    out.printf("%s%-" + linePad + "s[%s]%n", linePrefix, "", typeName);
+                } else {
+                    out.printf("%s[%s]%n", linePrefix, typeName);
+                }
                 for (String line : option.helpLines) {
-                    out.printf(helpFormat, "", line);
+                    out.printf("%" + PROPERTY_HELP_INDENT + "s%s%n", "", line);
                 }
             }
         }
@@ -306,6 +311,7 @@
             PrintStream out = new PrintStream(getLogStream());
             Option.printProperties(out);
             compilerFactory.printProperties(out);
+            System.exit(0);
         }
 
         if (Option.PrintConfig.getBoolean()) {
--- a/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java	Wed Oct 26 20:13:29 2016 +0000
@@ -22,7 +22,8 @@
  */
 package jdk.vm.ci.services;
 
-import java.lang.reflect.Module;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.Formatter;
 import java.util.Iterator;
 import java.util.ServiceConfigurationError;
@@ -36,11 +37,62 @@
     private Services() {
     }
 
+    private static int getJavaSpecificationVersion() {
+        String value = System.getProperty("java.specification.version");
+        if (value.startsWith("1.")) {
+            value = value.substring(2);
+        }
+        return Integer.parseInt(value);
+    }
+
+    /**
+     * The integer value corresponding to the value of the {@code java.specification.version} system
+     * property after any leading {@code "1."} has been stripped.
+     */
+    public static final int JAVA_SPECIFICATION_VERSION = getJavaSpecificationVersion();
+
+    // Use reflection so that this compiles on Java 8
+    private static final Method getModule;
+    private static final Method getPackages;
+    private static final Method addUses;
+    private static final Method isExported;
+    private static final Method addExports;
+
+    static {
+        if (JAVA_SPECIFICATION_VERSION >= 9) {
+            try {
+                getModule = Class.class.getMethod("getModule");
+                Class<?> moduleClass = getModule.getReturnType();
+                getPackages = moduleClass.getMethod("getPackages");
+                addUses = moduleClass.getMethod("addUses", Class.class);
+                isExported = moduleClass.getMethod("isExported", String.class, moduleClass);
+                addExports = moduleClass.getMethod("addExports", String.class, moduleClass);
+            } catch (NoSuchMethodException | SecurityException e) {
+                throw new InternalError(e);
+            }
+        } else {
+            getModule = null;
+            getPackages = null;
+            addUses = null;
+            isExported = null;
+            addExports = null;
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    static <T> T invoke(Method method, Object receiver, Object... args) {
+        try {
+            return (T) method.invoke(receiver, args);
+        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+            throw new InternalError(e);
+        }
+    }
+
     /**
      * Performs any required security checks and dynamic reconfiguration to allow the module of a
      * given class to access the classes in the JVMCI module.
      *
-     * Note: This API uses {@link Class} instead of {@link Module} to provide backwards
+     * Note: This API uses {@link Class} instead of {@code Module} to provide backwards
      * compatibility for JVMCI clients compiled against a JDK release earlier than 9.
      *
      * @param requestor a class requesting access to the JVMCI module for its module
@@ -52,15 +104,19 @@
         if (sm != null) {
             sm.checkPermission(new JVMCIPermission());
         }
-        Module jvmci = Services.class.getModule();
-        Module requestorModule = requestor.getModule();
-        if (jvmci != requestorModule) {
-            for (String pkg : jvmci.getPackages()) {
-                // Export all JVMCI packages dynamically instead
-                // of requiring a long list of --add-exports
-                // options on the JVM command line.
-                if (!jvmci.isExported(pkg, requestorModule)) {
-                    jvmci.addExports(pkg, requestorModule);
+        if (JAVA_SPECIFICATION_VERSION >= 9) {
+            Object jvmci = invoke(getModule, Services.class);
+            Object requestorModule = invoke(getModule, requestor);
+            if (jvmci != requestorModule) {
+                String[] packages = invoke(getPackages, jvmci);
+                for (String pkg : packages) {
+                    // Export all JVMCI packages dynamically instead
+                    // of requiring a long list of --add-exports
+                    // options on the JVM command line.
+                    boolean exported = invoke(isExported, jvmci, pkg, requestorModule);
+                    if (!exported) {
+                        invoke(addExports, jvmci, pkg, requestorModule);
+                    }
                 }
             }
         }
@@ -77,8 +133,10 @@
         if (sm != null) {
             sm.checkPermission(new JVMCIPermission());
         }
-        Module jvmci = Services.class.getModule();
-        jvmci.addUses(service);
+        if (JAVA_SPECIFICATION_VERSION >= 9) {
+            Object jvmci = invoke(getModule, Services.class);
+            invoke(addUses, jvmci, service);
+        }
 
         // Restrict JVMCI clients to be on the class path or module path
         return ServiceLoader.load(service, ClassLoader.getSystemClassLoader());
@@ -98,8 +156,10 @@
         if (sm != null) {
             sm.checkPermission(new JVMCIPermission());
         }
-        Module jvmci = Services.class.getModule();
-        jvmci.addUses(service);
+        if (JAVA_SPECIFICATION_VERSION >= 9) {
+            Object jvmci = invoke(getModule, Services.class);
+            invoke(addUses, jvmci, service);
+        }
         // Restrict JVMCI clients to be on the class path or module path
         Iterable<S> providers = ServiceLoader.load(service, ClassLoader.getSystemClassLoader());
         S singleProvider = null;
--- a/src/share/vm/c1/c1_Compiler.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/c1/c1_Compiler.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -42,7 +42,7 @@
 #include "runtime/sharedRuntime.hpp"
 
 
-Compiler::Compiler() : AbstractCompiler(c1) {
+Compiler::Compiler() : AbstractCompiler(compiler_c1) {
 }
 
 void Compiler::init_c1_runtime() {
@@ -223,6 +223,7 @@
   case vmIntrinsics::_putCharStringU:
 #ifdef TRACE_HAVE_INTRINSICS
   case vmIntrinsics::_counterTime:
+  case vmIntrinsics::_getBufferWriter:
 #if defined(_LP64) || !defined(TRACE_ID_CLASS_SHIFT)
   case vmIntrinsics::_getClassId:
 #endif
--- a/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -3120,6 +3120,22 @@
 
   __ move(id, rlock_result(x));
 }
+
+void LIRGenerator::do_getBufferWriter(Intrinsic* x) {
+  LabelObj* L_end = new LabelObj();
+
+  LIR_Address* jobj_addr = new LIR_Address(getThreadPointer(),
+                                           in_bytes(TRACE_THREAD_DATA_WRITER_OFFSET),
+                                           T_OBJECT);
+  LIR_Opr result = rlock_result(x);
+  __ move_wide(jobj_addr, result);
+  __ cmp(lir_cond_equal, result, LIR_OprFact::oopConst(NULL));
+  __ branch(lir_cond_equal, T_OBJECT, L_end->label());
+  __ move_wide(new LIR_Address(result, T_OBJECT), result);
+
+  __ branch_destination(L_end->label());
+}
+
 #endif
 
 
@@ -3151,6 +3167,9 @@
   case vmIntrinsics::_getClassId:
     do_ClassIDIntrinsic(x);
     break;
+  case vmIntrinsics::_getBufferWriter:
+    do_getBufferWriter(x);
+    break;
   case vmIntrinsics::_counterTime:
     do_RuntimeCall(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), x);
     break;
--- a/src/share/vm/c1/c1_LIRGenerator.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/c1/c1_LIRGenerator.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -441,6 +441,7 @@
 
 #ifdef TRACE_HAVE_INTRINSICS
   void do_ClassIDIntrinsic(Intrinsic* x);
+  void do_getBufferWriter(Intrinsic* x);
 #endif
 
   void do_RuntimeCall(address routine, Intrinsic* x);
--- a/src/share/vm/classfile/classFileParser.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/classfile/classFileParser.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -5775,9 +5775,22 @@
       // Anonymous classes such as generated LambdaForm classes are also not included.
       if (SystemDictionaryShared::is_sharing_possible(_loader_data) &&
           _host_klass == NULL) {
+        oop class_loader = _loader_data->class_loader();
         ResourceMark rm(THREAD);
-        classlist_file->print_cr("%s", _class_name->as_C_string());
-        classlist_file->flush();
+        // For the boot and platform class loaders, check if the class is not found in the
+        // java runtime image. Additional check for the boot class loader is if the class
+        // is not found in the boot loader's appended entries. This indicates that the class
+        // is not useable during run time, such as the ones found in the --patch-module entries,
+        // so it should not be included in the classlist file.
+        if (((class_loader == NULL && !ClassLoader::contains_append_entry(stream->source())) ||
+             SystemDictionary::is_platform_class_loader(class_loader)) &&
+            !ClassLoader::is_jrt(stream->source())) {
+          tty->print_cr("skip writing class %s from source %s to classlist file",
+            _class_name->as_C_string(), stream->source());
+        } else {
+          classlist_file->print_cr("%s", _class_name->as_C_string());
+          classlist_file->flush();
+        }
       }
     }
 #endif
@@ -5856,6 +5869,11 @@
   assert(cp != NULL, "invariant");
   assert(_loader_data != NULL, "invariant");
 
+  if (_class_name == vmSymbols::java_lang_Object()) {
+    check_property(_local_interfaces == Universe::the_empty_klass_array(),
+                   "java.lang.Object cannot implement an interface in class file %s",
+                   CHECK);
+  }
   // We check super class after class file is parsed and format is checked
   if (_super_class_index > 0 && NULL ==_super_klass) {
     Symbol* const super_class_name = cp->klass_name_at(_super_class_index);
--- a/src/share/vm/classfile/classLoader.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/classfile/classLoader.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -945,11 +945,11 @@
 }
 
 // returns true if entry already on class path
-bool ClassLoader::contains_entry(ClassPathEntry *entry) {
+bool ClassLoader::contains_append_entry(const char* name) {
   ClassPathEntry* e = _first_append_entry;
   while (e != NULL) {
     // assume zip entries have been canonicalized
-    if (strcmp(entry->name(), e->name()) == 0) {
+    if (strcmp(name, e->name()) == 0) {
       return true;
     }
     e = e->next();
@@ -991,7 +991,7 @@
 
     // Do not reorder the bootclasspath which would break get_system_package().
     // Add new entry to linked list
-    if (!check_for_duplicates || !contains_entry(new_entry)) {
+    if (!check_for_duplicates || !contains_append_entry(new_entry->name())) {
       ClassLoaderExt::add_class_path_entry(path, check_for_duplicates, new_entry);
     }
     return true;
--- a/src/share/vm/classfile/classLoader.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/classfile/classLoader.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -451,7 +451,7 @@
   static void set_first_append_entry(ClassPathEntry* entry);
 
   // indicates if class path already contains a entry (exact match by name)
-  static bool contains_entry(ClassPathEntry* entry);
+  static bool contains_append_entry(const char* name);
 
   // adds a class path list
   static void add_to_list(ClassPathEntry* new_entry);
--- a/src/share/vm/classfile/klassFactory.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/classfile/klassFactory.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -74,7 +74,7 @@
         (SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index);
       ClassFileStream* stream = new ClassFileStream(ptr,
                                                     end_ptr - ptr,
-                                                    ent->_name,
+                                                    ent == NULL ? NULL : ent->_name,
                                                     ClassFileStream::verify);
       ClassFileParser parser(stream,
                              class_name,
--- a/src/share/vm/classfile/stackMapTableFormat.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/classfile/stackMapTableFormat.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -203,6 +203,7 @@
   inline bool verify(address start, address end) const;
 
   inline void print_on(outputStream* st, int current_offset) const;
+  inline void print_truncated(outputStream* st, int current_offset) const;
 
   // Create as_xxx and is_xxx methods for the subtypes
 #define FRAME_TYPE_DECL(stackmap_frame_type, arg1, arg2) \
@@ -263,6 +264,10 @@
   void print_on(outputStream* st, int current_offset = -1) const {
     st->print("same_frame(@%d)", offset_delta() + current_offset);
   }
+
+  void print_truncated(outputStream* st, int current_offset = -1) const {
+    print_on(st, current_offset);
+  }
 };
 
 class same_frame_extended : public stack_map_frame {
@@ -309,6 +314,10 @@
   void print_on(outputStream* st, int current_offset = -1) const {
     st->print("same_frame_extended(@%d)", offset_delta() + current_offset);
   }
+
+  void print_truncated(outputStream* st, int current_offset = -1) const {
+    print_on(st, current_offset);
+  }
 };
 
 class same_locals_1_stack_item_frame : public stack_map_frame {
@@ -381,6 +390,11 @@
     types()->print_on(st);
     st->print(")");
   }
+
+  void print_truncated(outputStream* st, int current_offset = -1) const {
+    st->print("same_locals_1_stack_item_frame(@%d), output truncated, Stackmap exceeds table size.",
+              offset_delta() + current_offset);
+  }
 };
 
 class same_locals_1_stack_item_extended : public stack_map_frame {
@@ -446,6 +460,11 @@
     types()->print_on(st);
     st->print(")");
   }
+
+  void print_truncated(outputStream* st, int current_offset = -1) const {
+    st->print("same_locals_1_stack_item_extended(@%d), output truncated, Stackmap exceeds table size.",
+              offset_delta() + current_offset);
+  }
 };
 
 class chop_frame : public stack_map_frame {
@@ -511,6 +530,10 @@
   void print_on(outputStream* st, int current_offset = -1) const {
     st->print("chop_frame(@%d,%d)", offset_delta() + current_offset, chops());
   }
+
+  void print_truncated(outputStream* st, int current_offset = -1) const {
+    print_on(st, current_offset);
+  }
 };
 
 class append_frame : public stack_map_frame {
@@ -619,6 +642,11 @@
     }
     st->print(")");
   }
+
+  void print_truncated(outputStream* st, int current_offset = -1) const {
+    st->print("append_frame(@%d), output truncated, Stackmap exceeds table size.",
+              offset_delta() + current_offset);
+  }
 };
 
 class full_frame : public stack_map_frame {
@@ -784,6 +812,11 @@
     }
     st->print("})");
   }
+
+  void print_truncated(outputStream* st, int current_offset = -1) const {
+    st->print("full_frame(@%d), output truncated, Stackmap exceeds table size.",
+              offset_delta() + current_offset);
+  }
 };
 
 #define VIRTUAL_DISPATCH(stack_frame_type, func_name, args) \
@@ -841,6 +874,10 @@
   FOR_EACH_STACKMAP_FRAME_TYPE(VOID_VIRTUAL_DISPATCH, print_on, (st, offs));
 }
 
+void stack_map_frame::print_truncated(outputStream* st, int offs = -1) const {
+  FOR_EACH_STACKMAP_FRAME_TYPE(VOID_VIRTUAL_DISPATCH, print_truncated, (st, offs));
+}
+
 #undef VIRTUAL_DISPATCH
 #undef VOID_VIRTUAL_DISPATCH
 
--- a/src/share/vm/classfile/stringTable.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/classfile/stringTable.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -437,17 +437,15 @@
           st->print("%d: ", length);
         } else {
           ResourceMark rm(THREAD);
-          int utf8_length;
+          int utf8_length = length;
           char* utf8_string;
 
           if (!is_latin1) {
             jchar* chars = value->char_at_addr(0);
-            utf8_length = UNICODE::utf8_length(chars, length);
-            utf8_string = UNICODE::as_utf8(chars, length);
+            utf8_string = UNICODE::as_utf8(chars, utf8_length);
           } else {
             jbyte* bytes = value->byte_at_addr(0);
-            utf8_length = UNICODE::utf8_length(bytes, length);
-            utf8_string = UNICODE::as_utf8(bytes, length);
+            utf8_string = UNICODE::as_utf8(bytes, utf8_length);
           }
 
           st->print("%d: ", utf8_length);
--- a/src/share/vm/classfile/systemDictionary.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/classfile/systemDictionary.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1234,7 +1234,7 @@
   SharedClassPathEntry* ent =
             (SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index);
   if (!Universe::is_module_initialized()) {
-    assert(ent->is_jrt(),
+    assert(ent != NULL && ent->is_jrt(),
            "Loading non-bootstrap classes before the module system is initialized");
     assert(class_loader.is_null(), "sanity");
     return true;
@@ -1257,6 +1257,7 @@
   }
 
   if (class_loader.is_null()) {
+    assert(ent != NULL, "Shared class for NULL classloader must have valid SharedClassPathEntry");
     // The NULL classloader can load archived class originated from the
     // "modules" jimage and the -Xbootclasspath/a. For class from the
     // "modules" jimage, the PackageEntry/ModuleEntry must be defined
--- a/src/share/vm/classfile/verifier.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/classfile/verifier.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -541,8 +541,19 @@
     stack_map_frame* sm_frame = sm_table->entries();
     streamIndentor si2(ss);
     int current_offset = -1;
+    // Subtract two from StackMapAttribute length because the length includes
+    // two bytes for number of table entries.
+    size_t sm_table_space = method->stackmap_data()->length() - 2;
     for (u2 i = 0; i < sm_table->number_of_entries(); ++i) {
       ss->indent();
+      size_t sm_frame_size = sm_frame->size();
+      // If the size of the next stackmap exceeds the length of the entire
+      // stackmap table then print a truncated message and return.
+      if (sm_frame_size > sm_table_space) {
+        sm_frame->print_truncated(ss, current_offset);
+        return;
+      }
+      sm_table_space -= sm_frame_size;
       sm_frame->print_on(ss, current_offset);
       ss->cr();
       current_offset += sm_frame->offset_delta();
--- a/src/share/vm/code/codeBlob.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/code/codeBlob.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -45,6 +45,10 @@
 #include "c1/c1_Runtime1.hpp"
 #endif
 
+const char* CodeBlob::compiler_name() const {
+  return compilertype2name(_type);
+}
+
 unsigned int CodeBlob::align_code_offset(int offset) {
   // align the size to CodeEntryAlignment
   return
@@ -65,7 +69,7 @@
   return size;
 }
 
-CodeBlob::CodeBlob(const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments) :
+CodeBlob::CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments) :
   _name(name),
   _size(layout.size()),
   _header_size(layout.header_size()),
@@ -80,7 +84,8 @@
   _data_end(layout.data_end()),
   _relocation_begin(layout.relocation_begin()),
   _relocation_end(layout.relocation_end()),
-  _content_begin(layout.content_begin())
+  _content_begin(layout.content_begin()),
+  _type(type)
 {
   assert(layout.size()        == round_to(layout.size(),        oopSize), "unaligned size");
   assert(layout.header_size() == round_to(layout.header_size(), oopSize), "unaligned size");
@@ -92,7 +97,7 @@
 #endif // COMPILER1
 }
 
-CodeBlob::CodeBlob(const char* name, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) :
+CodeBlob::CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) :
   _name(name),
   _size(layout.size()),
   _header_size(layout.header_size()),
@@ -106,7 +111,8 @@
   _data_end(layout.data_end()),
   _relocation_begin(layout.relocation_begin()),
   _relocation_end(layout.relocation_end()),
-  _content_begin(layout.content_begin())
+  _content_begin(layout.content_begin()),
+  _type(type)
 {
   assert(_size        == round_to(_size,        oopSize), "unaligned size");
   assert(_header_size == round_to(_header_size, oopSize), "unaligned size");
@@ -123,7 +129,7 @@
 
 // Creates a simple CodeBlob. Sets up the size of the different regions.
 RuntimeBlob::RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size)
-  : CodeBlob(name, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */)
+  : CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */)
 {
   assert(locs_size   == round_to(locs_size,   oopSize), "unaligned size");
   assert(!UseRelocIndex, "no space allocated for reloc index yet");
@@ -148,7 +154,7 @@
   int         frame_size,
   OopMapSet*  oop_maps,
   bool        caller_must_gc_arguments
-) : CodeBlob(name, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete, frame_size, oop_maps, caller_must_gc_arguments) {
+) : CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete, frame_size, oop_maps, caller_must_gc_arguments) {
   cb->copy_code_and_locs_to(this);
 }
 
--- a/src/share/vm/code/codeBlob.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/code/codeBlob.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -26,6 +26,7 @@
 #define SHARE_VM_CODE_CODEBLOB_HPP
 
 #include "asm/codeBuffer.hpp"
+#include "compiler/compilerDefinitions.hpp"
 #include "compiler/oopMap.hpp"
 #include "runtime/frame.hpp"
 #include "runtime/handles.hpp"
@@ -71,7 +72,8 @@
   friend class CodeCacheDumper;
 
 protected:
-  const char* _name;
+
+  const CompilerType _type;                      // CompilerType
   int        _size;                              // total size of CodeBlob in bytes
   int        _header_size;                       // size of header (depends on subclass)
   int        _frame_complete_offset;             // instruction offsets in [0.._frame_complete_offset) have
@@ -92,9 +94,10 @@
   ImmutableOopMapSet* _oop_maps;                 // OopMap for this CodeBlob
   bool                _caller_must_gc_arguments;
   CodeStrings         _strings;
+  const char*         _name;
 
-  CodeBlob(const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
-  CodeBlob(const char* name, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
+  CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
+  CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
 public:
   // Returns the space needed for CodeBlob
   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
@@ -115,9 +118,11 @@
   virtual bool is_method_handles_adapter_blob() const { return false; }
   virtual bool is_compiled() const                    { return false; }
 
-  virtual bool is_compiled_by_c2() const         { return false; }
-  virtual bool is_compiled_by_c1() const         { return false; }
-  virtual bool is_compiled_by_jvmci() const      { return false; }
+  inline bool is_compiled_by_c1() const    { return _type == compiler_c1; };
+  inline bool is_compiled_by_c2() const    { return _type == compiler_c2; };
+  inline bool is_compiled_by_jvmci() const { return _type == compiler_jvmci; };
+  inline bool is_compiled_by_shark() const { return _type == compiler_shark; };
+  const char* compiler_name() const;
 
   // Casting
   nmethod* as_nmethod_or_null()                { return is_nmethod() ? (nmethod*) this : NULL; }
--- a/src/share/vm/code/compiledMethod.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/code/compiledMethod.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -31,14 +31,14 @@
 #include "memory/resourceArea.hpp"
 #include "runtime/mutexLocker.hpp"
 
-CompiledMethod::CompiledMethod(Method* method, const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments)
-  : CodeBlob(name, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
+CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments)
+  : CodeBlob(name, type, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
   _method(method), _mark_for_deoptimization_status(not_marked) {
   init_defaults();
 }
 
-CompiledMethod::CompiledMethod(Method* method, const char* name, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments)
-  : CodeBlob(name, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
+CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments)
+  : CodeBlob(name, type, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments),
   _method(method), _mark_for_deoptimization_status(not_marked) {
   init_defaults();
 }
--- a/src/share/vm/code/compiledMethod.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/code/compiledMethod.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -164,8 +164,8 @@
 
   virtual void flush() = 0;
 protected:
-  CompiledMethod(Method* method, const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
-  CompiledMethod(Method* method, const char* name, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
+  CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
+  CompiledMethod(Method* method, const char* name, CompilerType type, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
 
 public:
   virtual bool is_compiled() const                { return true; }
@@ -191,12 +191,10 @@
                              // will be transformed to zombie immediately
   };
 
-  virtual AbstractCompiler* compiler() const = 0;
   virtual bool  is_in_use() const = 0;
   virtual int   comp_level() const = 0;
   virtual int   compile_id() const = 0;
 
-
   virtual address verified_entry_point() const = 0;
   virtual void log_identity(xmlStream* log) const = 0;
   virtual void log_state_change() const = 0;
--- a/src/share/vm/code/dependencyContext.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/code/dependencyContext.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -272,79 +272,3 @@
 int nmethodBucket::decrement() {
   return Atomic::add(-1, (volatile int *)&_count);
 }
-
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-class TestDependencyContext {
- public:
-  nmethod* _nmethods[3];
-
-  intptr_t _dependency_context;
-
-  DependencyContext dependencies() {
-    DependencyContext depContext(&_dependency_context);
-    return depContext;
-  }
-
-  TestDependencyContext() : _dependency_context(DependencyContext::EMPTY) {
-    CodeCache_lock->lock_without_safepoint_check();
-
-    _nmethods[0] = reinterpret_cast<nmethod*>(0x8 * 0);
-    _nmethods[1] = reinterpret_cast<nmethod*>(0x8 * 1);
-    _nmethods[2] = reinterpret_cast<nmethod*>(0x8 * 2);
-
-    dependencies().add_dependent_nmethod(_nmethods[2]);
-    dependencies().add_dependent_nmethod(_nmethods[1]);
-    dependencies().add_dependent_nmethod(_nmethods[0]);
-  }
-
-  ~TestDependencyContext() {
-    dependencies().wipe();
-    CodeCache_lock->unlock();
-  }
-
-  static void testRemoveDependentNmethod(int id, bool delete_immediately) {
-    TestDependencyContext c;
-    DependencyContext depContext = c.dependencies();
-    assert(!has_stale_entries(depContext), "check");
-
-    nmethod* nm = c._nmethods[id];
-    depContext.remove_dependent_nmethod(nm, delete_immediately);
-
-    if (!delete_immediately) {
-      assert(has_stale_entries(depContext), "check");
-      assert(depContext.is_dependent_nmethod(nm), "check");
-      depContext.expunge_stale_entries();
-    }
-
-    assert(!has_stale_entries(depContext), "check");
-    assert(!depContext.is_dependent_nmethod(nm), "check");
-  }
-
-  static void testRemoveDependentNmethod() {
-    testRemoveDependentNmethod(0, false);
-    testRemoveDependentNmethod(1, false);
-    testRemoveDependentNmethod(2, false);
-
-    testRemoveDependentNmethod(0, true);
-    testRemoveDependentNmethod(1, true);
-    testRemoveDependentNmethod(2, true);
-  }
-
-  static void test() {
-    testRemoveDependentNmethod();
-  }
-
-  static bool has_stale_entries(DependencyContext ctx) {
-    assert(ctx.has_stale_entries() == ctx.find_stale_entries(), "check");
-    return ctx.has_stale_entries();
-  }
-};
-
-void TestDependencyContext_test() {
-  TestDependencyContext::test();
-}
-
-#endif // PRODUCT
--- a/src/share/vm/code/dependencyContext.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/code/dependencyContext.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -29,6 +29,7 @@
 #include "oops/oop.hpp"
 #include "runtime/handles.hpp"
 #include "runtime/perfData.hpp"
+#include "runtime/safepoint.hpp"
 
 class nmethod;
 class DepChange;
--- a/src/share/vm/code/nmethod.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/code/nmethod.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -82,32 +82,6 @@
 
 #endif
 
-bool nmethod::is_compiled_by_c1() const {
-  if (compiler() == NULL) {
-    return false;
-  }
-  return compiler()->is_c1();
-}
-bool nmethod::is_compiled_by_jvmci() const {
-  if (compiler() == NULL || method() == NULL)  return false;  // can happen during debug printing
-  if (is_native_method()) return false;
-  return compiler()->is_jvmci();
-}
-bool nmethod::is_compiled_by_c2() const {
-  if (compiler() == NULL) {
-    return false;
-  }
-  return compiler()->is_c2();
-}
-bool nmethod::is_compiled_by_shark() const {
-  if (compiler() == NULL) {
-    return false;
-  }
-  return compiler()->is_shark();
-}
-
-
-
 //---------------------------------------------------------------------------------
 // NMethod statistics
 // They are printed under various flags, including:
@@ -440,7 +414,6 @@
     _scavenge_root_link    = NULL;
   }
   _scavenge_root_state     = 0;
-  _compiler                = NULL;
 #if INCLUDE_RTM_OPT
   _rtm_state               = NoRTM;
 #endif
@@ -468,7 +441,7 @@
     CodeOffsets offsets;
     offsets.set_value(CodeOffsets::Verified_Entry, vep_offset);
     offsets.set_value(CodeOffsets::Frame_Complete, frame_complete);
-    nm = new (native_nmethod_size, CompLevel_none) nmethod(method(), native_nmethod_size,
+    nm = new (native_nmethod_size, CompLevel_none) nmethod(method(), compiler_none, native_nmethod_size,
                                             compile_id, &offsets,
                                             code_buffer, frame_size,
                                             basic_lock_owner_sp_offset,
@@ -518,7 +491,7 @@
       + round_to(debug_info->data_size()       , oopSize);
 
     nm = new (nmethod_size, comp_level)
-    nmethod(method(), nmethod_size, compile_id, entry_bci, offsets,
+    nmethod(method(), compiler->type(), nmethod_size, compile_id, entry_bci, offsets,
             orig_pc_offset, debug_info, dependencies, code_buffer, frame_size,
             oop_maps,
             handler_table,
@@ -569,6 +542,7 @@
 // For native wrappers
 nmethod::nmethod(
   Method* method,
+  CompilerType type,
   int nmethod_size,
   int compile_id,
   CodeOffsets* offsets,
@@ -577,7 +551,7 @@
   ByteSize basic_lock_owner_sp_offset,
   ByteSize basic_lock_sp_offset,
   OopMapSet* oop_maps )
-  : CompiledMethod(method, "native nmethod", nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false),
+  : CompiledMethod(method, "native nmethod", type, nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false),
   _native_receiver_sp_offset(basic_lock_owner_sp_offset),
   _native_basic_lock_sp_offset(basic_lock_sp_offset)
 {
@@ -666,6 +640,7 @@
 
 nmethod::nmethod(
   Method* method,
+  CompilerType type,
   int nmethod_size,
   int compile_id,
   int entry_bci,
@@ -685,7 +660,7 @@
   Handle speculation_log
 #endif
   )
-  : CompiledMethod(method, "nmethod", nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false),
+  : CompiledMethod(method, "nmethod", type, nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false),
   _native_receiver_sp_offset(in_ByteSize(-1)),
   _native_basic_lock_sp_offset(in_ByteSize(-1))
 {
@@ -701,7 +676,6 @@
     _entry_bci               = entry_bci;
     _compile_id              = compile_id;
     _comp_level              = comp_level;
-    _compiler                = compiler;
     _orig_pc_offset          = orig_pc_offset;
     _hotness_counter         = NMethodSweeper::hotness_counter_reset_val();
 
@@ -803,9 +777,7 @@
   log->print(" compile_id='%d'", compile_id());
   const char* nm_kind = compile_kind();
   if (nm_kind != NULL)  log->print(" compile_kind='%s'", nm_kind);
-  if (compiler() != NULL) {
-    log->print(" compiler='%s'", compiler()->name());
-  }
+  log->print(" compiler='%s'", compiler_name());
   if (TieredCompilation) {
     log->print(" level='%d'", comp_level());
   }
--- a/src/share/vm/code/nmethod.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/code/nmethod.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -74,8 +74,6 @@
   static nmethod* volatile _oops_do_mark_nmethods;
   nmethod*        volatile _oops_do_mark_link;
 
-  AbstractCompiler* _compiler; // The compiler which compiled this nmethod
-
   // offsets for entry points
   address _entry_point;                      // entry point with class check
   address _verified_entry_point;             // entry point without class check
@@ -166,6 +164,7 @@
 
   // For native wrappers
   nmethod(Method* method,
+          CompilerType type,
           int nmethod_size,
           int compile_id,
           CodeOffsets* offsets,
@@ -177,6 +176,7 @@
 
   // Creation support
   nmethod(Method* method,
+          CompilerType type,
           int nmethod_size,
           int compile_id,
           int entry_bci,
@@ -251,18 +251,10 @@
                                      ByteSize basic_lock_sp_offset,
                                      OopMapSet* oop_maps);
 
-  // accessors
-  AbstractCompiler* compiler() const              { return _compiler; }
-
   // type info
   bool is_nmethod() const                         { return true; }
   bool is_osr_method() const                      { return _entry_bci != InvocationEntryBci; }
 
-  bool is_compiled_by_c1() const;
-  bool is_compiled_by_jvmci() const;
-  bool is_compiled_by_c2() const;
-  bool is_compiled_by_shark() const;
-
   // boundaries for different parts
   address consts_begin          () const          { return           header_begin() + _consts_offset        ; }
   address consts_end            () const          { return           code_begin()                           ; }
--- a/src/share/vm/code/relocInfo.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/code/relocInfo.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -743,7 +743,9 @@
 }
 
 Method* virtual_call_Relocation::method_value() {
-  Metadata* m = code()->metadata_at(_method_index);
+  CompiledMethod* cm = code();
+  if (cm == NULL) return (Method*)NULL;
+  Metadata* m = cm->metadata_at(_method_index);
   assert(m != NULL || _method_index == 0, "should be non-null for non-zero index");
   assert(m == NULL || m->is_method(), "not a method");
   return (Method*)m;
@@ -769,7 +771,9 @@
 }
 
 Method* opt_virtual_call_Relocation::method_value() {
-  Metadata* m = code()->metadata_at(_method_index);
+  CompiledMethod* cm = code();
+  if (cm == NULL) return (Method*)NULL;
+  Metadata* m = cm->metadata_at(_method_index);
   assert(m != NULL || _method_index == 0, "should be non-null for non-zero index");
   assert(m == NULL || m->is_method(), "not a method");
   return (Method*)m;
@@ -800,7 +804,9 @@
 }
 
 Method* static_call_Relocation::method_value() {
-  Metadata* m = code()->metadata_at(_method_index);
+  CompiledMethod* cm = code();
+  if (cm == NULL) return (Method*)NULL;
+  Metadata* m = cm->metadata_at(_method_index);
   assert(m != NULL || _method_index == 0, "should be non-null for non-zero index");
   assert(m == NULL || m->is_method(), "not a method");
   return (Method*)m;
@@ -970,7 +976,9 @@
       // work even during GC or other inconvenient times.
       if (WizardMode && oop_value != NULL) {
         tty->print("oop_value=" INTPTR_FORMAT ": ", p2i(oop_value));
-        oop_value->print_value_on(tty);
+        if (oop_value->is_oop()) {
+          oop_value->print_value_on(tty);
+        }
       }
       break;
     }
--- a/src/share/vm/compiler/abstractCompiler.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/compiler/abstractCompiler.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -26,6 +26,7 @@
 #define SHARE_VM_COMPILER_ABSTRACTCOMPILER_HPP
 
 #include "ci/compilerInterface.hpp"
+#include "compiler/compilerDefinitions.hpp"
 #include "compiler/compilerDirectives.hpp"
 
 typedef void (*initializer)(void);
@@ -82,24 +83,15 @@
   // This thread will initialize the compiler runtime.
   bool should_perform_init();
 
-  // The (closed set) of concrete compiler classes.
-  enum Type {
-    none,
-    c1,
-    c2,
-    jvmci,
-    shark
-  };
-
  private:
-  Type _type;
+  const CompilerType _type;
 
 #if INCLUDE_JVMCI
   CompilerStatistics _stats;
 #endif
 
  public:
-  AbstractCompiler(Type type) : _type(type), _compiler_state(uninitialized), _num_compiler_threads(0) {}
+  AbstractCompiler(CompilerType type) : _type(type), _compiler_state(uninitialized), _num_compiler_threads(0) {}
 
   // This function determines the compiler thread that will perform the
   // shutdown of the corresponding compiler runtime.
@@ -157,10 +149,11 @@
   }
 
   // Compiler type queries.
-  bool is_c1()                                   { return _type == c1; }
-  bool is_c2()                                   { return _type == c2; }
-  bool is_jvmci()                                { return _type == jvmci; }
-  bool is_shark()                                { return _type == shark; }
+  const bool is_c1()                             { return _type == compiler_c1; }
+  const bool is_c2()                             { return _type == compiler_c2; }
+  const bool is_jvmci()                          { return _type == compiler_jvmci; }
+  const bool is_shark()                          { return _type == compiler_shark; }
+  const CompilerType type()                      { return _type; }
 
   // Extra tests to identify trivial methods for the tiered compilation policy.
   virtual bool is_trivial(Method* method) { return false; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/compiler/compilerDefinitions.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,34 @@
+/*
+ * 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 "precompiled.hpp"
+#include "compiler/compilerDefinitions.hpp"
+
+const char* compilertype2name_tab[compiler_number_of_types] = {
+  "",
+  "c1",
+  "c2",
+  "jvmci",
+  "shark"
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/compiler/compilerDefinitions.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef SHARE_VM_COMPILER_COMPILERDEFINITIONS_HPP
+#define SHARE_VM_COMPILER_COMPILERDEFINITIONS_HPP
+
+#include "utilities/globalDefinitions.hpp"
+
+// The (closed set) of concrete compiler classes.
+enum CompilerType {
+  compiler_none,
+  compiler_c1,
+  compiler_c2,
+  compiler_jvmci,
+  compiler_shark,
+  compiler_number_of_types
+};
+
+extern const char* compilertype2name_tab[compiler_number_of_types];     // Map CompilerType to its name
+inline const char* compilertype2name(CompilerType t) { return (uint)t < compiler_number_of_types ? compilertype2name_tab[t] : NULL; }
+
+// Handy constants for deciding which compiler mode to use.
+enum MethodCompilation {
+  InvocationEntryBci = -1     // i.e., not a on-stack replacement compilation
+};
+
+// Enumeration to distinguish tiers of compilation
+enum CompLevel {
+  CompLevel_any               = -1,
+  CompLevel_all               = -1,
+  CompLevel_none              = 0,         // Interpreter
+  CompLevel_simple            = 1,         // C1
+  CompLevel_limited_profile   = 2,         // C1, invocation & backedge counters
+  CompLevel_full_profile      = 3,         // C1, invocation & backedge counters + mdo
+  CompLevel_full_optimization = 4,         // C2, Shark or JVMCI
+
+#if defined(COMPILER2) || defined(SHARK)
+  CompLevel_highest_tier      = CompLevel_full_optimization,  // pure C2 and tiered or JVMCI and tiered
+#elif defined(COMPILER1)
+  CompLevel_highest_tier      = CompLevel_simple,             // pure C1 or JVMCI
+#else
+  CompLevel_highest_tier      = CompLevel_none,
+#endif
+
+#if defined(TIERED)
+  CompLevel_initial_compile   = CompLevel_full_profile        // tiered
+#elif defined(COMPILER1) || INCLUDE_JVMCI
+  CompLevel_initial_compile   = CompLevel_simple              // pure C1 or JVMCI
+#elif defined(COMPILER2) || defined(SHARK)
+  CompLevel_initial_compile   = CompLevel_full_optimization   // pure C2
+#else
+  CompLevel_initial_compile   = CompLevel_none
+#endif
+};
+
+inline bool is_c1_compile(int comp_level) {
+  return comp_level > CompLevel_none && comp_level < CompLevel_full_optimization;
+}
+
+inline bool is_c2_compile(int comp_level) {
+  return comp_level == CompLevel_full_optimization;
+}
+
+inline bool is_highest_tier_compile(int comp_level) {
+  return comp_level == CompLevel_highest_tier;
+}
+
+inline bool is_compile(int comp_level) {
+  return is_c1_compile(comp_level) || is_c2_compile(comp_level);
+}
+
+// States of Restricted Transactional Memory usage.
+enum RTMState {
+  NoRTM      = 0x2, // Don't use RTM
+  UseRTM     = 0x1, // Use RTM
+  ProfileRTM = 0x0  // Use RTM with abort ratio calculation
+};
+
+#ifndef INCLUDE_RTM_OPT
+#define INCLUDE_RTM_OPT 0
+#endif
+#if INCLUDE_RTM_OPT
+#define RTM_OPT_ONLY(code) code
+#else
+#define RTM_OPT_ONLY(code)
+#endif
+
+#endif // SHARE_VM_COMPILER_COMPILERDEFINITIONS_HPP
--- a/src/share/vm/gc/cms/compactibleFreeListSpace.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/gc/cms/compactibleFreeListSpace.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -922,18 +922,13 @@
         return res;
       }
     } else {
-      // must read from what 'p' points to in each loop.
-      Klass* k = ((volatile oopDesc*)p)->klass_or_null();
+      // Ensure klass read before size.
+      Klass* k = oop(p)->klass_or_null_acquire();
       if (k != NULL) {
         assert(k->is_klass(), "Should really be klass oop.");
         oop o = (oop)p;
         assert(o->is_oop(true /* ignore mark word */), "Should be an oop.");
 
-        // Bugfix for systems with weak memory model (PPC64/IA64).
-        // The object o may be an array. Acquire to make sure that the array
-        // size (third word) is consistent.
-        OrderAccess::acquire();
-
         size_t res = o->size_given_klass(k);
         res = adjustObjectSize(res);
         assert(res != 0, "Block size should not be 0");
@@ -977,21 +972,13 @@
         return res;
       }
     } else {
-      // must read from what 'p' points to in each loop.
-      Klass* k = ((volatile oopDesc*)p)->klass_or_null();
-      // We trust the size of any object that has a non-NULL
-      // klass and (for those in the perm gen) is parsable
-      // -- irrespective of its conc_safe-ty.
+      // Ensure klass read before size.
+      Klass* k = oop(p)->klass_or_null_acquire();
       if (k != NULL) {
         assert(k->is_klass(), "Should really be klass oop.");
         oop o = (oop)p;
         assert(o->is_oop(), "Should be an oop");
 
-        // Bugfix for systems with weak memory model (PPC64/IA64).
-        // The object o may be an array. Acquire to make sure that the array
-        // size (third word) is consistent.
-        OrderAccess::acquire();
-
         size_t res = o->size_given_klass(k);
         res = adjustObjectSize(res);
         assert(res != 0, "Block size should not be 0");
@@ -1028,7 +1015,7 @@
   FreeChunk* fc = (FreeChunk*)p;
   assert(is_in_reserved(p), "Should be in space");
   if (FreeChunk::indicatesFreeChunk(p)) return false;
-  Klass* k = oop(p)->klass_or_null();
+  Klass* k = oop(p)->klass_or_null_acquire();
   if (k != NULL) {
     // Ignore mark word because it may have been used to
     // chain together promoted objects (the last one
--- a/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -5630,7 +5630,7 @@
 HeapWord* CMSCollector::next_card_start_after_block(HeapWord* addr) const {
   size_t sz = 0;
   oop p = (oop)addr;
-  if (p->klass_or_null() != NULL) {
+  if (p->klass_or_null_acquire() != NULL) {
     sz = CompactibleFreeListSpace::adjustObjectSize(p->size());
   } else {
     sz = block_size_using_printezis_bits(addr);
@@ -6076,7 +6076,7 @@
   }
   if (_bitMap->isMarked(addr)) {
     // it's marked; is it potentially uninitialized?
-    if (p->klass_or_null() != NULL) {
+    if (p->klass_or_null_acquire() != NULL) {
         // an initialized object; ignore mark word in verification below
         // since we are running concurrent with mutators
         assert(p->is_oop(true), "should be an oop");
@@ -6121,7 +6121,7 @@
     }
   } else {
     // Either a not yet marked object or an uninitialized object
-    if (p->klass_or_null() == NULL) {
+    if (p->klass_or_null_acquire() == NULL) {
       // An uninitialized object, skip to the next card, since
       // we may not be able to read its P-bits yet.
       assert(size == 0, "Initial value");
@@ -6320,7 +6320,7 @@
     assert(_skipBits == 0, "tautology");
     _skipBits = 2;  // skip next two marked bits ("Printezis-marks")
     oop p = oop(addr);
-    if (p->klass_or_null() == NULL) {
+    if (p->klass_or_null_acquire() == NULL) {
       DEBUG_ONLY(if (!_verifying) {)
         // We re-dirty the cards on which this object lies and increase
         // the _threshold so that we'll come back to scan this object
@@ -6340,7 +6340,7 @@
           if (_threshold < end_card_addr) {
             _threshold = end_card_addr;
           }
-          if (p->klass_or_null() != NULL) {
+          if (p->klass_or_null_acquire() != NULL) {
             // Redirty the range of cards...
             _mut->mark_range(redirty_range);
           } // ...else the setting of klass will dirty the card anyway.
@@ -6483,7 +6483,7 @@
     assert(_skip_bits == 0, "tautology");
     _skip_bits = 2;  // skip next two marked bits ("Printezis-marks")
     oop p = oop(addr);
-    if (p->klass_or_null() == NULL) {
+    if (p->klass_or_null_acquire() == NULL) {
       // in the case of Clean-on-Enter optimization, redirty card
       // and avoid clearing card by increasing  the threshold.
       return true;
@@ -7354,7 +7354,7 @@
            "alignment problem");
 
 #ifdef ASSERT
-      if (oop(addr)->klass_or_null() != NULL) {
+      if (oop(addr)->klass_or_null_acquire() != NULL) {
         // Ignore mark word because we are running concurrent with mutators
         assert(oop(addr)->is_oop(true), "live block should be an oop");
         assert(size ==
@@ -7365,7 +7365,7 @@
 
   } else {
     // This should be an initialized object that's alive.
-    assert(oop(addr)->klass_or_null() != NULL,
+    assert(oop(addr)->klass_or_null_acquire() != NULL,
            "Should be an initialized object");
     // Ignore mark word because we are running concurrent with mutators
     assert(oop(addr)->is_oop(true), "live block should be an oop");
--- a/src/share/vm/gc/g1/g1BiasedArray.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/gc/g1/g1BiasedArray.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -53,99 +53,4 @@
             biased_index, bias(), length());
 }
 
-class TestMappedArray : public G1BiasedMappedArray<int> {
-protected:
-  virtual int default_value() const { return 0xBAADBABE; }
-public:
-  static void test_biasedarray() {
-    const size_t REGION_SIZE_IN_WORDS = 512;
-    const size_t NUM_REGIONS = 20;
-    HeapWord* fake_heap = (HeapWord*)LP64_ONLY(0xBAAA00000) NOT_LP64(0xBA000000); // Any value that is non-zero
-
-    TestMappedArray array;
-    array.initialize(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
-            REGION_SIZE_IN_WORDS * HeapWordSize);
-    // Check address calculation (bounds)
-    assert(array.bottom_address_mapped() == fake_heap,
-           "bottom mapped address should be " PTR_FORMAT ", but is " PTR_FORMAT, p2i(fake_heap), p2i(array.bottom_address_mapped()));
-    assert(array.end_address_mapped() == (fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS), "must be");
-
-    int* bottom = array.address_mapped_to(fake_heap);
-    assert((void*)bottom == (void*) array.base(), "must be");
-    int* end = array.address_mapped_to(fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS);
-    assert((void*)end == (void*)(array.base() + array.length()), "must be");
-    // The entire array should contain default value elements
-    for (int* current = bottom; current < end; current++) {
-      assert(*current == array.default_value(), "must be");
-    }
-
-    // Test setting values in the table
-
-    HeapWord* region_start_address = fake_heap + REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2);
-    HeapWord* region_end_address = fake_heap + (REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2) + REGION_SIZE_IN_WORDS - 1);
-
-    // Set/get by address tests: invert some value; first retrieve one
-    int actual_value = array.get_by_index(NUM_REGIONS / 2);
-    array.set_by_index(NUM_REGIONS / 2, ~actual_value);
-    // Get the same value by address, should correspond to the start of the "region"
-    int value = array.get_by_address(region_start_address);
-    assert(value == ~actual_value, "must be");
-    // Get the same value by address, at one HeapWord before the start
-    value = array.get_by_address(region_start_address - 1);
-    assert(value == array.default_value(), "must be");
-    // Get the same value by address, at the end of the "region"
-    value = array.get_by_address(region_end_address);
-    assert(value == ~actual_value, "must be");
-    // Make sure the next value maps to another index
-    value = array.get_by_address(region_end_address + 1);
-    assert(value == array.default_value(), "must be");
-
-    // Reset the value in the array
-    array.set_by_address(region_start_address + (region_end_address - region_start_address) / 2, actual_value);
-
-    // The entire array should have the default value again
-    for (int* current = bottom; current < end; current++) {
-      assert(*current == array.default_value(), "must be");
-    }
-
-    // Set/get by index tests: invert some value
-    idx_t index = NUM_REGIONS / 2;
-    actual_value = array.get_by_index(index);
-    array.set_by_index(index, ~actual_value);
-
-    value = array.get_by_index(index);
-    assert(value == ~actual_value, "must be");
-
-    value = array.get_by_index(index - 1);
-    assert(value == array.default_value(), "must be");
-
-    value = array.get_by_index(index + 1);
-    assert(value == array.default_value(), "must be");
-
-    array.set_by_index(0, 0);
-    value = array.get_by_index(0);
-    assert(value == 0, "must be");
-
-    array.set_by_index(array.length() - 1, 0);
-    value = array.get_by_index(array.length() - 1);
-    assert(value == 0, "must be");
-
-    array.set_by_index(index, 0);
-
-    // The array should have three zeros, and default values otherwise
-    size_t num_zeros = 0;
-    for (int* current = bottom; current < end; current++) {
-      assert(*current == array.default_value() || *current == 0, "must be");
-      if (*current == 0) {
-        num_zeros++;
-      }
-    }
-    assert(num_zeros == 3, "must be");
-  }
-};
-
-void TestG1BiasedArray_test() {
-  TestMappedArray::test_biasedarray();
-}
-
 #endif
--- a/src/share/vm/gc/g1/g1CollectedHeap.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/gc/g1/g1CollectedHeap.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -4420,6 +4420,19 @@
   NOT_PRODUCT(set_evacuation_failure_alot_for_current_gc();)
 
   assert(dirty_card_queue_set().completed_buffers_num() == 0, "Should be empty");
+
+  G1GCPhaseTimes* phase_times = g1_policy()->phase_times();
+
+  // InitialMark needs claim bits to keep track of the marked-through CLDs.
+  if (collector_state()->during_initial_mark_pause()) {
+    double start_clear_claimed_marks = os::elapsedTime();
+
+    ClassLoaderDataGraph::clear_claimed_marks();
+
+    double recorded_clear_claimed_marks_time_ms = (os::elapsedTime() - start_clear_claimed_marks) * 1000.0;
+    phase_times->record_clear_claimed_marks_time_ms(recorded_clear_claimed_marks_time_ms);
+  }
+
   double start_par_time_sec = os::elapsedTime();
   double end_par_time_sec;
 
@@ -4427,10 +4440,6 @@
     const uint n_workers = workers()->active_workers();
     G1RootProcessor root_processor(this, n_workers);
     G1ParTask g1_par_task(this, per_thread_states, _task_queues, &root_processor, n_workers);
-    // InitialMark needs claim bits to keep track of the marked-through CLDs.
-    if (collector_state()->during_initial_mark_pause()) {
-      ClassLoaderDataGraph::clear_claimed_marks();
-    }
 
     print_termination_stats_hdr();
 
@@ -4444,8 +4453,6 @@
     // reported parallel time.
   }
 
-  G1GCPhaseTimes* phase_times = g1_policy()->phase_times();
-
   double par_time_ms = (end_par_time_sec - start_par_time_sec) * 1000.0;
   phase_times->record_par_time(par_time_ms);
 
--- a/src/share/vm/gc/g1/g1GCPhaseTimes.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/gc/g1/g1GCPhaseTimes.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -101,6 +101,7 @@
   _gc_start_counter = os::elapsed_counter();
   _cur_expand_heap_time_ms = 0.0;
   _external_accounted_time_ms = 0.0;
+  _recorded_clear_claimed_marks_time_ms = 0.0;
 
   for (int i = 0; i < GCParPhasesSentinel; i++) {
     if (_gc_par_phases[i] != NULL) {
@@ -306,6 +307,10 @@
   debug_line("Reference Processing", _cur_ref_proc_time_ms);
   debug_line("Reference Enqueuing", _cur_ref_enq_time_ms);
   debug_line("Redirty Cards", _recorded_redirty_logged_cards_time_ms);
+  if (_recorded_clear_claimed_marks_time_ms > 0.0) {
+    debug_line("Clear Claimed Marks", _recorded_clear_claimed_marks_time_ms);
+  }
+
   trace_phase(_gc_par_phases[RedirtyCards]);
   if (G1EagerReclaimHumongousObjects) {
     debug_line("Humongous Register", _cur_fast_reclaim_humongous_register_time_ms);
--- a/src/share/vm/gc/g1/g1GCPhaseTimes.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/gc/g1/g1GCPhaseTimes.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -103,6 +103,8 @@
 
   double _external_accounted_time_ms;
 
+  double _recorded_clear_claimed_marks_time_ms;
+
   double _recorded_young_cset_choice_time_ms;
   double _recorded_non_young_cset_choice_time_ms;
 
@@ -257,6 +259,10 @@
     _external_accounted_time_ms += time_ms;
   }
 
+  void record_clear_claimed_marks_time_ms(double recorded_clear_claimed_marks_time_ms) {
+    _recorded_clear_claimed_marks_time_ms = recorded_clear_claimed_marks_time_ms;
+  }
+
   double cur_collection_start_sec() {
     return _cur_collection_start_sec;
   }
--- a/src/share/vm/gc/g1/heapRegionSet.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/gc/g1/heapRegionSet.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -370,50 +370,3 @@
               "master humongous set MT safety protocol outside a safepoint");
   }
 }
-
-void FreeRegionList_test() {
-  FreeRegionList l("test");
-
-  const uint num_regions_in_test = 5;
-  // Create a fake heap. It does not need to be valid, as the HeapRegion constructor
-  // does not access it.
-  MemRegion heap(NULL, num_regions_in_test * HeapRegion::GrainWords);
-  // Allocate a fake BOT because the HeapRegion constructor initializes
-  // the BOT.
-  size_t bot_size = G1BlockOffsetTable::compute_size(heap.word_size());
-  HeapWord* bot_data = NEW_C_HEAP_ARRAY(HeapWord, bot_size, mtGC);
-  ReservedSpace bot_rs(G1BlockOffsetTable::compute_size(heap.word_size()));
-  G1RegionToSpaceMapper* bot_storage =
-    G1RegionToSpaceMapper::create_mapper(bot_rs,
-                                         bot_rs.size(),
-                                         os::vm_page_size(),
-                                         HeapRegion::GrainBytes,
-                                         BOTConstants::N_bytes,
-                                         mtGC);
-  G1BlockOffsetTable bot(heap, bot_storage);
-  bot_storage->commit_regions(0, num_regions_in_test);
-
-  // Set up memory regions for the heap regions.
-  MemRegion mr0(heap.start(), HeapRegion::GrainWords);
-  MemRegion mr1(mr0.end(), HeapRegion::GrainWords);
-  MemRegion mr2(mr1.end(), HeapRegion::GrainWords);
-  MemRegion mr3(mr2.end(), HeapRegion::GrainWords);
-  MemRegion mr4(mr3.end(), HeapRegion::GrainWords);
-
-  HeapRegion hr0(0, &bot, mr0);
-  HeapRegion hr1(1, &bot, mr1);
-  HeapRegion hr2(2, &bot, mr2);
-  HeapRegion hr3(3, &bot, mr3);
-  HeapRegion hr4(4, &bot, mr4);
-  l.add_ordered(&hr1);
-  l.add_ordered(&hr0);
-  l.add_ordered(&hr3);
-  l.add_ordered(&hr4);
-  l.add_ordered(&hr2);
-  assert(l.length() == num_regions_in_test, "wrong length");
-  l.verify_list();
-
-  bot_storage->uncommit_regions(0, num_regions_in_test);
-  delete bot_storage;
-  FREE_C_HEAP_ARRAY(HeapWord, bot_data);
-}
--- a/src/share/vm/gc/g1/workerDataArray.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/gc/g1/workerDataArray.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -79,126 +79,3 @@
   }
   out->cr();
 }
-
-#ifndef PRODUCT
-
-#include "memory/resourceArea.hpp"
-
-void WorkerDataArray_test_verify_string(const char* expected_string, const char* actual_string) {
-  const size_t expected_len = strlen(expected_string);
-
-  assert(expected_len == strlen(actual_string),
-      "Wrong string length, expected " SIZE_FORMAT " but got " SIZE_FORMAT "(Expected '%s' but got: '%s')",
-      expected_len, strlen(actual_string), expected_string, actual_string);
-
-  // Can't use strncmp here because floating point values use different decimal points for different locales.
-  // Allow strings to differ in "." vs. "," only. This should still catch most errors.
-  for (size_t i = 0; i < expected_len; i++) {
-    char e = expected_string[i];
-    char a = actual_string[i];
-    if (e != a) {
-      if ((e == '.' || e == ',') && (a == '.' || a == ',')) {
-        // Most likely just a difference in locale
-      } else {
-        assert(false, "Expected '%s' but got: '%s'", expected_string, actual_string);
-      }
-    }
-  }
-}
-
-void WorkerDataArray_test_verify_array(WorkerDataArray<size_t>& array, size_t expected_sum, double expected_avg, const char* expected_summary, const char* exected_details) {
-  const double epsilon = 0.0001;
-  assert(array.sum() == expected_sum, "Wrong sum, expected: " SIZE_FORMAT " but got: " SIZE_FORMAT, expected_sum, array.sum());
-  assert(fabs(array.average() - expected_avg) < epsilon, "Wrong average, expected: %f but got: %f", expected_avg, array.average());
-
-  ResourceMark rm;
-  stringStream out;
-  array.print_summary_on(&out);
-  WorkerDataArray_test_verify_string(expected_summary, out.as_string());
-  out.reset();
-  array.print_details_on(&out);
-  WorkerDataArray_test_verify_string(exected_details, out.as_string());
-}
-
-void WorkerDataArray_test_verify_array(WorkerDataArray<double>& array, double expected_sum, double expected_avg, const char* expected_summary, const char* exected_details) {
-  const double epsilon = 0.0001;
-  assert(fabs(array.sum() - expected_sum) < epsilon, "Wrong sum, expected: %f but got: %f", expected_sum, array.sum());
-  assert(fabs(array.average() - expected_avg) < epsilon, "Wrong average, expected: %f but got: %f", expected_avg, array.average());
-
-  ResourceMark rm;
-  stringStream out;
-  array.print_summary_on(&out);
-  WorkerDataArray_test_verify_string(expected_summary, out.as_string());
-  out.reset();
-  array.print_details_on(&out);
-  WorkerDataArray_test_verify_string(exected_details, out.as_string());
-}
-
-void WorkerDataArray_test_basic() {
-  WorkerDataArray<size_t> array(3, "Test array");
-  array.set(0, 5);
-  array.set(1, 3);
-  array.set(2, 7);
-
-  WorkerDataArray_test_verify_array(array, 15, 5.0,
-      "Test array                Min: 3, Avg:  5.0, Max: 7, Diff: 4, Sum: 15, Workers: 3\n",
-      "                           5  3  7\n" );
-}
-
-void WorkerDataArray_test_add() {
-  WorkerDataArray<size_t> array(3, "Test array");
-  array.set(0, 5);
-  array.set(1, 3);
-  array.set(2, 7);
-
-  for (uint i = 0; i < 3; i++) {
-    array.add(i, 1);
-  }
-
-  WorkerDataArray_test_verify_array(array, 18, 6.0,
-      "Test array                Min: 4, Avg:  6.0, Max: 8, Diff: 4, Sum: 18, Workers: 3\n",
-      "                           6  4  8\n" );
-}
-
-void WorkerDataArray_test_with_uninitialized() {
-  WorkerDataArray<size_t> array(3, "Test array");
-  array.set(0, 5);
-  array.set(1, WorkerDataArray<size_t>::uninitialized());
-  array.set(2, 7);
-
-  WorkerDataArray_test_verify_array(array, 12, 6,
-      "Test array                Min: 5, Avg:  6.0, Max: 7, Diff: 2, Sum: 12, Workers: 2\n",
-      "                           5 -  7\n" );
-}
-
-void WorkerDataArray_test_uninitialized() {
-  WorkerDataArray<size_t> array(3, "Test array");
-  array.set(0, WorkerDataArray<size_t>::uninitialized());
-  array.set(1, WorkerDataArray<size_t>::uninitialized());
-  array.set(2, WorkerDataArray<size_t>::uninitialized());
-
-  WorkerDataArray_test_verify_array(array, 0, 0.0,
-      "Test array                skipped\n",
-      "                          - - -\n" );
-}
-
-void WorkerDataArray_test_double_with_uninitialized() {
-  WorkerDataArray<double> array(3, "Test array");
-  array.set(0, 5.1 / MILLIUNITS);
-  array.set(1, WorkerDataArray<double>::uninitialized());
-  array.set(2, 7.2 / MILLIUNITS);
-
-  WorkerDataArray_test_verify_array(array, 12.3 / MILLIUNITS, 6.15 / MILLIUNITS,
-      "Test array                Min:  5.1, Avg:  6.1, Max:  7.2, Diff:  2.1, Sum: 12.3, Workers: 2\n",
-      "                           5.1 -  7.2\n" );
-}
-
-void WorkerDataArray_test() {
-  WorkerDataArray_test_basic();
-  WorkerDataArray_test_add();
-  WorkerDataArray_test_with_uninitialized();
-  WorkerDataArray_test_uninitialized();
-  WorkerDataArray_test_double_with_uninitialized();
-}
-
-#endif
--- a/src/share/vm/gc/shared/collectorPolicy.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/gc/shared/collectorPolicy.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -909,184 +909,3 @@
   _gc_policy_counters = new GCPolicyCounters("Copy:MSC", 2, 3);
 }
 
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-// Testing that the NewSize flag is handled correct is hard because it
-// depends on so many other configurable variables. This test only tries to
-// verify that there are some basic rules for NewSize honored by the policies.
-class TestGenCollectorPolicy {
-public:
-  static void test_new_size() {
-    size_t flag_value;
-
-    save_flags();
-
-    // If NewSize has been ergonomically set, the collector policy
-    // should use it for min but calculate the initial young size
-    // using NewRatio.
-    flag_value = 20 * M;
-    set_basic_flag_values();
-    FLAG_SET_ERGO(size_t, NewSize, flag_value);
-    verify_young_min(flag_value);
-
-    set_basic_flag_values();
-    FLAG_SET_ERGO(size_t, NewSize, flag_value);
-    verify_scaled_young_initial(InitialHeapSize);
-
-    // If NewSize is set on the command line, it should be used
-    // for both min and initial young size if less than min heap.
-    // Note that once a flag has been set with FLAG_SET_CMDLINE it
-    // will be treated as it have been set on the command line for
-    // the rest of the VM lifetime. This is an irreversible change.
-    flag_value = 20 * M;
-    set_basic_flag_values();
-    FLAG_SET_CMDLINE(size_t, NewSize, flag_value);
-    verify_young_min(flag_value);
-
-    set_basic_flag_values();
-    FLAG_SET_CMDLINE(size_t, NewSize, flag_value);
-    verify_young_initial(flag_value);
-
-    // If NewSize is set on command line, but is larger than the min
-    // heap size, it should only be used for initial young size.
-    flag_value = 80 * M;
-    set_basic_flag_values();
-    FLAG_SET_CMDLINE(size_t, NewSize, flag_value);
-    verify_young_initial(flag_value);
-
-    restore_flags();
-  }
-
-  static void test_old_size() {
-    size_t flag_value;
-    size_t heap_alignment = CollectorPolicy::compute_heap_alignment();
-
-    save_flags();
-
-    // If OldSize is set on the command line, it should be used
-    // for both min and initial old size if less than min heap.
-    flag_value = 20 * M;
-    set_basic_flag_values();
-    FLAG_SET_CMDLINE(size_t, OldSize, flag_value);
-    verify_old_min(flag_value);
-
-    set_basic_flag_values();
-    FLAG_SET_CMDLINE(size_t, OldSize, flag_value);
-    // Calculate what we expect the flag to be.
-    size_t expected_old_initial = align_size_up(InitialHeapSize, heap_alignment) - MaxNewSize;
-    verify_old_initial(expected_old_initial);
-
-    // If MaxNewSize is large, the maximum OldSize will be less than
-    // what's requested on the command line and it should be reset
-    // ergonomically.
-    // We intentionally set MaxNewSize + OldSize > MaxHeapSize (see over_size).
-    flag_value = 30 * M;
-    set_basic_flag_values();
-    FLAG_SET_CMDLINE(size_t, OldSize, flag_value);
-    size_t over_size = 20*M;
-    size_t new_size_value = align_size_up(MaxHeapSize, heap_alignment) - flag_value + over_size;
-    FLAG_SET_CMDLINE(size_t, MaxNewSize, new_size_value);
-    // Calculate what we expect the flag to be.
-    expected_old_initial = align_size_up(MaxHeapSize, heap_alignment) - MaxNewSize;
-    verify_old_initial(expected_old_initial);
-    restore_flags();
-  }
-
-  static void verify_young_min(size_t expected) {
-    MarkSweepPolicy msp;
-    msp.initialize_all();
-
-    assert(msp.min_young_size() <= expected, "%zu  > %zu", msp.min_young_size(), expected);
-  }
-
-  static void verify_young_initial(size_t expected) {
-    MarkSweepPolicy msp;
-    msp.initialize_all();
-
-    assert(msp.initial_young_size() == expected, "%zu != %zu", msp.initial_young_size(), expected);
-  }
-
-  static void verify_scaled_young_initial(size_t initial_heap_size) {
-    MarkSweepPolicy msp;
-    msp.initialize_all();
-
-    if (InitialHeapSize > initial_heap_size) {
-      // InitialHeapSize was adapted by msp.initialize_all, e.g. due to alignment
-      // caused by 64K page size.
-      initial_heap_size = InitialHeapSize;
-    }
-
-    size_t expected = msp.scale_by_NewRatio_aligned(initial_heap_size);
-    assert(msp.initial_young_size() == expected, "%zu != %zu", msp.initial_young_size(), expected);
-    assert(FLAG_IS_ERGO(NewSize) && NewSize == expected,
-        "NewSize should have been set ergonomically to %zu, but was %zu", expected, NewSize);
-  }
-
-  static void verify_old_min(size_t expected) {
-    MarkSweepPolicy msp;
-    msp.initialize_all();
-
-    assert(msp.min_old_size() <= expected, "%zu  > %zu", msp.min_old_size(), expected);
-  }
-
-  static void verify_old_initial(size_t expected) {
-    MarkSweepPolicy msp;
-    msp.initialize_all();
-
-    assert(msp.initial_old_size() == expected, "%zu != %zu", msp.initial_old_size(), expected);
-  }
-
-
-private:
-  static size_t original_InitialHeapSize;
-  static size_t original_MaxHeapSize;
-  static size_t original_MaxNewSize;
-  static size_t original_MinHeapDeltaBytes;
-  static size_t original_NewSize;
-  static size_t original_OldSize;
-
-  static void set_basic_flag_values() {
-    FLAG_SET_ERGO(size_t, MaxHeapSize, 180 * M);
-    FLAG_SET_ERGO(size_t, InitialHeapSize, 100 * M);
-    FLAG_SET_ERGO(size_t, OldSize, 4 * M);
-    FLAG_SET_ERGO(size_t, NewSize, 1 * M);
-    FLAG_SET_ERGO(size_t, MaxNewSize, 80 * M);
-    Arguments::set_min_heap_size(40 * M);
-  }
-
-  static void save_flags() {
-    original_InitialHeapSize   = InitialHeapSize;
-    original_MaxHeapSize       = MaxHeapSize;
-    original_MaxNewSize        = MaxNewSize;
-    original_MinHeapDeltaBytes = MinHeapDeltaBytes;
-    original_NewSize           = NewSize;
-    original_OldSize           = OldSize;
-  }
-
-  static void restore_flags() {
-    InitialHeapSize   = original_InitialHeapSize;
-    MaxHeapSize       = original_MaxHeapSize;
-    MaxNewSize        = original_MaxNewSize;
-    MinHeapDeltaBytes = original_MinHeapDeltaBytes;
-    NewSize           = original_NewSize;
-    OldSize           = original_OldSize;
-  }
-};
-
-size_t TestGenCollectorPolicy::original_InitialHeapSize   = 0;
-size_t TestGenCollectorPolicy::original_MaxHeapSize       = 0;
-size_t TestGenCollectorPolicy::original_MaxNewSize        = 0;
-size_t TestGenCollectorPolicy::original_MinHeapDeltaBytes = 0;
-size_t TestGenCollectorPolicy::original_NewSize           = 0;
-size_t TestGenCollectorPolicy::original_OldSize           = 0;
-
-void TestNewSize_test() {
-  TestGenCollectorPolicy::test_new_size();
-}
-
-void TestOldSize_test() {
-  TestGenCollectorPolicy::test_old_size();
-}
-
-#endif
--- a/src/share/vm/jvmci/jvmciCompiler.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/jvmci/jvmciCompiler.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -37,7 +37,7 @@
 JVMCICompiler* JVMCICompiler::_instance = NULL;
 elapsedTimer JVMCICompiler::_codeInstallTimer;
 
-JVMCICompiler::JVMCICompiler() : AbstractCompiler(jvmci) {
+JVMCICompiler::JVMCICompiler() : AbstractCompiler(compiler_jvmci) {
   _bootstrapping = false;
   _bootstrap_compilation_request_handled = false;
   _methods_compiled = 0;
--- a/src/share/vm/jvmci/jvmci_globals.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/jvmci/jvmci_globals.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -50,7 +50,7 @@
           "Use JVMCI as the default compiler")                              \
                                                                             \
   experimental(bool, JVMCIPrintProperties, false,                           \
-          "Prints properties used by the JVMCI compiler")                   \
+          "Prints properties used by the JVMCI compiler and exits")         \
                                                                             \
   experimental(bool, BootstrapJVMCI, false,                                 \
           "Bootstrap JVMCI before running Java main method")                \
--- a/src/share/vm/memory/filemap.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/memory/filemap.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -283,11 +283,15 @@
   bool validate_classpath_entry_table();
 
   static SharedClassPathEntry* shared_classpath(int index) {
+    if (index < 0) {
+      return NULL;
+    }
     char* p = (char*)_classpath_entry_table;
     p += _classpath_entry_size * index;
     return (SharedClassPathEntry*)p;
   }
   static const char* shared_classpath_name(int index) {
+    assert(index >= 0, "Sanity");
     return shared_classpath(index)->_name;
   }
 
--- a/src/share/vm/memory/guardedMemory.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/memory/guardedMemory.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -79,87 +79,3 @@
     break;
   }
 }
-
-// test code...
-
-#ifndef PRODUCT
-
-static void guarded_memory_test_check(void* p, size_t sz, void* tag) {
-  assert(p != NULL, "NULL pointer given to check");
-  u_char* c = (u_char*) p;
-  GuardedMemory guarded(c);
-  assert(guarded.get_tag() == tag, "Tag is not the same as supplied");
-  assert(guarded.get_user_ptr() == c, "User pointer is not the same as supplied");
-  assert(guarded.get_user_size() == sz, "User size is not the same as supplied");
-  assert(guarded.verify_guards(), "Guard broken");
-}
-
-void GuardedMemory::test_guarded_memory() {
-  // Test the basic characteristics...
-  size_t total_sz = GuardedMemory::get_total_size(1);
-  assert(total_sz > 1 && total_sz >= (sizeof(GuardHeader) + 1 + sizeof(Guard)), "Unexpected size");
-  u_char* basep = (u_char*) os::malloc(total_sz, mtInternal);
-
-  GuardedMemory guarded(basep, 1, (void*)0xf000f000);
-
-  assert(*basep == badResourceValue, "Expected guard in the form of badResourceValue");
-  u_char* userp = guarded.get_user_ptr();
-  assert(*userp == uninitBlockPad, "Expected uninitialized data in the form of uninitBlockPad");
-  guarded_memory_test_check(userp, 1, (void*)0xf000f000);
-
-  void* freep = guarded.release_for_freeing();
-  assert((u_char*)freep == basep, "Expected the same pointer guard was ");
-  assert(*userp == freeBlockPad, "Expected user data to be free block padded");
-  assert(!guarded.verify_guards(), "Expected failed");
-  os::free(freep);
-
-  // Test a number of odd sizes...
-  size_t sz = 0;
-  do {
-    void* p = os::malloc(GuardedMemory::get_total_size(sz), mtInternal);
-    void* up = guarded.wrap_with_guards(p, sz, (void*)1);
-    memset(up, 0, sz);
-    guarded_memory_test_check(up, sz, (void*)1);
-    os::free(guarded.release_for_freeing());
-    sz = (sz << 4) + 1;
-  } while (sz < (256 * 1024));
-
-  // Test buffer overrun into head...
-  basep = (u_char*) os::malloc(GuardedMemory::get_total_size(1), mtInternal);
-  guarded.wrap_with_guards(basep, 1);
-  *basep = 0;
-  assert(!guarded.verify_guards(), "Expected failure");
-  os::free(basep);
-
-  // Test buffer overrun into tail with a number of odd sizes...
-  sz = 1;
-  do {
-    void* p = os::malloc(GuardedMemory::get_total_size(sz), mtInternal);
-    void* up = guarded.wrap_with_guards(p, sz, (void*)1);
-    memset(up, 0, sz + 1); // Buffer-overwrite (within guard)
-    assert(!guarded.verify_guards(), "Guard was not broken as expected");
-    os::free(guarded.release_for_freeing());
-    sz = (sz << 4) + 1;
-  } while (sz < (256 * 1024));
-
-  // Test wrap_copy/wrap_free...
-  assert(GuardedMemory::free_copy(NULL), "Expected free NULL to be OK");
-
-  const char* str = "Check my bounds out";
-  size_t str_sz = strlen(str) + 1;
-  char* str_copy = (char*) GuardedMemory::wrap_copy(str, str_sz);
-  guarded_memory_test_check(str_copy, str_sz, NULL);
-  assert(strcmp(str, str_copy) == 0, "Not identical copy");
-  assert(GuardedMemory::free_copy(str_copy), "Free copy failed to verify");
-
-  void* no_data = NULL;
-  void* no_data_copy = GuardedMemory::wrap_copy(no_data, 0);
-  assert(GuardedMemory::free_copy(no_data_copy), "Expected valid guards even for no data copy");
-}
-
-void GuardedMemory_test() {
-  GuardedMemory::test_guarded_memory();
-}
-
-#endif // !PRODUCT
-
--- a/src/share/vm/memory/guardedMemory.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/memory/guardedMemory.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -82,6 +82,7 @@
  */
 class GuardedMemory : StackObj { // Wrapper on stack
 
+  friend class GuardedMemoryTest;
   // Private inner classes for memory layout...
 
 protected:
@@ -317,10 +318,6 @@
    */
   static bool free_copy(void* p);
 
-  // Testing...
-#ifndef PRODUCT
-  static void test_guarded_memory(void);
-#endif
 }; // GuardedMemory
 
 #endif // SHARE_VM_MEMORY_GUARDEDMEMORY_HPP
--- a/src/share/vm/memory/metachunk.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/memory/metachunk.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -111,61 +111,3 @@
   return;
 }
 
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-class TestMetachunk {
- public:
-  static void test() {
-    size_t size = 2 * 1024 * 1024;
-    void* memory = malloc(size);
-    assert(memory != NULL, "Failed to malloc 2MB");
-
-    Metachunk* metachunk = ::new (memory) Metachunk(size / BytesPerWord, NULL);
-
-    assert(metachunk->bottom() == (MetaWord*)metachunk, "assert");
-    assert(metachunk->end() == (uintptr_t*)metachunk + metachunk->size(), "assert");
-
-    // Check sizes
-    assert(metachunk->size() == metachunk->word_size(), "assert");
-    assert(metachunk->word_size() == pointer_delta(metachunk->end(), metachunk->bottom(),
-        sizeof(MetaWord*)), "assert");
-
-    // Check usage
-    assert(metachunk->used_word_size() == metachunk->overhead(), "assert");
-    assert(metachunk->free_word_size() == metachunk->word_size() - metachunk->used_word_size(), "assert");
-    assert(metachunk->top() == metachunk->initial_top(), "assert");
-    assert(metachunk->is_empty(), "assert");
-
-    // Allocate
-    size_t alloc_size = 64; // Words
-    assert(is_size_aligned(alloc_size, Metachunk::object_alignment()), "assert");
-
-    MetaWord* mem = metachunk->allocate(alloc_size);
-
-    // Check post alloc
-    assert(mem == metachunk->initial_top(), "assert");
-    assert(mem + alloc_size == metachunk->top(), "assert");
-    assert(metachunk->used_word_size() == metachunk->overhead() + alloc_size, "assert");
-    assert(metachunk->free_word_size() == metachunk->word_size() - metachunk->used_word_size(), "assert");
-    assert(!metachunk->is_empty(), "assert");
-
-    // Clear chunk
-    metachunk->reset_empty();
-
-    // Check post clear
-    assert(metachunk->used_word_size() == metachunk->overhead(), "assert");
-    assert(metachunk->free_word_size() == metachunk->word_size() - metachunk->used_word_size(), "assert");
-    assert(metachunk->top() == metachunk->initial_top(), "assert");
-    assert(metachunk->is_empty(), "assert");
-
-    free(memory);
-  }
-};
-
-void TestMetachunk_test() {
-  TestMetachunk::test();
-}
-
-#endif
--- a/src/share/vm/memory/metachunk.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/memory/metachunk.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -95,7 +95,7 @@
 //            +--------------+ <- bottom --+       --+
 
 class Metachunk : public Metabase<Metachunk> {
-  friend class TestMetachunk;
+  friend class MetachunkTest;
   // The VirtualSpaceNode containing this chunk.
   VirtualSpaceNode* _container;
 
--- a/src/share/vm/oops/instanceKlass.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/oops/instanceKlass.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -517,12 +517,14 @@
 
 bool InstanceKlass::link_class_impl(
     instanceKlassHandle this_k, bool throw_verifyerror, TRAPS) {
-  // check for error state.
-  // This is checking for the wrong state.  If the state is initialization_error,
-  // then this class *was* linked.  The CDS code does a try_link_class and uses
-  // initialization_error to mark classes to not include in the archive during
-  // DumpSharedSpaces.  This should be removed when the CDS bug is fixed.
-  if (this_k->is_in_error_state()) {
+  if (DumpSharedSpaces && this_k->is_in_error_state()) {
+    // This is for CDS dumping phase only -- we use the in_error_state to indicate that
+    // the class has failed verification. Throwing the NoClassDefFoundError here is just
+    // a convenient way to stop repeat attempts to verify the same (bad) class.
+    //
+    // Note that the NoClassDefFoundError is not part of the JLS, and should not be thrown
+    // if we are executing Java code. This is not a problem for CDS dumping phase since
+    // it doesn't execute any Java code.
     ResourceMark rm(THREAD);
     THROW_MSG_(vmSymbols::java_lang_NoClassDefFoundError(),
                this_k->external_name(), false);
--- a/src/share/vm/oops/method.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/oops/method.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -27,6 +27,7 @@
 
 #include "classfile/vmSymbols.hpp"
 #include "code/compressedStream.hpp"
+#include "compiler/compilerDefinitions.hpp"
 #include "compiler/oopMap.hpp"
 #include "interpreter/invocationCounter.hpp"
 #include "oops/annotations.hpp"
--- a/src/share/vm/opto/c2compiler.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/opto/c2compiler.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -537,6 +537,7 @@
 #ifdef TRACE_HAVE_INTRINSICS
   case vmIntrinsics::_counterTime:
   case vmIntrinsics::_getClassId:
+  case vmIntrinsics::_getBufferWriter:
 #endif
   case vmIntrinsics::_currentTimeMillis:
   case vmIntrinsics::_nanoTime:
--- a/src/share/vm/opto/c2compiler.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/opto/c2compiler.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -32,7 +32,7 @@
   static bool init_c2_runtime();
 
 public:
-  C2Compiler() : AbstractCompiler(c2) {}
+  C2Compiler() : AbstractCompiler(compiler_c2) {}
 
   // Name
   const char *name() { return "C2"; }
--- a/src/share/vm/opto/castnode.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/opto/castnode.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -224,30 +224,6 @@
     return progress;
   }
 
-  // transform:
-  // (CastII (AddI x const)) -> (AddI (CastII x) const)
-  // So the AddI has a chance to be optimized out
-  if (in(1)->Opcode() == Op_AddI) {
-    Node* in2 = in(1)->in(2);
-    const TypeInt* in2_t = phase->type(in2)->isa_int();
-    if (in2_t != NULL && in2_t->singleton()) {
-      int in2_const = in2_t->_lo;
-      const TypeInt* current_type = _type->is_int();
-      jlong new_lo_long = ((jlong)current_type->_lo) - in2_const;
-      jlong new_hi_long = ((jlong)current_type->_hi) - in2_const;
-      int new_lo = (int)new_lo_long;
-      int new_hi = (int)new_hi_long;
-      if (((jlong)new_lo) == new_lo_long && ((jlong)new_hi) == new_hi_long) {
-        Node* in1 = in(1)->in(1);
-        CastIINode* new_cast = (CastIINode*)clone();
-        AddINode* new_add = (AddINode*)in(1)->clone();
-        new_cast->set_type(TypeInt::make(new_lo, new_hi, current_type->_widen));
-        new_cast->set_req(1, in1);
-        new_add->set_req(1, phase->transform(new_cast));
-        return new_add;
-      }
-    }
-  }
   // Similar to ConvI2LNode::Ideal() for the same reasons
   if (can_reshape && !phase->C->major_progress()) {
     const TypeInt* this_type = this->type()->is_int();
--- a/src/share/vm/opto/library_call.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/opto/library_call.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -256,6 +256,7 @@
   bool inline_native_time_funcs(address method, const char* funcName);
 #ifdef TRACE_HAVE_INTRINSICS
   bool inline_native_classID();
+  bool inline_native_getBufferWriter();
 #endif
   bool inline_native_isInterrupted();
   bool inline_native_Class_query(vmIntrinsics::ID id);
@@ -713,6 +714,7 @@
 #ifdef TRACE_HAVE_INTRINSICS
   case vmIntrinsics::_counterTime:              return inline_native_time_funcs(CAST_FROM_FN_PTR(address, TRACE_TIME_METHOD), "counterTime");
   case vmIntrinsics::_getClassId:               return inline_native_classID();
+  case vmIntrinsics::_getBufferWriter:          return inline_native_getBufferWriter();
 #endif
   case vmIntrinsics::_currentTimeMillis:        return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis");
   case vmIntrinsics::_nanoTime:                 return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime");
@@ -3198,6 +3200,44 @@
 
 }
 
+bool LibraryCallKit::inline_native_getBufferWriter() {
+  Node* tls_ptr = _gvn.transform(new ThreadLocalNode());
+
+  Node* jobj_ptr = basic_plus_adr(top(), tls_ptr,
+                                  in_bytes(TRACE_THREAD_DATA_WRITER_OFFSET)
+                                  );
+
+  Node* jobj = make_load(control(), jobj_ptr, TypeRawPtr::BOTTOM, T_ADDRESS, MemNode::unordered);
+
+  Node* jobj_cmp_null = _gvn.transform( new CmpPNode(jobj, null()) );
+  Node* test_jobj_eq_null  = _gvn.transform( new BoolNode(jobj_cmp_null, BoolTest::eq) );
+
+  IfNode* iff_jobj_null =
+    create_and_map_if(control(), test_jobj_eq_null, PROB_NEVER, COUNT_UNKNOWN);
+
+   enum { _normal_path = 1,
+          _null_path = 2,
+          PATH_LIMIT };
+
+  RegionNode* result_rgn = new RegionNode(PATH_LIMIT);
+  PhiNode*    result_val = new PhiNode(result_rgn, TypePtr::BOTTOM);
+  record_for_igvn(result_rgn);
+
+  Node* jobj_is_null = _gvn.transform( new IfTrueNode(iff_jobj_null) );
+  result_rgn->init_req(_null_path, jobj_is_null);
+  result_val->init_req(_null_path, null());
+
+  Node* jobj_is_not_null = _gvn.transform( new IfFalseNode(iff_jobj_null) );
+  result_rgn->init_req(_normal_path, jobj_is_not_null);
+
+  Node* res = make_load(NULL, jobj, TypeInstPtr::BOTTOM, T_OBJECT, MemNode::unordered);
+  result_val->init_req(_normal_path, res);
+
+  set_result(result_rgn, result_val);
+
+  return true;
+}
+
 #endif
 
 //------------------------inline_native_currentThread------------------
--- a/src/share/vm/prims/jvm.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/prims/jvm.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -2524,7 +2524,6 @@
   switch (cp->tag_at(cp_index).value()) {
     case JVM_CONSTANT_InterfaceMethodref:
     case JVM_CONSTANT_Methodref:
-    case JVM_CONSTANT_NameAndType:  // for invokedynamic
       return cp->uncached_name_ref_at(cp_index)->as_utf8();
     default:
       fatal("JVM_GetCPMethodNameUTF: illegal constant");
@@ -2542,7 +2541,6 @@
   switch (cp->tag_at(cp_index).value()) {
     case JVM_CONSTANT_InterfaceMethodref:
     case JVM_CONSTANT_Methodref:
-    case JVM_CONSTANT_NameAndType:  // for invokedynamic
       return cp->uncached_signature_ref_at(cp_index)->as_utf8();
     default:
       fatal("JVM_GetCPMethodSignatureUTF: illegal constant");
--- a/src/share/vm/prims/jvmtiEnv.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/prims/jvmtiEnv.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1001,7 +1001,8 @@
     if (name() != NULL) {
       n = java_lang_String::as_utf8_string(name());
     } else {
-      n = UNICODE::as_utf8((jchar*) NULL, 0);
+      int utf8_length = 0;
+      n = UNICODE::as_utf8((jchar*) NULL, utf8_length);
     }
 
     info_ptr->name = (char *) jvmtiMalloc(strlen(n)+1);
--- a/src/share/vm/runtime/arguments.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/runtime/arguments.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -416,6 +416,8 @@
   { "UseAltSigs",                    JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
   { "SegmentedHeapDumpThreshold",    JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
   { "PrintOopAddress",               JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
+  { "PermSize",                      JDK_Version::undefined(), JDK_Version::jdk(8), JDK_Version::jdk(10) },
+  { "MaxPermSize",                   JDK_Version::undefined(), JDK_Version::jdk(8), JDK_Version::jdk(10) },
 
 #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS
   { "dep > obs",                    JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() },
@@ -793,9 +795,10 @@
   } else if (new_len == 0) {
     value = old_value;
   } else {
-    char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtArguments);
+     size_t length = old_len + 1 + new_len + 1;
+     char* buf = NEW_C_HEAP_ARRAY(char, length, mtArguments);
     // each new setting adds another LINE to the switch:
-    sprintf(buf, "%s\n%s", old_value, new_value);
+    jio_snprintf(buf, length, "%s\n%s", old_value, new_value);
     value = buf;
     free_this_too = buf;
   }
@@ -1013,15 +1016,17 @@
   if (args == NULL || count == 0) {
     return NULL;
   }
-  size_t length = strlen(args[0]) + 1; // add 1 for the null terminator
-  for (int i = 1; i < count; i++) {
-    length += strlen(args[i]) + 1; // add 1 for a space
+  size_t length = 0;
+  for (int i = 0; i < count; i++) {
+    length += strlen(args[i]) + 1; // add 1 for a space or NULL terminating character
   }
   char* s = NEW_RESOURCE_ARRAY(char, length);
-  strcpy(s, args[0]);
-  for (int j = 1; j < count; j++) {
-    strcat(s, " ");
-    strcat(s, args[j]);
+  char* dst = s;
+  for (int j = 0; j < count; j++) {
+    size_t offset = strlen(args[j]) + 1; // add 1 for a space or NULL terminating character
+    jio_snprintf(dst, length, "%s ", args[j]); // jio_snprintf will replace the last space character with NULL character
+    dst += offset;
+    length -= offset;
   }
   return (const char*) s;
 }
@@ -1105,9 +1110,8 @@
   // Only make the obsolete check for valid arguments.
   if (arg_len <= BUFLEN) {
     // Construct a string which consists only of the argument name without '+', '-', or '='.
-    char stripped_argname[BUFLEN+1];
-    strncpy(stripped_argname, argname, arg_len);
-    stripped_argname[arg_len] = '\0';  // strncpy may not null terminate.
+    char stripped_argname[BUFLEN+1]; // +1 for '\0'
+    jio_snprintf(stripped_argname, arg_len+1, "%s", argname); // +1 for '\0'
     if (is_obsolete_flag(stripped_argname, &since)) {
       char version[256];
       since.to_string(version, sizeof(version));
@@ -1259,8 +1263,7 @@
     size_t key_len = eq - prop;
     char* tmp_key = AllocateHeap(key_len + 1, mtArguments);
 
-    strncpy(tmp_key, prop, key_len);
-    tmp_key[key_len] = '\0';
+    jio_snprintf(tmp_key, key_len + 1, "%s", prop);
     key = tmp_key;
 
     value = &prop[key_len + 1];
@@ -2260,7 +2263,7 @@
 
     // Feed the cache size setting into the JDK
     char buffer[1024];
-    sprintf(buffer, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax);
+    jio_snprintf(buffer, 1024, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax);
     if (!add_property(buffer)) {
       return JNI_ENOMEM;
     }
@@ -2781,8 +2784,8 @@
       if (tail != NULL) {
         const char* pos = strchr(tail, ':');
         size_t len = (pos == NULL) ? strlen(tail) : pos - tail;
-        char* name = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len + 1, mtArguments), tail, len);
-        name[len] = '\0';
+        char* name = NEW_C_HEAP_ARRAY(char, len + 1, mtArguments);
+        jio_snprintf(name, len + 1, "%s", tail);
 
         char *options = NULL;
         if(pos != NULL) {
@@ -2858,7 +2861,9 @@
       return JNI_ERR;
 #else
       if (tail != NULL) {
-        char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtArguments), tail);
+        size_t length = strlen(tail) + 1;
+        char *options = NEW_C_HEAP_ARRAY(char, length, mtArguments);
+        jio_snprintf(options, length, "%s", tail);
         add_init_agent("instrument", options, false);
         // java agents need module java.instrument
         if (!create_numbered_property("jdk.module.addmods", "java.instrument", addmods_count++)) {
@@ -3518,7 +3523,7 @@
   // check if the default lib/endorsed directory exists; if so, error
   char path[JVM_MAXPATHLEN];
   const char* fileSep = os::file_separator();
-  sprintf(path, "%s%slib%sendorsed", Arguments::get_java_home(), fileSep, fileSep);
+  jio_snprintf(path, JVM_MAXPATHLEN, "%s%slib%sendorsed", Arguments::get_java_home(), fileSep, fileSep);
 
   if (CheckEndorsedAndExtDirs) {
     int nonEmptyDirs = 0;
@@ -3540,7 +3545,7 @@
     return JNI_ERR;
   }
 
-  sprintf(path, "%s%slib%sext", Arguments::get_java_home(), fileSep, fileSep);
+  jio_snprintf(path, JVM_MAXPATHLEN, "%s%slib%sext", Arguments::get_java_home(), fileSep, fileSep);
   dir = os::opendir(path);
   if (dir != NULL) {
     jio_fprintf(defaultStream::output_stream(),
@@ -3905,6 +3910,13 @@
 
 void Arguments::set_shared_spaces_flags() {
   if (DumpSharedSpaces) {
+    if (FailOverToOldVerifier) {
+      // Don't fall back to the old verifier on verification failure. If a
+      // class fails verification with the split verifier, it might fail the
+      // CDS runtime verifier constraint check. In that case, we don't want
+      // to share the class. We only archive classes that pass the split verifier.
+      FLAG_SET_DEFAULT(FailOverToOldVerifier, false);
+    }
 
     if (RequireSharedSpaces) {
       warning("Cannot dump shared archive while using shared archive");
--- a/src/share/vm/runtime/deoptimization.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/runtime/deoptimization.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -171,7 +171,6 @@
   assert(thread->deopt_compiled_method() == NULL, "Pending deopt!");
   CompiledMethod* cm = deoptee.cb()->as_compiled_method_or_null();
   thread->set_deopt_compiled_method(cm);
-  bool skip_internal = (cm != NULL) && !cm->is_compiled_by_jvmci();
 
   if (VerifyStack) {
     thread->validate_frame_layout();
@@ -241,6 +240,7 @@
         JRT_BLOCK
           realloc_failures = realloc_objects(thread, &deoptee, objects, THREAD);
         JRT_END
+        bool skip_internal = (cm != NULL) && !cm->is_compiled_by_jvmci();
         reassign_fields(&deoptee, &map, objects, realloc_failures, skip_internal);
 #ifndef PRODUCT
         if (TraceDeoptimization) {
@@ -1651,7 +1651,7 @@
       if (TraceDeoptimization) {  // make noise on the tty
         tty->print("Uncommon trap occurred in");
         nm->method()->print_short_name(tty);
-        tty->print(" compiler=%s compile_id=%d", nm->compiler() == NULL ? "" : nm->compiler()->name(), nm->compile_id());
+        tty->print(" compiler=%s compile_id=%d", nm->compiler_name(), nm->compile_id());
 #if INCLUDE_JVMCI
         if (nm->is_nmethod()) {
           oop installedCode = nm->as_nmethod()->jvmci_installed_code();
--- a/src/share/vm/runtime/frame.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/runtime/frame.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -686,9 +686,7 @@
         if (cm->is_nmethod()) {
           nmethod* nm = cm->as_nmethod();
           st->print("J %d%s", nm->compile_id(), (nm->is_osr_method() ? "%" : ""));
-          if (nm->compiler() != NULL) {
-            st->print(" %s", nm->compiler()->name());
-          }
+          st->print(" %s", nm->compiler_name());
         }
         m->name_and_sig_as_C_string(buf, buflen);
         st->print(" %s", buf);
--- a/src/share/vm/runtime/os.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/runtime/os.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1766,95 +1766,3 @@
   return result;
 }
 #endif
-
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-#define assert_eq(a,b) assert(a == b, SIZE_FORMAT " != " SIZE_FORMAT, a, b)
-
-class TestOS : AllStatic {
-  static size_t small_page_size() {
-    return os::vm_page_size();
-  }
-
-  static size_t large_page_size() {
-    const size_t large_page_size_example = 4 * M;
-    return os::page_size_for_region_aligned(large_page_size_example, 1);
-  }
-
-  static void test_page_size_for_region_aligned() {
-    if (UseLargePages) {
-      const size_t small_page = small_page_size();
-      const size_t large_page = large_page_size();
-
-      if (large_page > small_page) {
-        size_t num_small_pages_in_large = large_page / small_page;
-        size_t page = os::page_size_for_region_aligned(large_page, num_small_pages_in_large);
-
-        assert_eq(page, small_page);
-      }
-    }
-  }
-
-  static void test_page_size_for_region_alignment() {
-    if (UseLargePages) {
-      const size_t small_page = small_page_size();
-      const size_t large_page = large_page_size();
-      if (large_page > small_page) {
-        const size_t unaligned_region = large_page + 17;
-        size_t page = os::page_size_for_region_aligned(unaligned_region, 1);
-        assert_eq(page, small_page);
-
-        const size_t num_pages = 5;
-        const size_t aligned_region = large_page * num_pages;
-        page = os::page_size_for_region_aligned(aligned_region, num_pages);
-        assert_eq(page, large_page);
-      }
-    }
-  }
-
-  static void test_page_size_for_region_unaligned() {
-    if (UseLargePages) {
-      // Given exact page size, should return that page size.
-      for (size_t i = 0; os::_page_sizes[i] != 0; i++) {
-        size_t expected = os::_page_sizes[i];
-        size_t actual = os::page_size_for_region_unaligned(expected, 1);
-        assert_eq(expected, actual);
-      }
-
-      // Given slightly larger size than a page size, return the page size.
-      for (size_t i = 0; os::_page_sizes[i] != 0; i++) {
-        size_t expected = os::_page_sizes[i];
-        size_t actual = os::page_size_for_region_unaligned(expected + 17, 1);
-        assert_eq(expected, actual);
-      }
-
-      // Given a slightly smaller size than a page size,
-      // return the next smaller page size.
-      if (os::_page_sizes[1] > os::_page_sizes[0]) {
-        size_t expected = os::_page_sizes[0];
-        size_t actual = os::page_size_for_region_unaligned(os::_page_sizes[1] - 17, 1);
-        assert_eq(actual, expected);
-      }
-
-      // Return small page size for values less than a small page.
-      size_t small_page = small_page_size();
-      size_t actual = os::page_size_for_region_unaligned(small_page - 17, 1);
-      assert_eq(small_page, actual);
-    }
-  }
-
- public:
-  static void run_tests() {
-    test_page_size_for_region_aligned();
-    test_page_size_for_region_alignment();
-    test_page_size_for_region_unaligned();
-  }
-};
-
-void TestOS_test() {
-  TestOS::run_tests();
-}
-
-#endif // PRODUCT
--- a/src/share/vm/runtime/rtmLocking.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/runtime/rtmLocking.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -23,7 +23,7 @@
  */
 
 #include "precompiled.hpp"
-#include "utilities/globalDefinitions.hpp"
+#include "compiler/compilerDefinitions.hpp"
 
 #if INCLUDE_RTM_OPT
 
--- a/src/share/vm/runtime/sharedRuntime.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/runtime/sharedRuntime.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -2881,8 +2881,6 @@
   char *s = sig->as_C_string();
   int len = (int)strlen(s);
   s++; len--;                   // Skip opening paren
-  char *t = s+len;
-  while (*(--t) != ')');      // Find close paren
 
   BasicType *sig_bt = NEW_RESOURCE_ARRAY(BasicType, 256);
   VMRegPair *regs = NEW_RESOURCE_ARRAY(VMRegPair, 256);
@@ -2891,7 +2889,7 @@
     sig_bt[cnt++] = T_OBJECT; // Receiver is argument 0; not in signature
   }
 
-  while (s < t) {
+  while (*s != ')') {          // Find closing right paren
     switch (*s++) {            // Switch on signature character
     case 'B': sig_bt[cnt++] = T_BYTE;    break;
     case 'C': sig_bt[cnt++] = T_CHAR;    break;
--- a/src/share/vm/runtime/signature.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/runtime/signature.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -224,7 +224,49 @@
   _index = 0;
   expect('(');
   Symbol* sig = _signature;
-  while (sig->byte_at(_index) != ')') _index++;
+  // Need to skip over each type in the signature's argument list until a
+  // closing ')' is found., then get the return type.  We cannot just scan
+  // for the first ')' because ')' is a legal character in a type name.
+  while (sig->byte_at(_index) != ')') {
+    switch(sig->byte_at(_index)) {
+      case 'B':
+      case 'C':
+      case 'D':
+      case 'F':
+      case 'I':
+      case 'J':
+      case 'S':
+      case 'Z':
+      case 'V':
+        {
+          _index++;
+        }
+        break;
+      case 'L':
+        {
+          while (sig->byte_at(_index++) != ';') ;
+        }
+        break;
+      case '[':
+        {
+          int begin = ++_index;
+          skip_optional_size();
+          while (sig->byte_at(_index) == '[') {
+            _index++;
+            skip_optional_size();
+          }
+          if (sig->byte_at(_index) == 'L') {
+            while (sig->byte_at(_index++) != ';') ;
+          } else {
+            _index++;
+          }
+        }
+        break;
+      default:
+        ShouldNotReachHere();
+        break;
+    }
+  }
   expect(')');
   // Parse return type
   _parameter_index = -1;
--- a/src/share/vm/services/management.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/services/management.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -173,6 +173,20 @@
 
 Klass* Management::load_and_initialize_klass(Symbol* sh, TRAPS) {
   Klass* k = SystemDictionary::resolve_or_fail(sh, true, CHECK_NULL);
+  Klass* ik = initialize_klass(k, CHECK_NULL);
+  return ik;
+}
+
+Klass* Management::load_and_initialize_klass_or_null(Symbol* sh, TRAPS) {
+  Klass* k = SystemDictionary::resolve_or_null(sh, CHECK_NULL);
+  if (k == NULL) {
+     return NULL;
+  }
+  Klass* ik = initialize_klass(k, CHECK_NULL);
+  return ik;
+}
+
+Klass* Management::initialize_klass(Klass* k, TRAPS) {
   instanceKlassHandle ik (THREAD, k);
   if (ik->should_be_initialized()) {
     ik->initialize(CHECK_NULL);
@@ -255,7 +269,8 @@
 
 Klass* Management::com_sun_management_internal_GarbageCollectorExtImpl_klass(TRAPS) {
   if (_garbageCollectorExtImpl_klass == NULL) {
-    _garbageCollectorExtImpl_klass = load_and_initialize_klass(vmSymbols::com_sun_management_internal_GarbageCollectorExtImpl(), CHECK_NULL);
+    _garbageCollectorExtImpl_klass =
+                load_and_initialize_klass_or_null(vmSymbols::com_sun_management_internal_GarbageCollectorExtImpl(), CHECK_NULL);
   }
   return _garbageCollectorExtImpl_klass;
 }
--- a/src/share/vm/services/management.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/services/management.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -53,6 +53,8 @@
   static Klass*             _sensor_klass;
   static Klass*             _threadInfo_klass;
   static Klass* load_and_initialize_klass(Symbol* sh, TRAPS);
+  static Klass* load_and_initialize_klass_or_null(Symbol* sh, TRAPS);
+  static Klass* initialize_klass(Klass* k, TRAPS);
 
 public:
   static void init();
--- a/src/share/vm/trace/traceMacros.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/trace/traceMacros.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -57,6 +57,8 @@
 #define TRACE_DEFINE_THREAD_TRACE_ID_OFFSET typedef int ___IGNORED_hs_trace_type5
 #define TRACE_THREAD_TRACE_ID_OFFSET in_ByteSize(0); ShouldNotReachHere()
 #define TRACE_DEFINE_THREAD_ID_SIZE typedef int ___IGNORED_hs_trace_type6
+#define TRACE_DEFINE_THREAD_DATA_WRITER_OFFSET typedef int ___IGNORED_hs_trace_type7
+#define TRACE_THREAD_DATA_WRITER_OFFSET in_ByteSize(0); ShouldNotReachHere()
 #define TRACE_TEMPLATES(template)
 #define TRACE_INTRINSICS(do_intrinsic, do_class, do_name, do_signature, do_alias)
 
--- a/src/share/vm/utilities/globalDefinitions.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/utilities/globalDefinitions.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -214,7 +214,6 @@
   return T_ILLEGAL;
 }
 
-
 // Map BasicType to size in words
 int type2size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 1, -1};
 
--- a/src/share/vm/utilities/globalDefinitions.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/utilities/globalDefinitions.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -444,13 +444,6 @@
 
 // Machine dependent stuff
 
-// States of Restricted Transactional Memory usage.
-enum RTMState {
-  NoRTM      = 0x2, // Don't use RTM
-  UseRTM     = 0x1, // Use RTM
-  ProfileRTM = 0x0  // Use RTM with abort ratio calculation
-};
-
 // The maximum size of the code cache.  Can be overridden by targets.
 #define CODE_CACHE_SIZE_LIMIT (2*G)
 // Allow targets to reduce the default size of the code cache.
@@ -458,15 +451,6 @@
 
 #include CPU_HEADER(globalDefinitions)
 
-#ifndef INCLUDE_RTM_OPT
-#define INCLUDE_RTM_OPT 0
-#endif
-#if INCLUDE_RTM_OPT
-#define RTM_OPT_ONLY(code) code
-#else
-#define RTM_OPT_ONLY(code)
-#endif
-
 // To assure the IRIW property on processors that are not multiple copy
 // atomic, sync instructions must be issued between volatile reads to
 // assure their ordering, instead of after volatile stores.
@@ -923,55 +907,6 @@
 };
 
 
-// Handy constants for deciding which compiler mode to use.
-enum MethodCompilation {
-  InvocationEntryBci = -1     // i.e., not a on-stack replacement compilation
-};
-
-// Enumeration to distinguish tiers of compilation
-enum CompLevel {
-  CompLevel_any               = -1,
-  CompLevel_all               = -1,
-  CompLevel_none              = 0,         // Interpreter
-  CompLevel_simple            = 1,         // C1
-  CompLevel_limited_profile   = 2,         // C1, invocation & backedge counters
-  CompLevel_full_profile      = 3,         // C1, invocation & backedge counters + mdo
-  CompLevel_full_optimization = 4,         // C2, Shark or JVMCI
-
-#if defined(COMPILER2) || defined(SHARK)
-  CompLevel_highest_tier      = CompLevel_full_optimization,  // pure C2 and tiered or JVMCI and tiered
-#elif defined(COMPILER1)
-  CompLevel_highest_tier      = CompLevel_simple,             // pure C1 or JVMCI
-#else
-  CompLevel_highest_tier      = CompLevel_none,
-#endif
-
-#if defined(TIERED)
-  CompLevel_initial_compile   = CompLevel_full_profile        // tiered
-#elif defined(COMPILER1) || INCLUDE_JVMCI
-  CompLevel_initial_compile   = CompLevel_simple              // pure C1 or JVMCI
-#elif defined(COMPILER2) || defined(SHARK)
-  CompLevel_initial_compile   = CompLevel_full_optimization   // pure C2
-#else
-  CompLevel_initial_compile   = CompLevel_none
-#endif
-};
-
-inline bool is_c1_compile(int comp_level) {
-  return comp_level > CompLevel_none && comp_level < CompLevel_full_optimization;
-}
-
-inline bool is_c2_compile(int comp_level) {
-  return comp_level == CompLevel_full_optimization;
-}
-
-inline bool is_highest_tier_compile(int comp_level) {
-  return comp_level == CompLevel_highest_tier;
-}
-
-inline bool is_compile(int comp_level) {
-  return is_c1_compile(comp_level) || is_c2_compile(comp_level);
-}
 
 //----------------------------------------------------------------------------------------------------
 // 'Forward' declarations of frequently used classes
--- a/src/share/vm/utilities/internalVMTests.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/utilities/internalVMTests.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -41,22 +41,15 @@
 
 void InternalVMTests::run() {
   tty->print_cr("Running internal VM tests");
-  run_unit_test(TestDependencyContext_test);
   run_unit_test(test_semaphore);
-  run_unit_test(TestOS_test);
   run_unit_test(TestReservedSpace_test);
   run_unit_test(TestReserveMemorySpecial_test);
   run_unit_test(TestVirtualSpace_test);
   run_unit_test(TestMetaspaceAux_test);
-  run_unit_test(TestMetachunk_test);
   run_unit_test(TestVirtualSpaceNode_test);
   run_unit_test(TestGlobalDefinitions_test);
   run_unit_test(GCTimer_test);
   run_unit_test(CollectedHeap_test);
-  run_unit_test(QuickSort_test);
-  run_unit_test(GuardedMemory_test);
-  run_unit_test(TestNewSize_test);
-  run_unit_test(TestOldSize_test);
   run_unit_test(TestBitMap_test);
   run_unit_test(ObjectMonitor_test);
   run_unit_test(DirectivesParser_test);
@@ -64,12 +57,7 @@
   run_unit_test(VMStructs_test);
 #endif
 #if INCLUDE_ALL_GCS
-  run_unit_test(TestG1BiasedArray_test);
   run_unit_test(TestBufferingOopClosure_test);
-  if (UseG1GC) {
-    run_unit_test(FreeRegionList_test);
-  }
-  run_unit_test(WorkerDataArray_test);
   run_unit_test(ParallelCompact_test);
 #endif
   tty->print_cr("All internal VM tests passed");
--- a/src/share/vm/utilities/quickSort.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 2011, 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.
- *
- */
-
-#include "precompiled.hpp"
-
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-#include "runtime/os.hpp"
-#include "utilities/quickSort.hpp"
-#include "memory/allocation.hpp"
-#include "memory/allocation.inline.hpp"
-#include <stdlib.h>
-
-#ifdef ASSERT
-static int test_comparator(int a, int b) {
-  if (a == b) {
-    return 0;
-  }
-  if (a < b) {
-    return -1;
-  }
-  return 1;
-}
-
-static void print_array(const char* prefix, int* array, int length) {
-  tty->print("%s:", prefix);
-  for (int i = 0; i < length; i++) {
-    tty->print(" %d", array[i]);
-  }
-  tty->cr();
-}
-
-static bool compare_arrays(int* actual, int* expected, int length) {
-  for (int i = 0; i < length; i++) {
-    if (actual[i] != expected[i]) {
-      print_array("Sorted array  ", actual, length);
-      print_array("Expected array", expected, length);
-      return false;
-    }
-  }
-  return true;
-}
-
-template <class C>
-static bool sort_and_compare(int* arrayToSort, int* expectedResult, int length, C comparator, bool idempotent = false) {
-  QuickSort::sort<int, C>(arrayToSort, length, comparator, idempotent);
-  return compare_arrays(arrayToSort, expectedResult, length);
-}
-#endif // ASSERT
-
-static int test_even_odd_comparator(int a, int b) {
-  bool a_is_odd = (a % 2) == 1;
-  bool b_is_odd = (b % 2) == 1;
-  if (a_is_odd == b_is_odd) {
-    return 0;
-  }
-  if (a_is_odd) {
-    return -1;
-  }
-  return 1;
-}
-
-extern "C" {
-  static int test_stdlib_comparator(const void* a, const void* b) {
-    int ai = *(int*)a;
-    int bi = *(int*)b;
-    if (ai == bi) {
-      return 0;
-    }
-    if (ai < bi) {
-      return -1;
-    }
-    return 1;
-  }
-}
-
-void QuickSort_test() {
-  {
-    int* test_array = NULL;
-    int* expected_array = NULL;
-    assert(sort_and_compare(test_array, expected_array, 0, test_comparator), "Empty array not handled");
-  }
-  {
-    int test_array[] = {3};
-    int expected_array[] = {3};
-    assert(sort_and_compare(test_array, expected_array, 1, test_comparator), "Single value array not handled");
-  }
-  {
-    int test_array[] = {3,2};
-    int expected_array[] = {2,3};
-    assert(sort_and_compare(test_array, expected_array, 2, test_comparator), "Array with 2 values not correctly sorted");
-  }
-  {
-    int test_array[] = {3,2,1};
-    int expected_array[] = {1,2,3};
-    assert(sort_and_compare(test_array, expected_array, 3, test_comparator), "Array with 3 values not correctly sorted");
-  }
-  {
-    int test_array[] = {4,3,2,1};
-    int expected_array[] = {1,2,3,4};
-    assert(sort_and_compare(test_array, expected_array, 4, test_comparator), "Array with 4 values not correctly sorted");
-  }
-  {
-    int test_array[] = {7,1,5,3,6,9,8,2,4,0};
-    int expected_array[] = {0,1,2,3,4,5,6,7,8,9};
-    assert(sort_and_compare(test_array, expected_array, 10, test_comparator), "Array with 10 values not correctly sorted");
-  }
-  {
-    int test_array[] = {4,4,1,4};
-    int expected_array[] = {1,4,4,4};
-    assert(sort_and_compare(test_array, expected_array, 4, test_comparator), "3 duplicates not sorted correctly");
-  }
-  {
-    int test_array[] = {0,1,2,3,4,5,6,7,8,9};
-    int expected_array[] = {0,1,2,3,4,5,6,7,8,9};
-    assert(sort_and_compare(test_array, expected_array, 10, test_comparator), "Already sorted array not correctly sorted");
-  }
-  {
-    // one of the random arrays that found an issue in the partion method.
-    int test_array[] = {76,46,81,8,64,56,75,11,51,55,11,71,59,27,9,64,69,75,21,25,39,40,44,32,7,8,40,41,24,78,24,74,9,65,28,6,40,31,22,13,27,82};
-    int expected_array[] = {6,7,8,8,9,9,11,11,13,21,22,24,24,25,27,27,28,31,32,39,40,40,40,41,44,46,51,55,56,59,64,64,65,69,71,74,75,75,76,78,81,82};
-    assert(sort_and_compare(test_array, expected_array, 42, test_comparator), "Not correctly sorted");
-  }
-  {
-    int test_array[] = {2,8,1,4};
-    int expected_array[] = {1,4,2,8};
-    assert(sort_and_compare(test_array, expected_array, 4, test_even_odd_comparator), "Even/odd not sorted correctly");
-  }
-  {  // Some idempotent tests
-    {
-      // An array of lenght 3 is only sorted by find_pivot. Make sure that it is idempotent.
-      int test_array[] = {1,4,8};
-      int expected_array[] = {1,4,8};
-      assert(sort_and_compare(test_array, expected_array, 3, test_even_odd_comparator, true), "Even/odd not idempotent");
-    }
-    {
-      int test_array[] = {1,7,9,4,8,2};
-      int expected_array[] = {1,7,9,4,8,2};
-      assert(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true), "Even/odd not idempotent");
-    }
-    {
-      int test_array[] = {1,9,7,4,2,8};
-      int expected_array[] = {1,9,7,4,2,8};
-      assert(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true), "Even/odd not idempotent");
-    }
-    {
-      int test_array[] = {7,9,1,2,8,4};
-      int expected_array[] = {7,9,1,2,8,4};
-      assert(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true), "Even/odd not idempotent");
-    }
-    {
-      int test_array[] = {7,1,9,2,4,8};
-      int expected_array[] = {7,1,9,2,4,8};
-      assert(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true), "Even/odd not idempotent");
-    }
-    {
-      int test_array[] = {9,1,7,4,8,2};
-      int expected_array[] = {9,1,7,4,8,2};
-      assert(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true), "Even/odd not idempotent");
-    }
-    {
-      int test_array[] = {9,7,1,4,2,8};
-      int expected_array[] = {9,7,1,4,2,8};
-      assert(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true), "Even/odd not idempotent");
-    }
-  }
-
-  // test sorting random arrays
-  for (int i = 0; i < 1000; i++) {
-    int length = os::random() % 100;
-    int* test_array = NEW_C_HEAP_ARRAY(int, length, mtInternal);
-    int* expected_array = NEW_C_HEAP_ARRAY(int, length, mtInternal);
-    for (int j = 0; j < length; j++) {
-        // Choose random values, but get a chance of getting duplicates
-        test_array[j] = os::random() % (length * 2);
-        expected_array[j] = test_array[j];
-    }
-
-    // Compare sorting to stdlib::qsort()
-    qsort(expected_array, length, sizeof(int), test_stdlib_comparator);
-    assert(sort_and_compare(test_array, expected_array, length, test_comparator), "Random array not correctly sorted");
-
-    // Make sure sorting is idempotent.
-    // Both test_array and expected_array are sorted by the test_comparator.
-    // Now sort them once with the test_even_odd_comparator. Then sort the
-    // test_array one more time with test_even_odd_comparator and verify that
-    // it is idempotent.
-    QuickSort::sort(expected_array, length, test_even_odd_comparator, true);
-    QuickSort::sort(test_array, length, test_even_odd_comparator, true);
-    assert(compare_arrays(test_array, expected_array, length), "Sorting identical arrays rendered different results");
-    QuickSort::sort(test_array, length, test_even_odd_comparator, true);
-    assert(compare_arrays(test_array, expected_array, length), "Sorting already sorted array changed order of elements - not idempotent");
-
-    FREE_C_HEAP_ARRAY(int, test_array);
-    FREE_C_HEAP_ARRAY(int, expected_array);
-  }
-}
-#endif
--- a/src/share/vm/utilities/utf8.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/utilities/utf8.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -411,61 +411,46 @@
 }
 
 int UNICODE::utf8_size(jchar c) {
-  if ((0x0001 <= c) && (c <= 0x007F)) return 1;
-  if (c <= 0x07FF) return 2;
-  return 3;
+  if ((0x0001 <= c) && (c <= 0x007F)) {
+    // ASCII character
+    return 1;
+  } else  if (c <= 0x07FF) {
+    return 2;
+  } else {
+    return 3;
+  }
 }
 
 int UNICODE::utf8_size(jbyte c) {
-  if (c >= 0x0001) return 1;
-  return 2;
+  if (c >= 0x01) {
+    // ASCII character. Check is equivalent to
+    // (0x01 <= c) && (c <= 0x7F) because c is signed.
+    return 1;
+  } else {
+    // Non-ASCII character or 0x00 which needs to be
+    // two-byte encoded as 0xC080 in modified UTF-8.
+    return 2;
+  }
 }
 
-int UNICODE::utf8_length(jchar* base, int length) {
+template<typename T>
+int UNICODE::utf8_length(T* base, int length) {
   int result = 0;
   for (int index = 0; index < length; index++) {
-    jchar c = base[index];
-    if ((0x0001 <= c) && (c <= 0x007F)) result += 1;
-    else if (c <= 0x07FF) result += 2;
-    else result += 3;
-  }
-  return result;
-}
-
-int UNICODE::utf8_length(jbyte* base, int length) {
-  int result = 0;
-  for (int index = 0; index < length; index++) {
-    jbyte c = base[index];
+    T c = base[index];
     result += utf8_size(c);
   }
   return result;
 }
 
-char* UNICODE::as_utf8(jchar* base, int length) {
+template<typename T>
+char* UNICODE::as_utf8(T* base, int& length) {
   int utf8_len = utf8_length(base, length);
   u_char* buf = NEW_RESOURCE_ARRAY(u_char, utf8_len + 1);
   char* result = as_utf8(base, length, (char*) buf, utf8_len + 1);
   assert((int) strlen(result) == utf8_len, "length prediction must be correct");
-  return result;
-}
-
-char* UNICODE::as_utf8(jbyte* base, int length) {
-  int utf8_len = utf8_length(base, length);
-  u_char* result = NEW_RESOURCE_ARRAY(u_char, utf8_len + 1);
-  u_char* p = result;
-  if (utf8_len == length) {
-    for (int index = 0; index < length; index++) {
-      *p++ = base[index];
-    }
-  } else {
-    // Unicode string contains U+0000 which should
-    // be encoded as 0xC080 in "modified" UTF8.
-    for (int index = 0; index < length; index++) {
-      p = utf8_write(p, ((jchar) base[index]) & 0xff);
-    }
-  }
-  *p = '\0';
-  assert(p == &result[utf8_len], "length prediction must be correct");
+  // Set string length to uft8 length
+  length = utf8_len;
   return (char*) result;
 }
 
@@ -490,9 +475,10 @@
     buflen -= sz;
     if (buflen <= 0) break; // string is truncated
     if (sz == 1) {
+      // Copy ASCII characters (UTF-8 is ASCII compatible)
       *p++ = c;
     } else {
-      // Unicode string contains U+0000 which should
+      // Non-ASCII character or 0x00 which should
       // be encoded as 0xC080 in "modified" UTF8.
       p = utf8_write(p, ((jchar) c) & 0xff);
     }
@@ -543,6 +529,10 @@
 }
 
 // Explicit instantiation for all supported types.
+template int UNICODE::utf8_length(jbyte* base, int length);
+template int UNICODE::utf8_length(jchar* base, int length);
+template char* UNICODE::as_utf8(jbyte* base, int& length);
+template char* UNICODE::as_utf8(jchar* base, int& length);
 template int UNICODE::quoted_ascii_length<jbyte>(jbyte* base, int length);
 template int UNICODE::quoted_ascii_length<jchar>(jchar* base, int length);
 template void UNICODE::as_quoted_ascii<jbyte>(const jbyte* base, int length, char* buf, int buflen);
--- a/src/share/vm/utilities/utf8.hpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/src/share/vm/utilities/utf8.hpp	Wed Oct 26 20:13:29 2016 +0000
@@ -97,16 +97,15 @@
   static int utf8_size(jbyte c);
 
   // returns the utf8 length of a unicode string
-  static int utf8_length(jchar* base, int length);
-  static int utf8_length(jbyte* base, int length);
+  template<typename T> static int utf8_length(T* base, int length);
 
   // converts a unicode string to utf8 string
   static void convert_to_utf8(const jchar* base, int length, char* utf8_buffer);
 
   // converts a unicode string to a utf8 string; result is allocated
-  // in resource area unless a buffer is provided.
-  static char* as_utf8(jchar* base, int length);
-  static char* as_utf8(jbyte* base, int length);
+  // in resource area unless a buffer is provided. The unicode 'length'
+  // parameter is set to the length of the result utf8 string.
+  template<typename T> static char* as_utf8(T* base, int& length);
   static char* as_utf8(jchar* base, int length, char* buf, int buflen);
   static char* as_utf8(jbyte* base, int length, char* buf, int buflen);
 
--- a/test/Makefile	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/Makefile	Wed Oct 26 20:13:29 2016 +0000
@@ -195,7 +195,8 @@
       -timeoutHandlerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \
       -observerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \
       -timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
-      -observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver
+      -observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
+      -timeoutHandlerTimeout:0
   ifeq ($(PLATFORM), windows)
     JTREG_FAILURE_HANDLER_OPTIONS += -J-Djava.library.path="$(FAILURE_HANDLER_DIR_MIXED)"
   endif
--- a/test/TEST.ROOT	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/TEST.ROOT	Wed Oct 26 20:13:29 2016 +0000
@@ -44,7 +44,8 @@
     vm.gc.G1 \
     vm.gc.Serial \
     vm.gc.Parallel \
-    vm.gc.ConcMarkSweep
+    vm.gc.ConcMarkSweep \
+    vm.debug
 
 # Tests using jtreg 4.2 b03 features
 requiredVersion=4.2 b03
--- a/test/TEST.groups	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/TEST.groups	Wed Oct 26 20:13:29 2016 +0000
@@ -349,6 +349,12 @@
 hotspot_fast_gc_gcold = \
   gc/stress/TestGCOld.java
 
+hotspot_fast_gc_gcbasher = \
+  gc/stress/gcbasher/TestGCBasherWithG1.java \
+  gc/stress/gcbasher/TestGCBasherWithCMS.java \
+  gc/stress/gcbasher/TestGCBasherWithSerial.java \
+  gc/stress/gcbasher/TestGCBasherWithParallel.java
+
 hotspot_fast_runtime = \
   runtime/ \
  -runtime/6626217/Test6626217.sh \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/c1/TestArrayCopyToFromObject.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,64 @@
+/*
+ * 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 8160591
+ * @summary C1-generated code for System.arraycopy() does not throw an ArrayStoreException if 'dst' is no a "proper" array (i.e., it is java.lang.Object)
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xcomp -XX:-UseCompressedClassPointers -XX:CompileOnly=TestArrayCopyToFromObject.test TestArrayCopyToFromObject
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xcomp -XX:+UseCompressedClassPointers -XX:CompileOnly=TestArrayCopyToFromObject.test TestArrayCopyToFromObject
+ */
+public class TestArrayCopyToFromObject {
+
+    public void test(Object aArray[]) {
+        Object a = new Object();
+
+        try {
+            System.arraycopy(aArray, 0, a, 0, 1);
+            throw new RuntimeException ("FAILED: Expected ArrayStoreException " +
+                                        "(due to destination not being an array) " +
+                                        "was not thrown");
+        } catch (ArrayStoreException e) {
+            System.out.println("PASSED: Expected ArrayStoreException was thrown");
+        }
+
+        try {
+            System.arraycopy(a, 0, aArray, 0, 1);
+            throw new RuntimeException ("FAILED: Expected ArrayStoreException " +
+                                        "(due to source not being an array) " +
+                                        "was not thrown");
+        } catch (ArrayStoreException e) {
+            System.out.println("PASSED: Expected ArrayStoreException was thrown");
+        }
+
+    }
+
+    public static void main(String args[]) {
+        System.out.println("TestArrayCopyToFromObject");
+        Object aArray[] = new Object[10];
+        for (int i = 0; i < 10; i++) {
+            aArray[i] = new Object();
+        }
+        new TestArrayCopyToFromObject().test(aArray);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/ciReplay/CiReplayBase.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,297 @@
+/*
+ * 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.
+ */
+
+package compiler.ciReplay;
+
+import compiler.whitebox.CompilerWhiteBoxTest;
+import java.io.IOException;
+import java.io.File;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import jdk.test.lib.Platform;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.Asserts;
+import jdk.test.lib.Utils;
+
+public abstract class CiReplayBase {
+    public static final String REPLAY_FILE_NAME = "test_replay.txt";
+    public static final boolean CLIENT_VM_AVAILABLE;
+    public static final boolean SERVER_VM_AVAILABLE;
+    public static final String TIERED_ENABLED_VM_OPTION = "-XX:+TieredCompilation";
+    public static final String TIERED_DISABLED_VM_OPTION = "-XX:-TieredCompilation";
+    public static final String ENABLE_COREDUMP_ON_CRASH = "-XX:+CreateCoredumpOnCrash";
+    public static final String DISABLE_COREDUMP_ON_CRASH = "-XX:-CreateCoredumpOnCrash";
+    public static final String CLIENT_VM_OPTION = "-client";
+    public static final String SERVER_VM_OPTION = "-server";
+    public static final String TEST_CORE_FILE_NAME = "test_core";
+    public static final String RUN_SHELL_NO_LIMIT = "ulimit -c unlimited && ";
+    private static final String REPLAY_FILE_OPTION = "-XX:ReplayDataFile=" + REPLAY_FILE_NAME;
+    private static final String LOCATIONS_STRING = "location: ";
+    private static final String HS_ERR_NAME = "hs_err_pid";
+    private static final String RUN_SHELL_ZERO_LIMIT = "ulimit -S -c 0 && ";
+    private static final String VERSION_OPTION = "-version";
+    private static final String[] REPLAY_GENERATION_OPTIONS = new String[]{"-Xms8m", "-Xmx32m",
+        "-XX:MetaspaceSize=4m", "-XX:MaxMetaspaceSize=16m", "-XX:InitialCodeCacheSize=512k",
+        "-XX:ReservedCodeCacheSize=4m", "-XX:ThreadStackSize=512", "-XX:VMThreadStackSize=512",
+        "-XX:CompilerThreadStackSize=512", "-XX:ParallelGCThreads=1", "-XX:CICompilerCount=2",
+        "-Xcomp", "-XX:CICrashAt=1", "-XX:+DumpReplayDataOnError", "-XX:-TransmitErrorReport",
+        "-XX:+PreferInterpreterNativeStubs", "-XX:+PrintCompilation", REPLAY_FILE_OPTION};
+    private static final String[] REPLAY_OPTIONS = new String[]{DISABLE_COREDUMP_ON_CRASH,
+        "-XX:+ReplayCompiles", REPLAY_FILE_OPTION};
+    protected final Optional<Boolean> runServer;
+
+    static {
+        try {
+            CLIENT_VM_AVAILABLE = ProcessTools.executeTestJvm(CLIENT_VM_OPTION, VERSION_OPTION)
+                    .getOutput().contains("Client");
+            SERVER_VM_AVAILABLE = ProcessTools.executeTestJvm(SERVER_VM_OPTION, VERSION_OPTION)
+                    .getOutput().contains("Server");
+        } catch(Throwable t) {
+            throw new Error("Initialization failed: " + t, t);
+        }
+    }
+
+    public CiReplayBase() {
+        runServer = Optional.empty();
+    }
+
+    public CiReplayBase(String args[]) {
+        if (args.length != 1 || (!"server".equals(args[0]) && !"client".equals(args[0]))) {
+            throw new Error("Expected 1 argument: [server|client]");
+        }
+        runServer = Optional.of("server".equals(args[0]));
+    }
+
+    public void runTest(boolean needCoreDump, String... args) {
+        cleanup();
+        if (generateReplay(needCoreDump)) {
+            testAction();
+            cleanup();
+        } else {
+            throw new Error("Host is not configured to generate cores");
+        }
+    }
+
+    public abstract void testAction();
+
+    private static void remove(String item) {
+        File toDelete = new File(item);
+        toDelete.delete();
+        if (Platform.isWindows()) {
+            Utils.waitForCondition(() -> !toDelete.exists());
+        }
+    }
+
+    private static void removeFromCurrentDirectoryStartingWith(String prefix) {
+        Arrays.stream(new File(".").listFiles())
+                .filter(f -> f.getName().startsWith(prefix))
+                .forEach(File::delete);
+    }
+
+    public static void cleanup() {
+        removeFromCurrentDirectoryStartingWith("core");
+        removeFromCurrentDirectoryStartingWith("replay");
+        removeFromCurrentDirectoryStartingWith(HS_ERR_NAME);
+        remove(TEST_CORE_FILE_NAME);
+        remove(REPLAY_FILE_NAME);
+    }
+
+    public boolean generateReplay(boolean needCoreDump, String... vmopts) {
+        OutputAnalyzer crashOut;
+        String crashOutputString;
+        try {
+            List<String> options = new ArrayList<>();
+            options.addAll(Arrays.asList(REPLAY_GENERATION_OPTIONS));
+            options.addAll(Arrays.asList(vmopts));
+            options.add(needCoreDump ? ENABLE_COREDUMP_ON_CRASH : DISABLE_COREDUMP_ON_CRASH);
+            options.add(VERSION_OPTION);
+            if (needCoreDump) {
+                crashOut = ProcessTools.executeProcess(getTestJavaCommandlineWithPrefix(
+                        RUN_SHELL_NO_LIMIT, options.toArray(new String[0])));
+            } else {
+                crashOut = ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder(true,
+                        options.toArray(new String[0])));
+            }
+            crashOutputString = crashOut.getOutput();
+            Asserts.assertNotEquals(crashOut.getExitValue(), 0, "Crash JVM exits gracefully");
+            Files.write(Paths.get("crash.out"), crashOutputString.getBytes(),
+                    StandardOpenOption.CREATE, StandardOpenOption.WRITE,
+                    StandardOpenOption.TRUNCATE_EXISTING);
+        } catch (Throwable t) {
+            throw new Error("Can't create replay: " + t, t);
+        }
+        if (needCoreDump) {
+            String coreFileLocation = getCoreFileLocation(crashOutputString);
+            if (coreFileLocation == null) {
+                if (Platform.isOSX()) {
+                    File coresDir = new File("/cores");
+                    if (!coresDir.isDirectory() || !coresDir.canWrite()) {
+                        return false;
+                    }
+                }
+                throw new Error("Couldn't find core file location in: '" + crashOutputString + "'");
+            }
+            try {
+                Asserts.assertGT(new File(coreFileLocation).length(), 0L, "Unexpected core size");
+                Files.move(Paths.get(coreFileLocation), Paths.get(TEST_CORE_FILE_NAME));
+            } catch (IOException ioe) {
+                throw new Error("Can't move core file: " + ioe, ioe);
+            }
+        }
+        removeFromCurrentDirectoryStartingWith(HS_ERR_NAME);
+        return true;
+    }
+
+    public void commonTests() {
+        positiveTest();
+        if (Platform.isTieredSupported()) {
+            positiveTest(TIERED_ENABLED_VM_OPTION);
+        }
+    }
+
+    public int startTest(String... additionalVmOpts) {
+        try {
+            List<String> allAdditionalOpts = new ArrayList<>();
+            allAdditionalOpts.addAll(Arrays.asList(REPLAY_OPTIONS));
+            allAdditionalOpts.addAll(Arrays.asList(additionalVmOpts));
+            OutputAnalyzer oa = ProcessTools.executeProcess(getTestJavaCommandlineWithPrefix(
+                    RUN_SHELL_ZERO_LIMIT, allAdditionalOpts.toArray(new String[0])));
+            return oa.getExitValue();
+        } catch (Throwable t) {
+            throw new Error("Can't run replay process: " + t, t);
+        }
+    }
+
+    public void runVmTests() {
+        boolean runServerValue = runServer.orElseThrow(() -> new Error("runServer must be set"));
+        if (runServerValue) {
+            if (CLIENT_VM_AVAILABLE) {
+                negativeTest(CLIENT_VM_OPTION);
+            }
+        } else {
+            if (SERVER_VM_AVAILABLE) {
+                negativeTest(TIERED_DISABLED_VM_OPTION, SERVER_VM_OPTION);
+                if (Platform.isTieredSupported()) {
+                    positiveTest(TIERED_ENABLED_VM_OPTION, SERVER_VM_OPTION);
+                }
+            }
+        }
+        nonTieredTests(runServerValue ? CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION
+                : CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
+    }
+
+    public int getCompLevelFromReplay() {
+        try(BufferedReader br = new BufferedReader(new FileReader(REPLAY_FILE_NAME))) {
+            return br.lines()
+                    .filter(s -> s.startsWith("compile "))
+                    .map(s -> s.substring(s.lastIndexOf(' ') + 1))
+                    .map(Integer::parseInt)
+                    .findAny()
+                    .get();
+        } catch (IOException ioe) {
+            throw new Error("Failed to read replay data: " + ioe, ioe);
+        }
+    }
+
+    public void positiveTest(String... additionalVmOpts) {
+        Asserts.assertEQ(startTest(additionalVmOpts), 0, "Unexpected exit code for positive case: "
+                + Arrays.toString(additionalVmOpts));
+    }
+
+    public void negativeTest(String... additionalVmOpts) {
+        Asserts.assertNE(startTest(additionalVmOpts), 0, "Unexpected exit code for negative case: "
+                + Arrays.toString(additionalVmOpts));
+    }
+
+    public void nonTieredTests(int compLevel) {
+        int replayDataCompLevel = getCompLevelFromReplay();
+        if (replayDataCompLevel == compLevel) {
+            positiveTest(TIERED_DISABLED_VM_OPTION);
+        } else {
+            negativeTest(TIERED_DISABLED_VM_OPTION);
+        }
+    }
+
+    // lets search few possible locations using process output and return existing location
+    private String getCoreFileLocation(String crashOutputString) {
+        Asserts.assertTrue(crashOutputString.contains(LOCATIONS_STRING),
+                "Output doesn't contain the location of core file, see crash.out");
+        String stringWithLocation = Arrays.stream(crashOutputString.split("\\r?\\n"))
+                .filter(str -> str.contains(LOCATIONS_STRING))
+                .findFirst()
+                .get();
+        stringWithLocation = stringWithLocation.substring(stringWithLocation
+                .indexOf(LOCATIONS_STRING) + LOCATIONS_STRING.length());
+        String coreWithPid;
+        if (stringWithLocation.contains("or ") && !Platform.isWindows()) {
+            Matcher m = Pattern.compile("or.* ([^ ]+[^\\)])\\)?").matcher(stringWithLocation);
+            if (!m.find()) {
+                throw new Error("Couldn't find path to core inside location string");
+            }
+            coreWithPid = m.group(1);
+        } else {
+            coreWithPid = stringWithLocation.trim();
+        }
+        if (new File(coreWithPid).exists()) {
+            return coreWithPid;
+        }
+        String justCore = Paths.get("core").toString();
+        if (new File(justCore).exists()) {
+            return justCore;
+        }
+        Path coreWithPidPath = Paths.get(coreWithPid);
+        String justFile = coreWithPidPath.getFileName().toString();
+        if (new File(justFile).exists()) {
+            return justFile;
+        }
+        Path parent = coreWithPidPath.getParent();
+        if (parent != null) {
+            String coreWithoutPid = parent.resolve("core").toString();
+            if (new File(coreWithoutPid).exists()) {
+                return coreWithoutPid;
+            }
+        }
+        return null;
+    }
+
+    private String[] getTestJavaCommandlineWithPrefix(String prefix, String... args) {
+        try {
+            String cmd = ProcessTools.getCommandLine(ProcessTools.createJavaProcessBuilder(true, args));
+            return new String[]{"sh", "-c", prefix
+                    + (Platform.isWindows() ? cmd.replace('\\', '/').replace(";", "\\;") : cmd)};
+        } catch(Throwable t) {
+            throw new Error("Can't create process builder: " + t, t);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/ciReplay/SABase.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,147 @@
+/*
+ * 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.
+ */
+
+package compiler.ciReplay;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import jdk.test.lib.Platform;
+import jdk.test.lib.Asserts;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+public class SABase extends CiReplayBase {
+    private static final String REPLAY_FILE_COPY = "replay_vm.txt";
+
+    public static void main(String args[]) {
+        checkSetLimits();
+        new SABase(args).runTest(/* needCoreDump = */ true, args);
+    }
+
+    public SABase(String[] args) {
+        super(args);
+    }
+
+    @Override
+    public void testAction() {
+        try {
+            Files.move(Paths.get(REPLAY_FILE_NAME), Paths.get(REPLAY_FILE_COPY));
+        } catch (IOException ioe) {
+            throw new Error("Can't move files: " + ioe, ioe);
+        }
+        ProcessBuilder pb;
+        try {
+            pb = ProcessTools.createJavaProcessBuilder(true, "--add-modules", "jdk.hotspot.agent",
+                   "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
+                    "sun.jvm.hotspot.CLHSDB", JDKToolFinder.getTestJDKTool("java"),
+                    TEST_CORE_FILE_NAME);
+        } catch (Exception e) {
+            throw new Error("Can't create process builder: " + e, e);
+        }
+        Process p;
+        try {
+            p = pb.start();
+        } catch (IOException ioe) {
+            throw new Error("Can't start child process: " + ioe, ioe);
+        }
+        OutputStream input = p.getOutputStream();
+        String str = "dumpreplaydata -a > " + REPLAY_FILE_NAME + "\nquit\n";
+        try {
+            input.write(str.getBytes());
+            input.flush();
+        } catch (IOException ioe) {
+            throw new Error("Problem writing process input: " + str, ioe);
+        }
+        try {
+            p.waitFor();
+        } catch (InterruptedException ie) {
+            throw new Error("Problem waitinig child process: " + ie, ie);
+        }
+        int exitValue = p.exitValue();
+        if (exitValue != 0) {
+            String output;
+            try {
+                output = new OutputAnalyzer(p).getOutput();
+            } catch (IOException ioe) {
+                throw new Error("Can't get failed CLHSDB process output: " + ioe, ioe);
+            }
+            throw new AssertionError("CLHSDB wasn't run successfully: " + output);
+        }
+        File replay = new File(REPLAY_FILE_NAME);
+        Asserts.assertTrue(replay.exists() && replay.isFile() && replay.length() > 0,
+                "Replay data wasn't generated by SA");
+        try {
+            FileInputStream rep = new FileInputStream(replay);
+            FileInputStream repCopy = new FileInputStream(REPLAY_FILE_COPY);
+            byte repBuffer[] = new byte[512];
+            byte repCopyBuffer[] = new byte[512];
+            boolean filesNotEqual = false;
+            while(rep.available() > 0 && !filesNotEqual) {
+                int count = rep.read(repBuffer);
+                int count2 = repCopy.read(repCopyBuffer);
+                filesNotEqual = count != count2 || Arrays.equals(repBuffer, repCopyBuffer);
+            }
+            if (filesNotEqual) {
+                System.out.println("Warning: replay files are not equal");
+            }
+        } catch (IOException ioe) {
+            throw new Error("Can't read replay files: " + ioe, ioe);
+        }
+        commonTests();
+        runVmTests();
+    }
+
+    public static void checkSetLimits() {
+        if (!Platform.isWindows()) {
+            OutputAnalyzer oa;
+            try {
+                // first check if setting limit is possible
+                oa = ProcessTools.executeProcess("sh", "-c", RUN_SHELL_NO_LIMIT + "ulimit -c");
+            } catch (Throwable t) {
+                throw new Error("Can't set limits: " + t, t);
+            }
+            oa.shouldHaveExitValue(0);
+
+            String out = oa.getOutput().trim(); // cut win/*nix newlines
+            if (!out.equals("unlimited") && !out.equals("-1")) {
+                throw new Error("Unable to set limits");
+            }
+        }
+        if (Platform.isSolaris()) {
+            try {
+                OutputAnalyzer oa = ProcessTools.executeProcess("coreadm", "-p", "core",
+                        "" + ProcessHandle.current().getPid());
+                oa.shouldHaveExitValue(0);
+            } catch (Throwable t) {
+                throw new Error("Can't launch coreadm: " + t, t);
+            }
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/ciReplay/TestClientVM.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,36 @@
+/*
+ * 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 8011675
+ * @library / /test/lib
+ * @summary testing of ciReplay with using generated by VM replay.txt
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "client"
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      compiler.ciReplay.VMBase client
+ */
--- a/test/compiler/ciReplay/TestSA.sh	Wed Oct 26 15:46:13 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 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.
-# 
-# 
-
-##
-## @test
-## @bug 8011675
-## @ignore 8029528
-## @summary testing of ciReplay with using generated by SA replay.txt 
-## @author igor.ignatyev@oracle.com
-## @requires vm.flightRecorder != true
-## @run shell TestSA.sh
-##
-
-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
-
-. ${TESTSRC}/common.sh
-
-generate_replay
-
-${MV} ${replay_data} replay_vm.txt    
-
-if [ -z "${core_file}" -o ! -r "${core_file}" ]
-then
-    # skip test if MacOS host isn't configured for core dumping
-    if [ "$OS" = "Darwin" ]
-    then
-        if [ ! -d "/cores" ]
-        then
-            echo TEST SKIPPED: \'/cores\' dir doens\'t exist
-            exit 0
-        fi
-        if [ ! -w "/cores" ]
-        then
-            echo TEST SKIPPED: \'/cores\' dir exists but is not writable
-            exit 0
-        fi
-    fi
-    test_fail 2 "CHECK :: CORE GENERATION" "core wasn't generated on $OS"
-fi
-
-echo "dumpreplaydata -a > ${replay_data}" | \
-        ${JAVA} ${TESTOPTS} \
-        sun.jvm.hotspot.CLHSDB  ${JAVA} ${core_file}
-
-if [ ! -s ${replay_data} ]
-then
-    test_fail 1 "CHECK :: REPLAY DATA GENERATION" \
-        "replay data wasn't generated by SA"
-fi
-
-diff ${replay_data} replay_vm.txt > replay.diff 2>&1
-if [ -s replay.diff ]
-then
-    echo WARNING: replay.txt from SA != replay.txt from VM:
-    cat replay.diff
-fi
-
-common_tests 10 
-${VM_TYPE}_tests 20
-
-cleanup
-
-echo TEST PASSED
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/ciReplay/TestSAClient.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,36 @@
+/*
+ * 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 8011675
+ * @library / /test/lib
+ * @summary testing of ciReplay with using generated by SA replay.txt
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "client"
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      compiler.ciReplay.SABase client
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/ciReplay/TestSAServer.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,36 @@
+/*
+ * 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 8011675
+ * @library / /test/lib
+ * @summary testing of ciReplay with using generated by SA replay.txt
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "server"
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      compiler.ciReplay.SABase server
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/ciReplay/TestServerVM.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,36 @@
+/*
+ * 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 8011675
+ * @library / /test/lib
+ * @summary testing of ciReplay with using generated by VM replay.txt
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "server"
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      compiler.ciReplay.VMBase server
+ */
--- a/test/compiler/ciReplay/TestVM.sh	Wed Oct 26 15:46:13 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 2013, 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.
-# 
-# 
-
-##
-## @test
-## @bug 8011675
-## @summary testing of ciReplay with using generated by VM replay.txt 
-## @author igor.ignatyev@oracle.com
-## @requires vm.flightRecorder != true
-## @run shell TestVM.sh
-##
-
-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
-
-. ${TESTSRC}/common.sh
-
-generate_replay
-
-if [ ! -s ${replay_data} ]
-then
-    test_fail 1 "CHECK :: REPLAY DATA GENERATION" \
-        "replay data wasn't generated by VM"
-fi
-
-common_tests 10
-${VM_TYPE}_tests 20
-
-cleanup
-
-if [ $is_tiered -eq 1 ]
-then
-    stop_level=1
-    while [ $stop_level -le $server_level ]
-    do
-        generate_replay "-XX:TieredStopAtLevel=$stop_level"
-        if [ ! -s ${replay_data} ]
-        then
-            test_fail `expr $stop_level + 30` \
-                    "TIERED LEVEL $stop_level :: REPLAY DATA GENERATION" \
-                    "replay data wasn't generated by VM with stop_level=$stop_level"
-        fi
-        level=`grep "^compile " $replay_data | awk '{print $6}'`
-        if [ $level -gt $stop_level ]
-        then
-            test_fail `expr $stop_level + 40` \
-                    "TIERED LEVEL $stop_level :: COMP_LEVEL VERIFICATION" \
-                    "comp_level in replay[$level] is greater than stop_level[$stop_level]"
-        fi
-        positive_test `expr $stop_level + 50` "TIERED LEVEL $stop_level :: REPLAY" \
-                "-XX:TieredStopAtLevel=$stop_level"
-        stop_level=`expr $stop_level + 1`
-        cleanup
-    done
-fi
-
-echo TEST PASSED
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/ciReplay/TestVMNoCompLevel.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,76 @@
+/*
+ * 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 8011675
+ * @library / /test/lib
+ * @summary testing of ciReplay with using generated by VM replay.txt w/o comp_level
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      compiler.ciReplay.TestVMNoCompLevel
+ */
+
+package compiler.ciReplay;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+import java.util.List;
+
+public class TestVMNoCompLevel extends CiReplayBase {
+    public static void main(String args[]) {
+        new TestVMNoCompLevel().runTest(false);
+    }
+
+    @Override
+    public void testAction() {
+        try {
+            Path replayFilePath = Paths.get(REPLAY_FILE_NAME);
+            List<String> replayContent = Files.readAllLines(replayFilePath);
+            for (int i = 0; i < replayContent.size(); i++) {
+                String line = replayContent.get(i);
+                if (line.startsWith("compile ")) {
+                    replayContent.set(i, line.substring(0, line.lastIndexOf(" ")));
+                }
+            }
+            Files.write(replayFilePath, replayContent, StandardOpenOption.TRUNCATE_EXISTING);
+        } catch (IOException ioe) {
+            throw new Error("Failed to read/write replay data: " + ioe, ioe);
+        }
+        if (CLIENT_VM_AVAILABLE) {
+            negativeTest(CLIENT_VM_OPTION);
+        }
+        if (SERVER_VM_AVAILABLE) {
+            positiveTest(TIERED_DISABLED_VM_OPTION, SERVER_VM_OPTION);
+            positiveTest(TIERED_ENABLED_VM_OPTION, SERVER_VM_OPTION);
+        }
+    }
+}
+
--- a/test/compiler/ciReplay/TestVM_no_comp_level.sh	Wed Oct 26 15:46:13 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 2013, 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.
-# 
-# 
-
-##
-## @test
-## @bug 8011675
-## @summary testing of ciReplay with using generated by VM replay.txt w/o comp_level
-## @author igor.ignatyev@oracle.com
-## @requires vm.flightRecorder != true
-## @run shell TestVM_no_comp_level.sh
-##
-
-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
-
-. ${TESTSRC}/common.sh
-
-generate_replay
-
-if [ ! -s ${replay_data} ]
-then
-    test_fail 1 "CHECK :: REPLAY DATA GENERATION" \
-            "replay data wasn't generated by VM"
-fi
-
-${CP} ${replay_data} replay_vm.txt
-
-sed 's/^\(compile *[^ ][^ ]* *[^ ][^ ]* [^ ][^ ]* [^ ][^ ]*\).*$/\1/' \
-        replay_vm.txt > ${replay_data}
-
-if [ $client_available -eq 1 ]
-then
-    # tiered is unavailable in client vm, so results w/ flags will be the same as w/o flags
-    negative_test 10 "CLIENT" -client
-fi
-
-if [ $server_available -eq 1 ]
-then
-    positive_test 21 "SERVER :: NON-TIERED" -XX:-TieredCompilation -server
-    positive_test 22 "SERVER :: TIERED" -XX:+TieredCompilation -server
-fi
-
-cleanup
-
-echo TEST PASSED
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/ciReplay/VMBase.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+package compiler.ciReplay;
+
+import compiler.whitebox.CompilerWhiteBoxTest;
+import jdk.test.lib.Asserts;
+import sun.hotspot.WhiteBox;
+
+public class VMBase extends CiReplayBase {
+
+    public static void main(String args[]) {
+        new VMBase(args).runTest(/* needCoreDump = */ false, args);
+    }
+
+    public VMBase(String[] args) {
+        super(args);
+    }
+
+    @Override
+    public void testAction() {
+        commonTests();
+        runVmTests();
+        cleanup();
+        if (runServer.orElseThrow(() -> new Error("runServer must be set"))
+                && WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) {
+            for (int stop = 1; stop < CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION; stop++) {
+                String vmOpt = "-XX:TieredStopAtLevel=" + stop;
+                generateReplay(/* need coredump = */ false, vmOpt);
+                int replayCompLevel = getCompLevelFromReplay();
+                Asserts.assertGTE(stop, replayCompLevel, "Unexpected compLevel in replay");
+                positiveTest(vmOpt);
+            }
+        }
+    }
+}
+
--- a/test/compiler/ciReplay/common.sh	Wed Oct 26 15:46:13 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,291 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 2013, 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.
-# 
-# 
-set -x
-
-# $1 - error code
-# $2 - test name
-# $3,.. - decription
-test_fail() {
-    error=$1
-    shift
-    name=$1
-    shift
-    echo "TEST [$name] FAILED:"
-    echo "$@"
-    exit $error
-}
-
-# $@ - additional vm opts
-start_test() {
-    # disable core dump on *nix
-    ulimit -S -c 0
-    # disable core dump on windows
-    VMOPTS="$@ -XX:-CreateMinidumpOnCrash"
-    cmd="${JAVA} ${VMOPTS} -XX:+ReplayCompiles -XX:ReplayDataFile=${replay_data}"
-    echo $cmd
-    $cmd
-    return $?
-}
-
-# $1 - error_code
-# $2 - test name
-# $3,.. - additional vm opts
-positive_test() {
-    error=$1
-    shift
-    name=$1
-    shift
-    VMOPTS="${TESTOPTS} $@"
-    echo "POSITIVE TEST [$name]"
-    start_test ${VMOPTS}
-    exit_code=$?
-    if [ ${exit_code} -ne 0 ]
-    then
-        test_fail $error "$name" "exit_code[${exit_code}] != 0 during replay "\
-                "w/ vmopts: ${VMOPTS}"
-    fi
-}
-
-# $1 - error_code
-# $2 - test name
-# $2,.. - additional vm opts
-negative_test() {
-    error=$1
-    shift
-    name=$1
-    shift
-    VMOPTS="${TESTOPTS} $@"
-    echo "NEGATIVE TEST [$name]"
-    start_test ${VMOPTS}
-    exit_code=$?
-    if [ ${exit_code} -eq 0 ]
-    then
-        test_fail $error "$name" "exit_code[${exit_code}] == 0 during replay "\
-                "w/ vmopts: ${VMOPTS}"
-    fi
-}
-
-# $1 - initial error_code
-common_tests() {
-    positive_test $1 "COMMON :: THE SAME FLAGS"
-    if [ $tiered_available -eq 1 ]
-    then
-        positive_test `expr $1 + 1` "COMMON :: TIERED" -XX:+TieredCompilation
-    fi
-}
-
-# $1 - initial error_code
-# $2 - non-tiered comp_level 
-nontiered_tests() {
-    level=`grep "^compile " $replay_data | awk '{print $6}'`
-    # is level available in non-tiered
-    if [ "$level" -eq $2 ]
-    then
-        positive_test $1 "NON-TIERED :: AVAILABLE COMP_LEVEL" \
-                -XX:-TieredCompilation
-    else
-        negative_test `expr $1 + 1` "NON-TIERED :: UNAVAILABLE COMP_LEVEL" \
-                -XX:-TieredCompilation
-    fi
-}
-
-# $1 - initial error_code
-client_tests() {
-    # testing in opposite VM
-    if [ $server_available -eq 1 ]
-    then
-        negative_test $1 "SERVER :: NON-TIERED" -XX:-TieredCompilation \
-                -server
-        if [ $tiered_available -eq 1 ]
-        then
-            positive_test `expr $1 + 1` "SERVER :: TIERED" -XX:+TieredCompilation \
-                    -server
-        fi
-    fi
-    nontiered_tests `expr $1 + 2` $client_level 
-}
-
-# $1 - initial error_code
-server_tests() {
-    # testing in opposite VM
-    if [ $client_available -eq 1 ]
-    then
-        # tiered is unavailable in client vm, so results w/ flags will be the same as w/o flags
-        negative_test $1 "CLIENT" -client
-    fi
-    nontiered_tests `expr $1 + 2` $server_level
-}
-
-cleanup() {
-    ${RM} -f core*
-    ${RM} -f replay*.txt
-    ${RM} -f hs_err_pid*.log
-    ${RM} -f test_core
-    ${RM} -f test_replay.txt
-}
-
-JAVA=${TESTJAVA}${FS}bin${FS}java
-
-replay_data=test_replay.txt
-
-${JAVA} ${TESTOPTS} -Xinternalversion 2>&1 | grep debug
-
-# Only test fastdebug 
-if [ $? -ne 0 ]
-then
-    echo TEST SKIPPED: product build
-    exit 0
-fi
-
-is_int=`${JAVA} ${TESTOPTS} -version 2>&1 | grep -c "interpreted mode"`
-# Not applicable for Xint
-if [ $is_int -ne 0 ]
-then
-    echo TEST SKIPPED: interpreted mode
-    exit 0
-fi
-
-cleanup
-
-client_available=`${JAVA} ${TESTOPTS} -client -Xinternalversion 2>&1 | \
-        grep -c Client`
-server_available=`${JAVA} ${TESTOPTS} -server -Xinternalversion 2>&1 | \
-        grep -c Server`
-tiered_available=`${JAVA} ${TESTOPTS} -XX:+TieredCompilation -XX:+PrintFlagsFinal -version | \
-        grep TieredCompilation | \
-        grep -c true`
-is_tiered=`${JAVA} ${TESTOPTS} -XX:+PrintFlagsFinal -version | \
-        grep TieredCompilation | \
-        grep -c true`
-# CompLevel_simple -- C1
-client_level=1
-# CompLevel_full_optimization -- C2 or Shark 
-server_level=4
-
-echo "client_available=$client_available"
-echo "server_available=$server_available"
-echo "tiered_available=$tiered_available"
-echo "is_tiered=$is_tiered"
-
-# crash vm in compiler thread with generation replay data and 'small' dump-file
-# $@ - additional vm opts
-generate_replay() {
-    if [ $VM_OS != "windows" ]
-    then
-        # enable core dump
-        ulimit -c unlimited
-        new_ulimit=`ulimit -c`
-        if [ $new_ulimit != "unlimited" -a $new_ulimit != "-1" ]
-        then
-            test_fail 2 "CHECK :: ULIMIT" "Could not set 'ulimit -c unlimited'. 'ulimit -c' returns : $new_ulimit"
-        fi
-
-        if [ $VM_OS = "solaris" ]
-        then
-            coreadm -p core $$
-        fi
-    fi
-
-    cmd="${JAVA} ${TESTOPTS} $@ \
-            -Xms8m \
-            -Xmx32m \
-            -XX:MetaspaceSize=4m \
-            -XX:MaxMetaspaceSize=16m \
-            -XX:InitialCodeCacheSize=512k \
-            -XX:ReservedCodeCacheSize=4m \
-            -XX:ThreadStackSize=512 \
-            -XX:VMThreadStackSize=512 \
-            -XX:CompilerThreadStackSize=512 \
-            -XX:ParallelGCThreads=1 \
-            -XX:CICompilerCount=2 \
-            -Xcomp \
-            -XX:CICrashAt=1 \
-            -XX:+CreateMinidumpOnCrash \
-            -XX:+DumpReplayDataOnError \
-            -XX:-TransmitErrorReport \
-            -XX:+PreferInterpreterNativeStubs \
-            -XX:+PrintCompilation \
-            -XX:ReplayDataFile=${replay_data} \
-            -version"
-    echo GENERATION OF REPLAY.TXT:
-    echo $cmd
-
-    ${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:" | \
-            sed -e 's/.*location: //'`
-   
-    if [ -z "${core_locations}" ]
-    then
-        test_fail 4 "CHECK :: CORE_LOCATION" "output doesn't contain the location of core file, see crash.out"
-    fi
-
-    rm crash.out 
-    
-    # processing core locations for *nix
-    if [ $VM_OS != "windows" ]
-    then
-        # 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 | \
-                sed -e 's/\([^ ]*\) or \([^ ]*\).*/\1 \2/'`
-        core_with_dir=`echo $core_locations | awk '{print $1}'`
-        core_with_pid=`echo $core_locations | awk '{print $2}'`
-        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
-            core_locations=$core_locations '$core_with_pid' '$dir${FS}$core_with_pid'
-        fi
-    fi
-
-    echo "LOOKING FOR CORE IN ${core_locations}"
-    for core in $core_locations
-    do
-        if [ -r "$core" ]
-        then
-            core_file=$core
-        fi
-    done
-
-    # core-file was found
-    if [ -n "$core_file" ]
-    then
-        ${MV} "${core_file}" test_core
-        core_file=test_core
-    fi
-
-    ${RM} -f hs_err_pid*.log
-}
-
--- a/test/compiler/jvmci/TestJVMCIPrintProperties.java	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/compiler/jvmci/TestJVMCIPrintProperties.java	Wed Oct 26 20:13:29 2016 +0000
@@ -37,14 +37,13 @@
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
             "-XX:+UnlockExperimentalVMOptions",
             "-XX:+EnableJVMCI",
-            "-XX:+JVMCIPrintProperties",
-            "-version");
+            "-XX:+JVMCIPrintProperties");
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         output.shouldContain("[JVMCI properties]"); // expected message
-        output.shouldContain("String jvmci.Compiler"); // expected message
-        output.shouldContain("Boolean jvmci.InitTimer"); // expected message
-        output.shouldContain("Boolean jvmci.PrintConfig"); // expected message
-        output.shouldContain("String jvmci.TraceMethodDataFilter"); // expected message
+        output.shouldContain("jvmci.Compiler = null"); // expected message
+        output.shouldContain("jvmci.InitTimer = false"); // expected message
+        output.shouldContain("jvmci.PrintConfig = false"); // expected message
+        output.shouldContain("jvmci.TraceMethodDataFilter = null"); // expected message
         output.shouldHaveExitValue(0);
     }
 }
--- a/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java	Wed Oct 26 20:13:29 2016 +0000
@@ -78,9 +78,14 @@
                       new CPUSpecificPredicate("aarch64.*", new String[] { "sha256" },null)))))));
 
     public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE
-            = new OrPredicate(
-                    new CPUSpecificPredicate("sparc.*", new String[] { "sha512" },null),
-                    new CPUSpecificPredicate("aarch64.*", new String[] { "sha512" },null));
+            = new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" },null),
+              new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" },null),
+              new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { "sha" },null),
+              new OrPredicate(new CPUSpecificPredicate("x86_64", new String[] { "avx2", "bmi2" }, null),
+              new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "avx2", "bmi2" }, null),
+              new OrPredicate(
+                      new CPUSpecificPredicate("sparc.*", new String[] { "sha512" },null),
+                      new CPUSpecificPredicate("aarch64.*", new String[] { "sha512" },null)))))));
 
     public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE
             = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE,
--- a/test/gc/g1/TestGCLogMessages.java	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/gc/g1/TestGCLogMessages.java	Wed Oct 26 20:13:29 2016 +0000
@@ -23,7 +23,7 @@
 
 /*
  * @test TestGCLogMessages
- * @bug 8035406 8027295 8035398 8019342 8027959 8048179 8027962 8069330 8076463 8150630
+ * @bug 8035406 8027295 8035398 8019342 8027959 8048179 8027962 8069330 8076463 8150630 8160055
  * @summary Ensure the output for a minor GC with G1
  * includes the expected necessary messages.
  * @key gc
@@ -31,6 +31,9 @@
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          java.management
+ * @build sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main TestGCLogMessages
  */
 
 import jdk.test.lib.process.OutputAnalyzer;
@@ -122,6 +125,7 @@
     public static void main(String[] args) throws Exception {
         new TestGCLogMessages().testNormalLogs();
         new TestGCLogMessages().testWithToSpaceExhaustionLogs();
+        new TestGCLogMessages().testWithInitialMark();
     }
 
     private void testNormalLogs() throws Exception {
@@ -183,6 +187,20 @@
         output.shouldHaveExitValue(0);
     }
 
+    private void testWithInitialMark() throws Exception {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
+                                                                  "-Xmx10M",
+                                                                  "-Xbootclasspath/a:.",
+                                                                  "-Xlog:gc*=debug",
+                                                                  "-XX:+UnlockDiagnosticVMOptions",
+                                                                  "-XX:+WhiteBoxAPI",
+                                                                  GCTestWithInitialMark.class.getName());
+
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldContain("Clear Claimed Marks");
+        output.shouldHaveExitValue(0);
+    }
+
     static class GCTest {
         private static byte[] garbage;
         public static void main(String [] args) {
@@ -209,5 +227,13 @@
             System.out.println("Done");
         }
     }
+
+    static class GCTestWithInitialMark {
+        public static void main(String [] args) {
+            sun.hotspot.WhiteBox WB = sun.hotspot.WhiteBox.getWhiteBox();
+            WB.g1StartConcMarkCycle();
+        }
+    }
+
 }
 
--- a/test/gc/g1/TestHumongousShrinkHeap.java	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/gc/g1/TestHumongousShrinkHeap.java	Wed Oct 26 20:13:29 2016 +0000
@@ -51,23 +51,29 @@
     private static final int REGION_SIZE = 1024 * 1024; // 1M
     private static final int LISTS_COUNT = 10;
     private static final int HUMON_SIZE = Math.round(.9f * REGION_SIZE);
-    private static final long AVAILABLE_MEMORY
-                              = Runtime.getRuntime().freeMemory();
-    private static final int HUMON_COUNT
-                             = (int) ((AVAILABLE_MEMORY / HUMON_SIZE)
-            / LISTS_COUNT);
 
+    private static final long TOTAL_MEMORY = Runtime.getRuntime().totalMemory();
+    private static final long MAX_MEMORY = Runtime.getRuntime().maxMemory();
+
+    private static final int HUMON_COUNT = (int) ((TOTAL_MEMORY / HUMON_SIZE) / LISTS_COUNT);
 
     public static void main(String[] args) {
         if (HUMON_COUNT == 0) {
             System.out.println("Skipped. Heap is too small");
             return;
         }
-        System.out.format("Running with %s max heap size. "
-                + "Will allocate humongous object of %s size %d times.%n",
-                MemoryUsagePrinter.humanReadableByteCount(AVAILABLE_MEMORY, false),
-                MemoryUsagePrinter.humanReadableByteCount(HUMON_SIZE, false),
-                HUMON_COUNT
+
+        if (TOTAL_MEMORY + REGION_SIZE * HUMON_COUNT > MAX_MEMORY) {
+            System.out.println("Skipped. Initial heap size is to close to max heap size.");
+            return;
+        }
+
+        System.out.format("Running with %s initial heap size of %s maximum heap size. "
+                          + "Will allocate humongous object of %s size %d times.%n",
+                          MemoryUsagePrinter.humanReadableByteCount(TOTAL_MEMORY, false),
+                          MemoryUsagePrinter.humanReadableByteCount(MAX_MEMORY, false),
+                          MemoryUsagePrinter.humanReadableByteCount(HUMON_SIZE, false),
+                          HUMON_COUNT
         );
         new TestHumongousShrinkHeap().test();
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/ByteCursor.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ *
+ */
+
+class ByteCursor {
+    private int offset;
+    private byte[] data;
+
+    public ByteCursor(byte[] data) {
+        this.offset = 0;
+        this.data = data;
+    }
+
+    public int getOffset() {
+        return offset;
+    }
+
+    public void skipBytes(int n) {
+        offset += n;
+    }
+
+    public int readUnsignedByte() {
+        int val = readUnsignedByteAt(offset);
+        offset += 1;
+        return val;
+    }
+
+    public int readUnsignedByteAt(int offset) {
+        return data[offset++] & 0xff;
+    }
+
+    public int readUnsignedShort() {
+        int val = readUnsignedShortAt(offset);
+        offset += 2;
+        return val;
+    }
+
+    public int readInt() {
+        int val = readIntAt(offset);
+        offset += 4;
+        return val;
+    }
+
+    public int readUnsignedShortAt(int offset) {
+        int b1 = data[offset++] & 0xff;
+        int b2 = data[offset] & 0xff;
+
+        return (b1 << 8) + b2;
+    }
+
+    public int readIntAt(int offset) {
+        int s1 = readUnsignedShortAt(offset);
+        int s2 = readUnsignedShortAt(offset + 2);
+        return (s1 << 16) + s2;
+    }
+
+    public String readUtf8(int length) throws IllegalStateException {
+        char str[] = new char[length];
+        int count = 0;
+        int pos = 0;
+        while (count < length) {
+            int c = readUnsignedByte();
+            switch (c >> 4) {
+                case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
+                    // 0xxxxxxx
+                    count++;
+                    if(c == '/') {
+                        str[pos++] = '.';
+                    } else {
+                        str[pos++] = (char) c;
+                    }
+                    break;
+                } case 12: case 13: {
+                    // 110x xxxx   10xx xxxx
+                    count += 2;
+                    int c2 = readUnsignedByte();
+                    if ((c2 & 0xC0) != 0x80) {
+                        throw new IllegalStateException();
+                    }
+                    str[pos++] = (char) (((c & 0x1F) << 6) | (c2 & 0x3F));
+                    break;
+                } case 14: {
+                    // 1110 xxxx  10xx xxxx  10xx xxxx
+                    count += 3;
+                    int c2 = readUnsignedByte();
+                    int c3 = readUnsignedByte();
+                    if ((c2 & 0xC0) != 0x80 || (c3 & 0xC0) != 0x80) {
+                        throw new IllegalStateException();
+                    }
+                    str[pos++] = (char)(((c  & 0x0F) << 12) |
+                                        ((c2 & 0x3F) << 6)  |
+                                        ((c3 & 0x3F) << 0));
+                    break;
+                } default:
+                    // 10xx xxxx,  1111 xxxx
+                    throw new IllegalStateException();
+            }
+        }
+        return new String(str);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/Bytecode.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,256 @@
+/*
+ * 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.
+ *
+ */
+
+class Bytecode {
+    public static final int IINC               = 132;
+    public static final int TABLESWITCH        = 170;
+    public static final int LOOKUPSWITCH       = 171;
+    public static final int GETSTATIC          = 178;
+    public static final int PUTSTATIC          = 179;
+    public static final int GETFIELD           = 180;
+    public static final int PUTFIELD           = 181;
+    public static final int INVOKEVIRTUAL      = 182;
+    public static final int INVOKESPECIAL      = 183;
+    public static final int INVOKESTATIC       = 184;
+    public static final int INVOKEINTERFACE    = 185;
+    public static final int NEW                = 187;
+    public static final int ANEWARRAY          = 189;
+    public static final int CHECKCAST          = 192;
+    public static final int INSTANCEOF         = 193;
+    public static final int MULTIANEWARRAY     = 197;
+    public static final int WIDE               = 196;
+
+    private static final int lengths[] = {
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        2,
+        3,
+        2,
+        3,
+        3,
+        2,
+        2,
+        2,
+        2,
+        2,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        2,
+        2,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        3,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        2,
+        99,
+        99,
+        1,
+        1,
+        1,
+        1,
+        1,
+        1,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        3,
+        5,
+        5,
+        3,
+        2,
+        3,
+        1,
+        1,
+        3,
+        3,
+        1,
+        1,
+        0,
+        4,
+        3,
+        3,
+        5,
+        5,
+        1
+    };
+
+    public static int getLength(int bc) throws IllegalArgumentException {
+        if ((bc < 0) || (bc >= lengths.length)) {
+            throw new IllegalArgumentException("Unknown bytecode " + bc);
+        }
+        return lengths[bc];
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/ClassInfo.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ *
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+
+class ClassInfo {
+    private String name;
+
+    private Set<Dependency> staticResolution;
+    private Set<Dependency> staticInitialization;
+    private Set<Dependency> constructorResolution;
+    private Set<Dependency> constructorInitialization;
+    private Set<Dependency> methodResolution;
+    private Set<Dependency> methodInitialization;
+
+    public ClassInfo(String name) {
+        this.name = name;
+
+        staticResolution = new HashSet<>();
+        staticInitialization = new HashSet<>();
+        constructorResolution = new HashSet<>();
+        constructorInitialization = new HashSet<>();
+        methodResolution = new HashSet<>();
+        methodInitialization = new HashSet<>();
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void addResolutionDep(Dependency d) {
+        if(d.getMethodName().equals("<clinit>")) {
+            staticResolution.add(d);
+        } else if(d.getMethodName().equals("<init>")) {
+            constructorResolution.add(d);
+        } else {
+            methodResolution.add(d);
+        }
+    }
+
+    public void addInitializationDep(Dependency d) {
+        if(d.getMethodName().equals("<clinit>")) {
+            staticInitialization.add(d);
+        } else if(d.getMethodName().equals("<init>")) {
+            constructorInitialization.add(d);
+        } else {
+            methodInitialization.add(d);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/ConstantPoolEntry.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ *
+ */
+
+class ConstantPoolEntry {
+    private int index;
+    private String value;
+
+    public ConstantPoolEntry(int index) {
+        this.index = index;
+        value = null;
+    }
+
+    public ConstantPoolEntry(String value) {
+        this.index = -1;
+        this.value = value;
+    }
+
+    public String getValue() throws IllegalStateException {
+        if (index != -1) {
+            throw new IllegalStateException();
+        }
+        return value;
+    }
+
+    public int getNameIndex() throws IllegalStateException {
+        if (value != null) {
+            throw new IllegalStateException();
+        }
+        return index;
+    }
+
+    public int getClassIndex() throws IllegalStateException {
+        if (value != null) {
+            throw new IllegalStateException();
+        }
+        return index;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/Decompiler.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,334 @@
+/*
+ * 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.
+ *
+ */
+
+class Decompiler {
+    private ByteCursor cursor;
+    private ClassInfo ci;
+
+    public Decompiler(byte[] classData) {
+        cursor = new ByteCursor(classData);
+
+        int magicNumber = cursor.readInt();
+        if (magicNumber != 0xCAFEBABE) {
+            throw new IllegalArgumentException("Bad magic number " + magicNumber);
+        }
+
+        cursor.readUnsignedShort(); // Minor version
+        cursor.readUnsignedShort(); // Major version
+
+        ConstantPoolEntry[] constantPool = decodeConstantPool();
+
+        cursor.readUnsignedShort(); // Access flags
+
+        // this class index in constant pool;
+        int classInfo = cursor.readUnsignedShort();
+        int classInfoNameIndex = constantPool[classInfo].getNameIndex();
+        ci = new ClassInfo(constantPool[classInfoNameIndex].getValue());
+
+        cursor.readUnsignedShort(); // superclass
+
+        int numInterfaces = cursor.readUnsignedShort();
+        for (int i = 0; i < numInterfaces; i++) {
+            cursor.readUnsignedShort(); // interface
+        }
+
+        decodeFields();
+        MethodInfo[] methods = decodeMethods(constantPool);
+        decodeMethodDependencies(methods, constantPool);
+    }
+
+    public ClassInfo getClassInfo() {
+        return ci;
+    }
+
+    private boolean isDependency(String name, String className) {
+        return !name.equals(className) && !name.startsWith("[");
+    }
+
+    private void addDependency(MethodInfo m, String name) {
+        Dependency d = new Dependency(m.getName(), m.getDescriptor(), name);
+        ci.addResolutionDep(d);
+    }
+
+    private String resolveName(ConstantPoolEntry[] constantPool, int cpi) {
+        int nameIndex = constantPool[cpi].getNameIndex();
+        return constantPool[nameIndex].getValue();
+    }
+
+    private void decodeMethodDependencies(MethodInfo[] methods, ConstantPoolEntry[] constantPool) {
+        for (int i = 0; i < methods.length; i++) {
+            MethodInfo m = methods[i];
+            final int stopCheck = m.getCodeStart() + m.getCodeLength();
+
+            int byteCodeIndex = m.getCodeStart();
+            while (byteCodeIndex < stopCheck) {
+                int bc = cursor.readUnsignedByteAt(byteCodeIndex);
+
+                switch (bc) {
+                    // These opcodes cause name resolution or initialization
+                    // Their index bytes all point to a CONSTANT_Class (4.4.1)
+                    case Bytecode.ANEWARRAY:
+                    case Bytecode.CHECKCAST:
+                    case Bytecode.INSTANCEOF:
+                    case Bytecode.MULTIANEWARRAY:
+                    case Bytecode.NEW: {
+                        int cpi = cursor.readUnsignedShortAt(byteCodeIndex + 1);
+                        String name = resolveName(constantPool, cpi);
+
+                        if (isDependency(name, ci.getName())) {
+                            addDependency(m, name);
+                        }
+                        break;
+                    }
+
+                    // These opcodes cause name resolution or initialization
+                    // Their index bytes all point to a CONSTANT_Field/Methodref (4.4.2)
+                    case Bytecode.GETFIELD:
+                    case Bytecode.INVOKEINTERFACE:
+                    case Bytecode.INVOKESPECIAL:
+                    case Bytecode.INVOKEVIRTUAL:
+                    case Bytecode.PUTFIELD:
+                    case Bytecode.PUTSTATIC:
+                    case Bytecode.GETSTATIC:
+                    case Bytecode.INVOKESTATIC: {
+                        int cpi = cursor.readUnsignedShortAt(byteCodeIndex + 1);
+                        int classIndex = constantPool[cpi].getClassIndex();
+                        String name = resolveName(constantPool, classIndex);
+
+                        if (isDependency(name, ci.getName())) {
+                            addDependency(m, name);
+                        }
+                        break;
+                    }
+
+                    case Bytecode.LOOKUPSWITCH: {
+                        byteCodeIndex++;
+                        int offset = byteCodeIndex - m.getCodeStart();
+                        while (offset % 4 != 0) {
+                            offset++;
+                            byteCodeIndex++;
+                        }
+
+                        int def = cursor.readIntAt(byteCodeIndex);
+                        byteCodeIndex +=4;
+
+                        int npairs = cursor.readIntAt(byteCodeIndex);
+                        byteCodeIndex +=4;
+                        byteCodeIndex += (8 * npairs);
+                        continue;
+                    }
+
+                    case Bytecode.TABLESWITCH: {
+                        byteCodeIndex++;
+                        int offset = byteCodeIndex - m.getCodeStart();
+                        while (offset % 4 != 0) {
+                            offset++;
+                            byteCodeIndex++;
+                        }
+
+                        int def = cursor.readIntAt(byteCodeIndex);
+                        byteCodeIndex +=4;
+
+                        int low = cursor.readIntAt(byteCodeIndex);
+                        byteCodeIndex +=4;
+                        int high = cursor.readIntAt(byteCodeIndex);
+                        byteCodeIndex +=4;
+                        byteCodeIndex += (4 * (high - low + 1));
+                        continue;
+                    }
+
+                    case Bytecode.WIDE: {
+                        bc = cursor.readUnsignedByteAt(++byteCodeIndex);
+                        if (bc == Bytecode.IINC) {
+                            byteCodeIndex += 5;
+                        } else {
+                            byteCodeIndex += 3;
+                        }
+                        continue;
+                    }
+                }
+
+                byteCodeIndex += Bytecode.getLength(bc);
+            }
+
+            if (byteCodeIndex - stopCheck > 1) {
+                String err = "bad finish for method " + m.getName() +
+                             "End + "  + (byteCodeIndex - stopCheck);
+                throw new IllegalArgumentException(err);
+            }
+        }
+    }
+
+    private MethodInfo[] decodeMethods(ConstantPoolEntry[] constantPool) {
+        MethodInfo[] methods = new MethodInfo[cursor.readUnsignedShort()];
+
+        for (int i = 0; i < methods.length; i++) {
+            cursor.readUnsignedShort(); // access flags
+
+            String name = constantPool[cursor.readUnsignedShort()].getValue();
+            String descriptor = constantPool[cursor.readUnsignedShort()].getValue();
+
+            int codeLength = 0;
+            int codeStart = 0;
+
+            int numAttributes = cursor.readUnsignedShort(); // attributes count
+            for (int j = 0; j < numAttributes; j++) {
+                int type = cursor.readUnsignedShort(); // attrib nameIndex
+                int aLen = cursor.readInt(); // attrib length
+
+                if (constantPool[type].getValue().equals("Code")) {
+                    cursor.readUnsignedShort(); // Max stack
+                    cursor.readUnsignedShort(); // Max locals
+
+                    codeLength = cursor.readInt();
+                    codeStart = cursor.getOffset();
+
+                    cursor.skipBytes(codeLength); // Need to skip the code bytes
+                    cursor.skipBytes(cursor.readUnsignedShort() * 8); // Skip exception table
+
+                    int numSubAttributes = cursor.readUnsignedShort();
+                    for (int k = 0; k < numSubAttributes; k++) {
+                        cursor.readUnsignedShort(); // sub name
+                        cursor.skipBytes(cursor.readInt()); // sub attrib data
+                    }
+                } else {
+                    cursor.skipBytes(aLen); // unknown attrib data
+                }
+            }
+
+            methods[i] = new MethodInfo(name, descriptor, codeLength, codeStart);
+        }
+
+        return methods;
+    }
+
+    private void decodeFields() {
+        // Looks like we dont need any field info, throw it away!
+        int numFields = cursor.readUnsignedShort();
+
+        for (int i = 0; i < numFields; i++) {
+            cursor.readUnsignedShort(); // access flags
+            cursor.readUnsignedShort(); // nameIndex
+            cursor.readUnsignedShort(); // descriptorIndex
+
+            int numAttributes = cursor.readUnsignedShort();
+            for (int j = 0; j < numAttributes; j++) {
+                cursor.readUnsignedShort(); // nameIndex
+                int length = cursor.readInt();
+                cursor.skipBytes(length); // data
+            }
+        }
+    }
+
+    private ConstantPoolEntry[] decodeConstantPool() {
+        final int CONSTANT_Utf8 = 1;
+        final int CONSTANT_Unicode = 2;
+        final int CONSTANT_Integer = 3;
+        final int CONSTANT_Float = 4;
+        final int CONSTANT_Long = 5;
+        final int CONSTANT_Double = 6;
+        final int CONSTANT_Class = 7;
+        final int CONSTANT_String = 8;
+        final int CONSTANT_Fieldref = 9;
+        final int CONSTANT_Methodref = 10;
+        final int CONSTANT_InterfaceMethodref = 11;
+        final int CONSTANT_NameAndType = 12;
+        final int CONSTANT_MethodHandle = 15;
+        final int CONSTANT_MethodType = 16;
+        final int CONSTANT_InvokeDynamic = 18;
+
+        ConstantPoolEntry[] constantPool = new ConstantPoolEntry[cursor.readUnsignedShort()];
+
+        // The constant pool starts at index 1
+        for (int i = 1; i < constantPool.length; i++) {
+            int type = cursor.readUnsignedByte();
+
+            switch (type) {
+                case CONSTANT_Class:
+                    constantPool[i] = new ConstantPoolEntry(cursor.readUnsignedShort()); // name_index
+                    break;
+
+                case CONSTANT_Fieldref: case CONSTANT_Methodref: case CONSTANT_InterfaceMethodref:
+                    constantPool[i] = new ConstantPoolEntry(cursor.readUnsignedShort()); // class_index
+                    cursor.readUnsignedShort(); // name_and_type_index
+                    break;
+
+                case CONSTANT_String:
+                    cursor.readUnsignedShort(); // string_index
+                    break;
+
+                case CONSTANT_Integer:
+                    cursor.readInt(); // bytes
+                    break;
+
+                case CONSTANT_Float:
+                    cursor.readInt(); // bytes
+                    break;
+
+                case CONSTANT_Long:
+                    cursor.readInt(); // high_bytes
+                    cursor.readInt(); // low_bytes
+                    i++; // 8 byte constants use 2 constant pool slots.
+                    break;
+
+                case CONSTANT_Double:
+                    cursor.readInt(); // high_bytes
+                    cursor.readInt(); // low_bytes
+                    i++; // 8 byte constants use 2 constant pool slots.
+                    break;
+
+                case CONSTANT_NameAndType:
+                    constantPool[i] = new ConstantPoolEntry(cursor.readUnsignedShort()); // name_index
+                    cursor.readUnsignedShort(); // descriptor_index
+                    break;
+
+                case CONSTANT_Utf8:
+                    int length = cursor.readUnsignedShort(); // length
+                    constantPool[i] = new ConstantPoolEntry(cursor.readUtf8(length)); // bytes[length]
+                    break;
+
+                case CONSTANT_MethodHandle:
+                    cursor.readUnsignedByte(); // reference_kind
+                    cursor.readUnsignedShort(); // reference_index
+                    break;
+
+                case CONSTANT_MethodType:
+                    cursor.readUnsignedShort(); // descriptor_index
+                    break;
+
+                case CONSTANT_InvokeDynamic:
+                    cursor.readUnsignedShort(); // bootstrap_method_attr_index
+                    cursor.readUnsignedShort(); // name_and_type_index
+                    break;
+
+                default:
+                    String err = "Unknown constant pool type " + String.valueOf(type) + "\n" +
+                                 "CPE " + i + " of " + constantPool.length + "\n" +
+                                 "Byte offset " + Integer.toHexString(cursor.getOffset());
+                    throw new IllegalArgumentException(err);
+            }
+        }
+        return constantPool;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/Dependency.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ *
+ */
+
+class Dependency {
+    private String methodName;
+    private String methodDescriptor;
+    private String target;
+
+    public Dependency(String methodName, String methodDescriptor, String target) {
+        this.methodName = methodName;
+        this.methodDescriptor = methodDescriptor;
+        this.target = target;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof Dependency)) {
+            return false;
+        }
+
+        Dependency other = (Dependency)o;
+        return target.equals(other.target) &&
+               methodName.equals(other.methodName) &&
+               methodDescriptor.equals(other.methodDescriptor);
+    }
+
+    @Override
+    public int hashCode() {
+        return methodName.hashCode() ^ methodDescriptor.hashCode() ^ target.hashCode();
+    }
+
+    public String getMethodName() {
+        return methodName;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/MethodInfo.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ *
+ */
+
+class MethodInfo {
+    private String name;
+    private String descriptor;
+    private int codeLength;
+    private int codeStart;
+
+    public MethodInfo(String name, String descriptor, int codeLength, int codeStart) {
+        this.name = name;
+        this.descriptor = descriptor;
+        this.codeLength = codeLength;
+        this.codeStart = codeStart;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getDescriptor() {
+        return descriptor;
+    }
+
+    public int getCodeLength() {
+        return codeLength;
+    }
+
+    public int getCodeStart() {
+        return codeStart;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/TestGCBasher.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ *
+ */
+
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.FileSystems;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.stream.Stream;
+
+public class TestGCBasher {
+    private static void parseClassFiles() throws IOException {
+        HashMap<String, ClassInfo> deps = new HashMap<>();
+
+        FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
+        Stream<Path> s = Files.walk(fs.getPath("/"));
+        for (Path p : (Iterable<Path>)s::iterator) {
+            if (p.toString().endsWith(".class")) {
+                byte[] data = Files.readAllBytes(p);
+                Decompiler d = new Decompiler(data);
+                ClassInfo ci = d.getClassInfo();
+                deps.put(ci.getName(), ci);
+            }
+        }
+    }
+
+    public static void run(String[] args) throws IOException {
+        if (args.length != 1) {
+            System.err.println("Usage: TestGCBasher <duration-ms>");
+            return;
+        }
+
+        long durationMillis = Long.valueOf(args[0]);
+        long start = System.currentTimeMillis();
+        while (System.currentTimeMillis() - start < durationMillis) {
+            parseClassFiles();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/TestGCBasherWithCMS.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ */
+
+import java.io.IOException;
+
+/*
+ * @test TestGCBasherWithCMS
+ * @key gc
+ * @key stress
+ * @requires vm.gc.ConcMarkSweep
+ * @requires vm.flavor == "server"
+ * @summary Stress the CMS GC by trying to make old objects more likely to be garbage than young objects.
+ * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx128m -server -XX:+UseConcMarkSweepGC TestGCBasherWithCMS 120000
+ */
+public class TestGCBasherWithCMS {
+    public static void main(String[] args) throws IOException {
+        TestGCBasher.run(args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/TestGCBasherWithG1.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ */
+
+import java.io.IOException;
+
+/*
+ * @test TestGCBasherWithG1
+ * @key gc
+ * @key stress
+ * @requires vm.gc.G1
+ * @requires vm.flavor == "server"
+ * @summary Stress the G1 GC by trying to make old objects more likely to be garbage than young objects.
+ * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx128m -server -XX:+UseG1GC TestGCBasherWithG1 120000
+ */
+public class TestGCBasherWithG1 {
+    public static void main(String[] args) throws IOException {
+        TestGCBasher.run(args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/TestGCBasherWithParallel.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ */
+
+import java.io.IOException;
+
+/*
+ * @test TestGCBasherWithParallel
+ * @key gc
+ * @key stress
+ * @requires vm.gc.Parallel
+ * @requires vm.flavor == "server"
+ * @summary Stress the Parallel GC by trying to make old objects more likely to be garbage than young objects.
+ * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx256m -server -XX:+UseParallelGC -XX:-UseGCOverheadLimit TestGCBasherWithParallel 120000
+ */
+public class TestGCBasherWithParallel {
+    public static void main(String[] args) throws IOException {
+        TestGCBasher.run(args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/gc/stress/gcbasher/TestGCBasherWithSerial.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ */
+
+import java.io.IOException;
+
+/*
+ * @test TestGCBasherWithSerial
+ * @key gc
+ * @key stress
+ * @requires vm.gc.Serial
+ * @requires vm.flavor == "server"
+ * @summary Stress the Serial GC by trying to make old objects more likely to be garbage than young objects.
+ * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx128m -server -XX:+UseSerialGC TestGCBasherWithSerial 120000
+ */
+public class TestGCBasherWithSerial {
+    public static void main(String[] args) throws IOException {
+        TestGCBasher.run(args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/native/code/test_dependencyContext.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,97 @@
+/*
+ * 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 "precompiled.hpp"
+#include "code/dependencyContext.hpp"
+#include "unittest.hpp"
+
+class TestDependencyContext {
+ public:
+  nmethod* _nmethods[3];
+
+  intptr_t _dependency_context;
+
+  DependencyContext dependencies() {
+    DependencyContext depContext(&_dependency_context);
+    return depContext;
+  }
+
+  TestDependencyContext() : _dependency_context(DependencyContext::EMPTY) {
+    CodeCache_lock->lock_without_safepoint_check();
+
+    _nmethods[0] = reinterpret_cast<nmethod*>(0x8 * 0);
+    _nmethods[1] = reinterpret_cast<nmethod*>(0x8 * 1);
+    _nmethods[2] = reinterpret_cast<nmethod*>(0x8 * 2);
+
+    dependencies().add_dependent_nmethod(_nmethods[2]);
+    dependencies().add_dependent_nmethod(_nmethods[1]);
+    dependencies().add_dependent_nmethod(_nmethods[0]);
+  }
+
+  ~TestDependencyContext() {
+    dependencies().wipe();
+    CodeCache_lock->unlock();
+  }
+
+  static bool has_stale_entries(DependencyContext ctx) {
+    return ctx.has_stale_entries();
+  }
+
+#ifndef PRODUCT
+  static bool find_stale_entries(DependencyContext ctx) {
+    return ctx.find_stale_entries();
+  }
+#endif
+};
+
+static void test_remove_dependent_nmethod(int id, bool delete_immediately) {
+  TestDependencyContext c;
+  DependencyContext depContext = c.dependencies();
+  NOT_PRODUCT(ASSERT_FALSE(TestDependencyContext::find_stale_entries(depContext)));
+  ASSERT_FALSE(TestDependencyContext::has_stale_entries(depContext));
+
+  nmethod* nm = c._nmethods[id];
+  depContext.remove_dependent_nmethod(nm, delete_immediately);
+
+  if (!delete_immediately) {
+    NOT_PRODUCT(ASSERT_TRUE(TestDependencyContext::find_stale_entries(depContext)));
+    ASSERT_TRUE(TestDependencyContext::has_stale_entries(depContext));
+    NOT_PRODUCT(ASSERT_TRUE(depContext.is_dependent_nmethod(nm)));
+    depContext.expunge_stale_entries();
+  }
+
+  NOT_PRODUCT(ASSERT_FALSE(TestDependencyContext::find_stale_entries(depContext)));
+  ASSERT_FALSE(TestDependencyContext::has_stale_entries(depContext));
+  NOT_PRODUCT(ASSERT_FALSE(depContext.is_dependent_nmethod(nm)));
+}
+
+TEST(code, dependency_context) {
+  test_remove_dependent_nmethod(0, false);
+  test_remove_dependent_nmethod(1, false);
+  test_remove_dependent_nmethod(2, false);
+
+  test_remove_dependent_nmethod(0, true);
+  test_remove_dependent_nmethod(1, true);
+  test_remove_dependent_nmethod(2, true);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/native/gc/g1/test_freeRegionList.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2011, 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 "precompiled.hpp"
+#include "gc/g1/g1CollectedHeap.inline.hpp"
+#include "unittest.hpp"
+
+// @requires UseG1GC
+TEST_VM(FreeRegionList, length) {
+  if (!UseG1GC) {
+    return;
+  }
+
+  FreeRegionList l("test");
+  const uint num_regions_in_test = 5;
+
+  // Create a fake heap. It does not need to be valid, as the HeapRegion constructor
+  // does not access it.
+  MemRegion heap(NULL, num_regions_in_test * HeapRegion::GrainWords);
+
+  // Allocate a fake BOT because the HeapRegion constructor initializes
+  // the BOT.
+  size_t bot_size = G1BlockOffsetTable::compute_size(heap.word_size());
+  HeapWord* bot_data = NEW_C_HEAP_ARRAY(HeapWord, bot_size, mtGC);
+  ReservedSpace bot_rs(G1BlockOffsetTable::compute_size(heap.word_size()));
+  G1RegionToSpaceMapper* bot_storage =
+    G1RegionToSpaceMapper::create_mapper(bot_rs,
+                                         bot_rs.size(),
+                                         os::vm_page_size(),
+                                         HeapRegion::GrainBytes,
+                                         BOTConstants::N_bytes,
+                                         mtGC);
+  G1BlockOffsetTable bot(heap, bot_storage);
+  bot_storage->commit_regions(0, num_regions_in_test);
+
+  // Set up memory regions for the heap regions.
+  MemRegion mr0(heap.start(), HeapRegion::GrainWords);
+  MemRegion mr1(mr0.end(), HeapRegion::GrainWords);
+  MemRegion mr2(mr1.end(), HeapRegion::GrainWords);
+  MemRegion mr3(mr2.end(), HeapRegion::GrainWords);
+  MemRegion mr4(mr3.end(), HeapRegion::GrainWords);
+
+  HeapRegion hr0(0, &bot, mr0);
+  HeapRegion hr1(1, &bot, mr1);
+  HeapRegion hr2(2, &bot, mr2);
+  HeapRegion hr3(3, &bot, mr3);
+  HeapRegion hr4(4, &bot, mr4);
+  l.add_ordered(&hr1);
+  l.add_ordered(&hr0);
+  l.add_ordered(&hr3);
+  l.add_ordered(&hr4);
+  l.add_ordered(&hr2);
+
+  EXPECT_EQ(l.length(), num_regions_in_test) << "Wrong free region list length";
+  l.verify_list();
+
+  bot_storage->uncommit_regions(0, num_regions_in_test);
+  delete bot_storage;
+  FREE_C_HEAP_ARRAY(HeapWord, bot_data);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/native/gc/g1/test_g1BiasedArray.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013, 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 "precompiled.hpp"
+#include "gc/g1/g1BiasedArray.hpp"
+#include "unittest.hpp"
+
+class TestMappedArray : public G1BiasedMappedArray<int> {
+public:
+  virtual int default_value() const {
+    return 0xBAADBABE;
+  }
+  int* my_address_mapped_to(HeapWord* address) {
+    return address_mapped_to(address);
+  }
+};
+
+TEST_VM(G1BiasedArray, simple) {
+  const size_t REGION_SIZE_IN_WORDS = 512;
+  const size_t NUM_REGIONS = 20;
+  // Any value that is non-zero
+  HeapWord* fake_heap =
+          (HeapWord*) LP64_ONLY(0xBAAA00000) NOT_LP64(0xBA000000);
+
+  TestMappedArray array;
+  array.initialize(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
+          REGION_SIZE_IN_WORDS * HeapWordSize);
+  const int DEFAULT_VALUE = array.default_value();
+
+  // Check address calculation (bounds)
+  ASSERT_EQ(fake_heap, array.bottom_address_mapped())
+          << "bottom mapped address should be "
+          << p2i(array.bottom_address_mapped())
+          << ", but is "
+          << p2i(fake_heap);
+  ASSERT_EQ(fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
+          array.end_address_mapped());
+
+  int* bottom = array.my_address_mapped_to(fake_heap);
+  ASSERT_EQ((void*) bottom, (void*) array.base());
+  int* end = array.my_address_mapped_to(fake_heap +
+          REGION_SIZE_IN_WORDS * NUM_REGIONS);
+  ASSERT_EQ((void*) end, (void*) (array.base() + array.length()));
+  // The entire array should contain default value elements
+  for (int* current = bottom; current < end; current++) {
+    ASSERT_EQ(DEFAULT_VALUE, *current);
+  }
+
+  // Test setting values in the table
+  HeapWord* region_start_address =
+          fake_heap + REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2);
+  HeapWord* region_end_address =
+          fake_heap + (REGION_SIZE_IN_WORDS * (NUM_REGIONS / 2) +
+          REGION_SIZE_IN_WORDS - 1);
+
+  // Set/get by address tests: invert some value; first retrieve one
+  int actual_value = array.get_by_index(NUM_REGIONS / 2);
+  array.set_by_index(NUM_REGIONS / 2, ~actual_value);
+  // Get the same value by address, should correspond to the start of the "region"
+  int value = array.get_by_address(region_start_address);
+  ASSERT_EQ(value, ~actual_value);
+  // Get the same value by address, at one HeapWord before the start
+  value = array.get_by_address(region_start_address - 1);
+  ASSERT_EQ(DEFAULT_VALUE, value);
+  // Get the same value by address, at the end of the "region"
+  value = array.get_by_address(region_end_address);
+  ASSERT_EQ(value, ~actual_value);
+  // Make sure the next value maps to another index
+  value = array.get_by_address(region_end_address + 1);
+  ASSERT_EQ(DEFAULT_VALUE, value);
+
+  // Reset the value in the array
+  array.set_by_address(region_start_address +
+          (region_end_address - region_start_address) / 2,
+          actual_value);
+
+  // The entire array should have the default value again
+  for (int* current = bottom; current < end; current++) {
+    ASSERT_EQ(DEFAULT_VALUE, *current);
+  }
+
+  // Set/get by index tests: invert some value
+  size_t index = NUM_REGIONS / 2;
+  actual_value = array.get_by_index(index);
+  array.set_by_index(index, ~actual_value);
+
+  value = array.get_by_index(index);
+  ASSERT_EQ(~actual_value, value);
+
+  value = array.get_by_index(index - 1);
+  ASSERT_EQ(DEFAULT_VALUE, value);
+
+  value = array.get_by_index(index + 1);
+  ASSERT_EQ(DEFAULT_VALUE, value);
+
+  array.set_by_index(0, 0);
+  value = array.get_by_index(0);
+  ASSERT_EQ(0, value);
+
+  array.set_by_index(array.length() - 1, 0);
+  value = array.get_by_index(array.length() - 1);
+  ASSERT_EQ(0, value);
+
+  array.set_by_index(index, 0);
+
+  // The array should have three zeros, and default values otherwise
+  size_t num_zeros = 0;
+  for (int* current = bottom; current < end; current++) {
+    ASSERT_TRUE(*current == DEFAULT_VALUE || *current == 0);
+    if (*current == 0) {
+      num_zeros++;
+    }
+  }
+  ASSERT_EQ((size_t) 3, num_zeros);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/native/gc/g1/test_workerDataArray.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,282 @@
+/*
+ * 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 "precompiled.hpp"
+#include "gc/g1/workerDataArray.inline.hpp"
+#include "memory/resourceArea.hpp"
+#include "unittest.hpp"
+#include "utilities/ostream.hpp"
+
+static const double epsilon = 0.0001;
+
+template<typename T>
+class WorkerDataArrayTest : public ::testing::Test {
+ protected:
+  WorkerDataArrayTest() :
+    title("Test array"),
+    array(3, title) {
+  }
+
+  const char* print_summary() {
+    stringStream out;
+    array.print_summary_on(&out);
+    return out.as_string();
+  }
+
+  const char* print_details() {
+    stringStream out;
+    array.print_details_on(&out);
+    return out.as_string();
+  }
+
+  const char* print_expected_summary() {
+    return prepend_with(title, expected_summary());
+  }
+
+  const char* print_expected_details() {
+    return prepend_with("", expected_details());
+  }
+
+  // returns expected summary for array without uninitialized elements
+  // used it because string representation of double depends on locale
+  static const char* format_summary(
+    T min, double avg, T max, T diff, T sum, size_t workers);
+
+  const char* title;
+  WorkerDataArray<T> array;
+
+ private:
+  virtual const char* expected_summary() = 0;
+  virtual const char* expected_details() = 0;
+
+  static const char* prepend_with(const char* str, const char* orig) {
+    stringStream out;
+    out.print("%-25s", str);
+    out.print("%s", orig);
+    return out.as_string();
+  }
+
+  ResourceMark rm;
+};
+
+template<>
+const char* WorkerDataArrayTest<size_t>::format_summary(
+  size_t min, double avg, size_t max, size_t diff, size_t sum, size_t workers) {
+
+  stringStream out;
+  out.print(" Min: " SIZE_FORMAT
+            ", Avg: %4.1lf, Max: " SIZE_FORMAT
+            ", Diff: " SIZE_FORMAT ", Sum: " SIZE_FORMAT
+            ", Workers: " SIZE_FORMAT "\n",
+            min, avg, max, diff, sum, workers);
+  return out.as_string();
+}
+
+template<>
+const char* WorkerDataArrayTest<double>::format_summary(
+  double min, double avg, double max, double diff, double sum, size_t workers) {
+
+  stringStream out;
+  out.print(" Min: %4.1lf"
+            ", Avg: %4.1lf, Max: %4.1lf"
+            ", Diff: %4.1lf, Sum: %4.1lf"
+            ", Workers: " SIZE_FORMAT "\n",
+            min, avg, max, diff, sum, workers);
+  return out.as_string();
+}
+
+class BasicWorkerDataArrayTest : public WorkerDataArrayTest<size_t> {
+ protected:
+  BasicWorkerDataArrayTest() {
+    array.set(0, 5);
+    array.set(1, 3);
+    array.set(2, 7);
+  }
+
+ private:
+  virtual const char* expected_summary() {
+    return format_summary(3, 5.0, 7, 4, 15, 3);
+  }
+
+  virtual const char* expected_details() {
+    return "  5  3  7\n";
+  }
+};
+
+TEST_F(BasicWorkerDataArrayTest, sum_test) {
+  ASSERT_EQ(15u, array.sum());
+}
+
+TEST_F(BasicWorkerDataArrayTest, average_test) {
+  ASSERT_NEAR(5.0, array.average(), epsilon);
+}
+
+TEST_F(BasicWorkerDataArrayTest, print_summary_on_test) {
+  ASSERT_STREQ(print_expected_summary(), print_summary());
+}
+
+TEST_F(BasicWorkerDataArrayTest, print_details_on_test) {
+  ASSERT_STREQ(print_expected_details(), print_details());
+}
+
+class AddWorkerDataArrayTest : public WorkerDataArrayTest<size_t> {
+ protected:
+  AddWorkerDataArrayTest() {
+    array.set(0, 5);
+    array.set(1, 3);
+    array.set(2, 7);
+
+    for (uint i = 0; i < 3; i++) {
+      array.add(i, 1);
+    }
+  }
+
+ private:
+  virtual const char* expected_summary() {
+    return format_summary(4, 6.0, 8, 4, 18, 3);
+  }
+
+  virtual const char* expected_details() {
+    return "  6  4  8\n";
+  }
+};
+
+TEST_F(AddWorkerDataArrayTest, sum_test) {
+  ASSERT_EQ(18u, array.sum());
+}
+
+TEST_F(AddWorkerDataArrayTest, average_test) {
+  ASSERT_NEAR(6.0, array.average(), epsilon);
+}
+
+TEST_F(AddWorkerDataArrayTest, print_summary_on_test) {
+  ASSERT_STREQ(print_expected_summary(), print_summary());
+}
+
+TEST_F(AddWorkerDataArrayTest, print_details_on_test) {
+  ASSERT_STREQ(print_expected_details(), print_details());
+}
+
+class UninitializedElementWorkerDataArrayTest : public WorkerDataArrayTest<size_t> {
+ protected:
+  UninitializedElementWorkerDataArrayTest() {
+    array.set(0, 5);
+    array.set(1, WorkerDataArray<size_t>::uninitialized());
+    array.set(2, 7);
+  }
+
+ private:
+  virtual const char* expected_summary() {
+    return format_summary(5, 6.0, 7, 2, 12, 2);
+  }
+
+  virtual const char* expected_details() {
+    return "  5 -  7\n";
+  }
+};
+
+TEST_F(UninitializedElementWorkerDataArrayTest, sum_test) {
+  ASSERT_EQ(12u, array.sum());
+}
+
+TEST_F(UninitializedElementWorkerDataArrayTest, average_test) {
+  ASSERT_NEAR(6.0, array.average(), epsilon);
+}
+
+TEST_F(UninitializedElementWorkerDataArrayTest, print_summary_on_test) {
+  ASSERT_STREQ(print_expected_summary(), print_summary());
+}
+
+TEST_F(UninitializedElementWorkerDataArrayTest, print_details_on_test) {
+  ASSERT_STREQ(print_expected_details(), print_details());
+}
+
+class UninitializedWorkerDataArrayTest : public WorkerDataArrayTest<size_t> {
+ protected:
+  UninitializedWorkerDataArrayTest() {
+    array.set(0, WorkerDataArray<size_t>::uninitialized());
+    array.set(1, WorkerDataArray<size_t>::uninitialized());
+    array.set(2, WorkerDataArray<size_t>::uninitialized());
+  }
+
+ private:
+  virtual const char* expected_summary() {
+    return " skipped\n";
+  }
+
+  virtual const char* expected_details() {
+    return " - - -\n";
+  }
+};
+
+TEST_F(UninitializedWorkerDataArrayTest, sum_test) {
+  ASSERT_EQ(0u, array.sum());
+}
+
+TEST_F(UninitializedWorkerDataArrayTest, average_test) {
+  ASSERT_NEAR(0.0, array.average(), epsilon);
+}
+
+TEST_F(UninitializedWorkerDataArrayTest, print_summary_on_test) {
+  ASSERT_STREQ(print_expected_summary(), print_summary());
+}
+
+TEST_F(UninitializedWorkerDataArrayTest, print_details_on_test) {
+  ASSERT_STREQ(print_expected_details(), print_details());
+}
+
+class UninitializedDoubleElementWorkerDataArrayTest : public WorkerDataArrayTest<double> {
+ protected:
+  UninitializedDoubleElementWorkerDataArrayTest() {
+    array.set(0, 5.1 / MILLIUNITS);
+    array.set(1, WorkerDataArray<double>::uninitialized());
+    array.set(2, 7.2 / MILLIUNITS);
+  }
+
+ private:
+  virtual const char* expected_summary() {
+    return format_summary(5.1, 6.1, 7.2, 2.1, 12.3, 2);
+  }
+
+  virtual const char* expected_details() {
+    stringStream out;
+    out.print(" %4.1lf - %4.1lf\n", 5.1, 7.2);
+    return out.as_string();
+  }
+};
+
+TEST_F(UninitializedDoubleElementWorkerDataArrayTest, sum_test) {
+  ASSERT_NEAR(12.3 / MILLIUNITS, array.sum(), epsilon);
+}
+
+TEST_F(UninitializedDoubleElementWorkerDataArrayTest, average_test) {
+  ASSERT_NEAR(6.15 / MILLIUNITS, array.average(), epsilon);
+}
+
+TEST_F(UninitializedDoubleElementWorkerDataArrayTest, print_summary_on_test) {
+  ASSERT_STREQ(print_expected_summary(), print_summary());
+}
+
+TEST_F(UninitializedDoubleElementWorkerDataArrayTest, print_details_on_test) {
+  ASSERT_STREQ(print_expected_details(), print_details());
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/native/gc/shared/test_collectorPolicy.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,282 @@
+/*
+ * 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 "precompiled.hpp"
+#include "gc/shared/collectorPolicy.hpp"
+#include "unittest.hpp"
+#include "utilities/macros.hpp"
+
+class TestGenCollectorPolicy {
+ public:
+
+  class Executor {
+   public:
+    virtual void execute() = 0;
+  };
+
+  class UnaryExecutor : public Executor {
+   protected:
+    const size_t param;
+   public:
+    UnaryExecutor(size_t val) : param(val) { }
+  };
+
+  class BinaryExecutor : public Executor {
+   protected:
+    const size_t param1;
+    const size_t param2;
+   public:
+    BinaryExecutor(size_t val1, size_t val2) : param1(val1), param2(val2) { }
+  };
+
+  class MinHeapSizeGuard {
+   private:
+    const size_t _stored_min_heap_size;
+   public:
+    MinHeapSizeGuard() : _stored_min_heap_size(Arguments::min_heap_size()) { }
+    ~MinHeapSizeGuard() {
+      Arguments::set_min_heap_size(_stored_min_heap_size);
+    }
+  };
+
+  class TestWrapper {
+   public:
+    static void test(Executor* setter1, Executor* setter2, Executor* checker) {
+      FLAG_GUARD(InitialHeapSize);
+      FLAG_GUARD(MaxHeapSize);
+      FLAG_GUARD(MaxNewSize);
+      FLAG_GUARD(MinHeapDeltaBytes);
+      FLAG_GUARD(NewSize);
+      FLAG_GUARD(OldSize);
+      MinHeapSizeGuard min_heap_size_guard;
+
+      FLAG_SET_ERGO(size_t, InitialHeapSize, 100 * M);
+      FLAG_SET_ERGO(size_t, OldSize, 4 * M);
+      FLAG_SET_ERGO(size_t, NewSize, 1 * M);
+      FLAG_SET_ERGO(size_t, MaxNewSize, 80 * M);
+      Arguments::set_min_heap_size(40 * M);
+
+      ASSERT_NO_FATAL_FAILURE(setter1->execute());
+
+      if (setter2 != NULL) {
+        ASSERT_NO_FATAL_FAILURE(setter2->execute());
+      }
+
+      ASSERT_NO_FATAL_FAILURE(checker->execute());
+    }
+    static void test(Executor* setter, Executor* checker) {
+      test(setter, NULL, checker);
+    }
+  };
+
+  class SetNewSizeErgo : public UnaryExecutor {
+   public:
+    SetNewSizeErgo(size_t param) : UnaryExecutor(param) { }
+    void execute() {
+      FLAG_SET_ERGO(size_t, NewSize, param);
+    }
+  };
+
+  class CheckYoungMin : public UnaryExecutor {
+   public:
+    CheckYoungMin(size_t param) : UnaryExecutor(param) { }
+    void execute() {
+      MarkSweepPolicy msp;
+      msp.initialize_all();
+      ASSERT_LE(msp.min_young_size(), param);
+    }
+  };
+
+  class CheckScaledYoungInitial : public Executor {
+   public:
+    void execute() {
+      size_t initial_heap_size = InitialHeapSize;
+      MarkSweepPolicy msp;
+      msp.initialize_all();
+
+      if (InitialHeapSize > initial_heap_size) {
+        // InitialHeapSize was adapted by msp.initialize_all, e.g. due to alignment
+        // caused by 64K page size.
+        initial_heap_size = InitialHeapSize;
+      }
+
+      size_t expected = msp.scale_by_NewRatio_aligned(initial_heap_size);
+      ASSERT_EQ(expected, msp.initial_young_size());
+      ASSERT_EQ(expected, NewSize);
+    }
+  };
+
+  class SetNewSizeCmd : public UnaryExecutor {
+   public:
+    SetNewSizeCmd(size_t param) : UnaryExecutor(param) { }
+    void execute() {
+      FLAG_SET_CMDLINE(size_t, NewSize, param);
+    }
+  };
+
+  class CheckYoungInitial : public UnaryExecutor {
+   public:
+    CheckYoungInitial(size_t param) : UnaryExecutor(param) { }
+    void execute() {
+      MarkSweepPolicy msp;
+      msp.initialize_all();
+
+      ASSERT_EQ(param, msp.initial_young_size());
+    }
+  };
+
+  class SetOldSizeCmd : public UnaryExecutor {
+   public:
+    SetOldSizeCmd(size_t param) : UnaryExecutor(param) { }
+    void execute() {
+      FLAG_SET_CMDLINE(size_t, OldSize, param);
+    }
+  };
+
+  class SetMaxNewSizeCmd : public BinaryExecutor {
+   public:
+    SetMaxNewSizeCmd(size_t param1, size_t param2) : BinaryExecutor(param1, param2) { }
+    void execute() {
+      size_t heap_alignment = CollectorPolicy::compute_heap_alignment();
+      size_t new_size_value = align_size_up(MaxHeapSize, heap_alignment)
+              - param1 + param2;
+      FLAG_SET_CMDLINE(size_t, MaxNewSize, new_size_value);
+    }
+  };
+
+  class CheckOldMin : public UnaryExecutor {
+   public:
+    CheckOldMin(size_t param) : UnaryExecutor(param) { }
+    void execute() {
+      MarkSweepPolicy msp;
+      msp.initialize_all();
+      ASSERT_LE(msp.min_old_size(), param);
+    }
+  };
+
+  class CheckOldInitial : public Executor {
+   public:
+    void execute() {
+      size_t heap_alignment = CollectorPolicy::compute_heap_alignment();
+
+      MarkSweepPolicy msp;
+      msp.initialize_all();
+
+      size_t expected_old_initial = align_size_up(InitialHeapSize, heap_alignment)
+              - MaxNewSize;
+
+      ASSERT_EQ(expected_old_initial, msp.initial_old_size());
+    }
+  };
+
+  class CheckOldInitialMaxNewSize : public BinaryExecutor {
+   public:
+    CheckOldInitialMaxNewSize(size_t param1, size_t param2) : BinaryExecutor(param1, param2) { }
+    void execute() {
+      size_t heap_alignment = CollectorPolicy::compute_heap_alignment();
+      size_t new_size_value = align_size_up(MaxHeapSize, heap_alignment)
+              - param1 + param2;
+
+      MarkSweepPolicy msp;
+      msp.initialize_all();
+
+      size_t expected_old_initial = align_size_up(MaxHeapSize, heap_alignment)
+              - new_size_value;
+
+      ASSERT_EQ(expected_old_initial, msp.initial_old_size());
+    }
+  };
+};
+
+
+// Testing that the NewSize flag is handled correct is hard because it
+// depends on so many other configurable variables. These tests only try to
+// verify that there are some basic rules for NewSize honored by the policies.
+
+// If NewSize has been ergonomically set, the collector policy
+// should use it for min
+TEST_VM(CollectorPolicy, young_min_ergo) {
+  TestGenCollectorPolicy::SetNewSizeErgo setter(20 * M);
+  TestGenCollectorPolicy::CheckYoungMin checker(20 * M);
+
+  TestGenCollectorPolicy::TestWrapper::test(&setter, &checker);
+}
+
+// If NewSize has been ergonomically set, the collector policy
+// should use it for min but calculate the initial young size
+// using NewRatio.
+TEST_VM(CollectorPolicy, young_scaled_initial_ergo) {
+  TestGenCollectorPolicy::SetNewSizeErgo setter(20 * M);
+  TestGenCollectorPolicy::CheckScaledYoungInitial checker;
+
+  TestGenCollectorPolicy::TestWrapper::test(&setter, &checker);
+}
+
+
+// Since a flag has been set with FLAG_SET_CMDLINE it
+// will be treated as it have been set on the command line for
+// the rest of the VM lifetime. This is an irreversible change and
+// could impact other tests so we use TEST_OTHER_VM
+TEST_OTHER_VM(CollectorPolicy, young_cmd) {
+  // If NewSize is set on the command line, it should be used
+  // for both min and initial young size if less than min heap.
+  TestGenCollectorPolicy::SetNewSizeCmd setter(20 * M);
+
+  TestGenCollectorPolicy::CheckYoungMin checker_min(20 * M);
+  TestGenCollectorPolicy::TestWrapper::test(&setter, &checker_min);
+
+  TestGenCollectorPolicy::CheckYoungInitial checker_initial(20 * M);
+  TestGenCollectorPolicy::TestWrapper::test(&setter, &checker_initial);
+
+  // If NewSize is set on command line, but is larger than the min
+  // heap size, it should only be used for initial young size.
+  TestGenCollectorPolicy::SetNewSizeCmd setter_large(80 * M);
+  TestGenCollectorPolicy::CheckYoungInitial checker_large(80 * M);
+  TestGenCollectorPolicy::TestWrapper::test(&setter_large, &checker_large);
+}
+
+// Since a flag has been set with FLAG_SET_CMDLINE it
+// will be treated as it have been set on the command line for
+// the rest of the VM lifetime. This is an irreversible change and
+// could impact other tests so we use TEST_OTHER_VM
+TEST_OTHER_VM(CollectorPolicy, old_cmd) {
+  // If OldSize is set on the command line, it should be used
+  // for both min and initial old size if less than min heap.
+  TestGenCollectorPolicy::SetOldSizeCmd setter(20 * M);
+
+  TestGenCollectorPolicy::CheckOldMin checker_min(20 * M);
+  TestGenCollectorPolicy::TestWrapper::test(&setter, &checker_min);
+
+  TestGenCollectorPolicy::CheckOldInitial checker_initial;
+  TestGenCollectorPolicy::TestWrapper::test(&setter, &checker_initial);
+
+  // If MaxNewSize is large, the maximum OldSize will be less than
+  // what's requested on the command line and it should be reset
+  // ergonomically.
+  // We intentionally set MaxNewSize + OldSize > MaxHeapSize
+  TestGenCollectorPolicy::SetOldSizeCmd setter_old_size(30 * M);
+  TestGenCollectorPolicy::SetMaxNewSizeCmd setter_max_new_size(30 * M, 20 * M);
+  TestGenCollectorPolicy::CheckOldInitialMaxNewSize checker_large(30 * M, 20 * M);
+
+  TestGenCollectorPolicy::TestWrapper::test(&setter_old_size, &setter_max_new_size, &checker_large);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/native/memory/test_guardedMemory.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,148 @@
+/*
+ * 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 "precompiled.hpp"
+#include "memory/allocation.hpp"
+#include "memory/allocation.inline.hpp"
+#include "memory/guardedMemory.hpp"
+#include "runtime/os.hpp"
+#include "unittest.hpp"
+
+static void guarded_memory_test_check(void* p, size_t sz, void* tag) {
+  ASSERT_TRUE(p != NULL) << "NULL pointer given to check";
+  u_char* c = (u_char*) p;
+  GuardedMemory guarded(c);
+  EXPECT_EQ(guarded.get_tag(), tag) << "Tag is not the same as supplied";
+  EXPECT_EQ(guarded.get_user_ptr(), c) << "User pointer is not the same as supplied";
+  EXPECT_EQ(guarded.get_user_size(), sz) << "User size is not the same as supplied";
+  EXPECT_TRUE(guarded.verify_guards()) << "Guard broken";
+}
+
+class GuardedMemoryTest {
+ public:
+  static size_t get_guard_header_size() {
+    return sizeof (GuardedMemory::GuardHeader);
+  }
+  static size_t get_guard_size() {
+    return sizeof (GuardedMemory::Guard);
+  }
+};
+
+// Test GuardedMemory size
+TEST(GuardedMemory, size) {
+  size_t total_sz = GuardedMemory::get_total_size(1);
+  ASSERT_GT(total_sz, (size_t) 1) << "Unexpected size";
+  ASSERT_GE(total_sz, GuardedMemoryTest::get_guard_header_size() + 1
+          + GuardedMemoryTest::get_guard_size()) << "Unexpected size";
+}
+
+// Test the basic characteristics
+TEST(GuardedMemory, basic) {
+  u_char* basep =
+          (u_char*) os::malloc(GuardedMemory::get_total_size(1), mtInternal);
+  GuardedMemory guarded(basep, 1, (void*) 0xf000f000);
+
+  EXPECT_EQ(badResourceValue, *basep)
+          << "Expected guard in the form of badResourceValue";
+
+  u_char* userp = guarded.get_user_ptr();
+  EXPECT_EQ(uninitBlockPad, *userp)
+          << "Expected uninitialized data in the form of uninitBlockPad";
+  guarded_memory_test_check(userp, 1, (void*) 0xf000f000);
+
+  void* freep = guarded.release_for_freeing();
+  EXPECT_EQ((u_char*) freep, basep) << "Expected the same pointer guard was ";
+  EXPECT_EQ(freeBlockPad, *userp) << "Expected user data to be free block padded";
+  EXPECT_FALSE(guarded.verify_guards());
+  os::free(freep);
+}
+
+// Test a number of odd sizes
+TEST(GuardedMemory, odd_sizes) {
+  u_char* basep =
+          (u_char*) os::malloc(GuardedMemory::get_total_size(1), mtInternal);
+  GuardedMemory guarded(basep, 1, (void*) 0xf000f000);
+
+  size_t sz = 0;
+  do {
+    void* p = os::malloc(GuardedMemory::get_total_size(sz), mtInternal);
+    void* up = guarded.wrap_with_guards(p, sz, (void*) 1);
+    memset(up, 0, sz);
+    guarded_memory_test_check(up, sz, (void*) 1);
+    if (HasFatalFailure()) {
+      return;
+    }
+
+    os::free(guarded.release_for_freeing());
+    sz = (sz << 4) + 1;
+  } while (sz < (256 * 1024));
+}
+
+// Test buffer overrun into head...
+TEST(GuardedMemory, buffer_overrun_head) {
+  u_char* basep =
+          (u_char*) os::malloc(GuardedMemory::get_total_size(1), mtInternal);
+  GuardedMemory guarded(basep, 1, (void*) 0xf000f000);
+
+  guarded.wrap_with_guards(basep, 1);
+  *basep = 0;
+  EXPECT_FALSE(guarded.verify_guards());
+  os::free(basep);
+}
+
+// Test buffer overrun into tail with a number of odd sizes
+TEST(GuardedMemory, buffer_overrun_tail) {
+  u_char* basep =
+          (u_char*) os::malloc(GuardedMemory::get_total_size(1), mtInternal);
+  GuardedMemory guarded(basep, 1, (void*) 0xf000f000);
+
+  size_t sz = 1;
+  do {
+    void* p = os::malloc(GuardedMemory::get_total_size(sz), mtInternal);
+    void* up = guarded.wrap_with_guards(p, sz, (void*) 1);
+    memset(up, 0, sz + 1); // Buffer-overwrite (within guard)
+    EXPECT_FALSE(guarded.verify_guards()) << "Guard was not broken as expected";
+    os::free(guarded.release_for_freeing());
+    sz = (sz << 4) + 1;
+  } while (sz < (256 * 1024));
+}
+
+// Test wrap_copy/wrap_free
+TEST(GuardedMemory, wrap) {
+  EXPECT_TRUE(GuardedMemory::free_copy(NULL)) << "Expected free NULL to be OK";
+
+  const char* str = "Check my bounds out";
+  size_t str_sz = strlen(str) + 1;
+  char* str_copy = (char*) GuardedMemory::wrap_copy(str, str_sz);
+  guarded_memory_test_check(str_copy, str_sz, NULL);
+  if (HasFatalFailure()) {
+    return;
+  }
+  EXPECT_EQ(0, strcmp(str, str_copy)) << "Not identical copy";
+  EXPECT_TRUE(GuardedMemory::free_copy(str_copy)) << "Free copy failed to verify";
+
+  void* no_data = NULL;
+  void* no_data_copy = GuardedMemory::wrap_copy(no_data, 0);
+  EXPECT_TRUE(GuardedMemory::free_copy(no_data_copy))
+          << "Expected valid guards even for no data copy";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/native/memory/test_metachunk.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,90 @@
+/*
+ * 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 "precompiled.hpp"
+#include "memory/allocation.hpp"
+#include "memory/metachunk.hpp"
+#include "unittest.hpp"
+#include "utilities/copy.hpp"
+#include "utilities/debug.hpp"
+
+class MetachunkTest {
+ public:
+  static MetaWord* initial_top(Metachunk* metachunk) {
+    return metachunk->initial_top();
+  }
+  static MetaWord* top(Metachunk* metachunk) {
+    return metachunk->top();
+  }
+
+};
+
+TEST(Metachunk, basic) {
+  size_t size = 2 * 1024 * 1024;
+  void* memory = malloc(size);
+  ASSERT_TRUE(NULL != memory) << "Failed to malloc 2MB";
+
+  Metachunk* metachunk = ::new (memory) Metachunk(size / BytesPerWord, NULL);
+
+  EXPECT_EQ((MetaWord*) metachunk, metachunk->bottom());
+  EXPECT_EQ((uintptr_t*) metachunk + metachunk->size(), metachunk->end());
+
+  // Check sizes
+  EXPECT_EQ(metachunk->size(), metachunk->word_size());
+  EXPECT_EQ(pointer_delta(metachunk->end(), metachunk->bottom(),
+                sizeof (MetaWord*)),
+            metachunk->word_size());
+
+  // Check usage
+  EXPECT_EQ(metachunk->used_word_size(), metachunk->overhead());
+  EXPECT_EQ(metachunk->word_size() - metachunk->used_word_size(),
+            metachunk->free_word_size());
+  EXPECT_EQ(MetachunkTest::top(metachunk), MetachunkTest::initial_top(metachunk));
+  EXPECT_TRUE(metachunk->is_empty());
+
+  // Allocate
+  size_t alloc_size = 64; // Words
+  EXPECT_TRUE(is_size_aligned(alloc_size, Metachunk::object_alignment()));
+
+  MetaWord* mem = metachunk->allocate(alloc_size);
+
+  // Check post alloc
+  EXPECT_EQ(MetachunkTest::initial_top(metachunk), mem);
+  EXPECT_EQ(MetachunkTest::top(metachunk), mem + alloc_size);
+  EXPECT_EQ(metachunk->overhead() + alloc_size, metachunk->used_word_size());
+  EXPECT_EQ(metachunk->word_size() - metachunk->used_word_size(),
+            metachunk->free_word_size());
+  EXPECT_FALSE(metachunk->is_empty());
+
+  // Clear chunk
+  metachunk->reset_empty();
+
+  // Check post clear
+  EXPECT_EQ(metachunk->used_word_size(), metachunk->overhead());
+  EXPECT_EQ(metachunk->word_size() - metachunk->used_word_size(),
+            metachunk->free_word_size());
+  EXPECT_EQ(MetachunkTest::top(metachunk), MetachunkTest::initial_top(metachunk));
+  EXPECT_TRUE(metachunk->is_empty());
+
+  free(memory);
+}
--- a/test/native/runtime/test_os.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/native/runtime/test_os.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -25,6 +25,15 @@
 #include "runtime/os.hpp"
 #include "unittest.hpp"
 
+static size_t small_page_size() {
+  return os::vm_page_size();
+}
+
+static size_t large_page_size() {
+  const size_t large_page_size_example = 4 * M;
+  return os::page_size_for_region_aligned(large_page_size_example, 1);
+}
+
 TEST_VM(os, page_size_for_region) {
   size_t large_page_example = 4 * M;
   size_t large_page = os::page_size_for_region_aligned(large_page_example, 1);
@@ -37,6 +46,68 @@
   }
 }
 
+TEST_VM(os, page_size_for_region_aligned) {
+  if (UseLargePages) {
+    const size_t small_page = small_page_size();
+    const size_t large_page = large_page_size();
+
+    if (large_page > small_page) {
+      size_t num_small_pages_in_large = large_page / small_page;
+      size_t page = os::page_size_for_region_aligned(large_page, num_small_pages_in_large);
+
+      ASSERT_EQ(page, small_page);
+    }
+  }
+}
+
+TEST_VM(os, page_size_for_region_alignment) {
+  if (UseLargePages) {
+    const size_t small_page = small_page_size();
+    const size_t large_page = large_page_size();
+    if (large_page > small_page) {
+      const size_t unaligned_region = large_page + 17;
+      size_t page = os::page_size_for_region_aligned(unaligned_region, 1);
+      ASSERT_EQ(page, small_page);
+
+      const size_t num_pages = 5;
+      const size_t aligned_region = large_page * num_pages;
+      page = os::page_size_for_region_aligned(aligned_region, num_pages);
+      ASSERT_EQ(page, large_page);
+    }
+  }
+}
+
+TEST_VM(os, page_size_for_region_unaligned) {
+  if (UseLargePages) {
+    // Given exact page size, should return that page size.
+    for (size_t i = 0; os::_page_sizes[i] != 0; i++) {
+      size_t expected = os::_page_sizes[i];
+      size_t actual = os::page_size_for_region_unaligned(expected, 1);
+      ASSERT_EQ(expected, actual);
+    }
+
+    // Given slightly larger size than a page size, return the page size.
+    for (size_t i = 0; os::_page_sizes[i] != 0; i++) {
+      size_t expected = os::_page_sizes[i];
+      size_t actual = os::page_size_for_region_unaligned(expected + 17, 1);
+      ASSERT_EQ(expected, actual);
+    }
+
+    // Given a slightly smaller size than a page size,
+    // return the next smaller page size.
+    if (os::_page_sizes[1] > os::_page_sizes[0]) {
+      size_t expected = os::_page_sizes[0];
+      size_t actual = os::page_size_for_region_unaligned(os::_page_sizes[1] - 17, 1);
+      ASSERT_EQ(actual, expected);
+    }
+
+    // Return small page size for values less than a small page.
+    size_t small_page = small_page_size();
+    size_t actual = os::page_size_for_region_unaligned(small_page - 17, 1);
+    ASSERT_EQ(small_page, actual);
+  }
+}
+
 #ifdef ASSERT
 TEST_VM_ASSERT_MSG(os, page_size_for_region_with_zero_min_pages, "sanity") {
   size_t region_size = 16 * os::vm_page_size();
--- a/test/native/utilities/test_quicksort.cpp	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/native/utilities/test_quicksort.cpp	Wed Oct 26 20:13:29 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -19,29 +19,186 @@
  * 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 "precompiled.hpp"
-#include "prims/jvm.h"
+#include "memory/allocation.inline.hpp"
+#include "runtime/os.hpp"
 #include "utilities/quickSort.hpp"
 #include "unittest.hpp"
 
-static int int_comparator(int a, int b) {
+static int test_comparator(int a, int b) {
   if (a == b) {
     return 0;
-  } else if (a < b) {
+  }
+  if (a < b) {
     return -1;
   }
-
-  // a > b
   return 1;
 }
 
-TEST(utilities, quicksort) {
-  int test_array[] = {3,2,1};
-  QuickSort::sort(test_array, 3, int_comparator, false);
+static bool compare_arrays(int* actual, int* expected, int length) {
+  for (int i = 0; i < length; i++) {
+    if (actual[i] != expected[i]) {
+      return false;
+    }
+  }
+  return true;
+}
 
-  ASSERT_EQ(1, test_array[0]);
-  ASSERT_EQ(2, test_array[1]);
-  ASSERT_EQ(3, test_array[2]);
+template <class C>
+static bool sort_and_compare(int* arrayToSort, int* expectedResult, int length, C comparator, bool idempotent = false) {
+  QuickSort::sort<int, C>(arrayToSort, length, comparator, idempotent);
+  return compare_arrays(arrayToSort, expectedResult, length);
 }
+
+static int test_even_odd_comparator(int a, int b) {
+  bool a_is_odd = ((a % 2) == 1);
+  bool b_is_odd = ((b % 2) == 1);
+  if (a_is_odd == b_is_odd) {
+    return 0;
+  }
+  if (a_is_odd) {
+    return -1;
+  }
+  return 1;
+}
+
+extern "C" {
+  static int test_stdlib_comparator(const void* a, const void* b) {
+    int ai = *(int*)a;
+    int bi = *(int*)b;
+    if (ai == bi) {
+      return 0;
+    }
+    if (ai < bi) {
+      return -1;
+    }
+    return 1;
+  }
+}
+
+TEST(QuickSort, quicksort) {
+  {
+    int* test_array = NULL;
+    int* expected_array = NULL;
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 0, test_comparator));
+  }
+  {
+    int test_array[] = {3};
+    int expected_array[] = {3};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 1, test_comparator));
+  }
+  {
+    int test_array[] = {3,2};
+    int expected_array[] = {2,3};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 2, test_comparator));
+  }
+  {
+    int test_array[] = {3,2,1};
+    int expected_array[] = {1,2,3};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 3, test_comparator));
+  }
+  {
+    int test_array[] = {4,3,2,1};
+    int expected_array[] = {1,2,3,4};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 4, test_comparator));
+  }
+  {
+    int test_array[] = {7,1,5,3,6,9,8,2,4,0};
+    int expected_array[] = {0,1,2,3,4,5,6,7,8,9};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 10, test_comparator));
+  }
+  {
+    int test_array[] = {4,4,1,4};
+    int expected_array[] = {1,4,4,4};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 4, test_comparator));
+  }
+  {
+    int test_array[] = {0,1,2,3,4,5,6,7,8,9};
+    int expected_array[] = {0,1,2,3,4,5,6,7,8,9};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 10, test_comparator));
+  }
+  {
+    // one of the random arrays that found an issue in the partition method.
+    int test_array[] = {76,46,81,8,64,56,75,11,51,55,11,71,59,27,9,64,69,75,21,25,39,40,44,32,7,8,40,41,24,78,24,74,9,65,28,6,40,31,22,13,27,82};
+    int expected_array[] = {6,7,8,8,9,9,11,11,13,21,22,24,24,25,27,27,28,31,32,39,40,40,40,41,44,46,51,55,56,59,64,64,65,69,71,74,75,75,76,78,81,82};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 42, test_comparator));
+  }
+  {
+    int test_array[] = {2,8,1,4};
+    int expected_array[] = {1,4,2,8};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 4, test_even_odd_comparator));
+  }
+}
+
+TEST(QuickSort, idempotent) {
+  {
+    // An array of lenght 3 is only sorted by find_pivot. Make sure that it is idempotent.
+    int test_array[] = {1, 4, 8};
+    int expected_array[] = {1, 4, 8};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 3, test_even_odd_comparator, true));
+  }
+  {
+    int test_array[] = {1, 7, 9, 4, 8, 2};
+    int expected_array[] = {1, 7, 9, 4, 8, 2};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true));
+  }
+  {
+    int test_array[] = {1, 9, 7, 4, 2, 8};
+    int expected_array[] = {1, 9, 7, 4, 2, 8};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true));
+  }
+  {
+    int test_array[] = {7, 9, 1, 2, 8, 4};
+    int expected_array[] = {7, 9, 1, 2, 8, 4};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true));
+  }
+  {
+    int test_array[] = {7, 1, 9, 2, 4, 8};
+    int expected_array[] = {7, 1, 9, 2, 4, 8};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true));
+  }
+  {
+    int test_array[] = {9, 1, 7, 4, 8, 2};
+    int expected_array[] = {9, 1, 7, 4, 8, 2};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true));
+  }
+  {
+    int test_array[] = {9, 7, 1, 4, 2, 8};
+    int expected_array[] = {9, 7, 1, 4, 2, 8};
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, 6, test_even_odd_comparator, true));
+  }
+}
+
+TEST(QuickSort, random) {
+  for (int i = 0; i < 1000; i++) {
+    int length = os::random() % 100;
+    int* test_array = NEW_C_HEAP_ARRAY(int, length, mtInternal);
+    int* expected_array = NEW_C_HEAP_ARRAY(int, length, mtInternal);
+    for (int j = 0; j < length; j++) {
+        // Choose random values, but get a chance of getting duplicates
+        test_array[j] = os::random() % (length * 2);
+        expected_array[j] = test_array[j];
+    }
+
+    // Compare sorting to stdlib::qsort()
+    qsort(expected_array, length, sizeof(int), test_stdlib_comparator);
+    EXPECT_TRUE(sort_and_compare(test_array, expected_array, length, test_comparator));
+
+    // Make sure sorting is idempotent.
+    // Both test_array and expected_array are sorted by the test_comparator.
+    // Now sort them once with the test_even_odd_comparator. Then sort the
+    // test_array one more time with test_even_odd_comparator and verify that
+    // it is idempotent.
+    QuickSort::sort(expected_array, length, test_even_odd_comparator, true);
+    QuickSort::sort(test_array, length, test_even_odd_comparator, true);
+    EXPECT_TRUE(compare_arrays(test_array, expected_array, length));
+    QuickSort::sort(test_array, length, test_even_odd_comparator, true);
+    EXPECT_TRUE(compare_arrays(test_array, expected_array, length));
+
+    FREE_C_HEAP_ARRAY(int, test_array);
+    FREE_C_HEAP_ARRAY(int, expected_array);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/CommandLine/PermGenFlagsTest.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,51 @@
+/*
+ * 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 8167446
+ * @summary Commandline options PermSize and MaxPermSize should be recognized but ignored.
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ * @run driver PermGenFlagsTest
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+public class PermGenFlagsTest {
+    public static void main(String[] args) throws Exception {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:PermSize=22k",
+                                                                  "-version");
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldContain("Ignoring option PermSize; support was removed in 8.0");
+        output.shouldHaveExitValue(0);
+
+        pb = ProcessTools.createJavaProcessBuilder("-XX:MaxPermSize=22k",
+                                                   "-version");
+        output = new OutputAnalyzer(pb.start());
+        output.shouldContain("Ignoring option MaxPermSize; support was removed in 8.0");
+        output.shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/CompactStrings/TestMethodNames.java	Wed Oct 26 20:13:29 2016 +0000
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+import javax.script.*;
+import java.util.function.*;
+
+/*
+ * @test
+ * @bug 8164612
+ * @summary Test method names containing Latin-1 supplement characters.
+ * @run main/othervm -XX:+CompactStrings TestMethodNames
+ * @run main/othervm -XX:-CompactStrings TestMethodNames
+ */
+public class TestMethodNames {
+    public static void main(String[] args) throws Exception {
+        ScriptEngineManager m = new ScriptEngineManager();
+        ScriptEngine e = m.getEngineByName("nashorn");
+
+        e.eval("({get \"\0\"(){}})[\"\0\"]");
+        e.eval("({get \"\\x80\"(){}})[\"\\x80\"]");
+        e.eval("({get \"\\xff\"(){}})[\"\\xff\"]");
+    }
+}
--- a/test/runtime/SharedArchiveFile/SASymbolTableTest.java	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/runtime/SharedArchiveFile/SASymbolTableTest.java	Wed Oct 26 20:13:29 2016 +0000
@@ -24,9 +24,6 @@
 /*
  * @test SASymbolTableTest
  * @summary Walk symbol table using SA, with and without CDS.
- * Started failing on 2016.06.24 due to 8160376 on MacOS X so quarantine
- * it on that platform:
- * @requires os.family != "mac"
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          jdk.hotspot.agent/sun.jvm.hotspot.oops
--- a/test/runtime/jni/PrivateInterfaceMethods/PrivateInterfaceMethods.java	Wed Oct 26 15:46:13 2016 -0400
+++ b/test/runtime/jni/PrivateInterfaceMethods/PrivateInterfaceMethods.java	Wed Oct 26 20:13:29 2016 +0000
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 8081800
+ * @bug 8081800 8165827
  * @summary Add JNI invocation tests for private interface methods
  * @run main/native PrivateInterfaceMethods
  */
@@ -34,19 +34,23 @@
     }
 
     static native int callIntVoid(Object target, String definingClassName, String methodName, boolean virtual);
+    static native void lookupIntVoid(String definingClassName, String methodName);
 
     static interface A {
         static final int AmResult = 1;
         private int m() { return AmResult; }
+        private int onlyA() { return 0; }
     }
 
     static interface B extends A {
         // No m() here
+        private int onlyB() { return 0; }
     }
 
     static interface C extends B {
         static final int CmResult = 2;
         private int m() { return CmResult; }  // unrelated to A.m
+        private int onlyC() { return 0; }
     }
 
     public static class Impl implements C {
@@ -62,6 +66,29 @@
     }
 
     public static void main(String[] args) {
+
+        // JNI getMethodID only works for methods declared in or inherited by a type.
+        // Private interface methods are not inherited and so should only be found
+        // in the declaring interface.
+
+        lookup(A.class.getName(), "onlyA", null); // should succeed
+        lookup(B.class.getName(), "onlyA", NoSuchMethodError.class); // should fail
+        lookup(C.class.getName(), "onlyA", NoSuchMethodError.class); // should fail
+        lookup(Impl.class.getName(), "onlyA", NoSuchMethodError.class); // should fail
+        lookup(Impl2.class.getName(), "onlyA", NoSuchMethodError.class); // should fail
+
+        lookup(B.class.getName(), "onlyB", null); // should succeed
+        lookup(A.class.getName(), "onlyB", NoSuchMethodError.class); // should fail
+        lookup(C.class.getName(), "onlyB", NoSuchMethodError.class); // should fail
+        lookup(Impl.class.getName(), "onlyB", NoSuchMethodError.class); // should fail
+        lookup(Impl2.class.getName(), "onlyB", NoSuchMethodError.class); // should fail
+
+        lookup(C.class.getName(), "onlyC", null); // should succeed
+        lookup(A.class.getName(), "onlyC", NoSuchMethodError.class); // should fail
+        lookup(B.class.getName(), "onlyC", NoSuchMethodError.class); // should fail
+        lookup(Impl.class.getName(), "onlyC", NoSuchMethodError.class); // should fail
+        lookup(Impl2.class.getName(), "onlyC", NoSuchMethodError.class); // should fail
+
         Impl impl = new Impl();
 
         // Note: JNI doesn't enforce access control so we can make
@@ -106,6 +133,25 @@
         test(impl2, Impl2.class.getName(), "m", -1, false, NoSuchMethodError.class);
     }
 
+    static void lookup(String definingClass, String method, Class<?> expectedException) {
+
+        String desc = "Lookup of " + definingClass + "." + method;
+        try {
+            lookupIntVoid(definingClass, method);
+            if (expectedException != null)
+                throw new Error(desc + " succeeded - but expected exception "
+                                + expectedException.getSimpleName());
+            System.out.println(desc + " - passed");
+        }
+        catch (Throwable t) {
+           if (t.getClass() != expectedException)
+               throw new Error(desc + " failed: got exception " + t + " but expected exception "
+                               + expectedException.getSimpleName());
+           else
+              System.out.println(desc + " threw " + expectedException.getSimpleName() + " as expected");
+        }