Merge
authoramurillo
Fri, 30 Sep 2016 02:52:38 -0700
changeset 41343 e42e78cd7c6f
parent 41192 6800d7168f89 (current diff)
parent 41342 18c64f6a5cc3 (diff)
child 41344 11390434331a
child 41666 6cca68fa5f84
Merge
hotspot/src/share/vm/oops/arrayOop.cpp
hotspot/src/share/vm/utilities/chunkedList.cpp
hotspot/src/share/vm/utilities/linkedlist.cpp
hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java
hotspot/test/native/runtime/test_instanceKlass.cpp
hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAttachee.java
--- a/hotspot/make/gensrc/GensrcJvmti.gmk	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/make/gensrc/GensrcJvmti.gmk	Fri Sep 30 02:52:38 2016 -0700
@@ -67,7 +67,8 @@
   $$($1_OUTPUT_DIR)/$1: $$($1_XML_FILE) $$($1_XSL_FILE) $$($1_DEPS) $$(BUILD_JVMTI_TOOLS)
 	$$(call LogInfo, Generating $$(@F))
 	$$(call MakeDir, $$(@D))
-	$$(call ExecuteWithLog, $$@, $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) -XSL $$($1_XSL_FILE) -OUT $$@ $$($1_ARGS))
+	$$(call ExecuteWithLog, $$@, $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) \
+	    -XSL $$($1_XSL_FILE) -OUT $$@ $$($1_ARGS))
         # jvmtiGen does not return error code properly on fail.
         # NOTE: We should really fix jvmtiGen.java instead.
 	test -f $$@
@@ -134,8 +135,8 @@
 TRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/tracefiles
 TRACE_SRCDIR := $(HOTSPOT_TOPDIR)/src/share/vm/trace
 
-# Append directories to search (might have been set by custom extensions)
-TRACE_SEARCH_DIRS += $(TRACE_SRCDIR)
+# Append list of XSL files to search (might have been set by custom extensions)
+TRACE_XSL_FILES += $(wildcard $(TRACE_SRCDIR)/*.xsl)
 
 TRACE_XML ?= $(TRACE_SRCDIR)/trace.xml
 
@@ -155,7 +156,7 @@
 define SetupTraceGeneration
   $$(eval $$(call SetupXslTransform, $1, \
       XML_FILE := $$(TRACE_XML), \
-      XSL_FILE := $$(firstword $$(wildcard $$(addsuffix /$$(basename $1).xsl, $$(TRACE_SEARCH_DIRS)))), \
+      XSL_FILE := $$(firstword $$(filter %/$$(basename $1).xsl, $$(TRACE_XSL_FILES))), \
       OUTPUT_DIR := $$(TRACE_OUTPUTDIR), \
       DEPS := $$(TRACE_DEPS), \
   ))
--- a/hotspot/make/lib/JvmOverrideFiles.gmk	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/make/lib/JvmOverrideFiles.gmk	Fri Sep 30 02:52:38 2016 -0700
@@ -31,6 +31,7 @@
 
 ifeq ($(TOOLCHAIN_TYPE), gcc)
   BUILD_LIBJVM_vmStructs.cpp_CXXFLAGS := -fno-var-tracking-assignments -O0
+  BUILD_LIBJVM_jvmciCompilerToVM.cpp_CXXFLAGS := -fno-var-tracking-assignments
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), linux)
--- a/hotspot/make/test/JtregNative.gmk	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/make/test/JtregNative.gmk	Fri Sep 30 02:52:38 2016 -0700
@@ -55,6 +55,9 @@
     $(HOTSPOT_TOPDIR)/test/testlibrary/jvmti \
     $(HOTSPOT_TOPDIR)/test/compiler/jvmci/jdk.vm.ci.code.test \
     $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/GetModulesInfo \
+    $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/ModuleAwareAgents/ClassFileLoadHook \
+    $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/ModuleAwareAgents/ClassLoadPrepare \
+    $(HOTSPOT_TOPDIR)/test/serviceability/jvmti/ModuleAwareAgents/ThreadStart \
     #
 
 # Add conditional directories here when needed.
@@ -75,6 +78,9 @@
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_liboverflow := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libSimpleClassFileLoadHook := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetNamedModuleTest := -lc
+    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libMAAClassFileLoadHook := -lc
+    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libMAAClassLoadPrepare := -lc
+    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libMAAThreadStart := -lc
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), linux)
--- a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -140,10 +140,11 @@
 LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
                                             int shift, int disp, BasicType type) {
   assert(base->is_register(), "must be");
+  intx large_disp = disp;
 
   // accumulate fixed displacements
   if (index->is_constant()) {
-    disp += index->as_constant_ptr()->as_jint() << shift;
+    large_disp += (intx)(index->as_constant_ptr()->as_jint()) << shift;
     index = LIR_OprFact::illegalOpr;
   }
 
@@ -154,31 +155,31 @@
       __ shift_left(index, shift, tmp);
       index = tmp;
     }
-    if (disp != 0) {
+    if (large_disp != 0) {
       LIR_Opr tmp = new_pointer_register();
-      if (Assembler::operand_valid_for_add_sub_immediate(disp)) {
-        __ add(tmp, tmp, LIR_OprFact::intptrConst(disp));
+      if (Assembler::operand_valid_for_add_sub_immediate(large_disp)) {
+        __ add(tmp, tmp, LIR_OprFact::intptrConst(large_disp));
         index = tmp;
       } else {
-        __ move(tmp, LIR_OprFact::intptrConst(disp));
+        __ move(tmp, LIR_OprFact::intptrConst(large_disp));
         __ add(tmp, index, tmp);
         index = tmp;
       }
-      disp = 0;
+      large_disp = 0;
     }
-  } else if (disp != 0 && !Address::offset_ok_for_immed(disp, shift)) {
+  } else if (large_disp != 0 && !Address::offset_ok_for_immed(large_disp, shift)) {
     // index is illegal so replace it with the displacement loaded into a register
     index = new_pointer_register();
-    __ move(LIR_OprFact::intptrConst(disp), index);
-    disp = 0;
+    __ move(LIR_OprFact::intptrConst(large_disp), index);
+    large_disp = 0;
   }
 
   // at this point we either have base + index or base + displacement
-  if (disp == 0) {
+  if (large_disp == 0) {
     return new LIR_Address(base, index, type);
   } else {
-    assert(Address::offset_ok_for_immed(disp, 0), "must be");
-    return new LIR_Address(base, disp, type);
+    assert(Address::offset_ok_for_immed(large_disp, 0), "must be");
+    return new LIR_Address(base, large_disp, type);
   }
 }
 
@@ -192,7 +193,7 @@
   LIR_Address* addr;
   if (index_opr->is_constant()) {
     addr = new LIR_Address(array_opr,
-                           offset_in_bytes + index_opr->as_jint() * elem_size, type);
+                           offset_in_bytes + (intx)(index_opr->as_jint()) * elem_size, type);
   } else {
     if (offset_in_bytes) {
       LIR_Opr tmp = new_pointer_register();
@@ -1032,6 +1033,10 @@
   Unimplemented();
 }
 
+void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) {
+  fatal("FMA intrinsic is not implemented on this platform");
+}
+
 void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
   fatal("vectorizedMismatch intrinsic is not implemented on this platform");
 }
--- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -327,7 +327,7 @@
 
 void InterpreterMacroAssembler::push_l(Register r) {
   str(zr, pre(esp, -wordSize));
-  str(r, pre(esp, -wordsize));
+  str(r, pre(esp, - wordSize));
 }
 
 void InterpreterMacroAssembler::pop_f(FloatRegister r) {
--- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -262,6 +262,11 @@
     FLAG_SET_DEFAULT(UseCRC32CIntrinsics, false);
   }
 
+  if (UseFMA) {
+    warning("FMA instructions are not available on this CPU");
+    FLAG_SET_DEFAULT(UseFMA, false);
+  }
+
   if (auxv & (HWCAP_SHA1 | HWCAP_SHA2)) {
     if (FLAG_IS_DEFAULT(UseSHA)) {
       FLAG_SET_DEFAULT(UseSHA, true);
--- a/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -506,6 +506,8 @@
     // Vector-Scalar (VSX) instruction support.
     LXVD2X_OPCODE  = (31u << OPCODE_SHIFT |  844u << 1),
     STXVD2X_OPCODE = (31u << OPCODE_SHIFT |  972u << 1),
+    MTVSRD_OPCODE  = (31u << OPCODE_SHIFT |  179u << 1),
+    MFVSRD_OPCODE  = (31u << OPCODE_SHIFT |   51u << 1),
 
     // Vector Permute and Formatting
     VPKPX_OPCODE   = (4u  << OPCODE_SHIFT |  782u     ),
@@ -1573,6 +1575,9 @@
   inline void stdu( Register d, int si16,    Register s1);
   inline void stdux(Register s, Register a,  Register b);
 
+  inline void st_ptr(Register d, int si16,    Register s1);
+  DEBUG_ONLY(inline void st_ptr(Register d, ByteSize b, Register s1);)
+
   // PPC 1, section 3.3.13 Move To/From System Register Instructions
   inline void mtlr( Register s1);
   inline void mflr( Register d);
@@ -2099,6 +2104,8 @@
   // Vector-Scalar (VSX) instructions.
   inline void lxvd2x(   VectorSRegister d, Register a, Register b);
   inline void stxvd2x(  VectorSRegister d, Register a, Register b);
+  inline void mtvrd(    VectorRegister  d, Register a);
+  inline void mfvrd(    Register        a, VectorRegister d);
 
   // AES (introduced with Power 8)
   inline void vcipher(     VectorRegister d, VectorRegister a, VectorRegister b);
--- a/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -349,6 +349,9 @@
 inline void Assembler::stdu( Register d, int si16,    Register s1) { emit_int32(STDU_OPCODE | rs(d) | ds(si16)   | rta0mem(s1));}
 inline void Assembler::stdux(Register s, Register a,  Register b)  { emit_int32(STDUX_OPCODE| rs(s) | rta0mem(a) | rb(b));}
 
+inline void Assembler::st_ptr(Register d, int b, Register s1) { std(d, b, s1); }
+DEBUG_ONLY(inline void Assembler::st_ptr(Register d, ByteSize b, Register s1) { std(d, in_bytes(b), s1); })
+
 // PPC 1, section 3.3.13 Move To/From System Register Instructions
 inline void Assembler::mtlr( Register s1)         { emit_int32(MTLR_OPCODE  | rs(s1)); }
 inline void Assembler::mflr( Register d )         { emit_int32(MFLR_OPCODE  | rt(d)); }
@@ -733,6 +736,8 @@
 // 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::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).
 
 inline void Assembler::vpkpx(   VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPKPX_OPCODE   | vrt(d) | vra(a) | vrb(b)); }
 inline void Assembler::vpkshss( VectorRegister d, VectorRegister a, VectorRegister b) { emit_int32( VPKSHSS_OPCODE | vrt(d) | vra(a) | vrb(b)); }
--- a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -157,10 +157,11 @@
 LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
                                             int shift, int disp, BasicType type) {
   assert(base->is_register(), "must be");
+  intx large_disp = disp;
 
   // Accumulate fixed displacements.
   if (index->is_constant()) {
-    disp += index->as_constant_ptr()->as_jint() << shift;
+    large_disp += (intx)(index->as_constant_ptr()->as_jint()) << shift;
     index = LIR_OprFact::illegalOpr;
   }
 
@@ -171,31 +172,31 @@
       __ shift_left(index, shift, tmp);
       index = tmp;
     }
-    if (disp != 0) {
+    if (large_disp != 0) {
       LIR_Opr tmp = new_pointer_register();
-      if (Assembler::is_simm16(disp)) {
-        __ add(index, LIR_OprFact::intptrConst(disp), tmp);
+      if (Assembler::is_simm16(large_disp)) {
+        __ add(index, LIR_OprFact::intptrConst(large_disp), tmp);
         index = tmp;
       } else {
-        __ move(LIR_OprFact::intptrConst(disp), tmp);
+        __ move(LIR_OprFact::intptrConst(large_disp), tmp);
         __ add(tmp, index, tmp);
         index = tmp;
       }
-      disp = 0;
+      large_disp = 0;
     }
-  } else if (!Assembler::is_simm16(disp)) {
+  } else if (!Assembler::is_simm16(large_disp)) {
     // Index is illegal so replace it with the displacement loaded into a register.
     index = new_pointer_register();
-    __ move(LIR_OprFact::intptrConst(disp), index);
-    disp = 0;
+    __ move(LIR_OprFact::intptrConst(large_disp), index);
+    large_disp = 0;
   }
 
   // At this point we either have base + index or base + displacement.
-  if (disp == 0) {
+  if (large_disp == 0) {
     return new LIR_Address(base, index, type);
   } else {
-    assert(Assembler::is_simm16(disp), "must be");
-    return new LIR_Address(base, disp, type);
+    assert(Assembler::is_simm16(large_disp), "must be");
+    return new LIR_Address(base, large_disp, type);
   }
 }
 
@@ -206,11 +207,11 @@
   int shift = exact_log2(elem_size);
 
   LIR_Opr base_opr;
-  int offset = arrayOopDesc::base_offset_in_bytes(type);
+  intx offset = arrayOopDesc::base_offset_in_bytes(type);
 
   if (index_opr->is_constant()) {
-    int i = index_opr->as_constant_ptr()->as_jint();
-    int array_offset = i * elem_size;
+    intx i = index_opr->as_constant_ptr()->as_jint();
+    intx array_offset = i * elem_size;
     if (Assembler::is_simm16(array_offset + offset)) {
       base_opr = array_opr;
       offset = array_offset + offset;
@@ -1433,6 +1434,10 @@
   }
 }
 
+void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) {
+  fatal("FMA intrinsic is not implemented on this platform");
+}
+
 void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
   fatal("vectorizedMismatch intrinsic is not implemented on this platform");
 }
--- a/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -261,6 +261,9 @@
 }
 
 void InterpreterMacroAssembler::push_l(Register r) {
+  // Clear unused slot.
+  load_const_optimized(R0, 0L);
+  std(R0, 0, R15_esp);
   std(r, - Interpreter::stackElementSize, R15_esp);
   addi(R15_esp, R15_esp, - 2 * Interpreter::stackElementSize );
 }
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -4332,6 +4332,565 @@
   BLOCK_COMMENT("} kernel_crc32_1byte");
 }
 
+/**
+ * @param crc             register containing existing CRC (32-bit)
+ * @param buf             register pointing to input byte buffer (byte*)
+ * @param len             register containing number of bytes
+ * @param table           register pointing to CRC table
+ * @param constants       register pointing to CRC table for 128-bit aligned memory
+ * @param barretConstants register pointing to table for barrett reduction
+ * @param t0              volatile register
+ * @param t1              volatile register
+ * @param t2              volatile register
+ * @param t3              volatile register
+ */
+void MacroAssembler::kernel_crc32_1word_vpmsumd(Register crc, Register buf, Register len, Register table,
+                        Register constants,  Register barretConstants,
+                        Register t0,  Register t1, Register t2, Register t3, Register t4) {
+  assert_different_registers(crc, buf, len, table);
+
+  Label L_alignedHead, L_tail, L_alignTail, L_start, L_end;
+
+  Register  prealign     = t0;
+  Register  postalign    = t0;
+
+  BLOCK_COMMENT("kernel_crc32_1word_vpmsumb {");
+
+  // 1. use kernel_crc32_1word for shorter than 384bit
+  clrldi(len, len, 32);
+  cmpdi(CCR0, len, 384);
+  bge(CCR0, L_start);
+
+    Register tc0 = t4;
+    Register tc1 = constants;
+    Register tc2 = barretConstants;
+    kernel_crc32_1word(crc, buf, len, table,t0, t1, t2, t3, tc0, tc1, tc2, table);
+    b(L_end);
+
+  BIND(L_start);
+
+    // 2. ~c
+    nand(crc, crc, crc);
+
+    // 3. calculate from 0 to first 128bit-aligned address
+    clrldi_(prealign, buf, 57);
+    beq(CCR0, L_alignedHead);
+
+    subfic(prealign, prealign, 128);
+
+    subf(len, prealign, len);
+    update_byteLoop_crc32(crc, buf, prealign, table, t2, false, false);
+
+    // 4. calculate from first 128bit-aligned address to last 128bit-aligned address
+    BIND(L_alignedHead);
+
+    clrldi(postalign, len, 57);
+    subf(len, postalign, len);
+
+    // len must be more than 256bit
+    kernel_crc32_1word_aligned(crc, buf, len, constants, barretConstants, t1, t2, t3);
+
+    // 5. calculate remaining
+    cmpdi(CCR0, postalign, 0);
+    beq(CCR0, L_tail);
+
+    update_byteLoop_crc32(crc, buf, postalign, table, t2, false, false);
+
+    BIND(L_tail);
+
+    // 6. ~c
+    nand(crc, crc, crc);
+
+  BIND(L_end);
+
+  BLOCK_COMMENT("} kernel_crc32_1word_vpmsumb");
+}
+
+/**
+ * @param crc             register containing existing CRC (32-bit)
+ * @param buf             register pointing to input byte buffer (byte*)
+ * @param len             register containing number of bytes
+ * @param constants       register pointing to CRC table for 128-bit aligned memory
+ * @param barretConstants register pointing to table for barrett reduction
+ * @param t0              volatile register
+ * @param t1              volatile register
+ * @param t2              volatile register
+ */
+void MacroAssembler::kernel_crc32_1word_aligned(Register crc, Register buf, Register len,
+    Register constants, Register barretConstants, Register t0, Register t1, Register t2) {
+  Label L_mainLoop, L_tail, L_alignTail, L_barrett_reduction, L_end, L_first_warm_up_done, L_first_cool_down, L_second_cool_down, L_XOR, L_test;
+  Label L_lv0, L_lv1, L_lv2, L_lv3, L_lv4, L_lv5, L_lv6, L_lv7, L_lv8, L_lv9, L_lv10, L_lv11, L_lv12, L_lv13, L_lv14, L_lv15;
+  Label L_1, L_2, L_3, L_4;
+
+  Register  rLoaded      = t0;
+  Register  rTmp1        = t1;
+  Register  rTmp2        = t2;
+  Register  off16        = R22;
+  Register  off32        = R23;
+  Register  off48        = R24;
+  Register  off64        = R25;
+  Register  off80        = R26;
+  Register  off96        = R27;
+  Register  off112       = R28;
+  Register  rIdx         = R29;
+  Register  rMax         = R30;
+  Register  constantsPos = R31;
+
+  VectorRegister mask_32bit = VR24;
+  VectorRegister mask_64bit = VR25;
+  VectorRegister zeroes     = VR26;
+  VectorRegister const1     = VR27;
+  VectorRegister const2     = VR28;
+
+  // Save non-volatile vector registers (frameless).
+  Register offset = t1;   int offsetInt = 0;
+  offsetInt -= 16; li(offset, -16);           stvx(VR20, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); stvx(VR21, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); stvx(VR22, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); stvx(VR23, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); stvx(VR24, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); stvx(VR25, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); stvx(VR26, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); stvx(VR27, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); stvx(VR28, offset, R1_SP);
+  offsetInt -= 8; std(R22, offsetInt, R1_SP);
+  offsetInt -= 8; std(R23, offsetInt, R1_SP);
+  offsetInt -= 8; std(R24, offsetInt, R1_SP);
+  offsetInt -= 8; std(R25, offsetInt, R1_SP);
+  offsetInt -= 8; std(R26, offsetInt, R1_SP);
+  offsetInt -= 8; std(R27, offsetInt, R1_SP);
+  offsetInt -= 8; std(R28, offsetInt, R1_SP);
+  offsetInt -= 8; std(R29, offsetInt, R1_SP);
+  offsetInt -= 8; std(R30, offsetInt, R1_SP);
+  offsetInt -= 8; std(R31, offsetInt, R1_SP);
+
+  // Set constants
+  li(off16, 16);
+  li(off32, 32);
+  li(off48, 48);
+  li(off64, 64);
+  li(off80, 80);
+  li(off96, 96);
+  li(off112, 112);
+
+  clrldi(crc, crc, 32);
+
+  vxor(zeroes, zeroes, zeroes);
+  vspltisw(VR0, -1);
+
+  vsldoi(mask_32bit, zeroes, VR0, 4);
+  vsldoi(mask_64bit, zeroes, VR0, -8);
+
+  // Get the initial value into v8
+  vxor(VR8, VR8, VR8);
+  mtvrd(VR8, crc);
+  vsldoi(VR8, zeroes, VR8, -8); // shift into bottom 32 bits
+
+  li (rLoaded, 0);
+
+  rldicr(rIdx, len, 0, 56);
+
+  {
+    BIND(L_1);
+    // Checksum in blocks of MAX_SIZE (32768)
+    lis(rMax, 0);
+    ori(rMax, rMax, 32768);
+    mr(rTmp2, rMax);
+    cmpd(CCR0, rIdx, rMax);
+    bgt(CCR0, L_2);
+    mr(rMax, rIdx);
+
+    BIND(L_2);
+    subf(rIdx, rMax, rIdx);
+
+    // our main loop does 128 bytes at a time
+    srdi(rMax, rMax, 7);
+
+    /*
+     * Work out the offset into the constants table to start at. Each
+     * constant is 16 bytes, and it is used against 128 bytes of input
+     * data - 128 / 16 = 8
+     */
+    sldi(rTmp1, rMax, 4);
+    srdi(rTmp2, rTmp2, 3);
+    subf(rTmp1, rTmp1, rTmp2);
+
+    // We reduce our final 128 bytes in a separate step
+    addi(rMax, rMax, -1);
+    mtctr(rMax);
+
+    // Find the start of our constants
+    add(constantsPos, constants, rTmp1);
+
+    // zero VR0-v7 which will contain our checksums
+    vxor(VR0, VR0, VR0);
+    vxor(VR1, VR1, VR1);
+    vxor(VR2, VR2, VR2);
+    vxor(VR3, VR3, VR3);
+    vxor(VR4, VR4, VR4);
+    vxor(VR5, VR5, VR5);
+    vxor(VR6, VR6, VR6);
+    vxor(VR7, VR7, VR7);
+
+    lvx(const1, constantsPos);
+
+    /*
+     * If we are looping back to consume more data we use the values
+     * already in VR16-v23.
+     */
+    cmpdi(CCR0, rLoaded, 1);
+    beq(CCR0, L_3);
+    {
+
+      // First warm up pass
+      lvx(VR16, buf);
+      lvx(VR17, off16, buf);
+      lvx(VR18, off32, buf);
+      lvx(VR19, off48, buf);
+      lvx(VR20, off64, buf);
+      lvx(VR21, off80, buf);
+      lvx(VR22, off96, buf);
+      lvx(VR23, off112, buf);
+      addi(buf, buf, 8*16);
+
+      // xor in initial value
+      vxor(VR16, VR16, VR8);
+    }
+
+    BIND(L_3);
+    bdz(L_first_warm_up_done);
+
+    addi(constantsPos, constantsPos, 16);
+    lvx(const2, constantsPos);
+
+    // Second warm up pass
+    vpmsumd(VR8, VR16, const1);
+    lvx(VR16, buf);
+
+    vpmsumd(VR9, VR17, const1);
+    lvx(VR17, off16, buf);
+
+    vpmsumd(VR10, VR18, const1);
+    lvx(VR18, off32, buf);
+
+    vpmsumd(VR11, VR19, const1);
+    lvx(VR19, off48, buf);
+
+    vpmsumd(VR12, VR20, const1);
+    lvx(VR20, off64, buf);
+
+    vpmsumd(VR13, VR21, const1);
+    lvx(VR21, off80, buf);
+
+    vpmsumd(VR14, VR22, const1);
+    lvx(VR22, off96, buf);
+
+    vpmsumd(VR15, VR23, const1);
+    lvx(VR23, off112, buf);
+
+    addi(buf, buf, 8 * 16);
+
+    bdz(L_first_cool_down);
+
+    /*
+     * main loop. We modulo schedule it such that it takes three iterations
+     * to complete - first iteration load, second iteration vpmsum, third
+     * iteration xor.
+     */
+    {
+      BIND(L_4);
+      lvx(const1, constantsPos); addi(constantsPos, constantsPos, 16);
+
+      vxor(VR0, VR0, VR8);
+      vpmsumd(VR8, VR16, const2);
+      lvx(VR16, buf);
+
+      vxor(VR1, VR1, VR9);
+      vpmsumd(VR9, VR17, const2);
+      lvx(VR17, off16, buf);
+
+      vxor(VR2, VR2, VR10);
+      vpmsumd(VR10, VR18, const2);
+      lvx(VR18, off32, buf);
+
+      vxor(VR3, VR3, VR11);
+      vpmsumd(VR11, VR19, const2);
+      lvx(VR19, off48, buf);
+      lvx(const2, constantsPos);
+
+      vxor(VR4, VR4, VR12);
+      vpmsumd(VR12, VR20, const1);
+      lvx(VR20, off64, buf);
+
+      vxor(VR5, VR5, VR13);
+      vpmsumd(VR13, VR21, const1);
+      lvx(VR21, off80, buf);
+
+      vxor(VR6, VR6, VR14);
+      vpmsumd(VR14, VR22, const1);
+      lvx(VR22, off96, buf);
+
+      vxor(VR7, VR7, VR15);
+      vpmsumd(VR15, VR23, const1);
+      lvx(VR23, off112, buf);
+
+      addi(buf, buf, 8 * 16);
+
+      bdnz(L_4);
+    }
+
+    BIND(L_first_cool_down);
+
+    // First cool down pass
+    lvx(const1, constantsPos);
+    addi(constantsPos, constantsPos, 16);
+
+    vxor(VR0, VR0, VR8);
+    vpmsumd(VR8, VR16, const1);
+
+    vxor(VR1, VR1, VR9);
+    vpmsumd(VR9, VR17, const1);
+
+    vxor(VR2, VR2, VR10);
+    vpmsumd(VR10, VR18, const1);
+
+    vxor(VR3, VR3, VR11);
+    vpmsumd(VR11, VR19, const1);
+
+    vxor(VR4, VR4, VR12);
+    vpmsumd(VR12, VR20, const1);
+
+    vxor(VR5, VR5, VR13);
+    vpmsumd(VR13, VR21, const1);
+
+    vxor(VR6, VR6, VR14);
+    vpmsumd(VR14, VR22, const1);
+
+    vxor(VR7, VR7, VR15);
+    vpmsumd(VR15, VR23, const1);
+
+    BIND(L_second_cool_down);
+    // Second cool down pass
+    vxor(VR0, VR0, VR8);
+    vxor(VR1, VR1, VR9);
+    vxor(VR2, VR2, VR10);
+    vxor(VR3, VR3, VR11);
+    vxor(VR4, VR4, VR12);
+    vxor(VR5, VR5, VR13);
+    vxor(VR6, VR6, VR14);
+    vxor(VR7, VR7, VR15);
+
+    /*
+     * vpmsumd produces a 96 bit result in the least significant bits
+     * of the register. Since we are bit reflected we have to shift it
+     * left 32 bits so it occupies the least significant bits in the
+     * bit reflected domain.
+     */
+    vsldoi(VR0, VR0, zeroes, 4);
+    vsldoi(VR1, VR1, zeroes, 4);
+    vsldoi(VR2, VR2, zeroes, 4);
+    vsldoi(VR3, VR3, zeroes, 4);
+    vsldoi(VR4, VR4, zeroes, 4);
+    vsldoi(VR5, VR5, zeroes, 4);
+    vsldoi(VR6, VR6, zeroes, 4);
+    vsldoi(VR7, VR7, zeroes, 4);
+
+    // xor with last 1024 bits
+    lvx(VR8, buf);
+    lvx(VR9, off16, buf);
+    lvx(VR10, off32, buf);
+    lvx(VR11, off48, buf);
+    lvx(VR12, off64, buf);
+    lvx(VR13, off80, buf);
+    lvx(VR14, off96, buf);
+    lvx(VR15, off112, buf);
+    addi(buf, buf, 8 * 16);
+
+    vxor(VR16, VR0, VR8);
+    vxor(VR17, VR1, VR9);
+    vxor(VR18, VR2, VR10);
+    vxor(VR19, VR3, VR11);
+    vxor(VR20, VR4, VR12);
+    vxor(VR21, VR5, VR13);
+    vxor(VR22, VR6, VR14);
+    vxor(VR23, VR7, VR15);
+
+    li(rLoaded, 1);
+    cmpdi(CCR0, rIdx, 0);
+    addi(rIdx, rIdx, 128);
+    bne(CCR0, L_1);
+  }
+
+  // Work out how many bytes we have left
+  andi_(len, len, 127);
+
+  // Calculate where in the constant table we need to start
+  subfic(rTmp1, len, 128);
+  add(constantsPos, constantsPos, rTmp1);
+
+  // How many 16 byte chunks are in the tail
+  srdi(rIdx, len, 4);
+  mtctr(rIdx);
+
+  /*
+   * Reduce the previously calculated 1024 bits to 64 bits, shifting
+   * 32 bits to include the trailing 32 bits of zeros
+   */
+  lvx(VR0, constantsPos);
+  lvx(VR1, off16, constantsPos);
+  lvx(VR2, off32, constantsPos);
+  lvx(VR3, off48, constantsPos);
+  lvx(VR4, off64, constantsPos);
+  lvx(VR5, off80, constantsPos);
+  lvx(VR6, off96, constantsPos);
+  lvx(VR7, off112, constantsPos);
+  addi(constantsPos, constantsPos, 8 * 16);
+
+  vpmsumw(VR0, VR16, VR0);
+  vpmsumw(VR1, VR17, VR1);
+  vpmsumw(VR2, VR18, VR2);
+  vpmsumw(VR3, VR19, VR3);
+  vpmsumw(VR4, VR20, VR4);
+  vpmsumw(VR5, VR21, VR5);
+  vpmsumw(VR6, VR22, VR6);
+  vpmsumw(VR7, VR23, VR7);
+
+  // Now reduce the tail (0 - 112 bytes)
+  cmpdi(CCR0, rIdx, 0);
+  beq(CCR0, L_XOR);
+
+  lvx(VR16, buf); addi(buf, buf, 16);
+  lvx(VR17, constantsPos);
+  vpmsumw(VR16, VR16, VR17);
+  vxor(VR0, VR0, VR16);
+  beq(CCR0, L_XOR);
+
+  lvx(VR16, buf); addi(buf, buf, 16);
+  lvx(VR17, off16, constantsPos);
+  vpmsumw(VR16, VR16, VR17);
+  vxor(VR0, VR0, VR16);
+  beq(CCR0, L_XOR);
+
+  lvx(VR16, buf); addi(buf, buf, 16);
+  lvx(VR17, off32, constantsPos);
+  vpmsumw(VR16, VR16, VR17);
+  vxor(VR0, VR0, VR16);
+  beq(CCR0, L_XOR);
+
+  lvx(VR16, buf); addi(buf, buf, 16);
+  lvx(VR17, off48,constantsPos);
+  vpmsumw(VR16, VR16, VR17);
+  vxor(VR0, VR0, VR16);
+  beq(CCR0, L_XOR);
+
+  lvx(VR16, buf); addi(buf, buf, 16);
+  lvx(VR17, off64, constantsPos);
+  vpmsumw(VR16, VR16, VR17);
+  vxor(VR0, VR0, VR16);
+  beq(CCR0, L_XOR);
+
+  lvx(VR16, buf); addi(buf, buf, 16);
+  lvx(VR17, off80, constantsPos);
+  vpmsumw(VR16, VR16, VR17);
+  vxor(VR0, VR0, VR16);
+  beq(CCR0, L_XOR);
+
+  lvx(VR16, buf); addi(buf, buf, 16);
+  lvx(VR17, off96, constantsPos);
+  vpmsumw(VR16, VR16, VR17);
+  vxor(VR0, VR0, VR16);
+
+  // Now xor all the parallel chunks together
+  BIND(L_XOR);
+  vxor(VR0, VR0, VR1);
+  vxor(VR2, VR2, VR3);
+  vxor(VR4, VR4, VR5);
+  vxor(VR6, VR6, VR7);
+
+  vxor(VR0, VR0, VR2);
+  vxor(VR4, VR4, VR6);
+
+  vxor(VR0, VR0, VR4);
+
+  b(L_barrett_reduction);
+
+  BIND(L_first_warm_up_done);
+  lvx(const1, constantsPos);
+  addi(constantsPos, constantsPos, 16);
+  vpmsumd(VR8,  VR16, const1);
+  vpmsumd(VR9,  VR17, const1);
+  vpmsumd(VR10, VR18, const1);
+  vpmsumd(VR11, VR19, const1);
+  vpmsumd(VR12, VR20, const1);
+  vpmsumd(VR13, VR21, const1);
+  vpmsumd(VR14, VR22, const1);
+  vpmsumd(VR15, VR23, const1);
+  b(L_second_cool_down);
+
+  BIND(L_barrett_reduction);
+
+  lvx(const1, barretConstants);
+  addi(barretConstants, barretConstants, 16);
+  lvx(const2, barretConstants);
+
+  vsldoi(VR1, VR0, VR0, -8);
+  vxor(VR0, VR0, VR1);    // xor two 64 bit results together
+
+  // shift left one bit
+  vspltisb(VR1, 1);
+  vsl(VR0, VR0, VR1);
+
+  vand(VR0, VR0, mask_64bit);
+
+  /*
+   * The reflected version of Barrett reduction. Instead of bit
+   * reflecting our data (which is expensive to do), we bit reflect our
+   * constants and our algorithm, which means the intermediate data in
+   * our vector registers goes from 0-63 instead of 63-0. We can reflect
+   * the algorithm because we don't carry in mod 2 arithmetic.
+   */
+  vand(VR1, VR0, mask_32bit);  // bottom 32 bits of a
+  vpmsumd(VR1, VR1, const1);   // ma
+  vand(VR1, VR1, mask_32bit);  // bottom 32bits of ma
+  vpmsumd(VR1, VR1, const2);   // qn */
+  vxor(VR0, VR0, VR1);         // a - qn, subtraction is xor in GF(2)
+
+  /*
+   * Since we are bit reflected, the result (ie the low 32 bits) is in
+   * the high 32 bits. We just need to shift it left 4 bytes
+   * V0 [ 0 1 X 3 ]
+   * V0 [ 0 X 2 3 ]
+   */
+  vsldoi(VR0, VR0, zeroes, 4);    // shift result into top 64 bits of
+
+  // Get it into r3
+  mfvrd(crc, VR0);
+
+  BIND(L_end);
+
+  offsetInt = 0;
+  // Restore non-volatile Vector registers (frameless).
+  offsetInt -= 16; li(offset, -16);           lvx(VR20, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); lvx(VR21, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); lvx(VR22, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); lvx(VR23, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); lvx(VR24, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); lvx(VR25, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); lvx(VR26, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); lvx(VR27, offset, R1_SP);
+  offsetInt -= 16; addi(offset, offset, -16); lvx(VR28, offset, R1_SP);
+  offsetInt -= 8;  ld(R22, offsetInt, R1_SP);
+  offsetInt -= 8;  ld(R23, offsetInt, R1_SP);
+  offsetInt -= 8;  ld(R24, offsetInt, R1_SP);
+  offsetInt -= 8;  ld(R25, offsetInt, R1_SP);
+  offsetInt -= 8;  ld(R26, offsetInt, R1_SP);
+  offsetInt -= 8;  ld(R27, offsetInt, R1_SP);
+  offsetInt -= 8;  ld(R28, offsetInt, R1_SP);
+  offsetInt -= 8;  ld(R29, offsetInt, R1_SP);
+  offsetInt -= 8;  ld(R30, offsetInt, R1_SP);
+  offsetInt -= 8;  ld(R31, offsetInt, R1_SP);
+}
+
 void MacroAssembler::kernel_crc32_singleByte(Register crc, Register buf, Register len, Register table, Register tmp) {
   assert_different_registers(crc, buf, /* len,  not used!! */ table, tmp);
 
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -834,6 +834,13 @@
                           Register tc0, Register tc1, Register tc2, Register tc3);
   void kernel_crc32_1byte(Register crc, Register buf, Register len, Register table,
                           Register t0,  Register t1,  Register t2,  Register t3);
+  void kernel_crc32_1word_vpmsumd(Register crc, Register buf, Register len, Register table,
+                          Register constants, Register barretConstants,
+                          Register t0,  Register t1, Register t2, Register t3, Register t4);
+  void kernel_crc32_1word_aligned(Register crc, Register buf, Register len,
+                          Register constants, Register barretConstants,
+                          Register t0, Register t1, Register t2);
+
   void kernel_crc32_singleByte(Register crc, Register buf, Register len, Register table, Register tmp);
 
   //
--- a/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -2489,6 +2489,11 @@
     __ verify_oop(R3_RET);
   }
 
+  if (CheckJNICalls) {
+    // clear_pending_jni_exception_check
+    __ load_const_optimized(R0, 0L);
+    __ st_ptr(R0, JavaThread::pending_jni_exception_check_fn_offset(), R16_thread);
+  }
 
   // Reset handle block.
   // --------------------------------------------------------------------------
--- a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -3205,28 +3205,59 @@
     const Register crc     = R3_ARG1;  // Current checksum, preset by caller or result from previous call.
     const Register data    = R4_ARG2;  // source byte array
     const Register dataLen = R5_ARG3;  // #bytes to process
-    const Register table   = R6_ARG4;  // crc table address
-
-    const Register t0      = R2;
-    const Register t1      = R7;
-    const Register t2      = R8;
-    const Register t3      = R9;
-    const Register tc0     = R10;
-    const Register tc1     = R11;
-    const Register tc2     = R12;
-
-    BLOCK_COMMENT("Stub body {");
-    assert_different_registers(crc, data, dataLen, table);
-
-    StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
-
-    __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, table);
-
-    BLOCK_COMMENT("return");
-    __ mr_if_needed(R3_RET, crc);      // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
-    __ blr();
-
-    BLOCK_COMMENT("} Stub body");
+
+    const Register table   = R6;       // crc table address
+
+#ifdef VM_LITTLE_ENDIAN
+    if (VM_Version::has_vpmsumb()) {
+      const Register constants    = R2;  // constants address
+      const Register bconstants   = R8;  // barret table address
+
+      const Register t0      = R9;
+      const Register t1      = R10;
+      const Register t2      = R11;
+      const Register t3      = R12;
+      const Register t4      = R7;
+
+      BLOCK_COMMENT("Stub body {");
+      assert_different_registers(crc, data, dataLen, table);
+
+      StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
+      StubRoutines::ppc64::generate_load_crc_constants_addr(_masm, constants);
+      StubRoutines::ppc64::generate_load_crc_barret_constants_addr(_masm, bconstants);
+
+      __ kernel_crc32_1word_vpmsumd(crc, data, dataLen, table, constants, bconstants, t0, t1, t2, t3, t4);
+
+      BLOCK_COMMENT("return");
+      __ mr_if_needed(R3_RET, crc);      // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
+      __ blr();
+
+      BLOCK_COMMENT("} Stub body");
+    } else
+#endif
+    {
+      const Register t0      = R2;
+      const Register t1      = R7;
+      const Register t2      = R8;
+      const Register t3      = R9;
+      const Register tc0     = R10;
+      const Register tc1     = R11;
+      const Register tc2     = R12;
+
+      BLOCK_COMMENT("Stub body {");
+      assert_different_registers(crc, data, dataLen, table);
+
+      StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
+
+      __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, table);
+
+      BLOCK_COMMENT("return");
+      __ mr_if_needed(R3_RET, crc);      // Updated crc is function result. No copying required (R3_ARG1 == R3_RET).
+      __ blr();
+
+      BLOCK_COMMENT("} Stub body");
+    }
+
     return start;
   }
 
--- a/hotspot/src/cpu/ppc/vm/stubRoutines_ppc.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/stubRoutines_ppc.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -45,6 +45,8 @@
 #else
   #define CRC32_TABLES 1
 #endif
+#define CRC32_CONSTANTS_SIZE 1084
+#define CRC32_BARRET_CONSTANTS 10
 
 class ppc64 {
  friend class StubGenerator;
@@ -53,11 +55,17 @@
 
   // CRC32 Intrinsics.
   static juint _crc_table[CRC32_TABLES][CRC32_COLUMN_SIZE];
+  static juint* _constants;
+  static juint* _barret_constants;
 
  public:
 
   // CRC32 Intrinsics.
   static void generate_load_crc_table_addr(MacroAssembler* masm, Register table);
+  static void generate_load_crc_constants_addr(MacroAssembler* masm, Register table);
+  static void generate_load_crc_barret_constants_addr(MacroAssembler* masm, Register table);
+  static juint* generate_crc_constants();
+  static juint* generate_crc_barret_constants();
 
 };
 
--- a/hotspot/src/cpu/ppc/vm/stubRoutines_ppc_64.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/stubRoutines_ppc_64.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -37,6 +37,311 @@
   __ load_const_optimized(table, StubRoutines::_crc_table_adr, R0);
 }
 
+void StubRoutines::ppc64::generate_load_crc_constants_addr(MacroAssembler* masm, Register table) {
+  __ load_const_optimized(table, (address)StubRoutines::ppc64::_constants, R0);
+}
+
+void StubRoutines::ppc64::generate_load_crc_barret_constants_addr(MacroAssembler* masm, Register table) {
+  __ load_const_optimized(table, (address)StubRoutines::ppc64::_barret_constants, R0);
+}
+
+juint* StubRoutines::ppc64::generate_crc_constants() {
+  juint constants[CRC32_CONSTANTS_SIZE] = {
+      // Reduce 262144 kbits to 1024 bits
+      0x99ea94a8UL, 0x00000000UL, 0x651797d2UL, 0x00000001UL,       // x^261120 mod p(x)` << 1, x^261184 mod p(x)` << 1
+      0x945a8420UL, 0x00000000UL, 0x21e0d56cUL, 0x00000000UL,       // x^260096 mod p(x)` << 1, x^260160 mod p(x)` << 1
+      0x30762706UL, 0x00000000UL, 0x0f95ecaaUL, 0x00000000UL,       // x^259072 mod p(x)` << 1, x^259136 mod p(x)` << 1
+      0xa52fc582UL, 0x00000001UL, 0xebd224acUL, 0x00000001UL,       // x^258048 mod p(x)` << 1, x^258112 mod p(x)` << 1
+      0xa4a7167aUL, 0x00000001UL, 0x0ccb97caUL, 0x00000000UL,       // x^257024 mod p(x)` << 1, x^257088 mod p(x)` << 1
+      0x0c18249aUL, 0x00000000UL, 0x006ec8a8UL, 0x00000001UL,       // x^256000 mod p(x)` << 1, x^256064 mod p(x)` << 1
+      0xa924ae7cUL, 0x00000000UL, 0x4f58f196UL, 0x00000001UL,       // x^254976 mod p(x)` << 1, x^255040 mod p(x)` << 1
+      0xe12ccc12UL, 0x00000001UL, 0xa7192ca6UL, 0x00000001UL,       // x^253952 mod p(x)` << 1, x^254016 mod p(x)` << 1
+      0xa0b9d4acUL, 0x00000000UL, 0x9a64bab2UL, 0x00000001UL,       // x^252928 mod p(x)` << 1, x^252992 mod p(x)` << 1
+      0x95e8ddfeUL, 0x00000000UL, 0x14f4ed2eUL, 0x00000000UL,       // x^251904 mod p(x)` << 1, x^251968 mod p(x)` << 1
+      0x233fddc4UL, 0x00000000UL, 0x1092b6a2UL, 0x00000001UL,       // x^250880 mod p(x)` << 1, x^250944 mod p(x)` << 1
+      0xb4529b62UL, 0x00000001UL, 0xc8a1629cUL, 0x00000000UL,       // x^249856 mod p(x)` << 1, x^249920 mod p(x)` << 1
+      0xa7fa0e64UL, 0x00000001UL, 0x7bf32e8eUL, 0x00000001UL,       // x^248832 mod p(x)` << 1, x^248896 mod p(x)` << 1
+      0xb5334592UL, 0x00000001UL, 0xf8cc6582UL, 0x00000001UL,       // x^247808 mod p(x)` << 1, x^247872 mod p(x)` << 1
+      0x1f8ee1b4UL, 0x00000001UL, 0x8631ddf0UL, 0x00000000UL,       // x^246784 mod p(x)` << 1, x^246848 mod p(x)` << 1
+      0x6252e632UL, 0x00000000UL, 0x7e5a76d0UL, 0x00000000UL,       // x^245760 mod p(x)` << 1, x^245824 mod p(x)` << 1
+      0xab973e84UL, 0x00000000UL, 0x2b09b31cUL, 0x00000000UL,       // x^244736 mod p(x)` << 1, x^244800 mod p(x)` << 1
+      0x7734f5ecUL, 0x00000000UL, 0xb2df1f84UL, 0x00000001UL,       // x^243712 mod p(x)` << 1, x^243776 mod p(x)` << 1
+      0x7c547798UL, 0x00000000UL, 0xd6f56afcUL, 0x00000001UL,       // x^242688 mod p(x)` << 1, x^242752 mod p(x)` << 1
+      0x7ec40210UL, 0x00000000UL, 0xb9b5e70cUL, 0x00000001UL,       // x^241664 mod p(x)` << 1, x^241728 mod p(x)` << 1
+      0xab1695a8UL, 0x00000001UL, 0x34b626d2UL, 0x00000000UL,       // x^240640 mod p(x)` << 1, x^240704 mod p(x)` << 1
+      0x90494bbaUL, 0x00000000UL, 0x4c53479aUL, 0x00000001UL,       // x^239616 mod p(x)` << 1, x^239680 mod p(x)` << 1
+      0x123fb816UL, 0x00000001UL, 0xa6d179a4UL, 0x00000001UL,       // x^238592 mod p(x)` << 1, x^238656 mod p(x)` << 1
+      0xe188c74cUL, 0x00000001UL, 0x5abd16b4UL, 0x00000001UL,       // x^237568 mod p(x)` << 1, x^237632 mod p(x)` << 1
+      0xc2d3451cUL, 0x00000001UL, 0x018f9852UL, 0x00000000UL,       // x^236544 mod p(x)` << 1, x^236608 mod p(x)` << 1
+      0xf55cf1caUL, 0x00000000UL, 0x1fb3084aUL, 0x00000000UL,       // x^235520 mod p(x)` << 1, x^235584 mod p(x)` << 1
+      0xa0531540UL, 0x00000001UL, 0xc53dfb04UL, 0x00000000UL,       // x^234496 mod p(x)` << 1, x^234560 mod p(x)` << 1
+      0x32cd7ebcUL, 0x00000001UL, 0xe10c9ad6UL, 0x00000000UL,       // x^233472 mod p(x)` << 1, x^233536 mod p(x)` << 1
+      0x73ab7f36UL, 0x00000000UL, 0x25aa994aUL, 0x00000000UL,       // x^232448 mod p(x)` << 1, x^232512 mod p(x)` << 1
+      0x41aed1c2UL, 0x00000000UL, 0xfa3a74c4UL, 0x00000000UL,       // x^231424 mod p(x)` << 1, x^231488 mod p(x)` << 1
+      0x36c53800UL, 0x00000001UL, 0x33eb3f40UL, 0x00000000UL,       // x^230400 mod p(x)` << 1, x^230464 mod p(x)` << 1
+      0x26835a30UL, 0x00000001UL, 0x7193f296UL, 0x00000001UL,       // x^229376 mod p(x)` << 1, x^229440 mod p(x)` << 1
+      0x6241b502UL, 0x00000000UL, 0x43f6c86aUL, 0x00000000UL,       // x^228352 mod p(x)` << 1, x^228416 mod p(x)` << 1
+      0xd5196ad4UL, 0x00000000UL, 0x6b513ec6UL, 0x00000001UL,       // x^227328 mod p(x)` << 1, x^227392 mod p(x)` << 1
+      0x9cfa769aUL, 0x00000000UL, 0xc8f25b4eUL, 0x00000000UL,       // x^226304 mod p(x)` << 1, x^226368 mod p(x)` << 1
+      0x920e5df4UL, 0x00000000UL, 0xa45048ecUL, 0x00000001UL,       // x^225280 mod p(x)` << 1, x^225344 mod p(x)` << 1
+      0x69dc310eUL, 0x00000001UL, 0x0c441004UL, 0x00000000UL,       // x^224256 mod p(x)` << 1, x^224320 mod p(x)` << 1
+      0x09fc331cUL, 0x00000000UL, 0x0e17cad6UL, 0x00000000UL,       // x^223232 mod p(x)` << 1, x^223296 mod p(x)` << 1
+      0x0d94a81eUL, 0x00000001UL, 0x253ae964UL, 0x00000001UL,       // x^222208 mod p(x)` << 1, x^222272 mod p(x)` << 1
+      0x27a20ab2UL, 0x00000000UL, 0xd7c88ebcUL, 0x00000001UL,       // x^221184 mod p(x)` << 1, x^221248 mod p(x)` << 1
+      0x14f87504UL, 0x00000001UL, 0xe7ca913aUL, 0x00000001UL,       // x^220160 mod p(x)` << 1, x^220224 mod p(x)` << 1
+      0x4b076d96UL, 0x00000000UL, 0x33ed078aUL, 0x00000000UL,       // x^219136 mod p(x)` << 1, x^219200 mod p(x)` << 1
+      0xda4d1e74UL, 0x00000000UL, 0xe1839c78UL, 0x00000000UL,       // x^218112 mod p(x)` << 1, x^218176 mod p(x)` << 1
+      0x1b81f672UL, 0x00000000UL, 0x322b267eUL, 0x00000001UL,       // x^217088 mod p(x)` << 1, x^217152 mod p(x)` << 1
+      0x9367c988UL, 0x00000000UL, 0x638231b6UL, 0x00000000UL,       // x^216064 mod p(x)` << 1, x^216128 mod p(x)` << 1
+      0x717214caUL, 0x00000001UL, 0xee7f16f4UL, 0x00000001UL,       // x^215040 mod p(x)` << 1, x^215104 mod p(x)` << 1
+      0x9f47d820UL, 0x00000000UL, 0x17d9924aUL, 0x00000001UL,       // x^214016 mod p(x)` << 1, x^214080 mod p(x)` << 1
+      0x0d9a47d2UL, 0x00000001UL, 0xe1a9e0c4UL, 0x00000000UL,       // x^212992 mod p(x)` << 1, x^213056 mod p(x)` << 1
+      0xa696c58cUL, 0x00000000UL, 0x403731dcUL, 0x00000001UL,       // x^211968 mod p(x)` << 1, x^212032 mod p(x)` << 1
+      0x2aa28ec6UL, 0x00000000UL, 0xa5ea9682UL, 0x00000001UL,       // x^210944 mod p(x)` << 1, x^211008 mod p(x)` << 1
+      0xfe18fd9aUL, 0x00000001UL, 0x01c5c578UL, 0x00000001UL,       // x^209920 mod p(x)` << 1, x^209984 mod p(x)` << 1
+      0x9d4fc1aeUL, 0x00000001UL, 0xdddf6494UL, 0x00000000UL,       // x^208896 mod p(x)` << 1, x^208960 mod p(x)` << 1
+      0xba0e3deaUL, 0x00000001UL, 0xf1c3db28UL, 0x00000000UL,       // x^207872 mod p(x)` << 1, x^207936 mod p(x)` << 1
+      0x74b59a5eUL, 0x00000000UL, 0x3112fb9cUL, 0x00000001UL,       // x^206848 mod p(x)` << 1, x^206912 mod p(x)` << 1
+      0xf2b5ea98UL, 0x00000000UL, 0xb680b906UL, 0x00000000UL,       // x^205824 mod p(x)` << 1, x^205888 mod p(x)` << 1
+      0x87132676UL, 0x00000001UL, 0x1a282932UL, 0x00000000UL,       // x^204800 mod p(x)` << 1, x^204864 mod p(x)` << 1
+      0x0a8c6ad4UL, 0x00000001UL, 0x89406e7eUL, 0x00000000UL,       // x^203776 mod p(x)` << 1, x^203840 mod p(x)` << 1
+      0xe21dfe70UL, 0x00000001UL, 0xdef6be8cUL, 0x00000001UL,       // x^202752 mod p(x)` << 1, x^202816 mod p(x)` << 1
+      0xda0050e4UL, 0x00000001UL, 0x75258728UL, 0x00000000UL,       // x^201728 mod p(x)` << 1, x^201792 mod p(x)` << 1
+      0x772172aeUL, 0x00000000UL, 0x9536090aUL, 0x00000001UL,       // x^200704 mod p(x)` << 1, x^200768 mod p(x)` << 1
+      0xe47724aaUL, 0x00000000UL, 0xf2455bfcUL, 0x00000000UL,       // x^199680 mod p(x)` << 1, x^199744 mod p(x)` << 1
+      0x3cd63ac4UL, 0x00000000UL, 0x8c40baf4UL, 0x00000001UL,       // x^198656 mod p(x)` << 1, x^198720 mod p(x)` << 1
+      0xbf47d352UL, 0x00000001UL, 0x4cd390d4UL, 0x00000000UL,       // x^197632 mod p(x)` << 1, x^197696 mod p(x)` << 1
+      0x8dc1d708UL, 0x00000001UL, 0xe4ece95aUL, 0x00000001UL,       // x^196608 mod p(x)` << 1, x^196672 mod p(x)` << 1
+      0x2d4620a4UL, 0x00000000UL, 0x1a3ee918UL, 0x00000000UL,       // x^195584 mod p(x)` << 1, x^195648 mod p(x)` << 1
+      0x58fd1740UL, 0x00000000UL, 0x7c652fb8UL, 0x00000000UL,       // x^194560 mod p(x)` << 1, x^194624 mod p(x)` << 1
+      0xdadd9bfcUL, 0x00000000UL, 0x1c67842cUL, 0x00000001UL,       // x^193536 mod p(x)` << 1, x^193600 mod p(x)` << 1
+      0xea2140beUL, 0x00000001UL, 0x254f759cUL, 0x00000000UL,       // x^192512 mod p(x)` << 1, x^192576 mod p(x)` << 1
+      0x9de128baUL, 0x00000000UL, 0x7ece94caUL, 0x00000000UL,       // x^191488 mod p(x)` << 1, x^191552 mod p(x)` << 1
+      0x3ac3aa8eUL, 0x00000001UL, 0x38f258c2UL, 0x00000000UL,       // x^190464 mod p(x)` << 1, x^190528 mod p(x)` << 1
+      0x99980562UL, 0x00000000UL, 0xcdf17b00UL, 0x00000001UL,       // x^189440 mod p(x)` << 1, x^189504 mod p(x)` << 1
+      0xc1579c86UL, 0x00000001UL, 0x1f882c16UL, 0x00000001UL,       // x^188416 mod p(x)` << 1, x^188480 mod p(x)` << 1
+      0x68dbbf94UL, 0x00000000UL, 0x00093fc8UL, 0x00000001UL,       // x^187392 mod p(x)` << 1, x^187456 mod p(x)` << 1
+      0x4509fb04UL, 0x00000000UL, 0xcd684f16UL, 0x00000001UL,       // x^186368 mod p(x)` << 1, x^186432 mod p(x)` << 1
+      0x202f6398UL, 0x00000001UL, 0x4bc6a70aUL, 0x00000000UL,       // x^185344 mod p(x)` << 1, x^185408 mod p(x)` << 1
+      0x3aea243eUL, 0x00000001UL, 0x4fc7e8e4UL, 0x00000000UL,       // x^184320 mod p(x)` << 1, x^184384 mod p(x)` << 1
+      0xb4052ae6UL, 0x00000001UL, 0x30103f1cUL, 0x00000001UL,       // x^183296 mod p(x)` << 1, x^183360 mod p(x)` << 1
+      0xcd2a0ae8UL, 0x00000001UL, 0x11b0024cUL, 0x00000001UL,       // x^182272 mod p(x)` << 1, x^182336 mod p(x)` << 1
+      0xfe4aa8b4UL, 0x00000001UL, 0x0b3079daUL, 0x00000001UL,       // x^181248 mod p(x)` << 1, x^181312 mod p(x)` << 1
+      0xd1559a42UL, 0x00000001UL, 0x0192bcc2UL, 0x00000001UL,       // x^180224 mod p(x)` << 1, x^180288 mod p(x)` << 1
+      0xf3e05eccUL, 0x00000001UL, 0x74838d50UL, 0x00000000UL,       // x^179200 mod p(x)` << 1, x^179264 mod p(x)` << 1
+      0x04ddd2ccUL, 0x00000001UL, 0x1b20f520UL, 0x00000000UL,       // x^178176 mod p(x)` << 1, x^178240 mod p(x)` << 1
+      0x5393153cUL, 0x00000001UL, 0x50c3590aUL, 0x00000000UL,       // x^177152 mod p(x)` << 1, x^177216 mod p(x)` << 1
+      0x57e942c6UL, 0x00000000UL, 0xb41cac8eUL, 0x00000000UL,       // x^176128 mod p(x)` << 1, x^176192 mod p(x)` << 1
+      0x2c633850UL, 0x00000001UL, 0x0c72cc78UL, 0x00000000UL,       // x^175104 mod p(x)` << 1, x^175168 mod p(x)` << 1
+      0xebcaae4cUL, 0x00000000UL, 0x30cdb032UL, 0x00000000UL,       // x^174080 mod p(x)` << 1, x^174144 mod p(x)` << 1
+      0x3ee532a6UL, 0x00000001UL, 0x3e09fc32UL, 0x00000001UL,       // x^173056 mod p(x)` << 1, x^173120 mod p(x)` << 1
+      0xbf0cbc7eUL, 0x00000001UL, 0x1ed624d2UL, 0x00000000UL,       // x^172032 mod p(x)` << 1, x^172096 mod p(x)` << 1
+      0xd50b7a5aUL, 0x00000000UL, 0x781aee1aUL, 0x00000000UL,       // x^171008 mod p(x)` << 1, x^171072 mod p(x)` << 1
+      0x02fca6e8UL, 0x00000000UL, 0xc4d8348cUL, 0x00000001UL,       // x^169984 mod p(x)` << 1, x^170048 mod p(x)` << 1
+      0x7af40044UL, 0x00000000UL, 0x57a40336UL, 0x00000000UL,       // x^168960 mod p(x)` << 1, x^169024 mod p(x)` << 1
+      0x16178744UL, 0x00000000UL, 0x85544940UL, 0x00000000UL,       // x^167936 mod p(x)` << 1, x^168000 mod p(x)` << 1
+      0x4c177458UL, 0x00000001UL, 0x9cd21e80UL, 0x00000001UL,       // x^166912 mod p(x)` << 1, x^166976 mod p(x)` << 1
+      0x1b6ddf04UL, 0x00000001UL, 0x3eb95bc0UL, 0x00000001UL,       // x^165888 mod p(x)` << 1, x^165952 mod p(x)` << 1
+      0xf3e29cccUL, 0x00000001UL, 0xdfc9fdfcUL, 0x00000001UL,       // x^164864 mod p(x)` << 1, x^164928 mod p(x)` << 1
+      0x35ae7562UL, 0x00000001UL, 0xcd028bc2UL, 0x00000000UL,       // x^163840 mod p(x)` << 1, x^163904 mod p(x)` << 1
+      0x90ef812cUL, 0x00000001UL, 0x90db8c44UL, 0x00000000UL,       // x^162816 mod p(x)` << 1, x^162880 mod p(x)` << 1
+      0x67a2c786UL, 0x00000000UL, 0x0010a4ceUL, 0x00000001UL,       // x^161792 mod p(x)` << 1, x^161856 mod p(x)` << 1
+      0x48b9496cUL, 0x00000000UL, 0xc8f4c72cUL, 0x00000001UL,       // x^160768 mod p(x)` << 1, x^160832 mod p(x)` << 1
+      0x5a422de6UL, 0x00000001UL, 0x1c26170cUL, 0x00000000UL,       // x^159744 mod p(x)` << 1, x^159808 mod p(x)` << 1
+      0xef0e3640UL, 0x00000001UL, 0xe3fccf68UL, 0x00000000UL,       // x^158720 mod p(x)` << 1, x^158784 mod p(x)` << 1
+      0x006d2d26UL, 0x00000001UL, 0xd513ed24UL, 0x00000000UL,       // x^157696 mod p(x)` << 1, x^157760 mod p(x)` << 1
+      0x170d56d6UL, 0x00000001UL, 0x141beadaUL, 0x00000000UL,       // x^156672 mod p(x)` << 1, x^156736 mod p(x)` << 1
+      0xa5fb613cUL, 0x00000000UL, 0x1071aea0UL, 0x00000001UL,       // x^155648 mod p(x)` << 1, x^155712 mod p(x)` << 1
+      0x40bbf7fcUL, 0x00000000UL, 0x2e19080aUL, 0x00000001UL,       // x^154624 mod p(x)` << 1, x^154688 mod p(x)` << 1
+      0x6ac3a5b2UL, 0x00000001UL, 0x00ecf826UL, 0x00000001UL,       // x^153600 mod p(x)` << 1, x^153664 mod p(x)` << 1
+      0xabf16230UL, 0x00000000UL, 0x69b09412UL, 0x00000000UL,       // x^152576 mod p(x)` << 1, x^152640 mod p(x)` << 1
+      0xebe23facUL, 0x00000001UL, 0x22297bacUL, 0x00000001UL,       // x^151552 mod p(x)` << 1, x^151616 mod p(x)` << 1
+      0x8b6a0894UL, 0x00000000UL, 0xe9e4b068UL, 0x00000000UL,       // x^150528 mod p(x)` << 1, x^150592 mod p(x)` << 1
+      0x288ea478UL, 0x00000001UL, 0x4b38651aUL, 0x00000000UL,       // x^149504 mod p(x)` << 1, x^149568 mod p(x)` << 1
+      0x6619c442UL, 0x00000001UL, 0x468360e2UL, 0x00000001UL,       // x^148480 mod p(x)` << 1, x^148544 mod p(x)` << 1
+      0x86230038UL, 0x00000000UL, 0x121c2408UL, 0x00000000UL,       // x^147456 mod p(x)` << 1, x^147520 mod p(x)` << 1
+      0x7746a756UL, 0x00000001UL, 0xda7e7d08UL, 0x00000000UL,       // x^146432 mod p(x)` << 1, x^146496 mod p(x)` << 1
+      0x91b8f8f8UL, 0x00000001UL, 0x058d7652UL, 0x00000001UL,       // x^145408 mod p(x)` << 1, x^145472 mod p(x)` << 1
+      0x8e167708UL, 0x00000000UL, 0x4a098a90UL, 0x00000001UL,       // x^144384 mod p(x)` << 1, x^144448 mod p(x)` << 1
+      0x48b22d54UL, 0x00000001UL, 0x20dbe72eUL, 0x00000000UL,       // x^143360 mod p(x)` << 1, x^143424 mod p(x)` << 1
+      0x44ba2c3cUL, 0x00000000UL, 0x1e7323e8UL, 0x00000001UL,       // x^142336 mod p(x)` << 1, x^142400 mod p(x)` << 1
+      0xb54d2b52UL, 0x00000000UL, 0xd5d4bf94UL, 0x00000000UL,       // x^141312 mod p(x)` << 1, x^141376 mod p(x)` << 1
+      0x05a4fd8aUL, 0x00000000UL, 0x99d8746cUL, 0x00000001UL,       // x^140288 mod p(x)` << 1, x^140352 mod p(x)` << 1
+      0x39f9fc46UL, 0x00000001UL, 0xce9ca8a0UL, 0x00000000UL,       // x^139264 mod p(x)` << 1, x^139328 mod p(x)` << 1
+      0x5a1fa824UL, 0x00000001UL, 0x136edeceUL, 0x00000000UL,       // x^138240 mod p(x)` << 1, x^138304 mod p(x)` << 1
+      0x0a61ae4cUL, 0x00000000UL, 0x9b92a068UL, 0x00000001UL,       // x^137216 mod p(x)` << 1, x^137280 mod p(x)` << 1
+      0x45e9113eUL, 0x00000001UL, 0x71d62206UL, 0x00000000UL,       // x^136192 mod p(x)` << 1, x^136256 mod p(x)` << 1
+      0x6a348448UL, 0x00000000UL, 0xdfc50158UL, 0x00000000UL,       // x^135168 mod p(x)` << 1, x^135232 mod p(x)` << 1
+      0x4d80a08cUL, 0x00000000UL, 0x517626bcUL, 0x00000001UL,       // x^134144 mod p(x)` << 1, x^134208 mod p(x)` << 1
+      0x4b6837a0UL, 0x00000001UL, 0x48d1e4faUL, 0x00000001UL,       // x^133120 mod p(x)` << 1, x^133184 mod p(x)` << 1
+      0x6896a7fcUL, 0x00000001UL, 0x94d8266eUL, 0x00000000UL,       // x^132096 mod p(x)` << 1, x^132160 mod p(x)` << 1
+      0x4f187140UL, 0x00000001UL, 0x606c5e34UL, 0x00000000UL,       // x^131072 mod p(x)` << 1, x^131136 mod p(x)` << 1
+      0x9581b9daUL, 0x00000001UL, 0x9766beaaUL, 0x00000001UL,       // x^130048 mod p(x)` << 1, x^130112 mod p(x)` << 1
+      0x091bc984UL, 0x00000001UL, 0xd80c506cUL, 0x00000001UL,       // x^129024 mod p(x)` << 1, x^129088 mod p(x)` << 1
+      0x1067223cUL, 0x00000000UL, 0x1e73837cUL, 0x00000000UL,       // x^128000 mod p(x)` << 1, x^128064 mod p(x)` << 1
+      0xab16ea02UL, 0x00000001UL, 0x64d587deUL, 0x00000000UL,       // x^126976 mod p(x)` << 1, x^127040 mod p(x)` << 1
+      0x3c4598a8UL, 0x00000001UL, 0xf4a507b0UL, 0x00000000UL,       // x^125952 mod p(x)` << 1, x^126016 mod p(x)` << 1
+      0xb3735430UL, 0x00000000UL, 0x40e342fcUL, 0x00000000UL,       // x^124928 mod p(x)` << 1, x^124992 mod p(x)` << 1
+      0xbb3fc0c0UL, 0x00000001UL, 0xd5ad9c3aUL, 0x00000001UL,       // x^123904 mod p(x)` << 1, x^123968 mod p(x)` << 1
+      0x570ae19cUL, 0x00000001UL, 0x94a691a4UL, 0x00000000UL,       // x^122880 mod p(x)` << 1, x^122944 mod p(x)` << 1
+      0xea910712UL, 0x00000001UL, 0x271ecdfaUL, 0x00000001UL,       // x^121856 mod p(x)` << 1, x^121920 mod p(x)` << 1
+      0x67127128UL, 0x00000001UL, 0x9e54475aUL, 0x00000000UL,       // x^120832 mod p(x)` << 1, x^120896 mod p(x)` << 1
+      0x19e790a2UL, 0x00000000UL, 0xc9c099eeUL, 0x00000000UL,       // x^119808 mod p(x)` << 1, x^119872 mod p(x)` << 1
+      0x3788f710UL, 0x00000000UL, 0x9a2f736cUL, 0x00000000UL,       // x^118784 mod p(x)` << 1, x^118848 mod p(x)` << 1
+      0x682a160eUL, 0x00000001UL, 0xbb9f4996UL, 0x00000000UL,       // x^117760 mod p(x)` << 1, x^117824 mod p(x)` << 1
+      0x7f0ebd2eUL, 0x00000000UL, 0xdb688050UL, 0x00000001UL,       // x^116736 mod p(x)` << 1, x^116800 mod p(x)` << 1
+      0x2b032080UL, 0x00000000UL, 0xe9b10af4UL, 0x00000000UL,       // x^115712 mod p(x)` << 1, x^115776 mod p(x)` << 1
+      0xcfd1664aUL, 0x00000000UL, 0x2d4545e4UL, 0x00000001UL,       // x^114688 mod p(x)` << 1, x^114752 mod p(x)` << 1
+      0xaa1181c2UL, 0x00000000UL, 0x0361139cUL, 0x00000000UL,       // x^113664 mod p(x)` << 1, x^113728 mod p(x)` << 1
+      0xddd08002UL, 0x00000000UL, 0xa5a1a3a8UL, 0x00000001UL,       // x^112640 mod p(x)` << 1, x^112704 mod p(x)` << 1
+      0xe8dd0446UL, 0x00000000UL, 0x6844e0b0UL, 0x00000000UL,       // x^111616 mod p(x)` << 1, x^111680 mod p(x)` << 1
+      0xbbd94a00UL, 0x00000001UL, 0xc3762f28UL, 0x00000000UL,       // x^110592 mod p(x)` << 1, x^110656 mod p(x)` << 1
+      0xab6cd180UL, 0x00000000UL, 0xd26287a2UL, 0x00000001UL,       // x^109568 mod p(x)` << 1, x^109632 mod p(x)` << 1
+      0x31803ce2UL, 0x00000000UL, 0xf6f0bba8UL, 0x00000001UL,       // x^108544 mod p(x)` << 1, x^108608 mod p(x)` << 1
+      0x24f40b0cUL, 0x00000000UL, 0x2ffabd62UL, 0x00000000UL,       // x^107520 mod p(x)` << 1, x^107584 mod p(x)` << 1
+      0xba1d9834UL, 0x00000001UL, 0xfb4516b8UL, 0x00000000UL,       // x^106496 mod p(x)` << 1, x^106560 mod p(x)` << 1
+      0x04de61aaUL, 0x00000001UL, 0x8cfa961cUL, 0x00000001UL,       // x^105472 mod p(x)` << 1, x^105536 mod p(x)` << 1
+      0x13e40d46UL, 0x00000001UL, 0x9e588d52UL, 0x00000001UL,       // x^104448 mod p(x)` << 1, x^104512 mod p(x)` << 1
+      0x415598a0UL, 0x00000001UL, 0x180f0bbcUL, 0x00000001UL,       // x^103424 mod p(x)` << 1, x^103488 mod p(x)` << 1
+      0xbf6c8c90UL, 0x00000000UL, 0xe1d9177aUL, 0x00000000UL,       // x^102400 mod p(x)` << 1, x^102464 mod p(x)` << 1
+      0x788b0504UL, 0x00000001UL, 0x05abc27cUL, 0x00000001UL,       // x^101376 mod p(x)` << 1, x^101440 mod p(x)` << 1
+      0x38385d02UL, 0x00000000UL, 0x972e4a58UL, 0x00000000UL,       // x^100352 mod p(x)` << 1, x^100416 mod p(x)` << 1
+      0xb6c83844UL, 0x00000001UL, 0x83499a5eUL, 0x00000001UL,       // x^99328 mod p(x)` << 1, x^99392 mod p(x)` << 1
+      0x51061a8aUL, 0x00000000UL, 0xc96a8ccaUL, 0x00000001UL,       // x^98304 mod p(x)` << 1, x^98368 mod p(x)` << 1
+      0x7351388aUL, 0x00000001UL, 0xa1a5b60cUL, 0x00000001UL,       // x^97280 mod p(x)` << 1, x^97344 mod p(x)` << 1
+      0x32928f92UL, 0x00000001UL, 0xe4b6ac9cUL, 0x00000000UL,       // x^96256 mod p(x)` << 1, x^96320 mod p(x)` << 1
+      0xe6b4f48aUL, 0x00000000UL, 0x807e7f5aUL, 0x00000001UL,       // x^95232 mod p(x)` << 1, x^95296 mod p(x)` << 1
+      0x39d15e90UL, 0x00000000UL, 0x7a7e3bc8UL, 0x00000001UL,       // x^94208 mod p(x)` << 1, x^94272 mod p(x)` << 1
+      0x312d6074UL, 0x00000000UL, 0xd73975daUL, 0x00000000UL,       // x^93184 mod p(x)` << 1, x^93248 mod p(x)` << 1
+      0x7bbb2cc4UL, 0x00000001UL, 0x7375d038UL, 0x00000001UL,       // x^92160 mod p(x)` << 1, x^92224 mod p(x)` << 1
+      0x6ded3e18UL, 0x00000001UL, 0x193680bcUL, 0x00000000UL,       // x^91136 mod p(x)` << 1, x^91200 mod p(x)` << 1
+      0xf1638b16UL, 0x00000000UL, 0x999b06f6UL, 0x00000000UL,       // x^90112 mod p(x)` << 1, x^90176 mod p(x)` << 1
+      0xd38b9eccUL, 0x00000001UL, 0xf685d2b8UL, 0x00000001UL,       // x^89088 mod p(x)` << 1, x^89152 mod p(x)` << 1
+      0x8b8d09dcUL, 0x00000001UL, 0xf4ecbed2UL, 0x00000001UL,       // x^88064 mod p(x)` << 1, x^88128 mod p(x)` << 1
+      0xe7bc27d2UL, 0x00000000UL, 0xba16f1a0UL, 0x00000000UL,       // x^87040 mod p(x)` << 1, x^87104 mod p(x)` << 1
+      0x275e1e96UL, 0x00000000UL, 0x15aceac4UL, 0x00000001UL,       // x^86016 mod p(x)` << 1, x^86080 mod p(x)` << 1
+      0xe2e3031eUL, 0x00000000UL, 0xaeff6292UL, 0x00000001UL,       // x^84992 mod p(x)` << 1, x^85056 mod p(x)` << 1
+      0x041c84d8UL, 0x00000001UL, 0x9640124cUL, 0x00000000UL,       // x^83968 mod p(x)` << 1, x^84032 mod p(x)` << 1
+      0x706ce672UL, 0x00000000UL, 0x14f41f02UL, 0x00000001UL,       // x^82944 mod p(x)` << 1, x^83008 mod p(x)` << 1
+      0x5d5070daUL, 0x00000001UL, 0x9c5f3586UL, 0x00000000UL,       // x^81920 mod p(x)` << 1, x^81984 mod p(x)` << 1
+      0x38f9493aUL, 0x00000000UL, 0x878275faUL, 0x00000001UL,       // x^80896 mod p(x)` << 1, x^80960 mod p(x)` << 1
+      0xa3348a76UL, 0x00000000UL, 0xddc42ce8UL, 0x00000000UL,       // x^79872 mod p(x)` << 1, x^79936 mod p(x)` << 1
+      0xad0aab92UL, 0x00000001UL, 0x81d2c73aUL, 0x00000001UL,       // x^78848 mod p(x)` << 1, x^78912 mod p(x)` << 1
+      0x9e85f712UL, 0x00000001UL, 0x41c9320aUL, 0x00000001UL,       // x^77824 mod p(x)` << 1, x^77888 mod p(x)` << 1
+      0x5a871e76UL, 0x00000000UL, 0x5235719aUL, 0x00000001UL,       // x^76800 mod p(x)` << 1, x^76864 mod p(x)` << 1
+      0x7249c662UL, 0x00000001UL, 0xbe27d804UL, 0x00000000UL,       // x^75776 mod p(x)` << 1, x^75840 mod p(x)` << 1
+      0x3a084712UL, 0x00000000UL, 0x6242d45aUL, 0x00000000UL,       // x^74752 mod p(x)` << 1, x^74816 mod p(x)` << 1
+      0xed438478UL, 0x00000000UL, 0x9a53638eUL, 0x00000000UL,       // x^73728 mod p(x)` << 1, x^73792 mod p(x)` << 1
+      0xabac34ccUL, 0x00000000UL, 0x001ecfb6UL, 0x00000001UL,       // x^72704 mod p(x)` << 1, x^72768 mod p(x)` << 1
+      0x5f35ef3eUL, 0x00000000UL, 0x6d7c2d64UL, 0x00000001UL,       // x^71680 mod p(x)` << 1, x^71744 mod p(x)` << 1
+      0x47d6608cUL, 0x00000000UL, 0xd0ce46c0UL, 0x00000001UL,       // x^70656 mod p(x)` << 1, x^70720 mod p(x)` << 1
+      0x2d01470eUL, 0x00000000UL, 0x24c907b4UL, 0x00000001UL,       // x^69632 mod p(x)` << 1, x^69696 mod p(x)` << 1
+      0x58bbc7b0UL, 0x00000001UL, 0x18a555caUL, 0x00000000UL,       // x^68608 mod p(x)` << 1, x^68672 mod p(x)` << 1
+      0xc0a23e8eUL, 0x00000000UL, 0x6b0980bcUL, 0x00000000UL,       // x^67584 mod p(x)` << 1, x^67648 mod p(x)` << 1
+      0xebd85c88UL, 0x00000001UL, 0x8bbba964UL, 0x00000000UL,       // x^66560 mod p(x)` << 1, x^66624 mod p(x)` << 1
+      0x9ee20bb2UL, 0x00000001UL, 0x070a5a1eUL, 0x00000001UL,       // x^65536 mod p(x)` << 1, x^65600 mod p(x)` << 1
+      0xacabf2d6UL, 0x00000001UL, 0x2204322aUL, 0x00000000UL,       // x^64512 mod p(x)` << 1, x^64576 mod p(x)` << 1
+      0xb7963d56UL, 0x00000001UL, 0xa27524d0UL, 0x00000000UL,       // x^63488 mod p(x)` << 1, x^63552 mod p(x)` << 1
+      0x7bffa1feUL, 0x00000001UL, 0x20b1e4baUL, 0x00000000UL,       // x^62464 mod p(x)` << 1, x^62528 mod p(x)` << 1
+      0x1f15333eUL, 0x00000000UL, 0x32cc27fcUL, 0x00000000UL,       // x^61440 mod p(x)` << 1, x^61504 mod p(x)` << 1
+      0x8593129eUL, 0x00000001UL, 0x44dd22b8UL, 0x00000000UL,       // x^60416 mod p(x)` << 1, x^60480 mod p(x)` << 1
+      0x9cb32602UL, 0x00000001UL, 0xdffc9e0aUL, 0x00000000UL,       // x^59392 mod p(x)` << 1, x^59456 mod p(x)` << 1
+      0x42b05cc8UL, 0x00000001UL, 0xb7a0ed14UL, 0x00000001UL,       // x^58368 mod p(x)` << 1, x^58432 mod p(x)` << 1
+      0xbe49e7a4UL, 0x00000001UL, 0xc7842488UL, 0x00000000UL,       // x^57344 mod p(x)` << 1, x^57408 mod p(x)` << 1
+      0x08f69d6cUL, 0x00000001UL, 0xc02a4feeUL, 0x00000001UL,       // x^56320 mod p(x)` << 1, x^56384 mod p(x)` << 1
+      0x6c0971f0UL, 0x00000000UL, 0x3c273778UL, 0x00000000UL,       // x^55296 mod p(x)` << 1, x^55360 mod p(x)` << 1
+      0x5b16467aUL, 0x00000000UL, 0xd63f8894UL, 0x00000001UL,       // x^54272 mod p(x)` << 1, x^54336 mod p(x)` << 1
+      0x551a628eUL, 0x00000001UL, 0x6be557d6UL, 0x00000000UL,       // x^53248 mod p(x)` << 1, x^53312 mod p(x)` << 1
+      0x9e42ea92UL, 0x00000001UL, 0x6a7806eaUL, 0x00000000UL,       // x^52224 mod p(x)` << 1, x^52288 mod p(x)` << 1
+      0x2fa83ff2UL, 0x00000001UL, 0x6155aa0cUL, 0x00000001UL,       // x^51200 mod p(x)` << 1, x^51264 mod p(x)` << 1
+      0x1ca9cde0UL, 0x00000001UL, 0x908650acUL, 0x00000000UL,       // x^50176 mod p(x)` << 1, x^50240 mod p(x)` << 1
+      0xc8e5cd74UL, 0x00000000UL, 0xaa5a8084UL, 0x00000000UL,       // x^49152 mod p(x)` << 1, x^49216 mod p(x)` << 1
+      0x96c27f0cUL, 0x00000000UL, 0x91bb500aUL, 0x00000001UL,       // x^48128 mod p(x)` << 1, x^48192 mod p(x)` << 1
+      0x2baed926UL, 0x00000000UL, 0x64e9bed0UL, 0x00000000UL,       // x^47104 mod p(x)` << 1, x^47168 mod p(x)` << 1
+      0x7c8de8d2UL, 0x00000001UL, 0x9444f302UL, 0x00000000UL,       // x^46080 mod p(x)` << 1, x^46144 mod p(x)` << 1
+      0xd43d6068UL, 0x00000000UL, 0x9db07d3cUL, 0x00000001UL,       // x^45056 mod p(x)` << 1, x^45120 mod p(x)` << 1
+      0xcb2c4b26UL, 0x00000000UL, 0x359e3e6eUL, 0x00000001UL,       // x^44032 mod p(x)` << 1, x^44096 mod p(x)` << 1
+      0x45b8da26UL, 0x00000001UL, 0xe4f10dd2UL, 0x00000001UL,       // x^43008 mod p(x)` << 1, x^43072 mod p(x)` << 1
+      0x8fff4b08UL, 0x00000001UL, 0x24f5735eUL, 0x00000001UL,       // x^41984 mod p(x)` << 1, x^42048 mod p(x)` << 1
+      0x50b58ed0UL, 0x00000001UL, 0x24760a4cUL, 0x00000001UL,       // x^40960 mod p(x)` << 1, x^41024 mod p(x)` << 1
+      0x549f39bcUL, 0x00000001UL, 0x0f1fc186UL, 0x00000000UL,       // x^39936 mod p(x)` << 1, x^40000 mod p(x)` << 1
+      0xef4d2f42UL, 0x00000000UL, 0x150e4cc4UL, 0x00000000UL,       // x^38912 mod p(x)` << 1, x^38976 mod p(x)` << 1
+      0xb1468572UL, 0x00000001UL, 0x2a6204e8UL, 0x00000000UL,       // x^37888 mod p(x)` << 1, x^37952 mod p(x)` << 1
+      0x3d7403b2UL, 0x00000001UL, 0xbeb1d432UL, 0x00000000UL,       // x^36864 mod p(x)` << 1, x^36928 mod p(x)` << 1
+      0xa4681842UL, 0x00000001UL, 0x35f3f1f0UL, 0x00000001UL,       // x^35840 mod p(x)` << 1, x^35904 mod p(x)` << 1
+      0x67714492UL, 0x00000001UL, 0x74fe2232UL, 0x00000000UL,       // x^34816 mod p(x)` << 1, x^34880 mod p(x)` << 1
+      0xe599099aUL, 0x00000001UL, 0x1ac6e2baUL, 0x00000000UL,       // x^33792 mod p(x)` << 1, x^33856 mod p(x)` << 1
+      0xfe128194UL, 0x00000000UL, 0x13fca91eUL, 0x00000000UL,       // x^32768 mod p(x)` << 1, x^32832 mod p(x)` << 1
+      0x77e8b990UL, 0x00000000UL, 0x83f4931eUL, 0x00000001UL,       // x^31744 mod p(x)` << 1, x^31808 mod p(x)` << 1
+      0xa267f63aUL, 0x00000001UL, 0xb6d9b4e4UL, 0x00000000UL,       // x^30720 mod p(x)` << 1, x^30784 mod p(x)` << 1
+      0x945c245aUL, 0x00000001UL, 0xb5188656UL, 0x00000000UL,       // x^29696 mod p(x)` << 1, x^29760 mod p(x)` << 1
+      0x49002e76UL, 0x00000001UL, 0x27a81a84UL, 0x00000000UL,       // x^28672 mod p(x)` << 1, x^28736 mod p(x)` << 1
+      0xbb8310a4UL, 0x00000001UL, 0x25699258UL, 0x00000001UL,       // x^27648 mod p(x)` << 1, x^27712 mod p(x)` << 1
+      0x9ec60bccUL, 0x00000001UL, 0xb23de796UL, 0x00000001UL,       // x^26624 mod p(x)` << 1, x^26688 mod p(x)` << 1
+      0x2d8590aeUL, 0x00000001UL, 0xfe4365dcUL, 0x00000000UL,       // x^25600 mod p(x)` << 1, x^25664 mod p(x)` << 1
+      0x65b00684UL, 0x00000000UL, 0xc68f497aUL, 0x00000000UL,       // x^24576 mod p(x)` << 1, x^24640 mod p(x)` << 1
+      0x5e5aeadcUL, 0x00000001UL, 0xfbf521eeUL, 0x00000000UL,       // x^23552 mod p(x)` << 1, x^23616 mod p(x)` << 1
+      0xb77ff2b0UL, 0x00000000UL, 0x5eac3378UL, 0x00000001UL,       // x^22528 mod p(x)` << 1, x^22592 mod p(x)` << 1
+      0x88da2ff6UL, 0x00000001UL, 0x34914b90UL, 0x00000001UL,       // x^21504 mod p(x)` << 1, x^21568 mod p(x)` << 1
+      0x63da929aUL, 0x00000000UL, 0x16335cfeUL, 0x00000000UL,       // x^20480 mod p(x)` << 1, x^20544 mod p(x)` << 1
+      0x389caa80UL, 0x00000001UL, 0x0372d10cUL, 0x00000001UL,       // x^19456 mod p(x)` << 1, x^19520 mod p(x)` << 1
+      0x3db599d2UL, 0x00000001UL, 0x5097b908UL, 0x00000001UL,       // x^18432 mod p(x)` << 1, x^18496 mod p(x)` << 1
+      0x22505a86UL, 0x00000001UL, 0x227a7572UL, 0x00000001UL,       // x^17408 mod p(x)` << 1, x^17472 mod p(x)` << 1
+      0x6bd72746UL, 0x00000001UL, 0x9a8f75c0UL, 0x00000000UL,       // x^16384 mod p(x)` << 1, x^16448 mod p(x)` << 1
+      0xc3faf1d4UL, 0x00000001UL, 0x682c77a2UL, 0x00000000UL,       // x^15360 mod p(x)` << 1, x^15424 mod p(x)` << 1
+      0x111c826cUL, 0x00000001UL, 0x231f091cUL, 0x00000000UL,       // x^14336 mod p(x)` << 1, x^14400 mod p(x)` << 1
+      0x153e9fb2UL, 0x00000000UL, 0x7d4439f2UL, 0x00000000UL,       // x^13312 mod p(x)` << 1, x^13376 mod p(x)` << 1
+      0x2b1f7b60UL, 0x00000000UL, 0x7e221efcUL, 0x00000001UL,       // x^12288 mod p(x)` << 1, x^12352 mod p(x)` << 1
+      0xb1dba570UL, 0x00000000UL, 0x67457c38UL, 0x00000001UL,       // x^11264 mod p(x)` << 1, x^11328 mod p(x)` << 1
+      0xf6397b76UL, 0x00000001UL, 0xbdf081c4UL, 0x00000000UL,       // x^10240 mod p(x)` << 1, x^10304 mod p(x)` << 1
+      0x56335214UL, 0x00000001UL, 0x6286d6b0UL, 0x00000001UL,       // x^9216 mod p(x)` << 1, x^9280 mod p(x)` << 1
+      0xd70e3986UL, 0x00000001UL, 0xc84f001cUL, 0x00000000UL,       // x^8192 mod p(x)` << 1, x^8256 mod p(x)` << 1
+      0x3701a774UL, 0x00000000UL, 0x64efe7c0UL, 0x00000000UL,       // x^7168 mod p(x)` << 1, x^7232 mod p(x)` << 1
+      0xac81ef72UL, 0x00000000UL, 0x0ac2d904UL, 0x00000000UL,       // x^6144 mod p(x)` << 1, x^6208 mod p(x)` << 1
+      0x33212464UL, 0x00000001UL, 0xfd226d14UL, 0x00000000UL,       // x^5120 mod p(x)` << 1, x^5184 mod p(x)` << 1
+      0xe4e45610UL, 0x00000000UL, 0x1cfd42e0UL, 0x00000001UL,       // x^4096 mod p(x)` << 1, x^4160 mod p(x)` << 1
+      0x0c1bd370UL, 0x00000000UL, 0x6e5a5678UL, 0x00000001UL,       // x^3072 mod p(x)` << 1, x^3136 mod p(x)` << 1
+      0xa7b9e7a6UL, 0x00000001UL, 0xd888fe22UL, 0x00000001UL,       // x^2048 mod p(x)` << 1, x^2112 mod p(x)` << 1
+      0x7d657a10UL, 0x00000000UL, 0xaf77fcd4UL, 0x00000001UL,       // x^1024 mod p(x)` << 1, x^1088 mod p(x)` << 1
+
+      // Reduce final 1024-2048 bits to 64 bits, shifting 32 bits to include the trailing 32 bits of zeros
+      0xec447f11UL, 0x99168a18UL, 0x13e8221eUL, 0xed837b26UL,       // x^2048 mod p(x)`, x^2016 mod p(x)`, x^1984 mod p(x)`, x^1952 mod p(x)`
+      0x8fd2cd3cUL, 0xe23e954eUL, 0x47b9ce5aUL, 0xc8acdd81UL,       // x^1920 mod p(x)`, x^1888 mod p(x)`, x^1856 mod p(x)`, x^1824 mod p(x)`
+      0x6b1d2b53UL, 0x92f8befeUL, 0xd4277e25UL, 0xd9ad6d87UL,       // x^1792 mod p(x)`, x^1760 mod p(x)`, x^1728 mod p(x)`, x^1696 mod p(x)`
+      0x291ea462UL, 0xf38a3556UL, 0x33fbca3bUL, 0xc10ec5e0UL,       // x^1664 mod p(x)`, x^1632 mod p(x)`, x^1600 mod p(x)`, x^1568 mod p(x)`
+      0x62b6ca4bUL, 0x974ac562UL, 0x82e02e2fUL, 0xc0b55b0eUL,       // x^1536 mod p(x)`, x^1504 mod p(x)`, x^1472 mod p(x)`, x^1440 mod p(x)`
+      0x784d2a56UL, 0x855712b3UL, 0xe172334dUL, 0x71aa1df0UL,       // x^1408 mod p(x)`, x^1376 mod p(x)`, x^1344 mod p(x)`, x^1312 mod p(x)`
+      0x0eaee722UL, 0xa5abe9f8UL, 0x3969324dUL, 0xfee3053eUL,       // x^1280 mod p(x)`, x^1248 mod p(x)`, x^1216 mod p(x)`, x^1184 mod p(x)`
+      0xdb54814cUL, 0x1fa0943dUL, 0x3eb2bd08UL, 0xf44779b9UL,       // x^1152 mod p(x)`, x^1120 mod p(x)`, x^1088 mod p(x)`, x^1056 mod p(x)`
+      0xd7bbfe6aUL, 0xa53ff440UL, 0x00cc3374UL, 0xf5449b3fUL,       // x^1024 mod p(x)`, x^992 mod p(x)`,  x^960 mod p(x)`,  x^928 mod p(x)`
+      0x6325605cUL, 0xebe7e356UL, 0xd777606eUL, 0x6f8346e1UL,       // x^896 mod p(x)`,  x^864 mod p(x)`,  x^832 mod p(x)`,  x^800 mod p(x)`
+      0xe5b592b8UL, 0xc65a272cUL, 0xc0b95347UL, 0xe3ab4f2aUL,       // x^768 mod p(x)`,  x^736 mod p(x)`,  x^704 mod p(x)`,  x^672 mod p(x)`
+      0x4721589fUL, 0x5705a9caUL, 0x329ecc11UL, 0xaa2215eaUL,       // x^640 mod p(x)`,  x^608 mod p(x)`,  x^576 mod p(x)`,  x^544 mod p(x)`
+      0x88d14467UL, 0xe3720acbUL, 0xd95efd26UL, 0x1ed8f66eUL,       // x^512 mod p(x)`,  x^480 mod p(x)`,  x^448 mod p(x)`,  x^416 mod p(x)`
+      0x15141c31UL, 0xba1aca03UL, 0xa700e96aUL, 0x78ed02d5UL,       // x^384 mod p(x)`,  x^352 mod p(x)`,  x^320 mod p(x)`,  x^288 mod p(x)`
+      0xed627daeUL, 0xad2a31b3UL, 0x32b39da3UL, 0xba8ccbe8UL,       // x^256 mod p(x)`,  x^224 mod p(x)`,  x^192 mod p(x)`,  x^160 mod p(x)`
+      0xa06a2517UL, 0x6655004fUL, 0xb1e6b092UL, 0xedb88320UL        // x^128 mod p(x)`,  x^96 mod p(x)`,   x^64 mod p(x)`,   x^32 mod p(x)`
+  };
+
+  juint* ptr = (juint*) malloc(sizeof(juint) * CRC32_CONSTANTS_SIZE);
+  guarantee(((intptr_t)ptr & 0xF) == 0, "16-byte alignment needed");
+  guarantee(ptr != NULL, "allocation error of a crc table");
+  memcpy((void*)ptr, constants, sizeof(juint) * CRC32_CONSTANTS_SIZE);
+  return ptr;
+}
+
+juint* StubRoutines::ppc64::generate_crc_barret_constants() {
+  juint barret_constants[CRC32_BARRET_CONSTANTS] = {
+      0xf7011641UL, 0x00000001UL, 0x00000000UL, 0x00000000UL,
+      0xdb710641UL, 0x00000001UL, 0x00000000UL, 0x00000000UL
+  };
+  juint* ptr = (juint*) malloc(sizeof(juint) * CRC32_CONSTANTS_SIZE);
+  guarantee(((intptr_t)ptr & 0xF) == 0, "16-byte alignment needed");
+  guarantee(ptr != NULL, "allocation error of a crc table");
+  memcpy((void*) ptr, barret_constants, sizeof(juint) * CRC32_BARRET_CONSTANTS);
+  return ptr;
+}
+
 // CRC32 Intrinsics.
 /**
  *  crc_table[] from jdk/src/share/native/java/util/zip/zlib-1.2.8/crc32.h
@@ -477,3 +782,7 @@
 #endif
   }
 };
+
+juint* StubRoutines::ppc64::_constants = StubRoutines::ppc64::generate_crc_constants();
+
+juint* StubRoutines::ppc64::_barret_constants = StubRoutines::ppc64::generate_crc_barret_constants();
--- a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1544,6 +1544,12 @@
     __ fence();
   }
 
+  if (CheckJNICalls) {
+    // clear_pending_jni_exception_check
+    __ load_const_optimized(R0, 0L);
+    __ st_ptr(R0, JavaThread::pending_jni_exception_check_fn_offset(), R16_thread);
+  }
+
   __ reset_last_Java_frame();
 
   // Jvmdi/jvmpi support. Whether we've got an exception pending or
--- a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -230,6 +230,11 @@
     FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
   }
 
+  if (UseFMA) {
+    warning("FMA instructions are not available on this CPU");
+    FLAG_SET_DEFAULT(UseFMA, false);
+  }
+
   if (UseSHA) {
     warning("SHA instructions are not available on this CPU");
     FLAG_SET_DEFAULT(UseSHA, false);
@@ -274,7 +279,14 @@
     }
     bool os_too_old = true;
 #ifdef AIX
-    if (os::Aix::os_version() >= 0x0701031e) { // at least AIX 7.1.3.30
+    // Actually, this is supported since AIX 7.1.. Unfortunately, this first
+    // contained bugs, so that it can only be enabled after AIX 7.1.3.30.
+    // The Java property os.version, which is used in RTM tests to decide
+    // whether the feature is available, only knows major and minor versions.
+    // We don't want to change this property, as user code might depend on it.
+    // So the tests can not check on subversion 3.30, and we only enable RTM
+    // with AIX 7.2.
+    if (os::Aix::os_version() >= 0x07020000) { // At least AIX 7.2.
       os_too_old = false;
     }
 #endif
--- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -147,10 +147,11 @@
 LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
                                             int shift, int disp, BasicType type) {
   assert(base->is_register(), "must be");
+  intx large_disp = disp;
 
   // accumulate fixed displacements
   if (index->is_constant()) {
-    disp += index->as_constant_ptr()->as_jint() << shift;
+    large_disp += (intx)(index->as_constant_ptr()->as_jint()) << shift;
     index = LIR_OprFact::illegalOpr;
   }
 
@@ -161,31 +162,31 @@
       __ shift_left(index, shift, tmp);
       index = tmp;
     }
-    if (disp != 0) {
+    if (large_disp != 0) {
       LIR_Opr tmp = new_pointer_register();
-      if (Assembler::is_simm13(disp)) {
-        __ add(tmp, LIR_OprFact::intptrConst(disp), tmp);
+      if (Assembler::is_simm13(large_disp)) {
+        __ add(tmp, LIR_OprFact::intptrConst(large_disp), tmp);
         index = tmp;
       } else {
-        __ move(LIR_OprFact::intptrConst(disp), tmp);
+        __ move(LIR_OprFact::intptrConst(large_disp), tmp);
         __ add(tmp, index, tmp);
         index = tmp;
       }
-      disp = 0;
+      large_disp = 0;
     }
-  } else if (disp != 0 && !Assembler::is_simm13(disp)) {
+  } else if (large_disp != 0 && !Assembler::is_simm13(large_disp)) {
     // index is illegal so replace it with the displacement loaded into a register
     index = new_pointer_register();
-    __ move(LIR_OprFact::intptrConst(disp), index);
-    disp = 0;
+    __ move(LIR_OprFact::intptrConst(large_disp), index);
+    large_disp = 0;
   }
 
   // at this point we either have base + index or base + displacement
-  if (disp == 0) {
+  if (large_disp == 0) {
     return new LIR_Address(base, index, type);
   } else {
-    assert(Assembler::is_simm13(disp), "must be");
-    return new LIR_Address(base, disp, type);
+    assert(Assembler::is_simm13(large_disp), "must be");
+    return new LIR_Address(base, large_disp, type);
   }
 }
 
@@ -196,11 +197,11 @@
   int shift = exact_log2(elem_size);
 
   LIR_Opr base_opr;
-  int offset = arrayOopDesc::base_offset_in_bytes(type);
+  intx offset = arrayOopDesc::base_offset_in_bytes(type);
 
   if (index_opr->is_constant()) {
-    int i = index_opr->as_constant_ptr()->as_jint();
-    int array_offset = i * elem_size;
+    intx i = index_opr->as_constant_ptr()->as_jint();
+    intx array_offset = i * elem_size;
     if (Assembler::is_simm13(array_offset + offset)) {
       base_opr = array_opr;
       offset = array_offset + offset;
@@ -953,6 +954,10 @@
   }
 }
 
+void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) {
+  fatal("FMA intrinsic is not implemented on this platform");
+}
+
 void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
   fatal("vectorizedMismatch intrinsic is not implemented on this platform");
 }
--- a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -881,20 +881,15 @@
         __ delayed()->st_ptr(tmp, G2_thread, satb_q_index_byte_offset);
 
         __ bind(refill);
-        __ save_frame(0);
 
-        __ mov(pre_val, L0);
-        __ mov(tmp,     L1);
-        __ mov(tmp2,    L2);
+        save_live_registers(sasm);
 
         __ call_VM_leaf(L7_thread_cache,
                         CAST_FROM_FN_PTR(address,
                                          SATBMarkQueueSet::handle_zero_index_for_thread),
                                          G2_thread);
 
-        __ mov(L0, pre_val);
-        __ mov(L1, tmp);
-        __ mov(L2, tmp2);
+        restore_live_registers(sasm);
 
         __ br(Assembler::always, /*annul*/false, Assembler::pt, restart);
         __ delayed()->restore();
@@ -986,20 +981,15 @@
         __ delayed()->st_ptr(tmp3, G2_thread, dirty_card_q_index_byte_offset);
 
         __ bind(refill);
-        __ save_frame(0);
 
-        __ mov(tmp2, L0);
-        __ mov(tmp3, L1);
-        __ mov(tmp4, L2);
+        save_live_registers(sasm);
 
         __ call_VM_leaf(L7_thread_cache,
                         CAST_FROM_FN_PTR(address,
                                          DirtyCardQueueSet::handle_zero_index_for_thread),
                                          G2_thread);
 
-        __ mov(L0, tmp2);
-        __ mov(L1, tmp3);
-        __ mov(L2, tmp4);
+        restore_live_registers(sasm);
 
         __ br(Assembler::always, /*annul*/false, Assembler::pt, restart);
         __ delayed()->restore();
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -266,6 +266,11 @@
     FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
   }
 
+  if (UseFMA) {
+    warning("FMA instructions are not available on this CPU");
+    FLAG_SET_DEFAULT(UseFMA, false);
+  }
+
   // SHA1, SHA256, and SHA512 instructions were added to SPARC T-series at different times
   if (has_sha1() || has_sha256() || has_sha512()) {
     if (UseVIS > 0) { // SHA intrinsics use VIS1 instructions
--- a/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -172,7 +172,9 @@
     case Interpreter::java_lang_math_log10   : // fall thru
     case Interpreter::java_lang_math_sqrt    : // fall thru
     case Interpreter::java_lang_math_pow     : // fall thru
-    case Interpreter::java_lang_math_exp     :
+    case Interpreter::java_lang_math_exp     : // fall thru
+    case Interpreter::java_lang_math_fmaD    : // fall thru
+    case Interpreter::java_lang_math_fmaF    :
       return false;
     default:
       return true;
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -4769,6 +4769,22 @@
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
+void Assembler::vfmadd231sd(XMMRegister dst, XMMRegister src1, XMMRegister src2) {
+  assert(VM_Version::supports_fma(), "");
+  InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(dst->encoding(), src1->encoding(), src2->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
+  emit_int8((unsigned char)0xB9);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::vfmadd231ss(XMMRegister dst, XMMRegister src1, XMMRegister src2) {
+  assert(VM_Version::supports_fma(), "");
+  InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = vex_prefix_and_encode(dst->encoding(), src1->encoding(), src2->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
+  emit_int8((unsigned char)0xB9);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
 void Assembler::vmulsd(XMMRegister dst, XMMRegister nds, Address src) {
   assert(VM_Version::supports_avx(), "");
   InstructionMark im(this);
--- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1860,6 +1860,8 @@
   void vdivsd(XMMRegister dst, XMMRegister nds, XMMRegister src);
   void vdivss(XMMRegister dst, XMMRegister nds, Address src);
   void vdivss(XMMRegister dst, XMMRegister nds, XMMRegister src);
+  void vfmadd231sd(XMMRegister dst, XMMRegister nds, XMMRegister src);
+  void vfmadd231ss(XMMRegister dst, XMMRegister nds, XMMRegister src);
   void vmulsd(XMMRegister dst, XMMRegister nds, Address src);
   void vmulsd(XMMRegister dst, XMMRegister nds, XMMRegister src);
   void vmulss(XMMRegister dst, XMMRegister nds, Address src);
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1345,6 +1345,18 @@
                       op->result_opr(),
                       op->info());
       break;
+    case lir_fmad:
+      __ fmad(op->result_opr()->as_xmm_double_reg(),
+              op->in_opr1()->as_xmm_double_reg(),
+              op->in_opr2()->as_xmm_double_reg(),
+              op->in_opr3()->as_xmm_double_reg());
+      break;
+    case lir_fmaf:
+      __ fmaf(op->result_opr()->as_xmm_float_reg(),
+              op->in_opr1()->as_xmm_float_reg(),
+              op->in_opr2()->as_xmm_float_reg(),
+              op->in_opr3()->as_xmm_float_reg());
+      break;
     default:      ShouldNotReachHere(); break;
   }
 }
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -152,7 +152,7 @@
   assert(base->is_register(), "must be");
   if (index->is_constant()) {
     return new LIR_Address(base,
-                           (index->as_constant_ptr()->as_jint() << shift) + disp,
+                           ((intx)(index->as_constant_ptr()->as_jint()) << shift) + disp,
                            type);
   } else {
     return new LIR_Address(base, index, (LIR_Address::Scale)shift, disp, type);
@@ -168,7 +168,7 @@
   if (index_opr->is_constant()) {
     int elem_size = type2aelembytes(type);
     addr = new LIR_Address(array_opr,
-                           offset_in_bytes + index_opr->as_jint() * elem_size, type);
+                           offset_in_bytes + (intx)(index_opr->as_jint()) * elem_size, type);
   } else {
 #ifdef _LP64
     if (index_opr->type() == T_INT) {
@@ -806,6 +806,32 @@
   }
 }
 
+void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) {
+  assert(x->number_of_arguments() == 3, "wrong type");
+  assert(UseFMA, "Needs FMA instructions support.");
+  LIRItem value(x->argument_at(0), this);
+  LIRItem value1(x->argument_at(1), this);
+  LIRItem value2(x->argument_at(2), this);
+
+  value2.set_destroys_register();
+
+  value.load_item();
+  value1.load_item();
+  value2.load_item();
+
+  LIR_Opr calc_input = value.result();
+  LIR_Opr calc_input1 = value1.result();
+  LIR_Opr calc_input2 = value2.result();
+  LIR_Opr calc_result = rlock_result(x);
+
+  switch (x->id()) {
+  case vmIntrinsics::_fmaD:   __ fmad(calc_input, calc_input1, calc_input2, calc_result); break;
+  case vmIntrinsics::_fmaF:   __ fmaf(calc_input, calc_input1, calc_input2, calc_result); break;
+  default:                    ShouldNotReachHere();
+  }
+
+}
+
 
 void LIRGenerator::do_MathIntrinsic(Intrinsic* x) {
   assert(x->number_of_arguments() == 1 || (x->number_of_arguments() == 2 && x->id() == vmIntrinsics::_dpow), "wrong type");
--- a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -100,9 +100,11 @@
 
 inline bool LinearScanWalker::pd_init_regs_for_alloc(Interval* cur) {
   int last_xmm_reg = pd_last_xmm_reg;
+#ifdef _LP64
   if (UseAVX < 3) {
     last_xmm_reg = pd_first_xmm_reg + (pd_nof_xmm_regs_frame_map / 2) - 1;
   }
+#endif
   if (allocator()->gen()->is_vreg_flag_set(cur->reg_num(), LIRGenerator::byte_reg)) {
     assert(cur->type() != T_FLOAT && cur->type() != T_DOUBLE, "cpu regs only");
     _first_reg = pd_first_byte_reg;
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -3147,6 +3147,24 @@
   fpop();
 }
 
+// dst = c = a * b + c
+void MacroAssembler::fmad(XMMRegister dst, XMMRegister a, XMMRegister b, XMMRegister c) {
+  Assembler::vfmadd231sd(c, a, b);
+  if (dst != c) {
+    movdbl(dst, c);
+  }
+}
+
+// dst = c = a * b + c
+void MacroAssembler::fmaf(XMMRegister dst, XMMRegister a, XMMRegister b, XMMRegister c) {
+  Assembler::vfmadd231ss(c, a, b);
+  if (dst != c) {
+    movflt(dst, c);
+  }
+}
+
+
+
 
 void MacroAssembler::incrementl(AddressLiteral dst) {
   if (reachable(dst)) {
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -449,6 +449,10 @@
   // tmp is a temporary register, if none is available use noreg
   void fremr(Register tmp);
 
+  // dst = c = a * b + c
+  void fmad(XMMRegister dst, XMMRegister a, XMMRegister b, XMMRegister c);
+  void fmaf(XMMRegister dst, XMMRegister a, XMMRegister b, XMMRegister c);
+
 
   // same as fcmp2int, but using SSE2
   void cmpss2int(XMMRegister opr1, XMMRegister opr2, Register dst, bool unordered_is_less);
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -720,19 +720,13 @@
 
 enum {
   _XFER_SIZE = 2*64*4, // 2 blocks, 64 rounds, 4 bytes/round
-#ifndef _WIN64
-  _XMM_SAVE_SIZE = 0,
-#else
-  _XMM_SAVE_SIZE = 8*16,
-#endif
   _INP_END_SIZE = 8,
   _INP_SIZE = 8,
   _CTX_SIZE = 8,
   _RSP_SIZE = 8,
 
   _XFER = 0,
-  _XMM_SAVE  = _XFER     + _XFER_SIZE,
-  _INP_END   = _XMM_SAVE + _XMM_SAVE_SIZE,
+  _INP_END   = _XFER     + _XFER_SIZE,
   _INP       = _INP_END  + _INP_END_SIZE,
   _CTX       = _INP      + _INP_SIZE,
   _RSP       = _CTX      + _CTX_SIZE,
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -3236,11 +3236,6 @@
 #ifdef _WIN64
     // on win64, fill len_reg from stack position
     __ movl(len_reg, len_mem);
-    // save the xmm registers which must be preserved 6-15
-    __ subptr(rsp, -rsp_after_call_off * wordSize);
-    for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
-      __ movdqu(xmm_save(i), as_XMMRegister(i));
-    }
 #else
     __ push(len_reg); // Save
 #endif
@@ -3281,10 +3276,6 @@
     __ movdqu(Address(rvec, 0), xmm_result);     // final value of r stored in rvec of CipherBlockChaining object
 
 #ifdef _WIN64
-    // restore xmm regs belonging to calling function
-    for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
-      __ movdqu(as_XMMRegister(i), xmm_save(i));
-    }
     __ movl(rax, len_mem);
 #else
     __ pop(rax); // return length
@@ -3446,11 +3437,6 @@
 #ifdef _WIN64
     // on win64, fill len_reg from stack position
     __ movl(len_reg, len_mem);
-    // save the xmm registers which must be preserved 6-15
-    __ subptr(rsp, -rsp_after_call_off * wordSize);
-    for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
-      __ movdqu(xmm_save(i), as_XMMRegister(i));
-    }
 #else
     __ push(len_reg); // Save
 #endif
@@ -3644,10 +3630,6 @@
     __ movdqu(Address(rvec, 0), xmm_prev_block_cipher);     // final value of r stored in rvec of CipherBlockChaining object
     __ pop(rbx);
 #ifdef _WIN64
-    // restore regs belonging to calling function
-    for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
-      __ movdqu(as_XMMRegister(i), xmm_save(i));
-    }
     __ movl(rax, len_mem);
 #else
     __ pop(rax); // return length
@@ -3699,25 +3681,12 @@
 
     __ enter();
 
-#ifdef _WIN64
-    // save the xmm registers which must be preserved 6-7
-    __ subptr(rsp, 4 * wordSize);
-    __ movdqu(Address(rsp, 0), xmm6);
-    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-#endif
-
     __ subptr(rsp, 4 * wordSize);
 
     __ fast_sha1(abcd, e0, e1, msg0, msg1, msg2, msg3, shuf_mask,
       buf, state, ofs, limit, rsp, multi_block);
 
     __ addptr(rsp, 4 * wordSize);
-#ifdef _WIN64
-    // restore xmm regs belonging to calling function
-    __ movdqu(xmm6, Address(rsp, 0));
-    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
-    __ addptr(rsp, 4 * wordSize);
-#endif
 
     __ leave();
     __ ret(0);
@@ -3775,22 +3744,6 @@
     const XMMRegister shuf_mask = xmm8;
 
     __ enter();
-#ifdef _WIN64
-    // save the xmm registers which must be preserved 6-7
-    __ subptr(rsp, 6 * wordSize);
-    __ movdqu(Address(rsp, 0), xmm6);
-    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-    __ movdqu(Address(rsp, 4 * wordSize), xmm8);
-
-    if (!VM_Version::supports_sha() && VM_Version::supports_avx2()) {
-      __ subptr(rsp, 10 * wordSize);
-      __ movdqu(Address(rsp, 0), xmm9);
-      __ movdqu(Address(rsp, 2 * wordSize), xmm10);
-      __ movdqu(Address(rsp, 4 * wordSize), xmm11);
-      __ movdqu(Address(rsp, 6 * wordSize), xmm12);
-      __ movdqu(Address(rsp, 8 * wordSize), xmm13);
-    }
-#endif
 
     __ subptr(rsp, 4 * wordSize);
 
@@ -3802,21 +3755,7 @@
         buf, state, ofs, limit, rsp, multi_block, shuf_mask);
     }
     __ addptr(rsp, 4 * wordSize);
-#ifdef _WIN64
-    // restore xmm regs belonging to calling function
-    if (!VM_Version::supports_sha() && VM_Version::supports_avx2()) {
-      __ movdqu(xmm9, Address(rsp, 0));
-      __ movdqu(xmm10, Address(rsp, 2 * wordSize));
-      __ movdqu(xmm11, Address(rsp, 4 * wordSize));
-      __ movdqu(xmm12, Address(rsp, 6 * wordSize));
-      __ movdqu(xmm13, Address(rsp, 8 * wordSize));
-      __ addptr(rsp, 10 * wordSize);
-    }
-    __ movdqu(xmm6, Address(rsp, 0));
-    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
-    __ movdqu(xmm8, Address(rsp, 4 * wordSize));
-    __ addptr(rsp, 6 * wordSize);
-#endif
+
     __ leave();
     __ ret(0);
     return start;
@@ -3917,18 +3856,14 @@
     }
 
 #ifdef _WIN64
-    // save the xmm registers which must be preserved 6-14
-    const int XMM_REG_NUM_KEY_LAST = 14;
-    __ subptr(rsp, -rsp_after_call_off * wordSize);
-    for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
-      __ movdqu(xmm_save(i), as_XMMRegister(i));
-    }
-
-    const Address r13_save(rbp, rdi_off * wordSize);
-    const Address r14_save(rbp, rsi_off * wordSize);
-
-    __ movptr(r13_save, r13);
-    __ movptr(r14_save, r14);
+    // allocate spill slots for r13, r14
+    enum {
+        saved_r13_offset,
+        saved_r14_offset
+    };
+    __ subptr(rsp, 2 * wordSize);
+    __ movptr(Address(rsp, saved_r13_offset * wordSize), r13);
+    __ movptr(Address(rsp, saved_r14_offset * wordSize), r14);
 
     // on win64, fill len_reg from stack position
     __ movl(len_reg, len_mem);
@@ -4130,13 +4065,10 @@
     __ movdqu(Address(counter, 0), xmm_curr_counter); //save counter back
     __ pop(rbx); // pop the saved RBX.
 #ifdef _WIN64
-    // restore regs belonging to calling function
-    for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) {
-      __ movdqu(as_XMMRegister(i), xmm_save(i));
-    }
     __ movl(rax, len_mem);
-    __ movptr(r13, r13_save);
-    __ movptr(r14, r14_save);
+    __ movptr(r13, Address(rsp, saved_r13_offset * wordSize));
+    __ movptr(r14, Address(rsp, saved_r14_offset * wordSize));
+    __ addptr(rsp, 2 * wordSize);
 #else
     __ pop(rax); // return 'len'
 #endif
@@ -4177,10 +4109,6 @@
     const Register data         = c_rarg2;
     const Register blocks       = c_rarg3;
 
-#ifdef _WIN64
-    const int XMM_REG_LAST  = 10;
-#endif
-
     const XMMRegister xmm_temp0 = xmm0;
     const XMMRegister xmm_temp1 = xmm1;
     const XMMRegister xmm_temp2 = xmm2;
@@ -4203,14 +4131,6 @@
       __ kmovql(k1, rax);
     }
 
-#ifdef _WIN64
-    // save the xmm registers which must be preserved 6-10
-    __ subptr(rsp, -rsp_after_call_off * wordSize);
-    for (int i = 6; i <= XMM_REG_LAST; i++) {
-      __ movdqu(xmm_save(i), as_XMMRegister(i));
-    }
-#endif
-
     __ movdqu(xmm_temp10, ExternalAddress(StubRoutines::x86::ghash_long_swap_mask_addr()));
 
     __ movdqu(xmm_temp0, Address(state, 0));
@@ -4310,12 +4230,6 @@
     __ pshufb(xmm_temp6, xmm_temp10);          // Byte swap 16-byte result
     __ movdqu(Address(state, 0), xmm_temp6);   // store the result
 
-#ifdef _WIN64
-    // restore xmm regs belonging to calling function
-    for (int i = 6; i <= XMM_REG_LAST; i++) {
-      __ movdqu(as_XMMRegister(i), xmm_save(i));
-    }
-#endif
     __ leave();
     __ ret(0);
     return start;
@@ -4652,21 +4566,8 @@
     BLOCK_COMMENT("Entry:");
     __ enter(); // required for proper stackwalking of RuntimeStub frame
 
-#ifdef _WIN64
-    // save the xmm registers which must be preserved 6-7
-    __ subptr(rsp, 4 * wordSize);
-    __ movdqu(Address(rsp, 0), xmm6);
-    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-#endif
       __ fast_exp(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp);
 
-#ifdef _WIN64
-    // restore xmm regs belonging to calling function
-      __ movdqu(xmm6, Address(rsp, 0));
-      __ movdqu(xmm7, Address(rsp, 2 * wordSize));
-      __ addptr(rsp, 4 * wordSize);
-#endif
-
     __ leave(); // required for proper stackwalking of RuntimeStub frame
     __ ret(0);
 
@@ -4693,21 +4594,8 @@
     BLOCK_COMMENT("Entry:");
     __ enter(); // required for proper stackwalking of RuntimeStub frame
 
-#ifdef _WIN64
-    // save the xmm registers which must be preserved 6-7
-    __ subptr(rsp, 4 * wordSize);
-    __ movdqu(Address(rsp, 0), xmm6);
-    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-#endif
     __ fast_log(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2);
 
-#ifdef _WIN64
-    // restore xmm regs belonging to calling function
-    __ movdqu(xmm6, Address(rsp, 0));
-    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
-    __ addptr(rsp, 4 * wordSize);
-#endif
-
     __ leave(); // required for proper stackwalking of RuntimeStub frame
     __ ret(0);
 
@@ -4733,21 +4621,8 @@
     BLOCK_COMMENT("Entry:");
     __ enter(); // required for proper stackwalking of RuntimeStub frame
 
-#ifdef _WIN64
-    // save the xmm registers which must be preserved 6-7
-    __ subptr(rsp, 4 * wordSize);
-    __ movdqu(Address(rsp, 0), xmm6);
-    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-#endif
     __ fast_log10(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp);
 
-#ifdef _WIN64
-    // restore xmm regs belonging to calling function
-    __ movdqu(xmm6, Address(rsp, 0));
-    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
-    __ addptr(rsp, 4 * wordSize);
-#endif
-
     __ leave(); // required for proper stackwalking of RuntimeStub frame
     __ ret(0);
 
@@ -4776,21 +4651,8 @@
     BLOCK_COMMENT("Entry:");
     __ enter(); // required for proper stackwalking of RuntimeStub frame
 
-#ifdef _WIN64
-    // save the xmm registers which must be preserved 6-7
-    __ subptr(rsp, 4 * wordSize);
-    __ movdqu(Address(rsp, 0), xmm6);
-    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
-#endif
     __ fast_pow(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
 
-#ifdef _WIN64
-    // restore xmm regs belonging to calling function
-    __ movdqu(xmm6, Address(rsp, 0));
-    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
-    __ addptr(rsp, 4 * wordSize);
-#endif
-
     __ leave(); // required for proper stackwalking of RuntimeStub frame
     __ ret(0);
 
@@ -4822,18 +4684,10 @@
 #ifdef _WIN64
     __ push(rsi);
     __ push(rdi);
-    // save the xmm registers which must be preserved 6-7
-    __ subptr(rsp, 4 * wordSize);
-    __ movdqu(Address(rsp, 0), xmm6);
-    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
 #endif
     __ fast_sin(x0, x1, x2, x3, x4, x5, x6, x7, rax, rbx, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
 
 #ifdef _WIN64
-    // restore xmm regs belonging to calling function
-    __ movdqu(xmm6, Address(rsp, 0));
-    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
-    __ addptr(rsp, 4 * wordSize);
     __ pop(rdi);
     __ pop(rsi);
 #endif
@@ -4869,18 +4723,10 @@
 #ifdef _WIN64
     __ push(rsi);
     __ push(rdi);
-    // save the xmm registers which must be preserved 6-7
-    __ subptr(rsp, 4 * wordSize);
-    __ movdqu(Address(rsp, 0), xmm6);
-    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
 #endif
     __ fast_cos(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
 
 #ifdef _WIN64
-    // restore xmm regs belonging to calling function
-    __ movdqu(xmm6, Address(rsp, 0));
-    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
-    __ addptr(rsp, 4 * wordSize);
     __ pop(rdi);
     __ pop(rsi);
 #endif
@@ -4916,18 +4762,10 @@
 #ifdef _WIN64
     __ push(rsi);
     __ push(rdi);
-    // save the xmm registers which must be preserved 6-7
-    __ subptr(rsp, 4 * wordSize);
-    __ movdqu(Address(rsp, 0), xmm6);
-    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
 #endif
     __ fast_tan(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4);
 
 #ifdef _WIN64
-    // restore xmm regs belonging to calling function
-    __ movdqu(xmm6, Address(rsp, 0));
-    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
-    __ addptr(rsp, 4 * wordSize);
     __ pop(rdi);
     __ pop(rsi);
 #endif
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -55,7 +55,7 @@
 // Run with +PrintInterpreter to get the VM to print out the size.
 // Max size with JVMTI
 #ifdef AMD64
-int TemplateInterpreter::InterpreterCodeSize = 256 * 1024;
+int TemplateInterpreter::InterpreterCodeSize = JVMCI_ONLY(268) NOT_JVMCI(256) * 1024;
 #else
 int TemplateInterpreter::InterpreterCodeSize = 224 * 1024;
 #endif // AMD64
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -341,6 +341,27 @@
   //        [ lo(arg) ]
   //        [ hi(arg) ]
   //
+  if (kind == Interpreter::java_lang_math_fmaD) {
+    __ movdbl(xmm2, Address(rsp, 5 * wordSize));
+    __ movdbl(xmm1, Address(rsp, 3 * wordSize));
+    __ movdbl(xmm0, Address(rsp, 1 * wordSize));
+    __ fmad(xmm0, xmm1, xmm2, xmm0);
+    __ pop(rdi);                               // get return address
+    __ mov(rsp, rsi);                          // set sp to sender sp
+    __ jmp(rdi);
+
+    return entry_point;
+  } else if (kind == Interpreter::java_lang_math_fmaF) {
+    __ movflt(xmm2, Address(rsp, 3 * wordSize));
+    __ movflt(xmm1, Address(rsp, 2 * wordSize));
+    __ movflt(xmm0, Address(rsp, 1 * wordSize));
+    __ fmaf(xmm0, xmm1, xmm2, xmm0);
+    __ pop(rdi);                               // get return address
+    __ mov(rsp, rsi);                          // set sp to sender sp
+    __ jmp(rdi);
+
+    return entry_point;
+ }
 
   __ fld_d(Address(rsp, 1*wordSize));
   switch (kind) {
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -369,8 +369,17 @@
   //        [ hi(arg) ]
   //
 
-
-  if (kind == Interpreter::java_lang_math_sqrt) {
+  if (kind == Interpreter::java_lang_math_fmaD) {
+    __ movdbl(xmm0, Address(rsp, wordSize));
+    __ movdbl(xmm1, Address(rsp, 3 * wordSize));
+    __ movdbl(xmm2, Address(rsp, 5 * wordSize));
+    __ fmad(xmm0, xmm1, xmm2, xmm0);
+  } else if (kind == Interpreter::java_lang_math_fmaF) {
+    __ movflt(xmm0, Address(rsp, wordSize));
+    __ movflt(xmm1, Address(rsp, 2 * wordSize));
+    __ movflt(xmm2, Address(rsp, 3 * wordSize));
+    __ fmaf(xmm0, xmm1, xmm2, xmm0);
+  } else if (kind == Interpreter::java_lang_math_sqrt) {
     __ sqrtsd(xmm0, Address(rsp, wordSize));
   } else if (kind == Interpreter::java_lang_math_exp) {
     __ movdbl(xmm0, Address(rsp, wordSize));
--- a/hotspot/src/cpu/x86/vm/vmStructs_x86.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/vmStructs_x86.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -73,6 +73,7 @@
 #define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
   declare_preprocessor_constant("VM_Version::CPU_AVX512BW", CPU_AVX512BW) \
   declare_preprocessor_constant("VM_Version::CPU_AVX512VL", CPU_AVX512VL) \
-  declare_preprocessor_constant("VM_Version::CPU_SHA", CPU_SHA)
+  declare_preprocessor_constant("VM_Version::CPU_SHA", CPU_SHA)           \
+  declare_preprocessor_constant("VM_Version::CPU_FMA", CPU_FMA)
 
 #endif // CPU_X86_VM_VMSTRUCTS_X86_HPP
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -578,7 +578,7 @@
   }
 
   char buf[256];
-  jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+  jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
                cores_per_cpu(), threads_per_core(),
                cpu_family(), _model, _stepping,
                (supports_cmov() ? ", cmov" : ""),
@@ -610,7 +610,8 @@
                (supports_bmi2() ? ", bmi2" : ""),
                (supports_adx() ? ", adx" : ""),
                (supports_evex() ? ", evex" : ""),
-               (supports_sha() ? ", sha" : ""));
+               (supports_sha() ? ", sha" : ""),
+               (supports_fma() ? ", fma" : ""));
   _features_string = os::strdup(buf);
 
   // UseSSE is set to the smaller of what hardware supports and what
@@ -732,6 +733,15 @@
     FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
   }
 
+  if (supports_fma() && UseSSE >= 2) {
+    if (FLAG_IS_DEFAULT(UseFMA)) {
+      UseFMA = true;
+    }
+  } else if (UseFMA) {
+    warning("FMA instructions are not available on this CPU");
+    FLAG_SET_DEFAULT(UseFMA, false);
+  }
+
   if (supports_sha() LP64_ONLY(|| supports_avx2() && supports_bmi2())) {
     if (FLAG_IS_DEFAULT(UseSHA)) {
       UseSHA = true;
@@ -773,7 +783,6 @@
     FLAG_SET_DEFAULT(UseAdler32Intrinsics, false);
   }
 
-  // Adjust RTM (Restricted Transactional Memory) flags
   if (!supports_rtm() && UseRTMLocking) {
     // Can't continue because UseRTMLocking affects UseBiasedLocking flag
     // setting during arguments processing. See use_biased_locking().
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -74,7 +74,8 @@
                         : 1,
                ssse3    : 1,
                cid      : 1,
-                        : 2,
+                        : 1,
+               fma      : 1,
                cmpxchg16: 1,
                         : 4,
                dca      : 1,
@@ -289,6 +290,7 @@
 #define CPU_AVX512BW ((uint64_t)UCONST64(0x100000000)) // enums are limited to 31 bit
 #define CPU_AVX512VL ((uint64_t)UCONST64(0x200000000)) // EVEX instructions with smaller vector length
 #define CPU_SHA ((uint64_t)UCONST64(0x400000000))      // SHA instructions
+#define CPU_FMA ((uint64_t)UCONST64(0x800000000))      // FMA instructions
 
   enum Extended_Family {
     // AMD
@@ -522,6 +524,8 @@
         result |= CPU_SHA;
       if(_cpuid_info.ext_cpuid1_ecx.bits.lzcnt_intel != 0)
         result |= CPU_LZCNT;
+      if (_cpuid_info.std_cpuid1_ecx.bits.fma != 0)
+        result |= CPU_FMA;
       // for Intel, ecx.bits.misalignsse bit (bit 8) indicates support for prefetchw
       if (_cpuid_info.ext_cpuid1_ecx.bits.misalignsse != 0) {
         result |= CPU_3DNOW_PREFETCH;
@@ -726,6 +730,7 @@
   static bool supports_avx256only() { return (supports_avx2() && !supports_evex()); }
   static bool supports_avxonly()    { return ((supports_avx2() || supports_avx()) && !supports_evex()); }
   static bool supports_sha()        { return (_features & CPU_SHA) != 0; }
+  static bool supports_fma()        { return (_features & CPU_FMA) != 0; }
   // Intel features
   static bool is_intel_family_core() { return is_intel() &&
                                        extended_cpu_family() == CPU_FAMILY_INTEL_CORE; }
--- a/hotspot/src/cpu/x86/vm/x86.ad	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/x86.ad	Fri Sep 30 02:52:38 2016 -0700
@@ -176,451 +176,6 @@
 reg_def XMM5o( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(14));
 reg_def XMM5p( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(15));
 
-#ifdef _WIN64
-
-reg_def XMM6 ( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg());
-reg_def XMM6b( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(1));
-reg_def XMM6c( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(2));
-reg_def XMM6d( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(3));
-reg_def XMM6e( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(4));
-reg_def XMM6f( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(5));
-reg_def XMM6g( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(6));
-reg_def XMM6h( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(7));
-reg_def XMM6i( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(8));
-reg_def XMM6j( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(9));
-reg_def XMM6k( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(10));
-reg_def XMM6l( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(11));
-reg_def XMM6m( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(12));
-reg_def XMM6n( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(13));
-reg_def XMM6o( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(14));
-reg_def XMM6p( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(15));
-
-reg_def XMM7 ( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg());
-reg_def XMM7b( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(1));
-reg_def XMM7c( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(2));
-reg_def XMM7d( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(3));
-reg_def XMM7e( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(4));
-reg_def XMM7f( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(5));
-reg_def XMM7g( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(6));
-reg_def XMM7h( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(7));
-reg_def XMM7i( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(8));
-reg_def XMM7j( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(9));
-reg_def XMM7k( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(10));
-reg_def XMM7l( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(11));
-reg_def XMM7m( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(12));
-reg_def XMM7n( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(13));
-reg_def XMM7o( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(14));
-reg_def XMM7p( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(15));
-
-reg_def XMM8 ( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg());
-reg_def XMM8b( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(1));
-reg_def XMM8c( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(2));
-reg_def XMM8d( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(3));
-reg_def XMM8e( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(4));
-reg_def XMM8f( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(5));
-reg_def XMM8g( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(6));
-reg_def XMM8h( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(7));
-reg_def XMM8i( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(8));
-reg_def XMM8j( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(9));
-reg_def XMM8k( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(10));
-reg_def XMM8l( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(11));
-reg_def XMM8m( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(12));
-reg_def XMM8n( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(13));
-reg_def XMM8o( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(14));
-reg_def XMM8p( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(15));
-
-reg_def XMM9 ( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg());
-reg_def XMM9b( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(1));
-reg_def XMM9c( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(2));
-reg_def XMM9d( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(3));
-reg_def XMM9e( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(4));
-reg_def XMM9f( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(5));
-reg_def XMM9g( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(6));
-reg_def XMM9h( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(7));
-reg_def XMM9i( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(8));
-reg_def XMM9j( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(9));
-reg_def XMM9k( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(10));
-reg_def XMM9l( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(11));
-reg_def XMM9m( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(12));
-reg_def XMM9n( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(13));
-reg_def XMM9o( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(14));
-reg_def XMM9p( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(15));
-
-reg_def XMM10 ( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg());
-reg_def XMM10b( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(1));
-reg_def XMM10c( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(2));
-reg_def XMM10d( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(3));
-reg_def XMM10e( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(4));
-reg_def XMM10f( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(5));
-reg_def XMM10g( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(6));
-reg_def XMM10h( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(7));
-reg_def XMM10i( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(8));
-reg_def XMM10j( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(9));
-reg_def XMM10k( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(10));
-reg_def XMM10l( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(11));
-reg_def XMM10m( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(12));
-reg_def XMM10n( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(13));
-reg_def XMM10o( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(14));
-reg_def XMM10p( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(15));
-
-reg_def XMM11 ( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg());
-reg_def XMM11b( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(1));
-reg_def XMM11c( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(2));
-reg_def XMM11d( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(3));
-reg_def XMM11e( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(4));
-reg_def XMM11f( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(5));
-reg_def XMM11g( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(6));
-reg_def XMM11h( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(7));
-reg_def XMM11i( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(8));
-reg_def XMM11j( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(9));
-reg_def XMM11k( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(10));
-reg_def XMM11l( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(11));
-reg_def XMM11m( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(12));
-reg_def XMM11n( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(13));
-reg_def XMM11o( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(14));
-reg_def XMM11p( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(15));
-
-reg_def XMM12 ( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg());
-reg_def XMM12b( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(1));
-reg_def XMM12c( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(2));
-reg_def XMM12d( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(3));
-reg_def XMM12e( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(4));
-reg_def XMM12f( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(5));
-reg_def XMM12g( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(6));
-reg_def XMM12h( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(7));
-reg_def XMM12i( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(8));
-reg_def XMM12j( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(9));
-reg_def XMM12k( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(10));
-reg_def XMM12l( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(11));
-reg_def XMM12m( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(12));
-reg_def XMM12n( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(13));
-reg_def XMM12o( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(14));
-reg_def XMM12p( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(15));
-
-reg_def XMM13 ( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg());
-reg_def XMM13b( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(1));
-reg_def XMM13c( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(2));
-reg_def XMM13d( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(3));
-reg_def XMM13e( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(4));
-reg_def XMM13f( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(5));
-reg_def XMM13g( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(6));
-reg_def XMM13h( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(7));
-reg_def XMM13i( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(8));
-reg_def XMM13j( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(9));
-reg_def XMM13k( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(10));
-reg_def XMM13l( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(11));
-reg_def XMM13m( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(12));
-reg_def XMM13n( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(13));
-reg_def XMM13o( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(14));
-reg_def XMM13p( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(15));
-
-reg_def XMM14 ( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg());
-reg_def XMM14b( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(1));
-reg_def XMM14c( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(2));
-reg_def XMM14d( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(3));
-reg_def XMM14e( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(4));
-reg_def XMM14f( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(5));
-reg_def XMM14g( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(6));
-reg_def XMM14h( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(7));
-reg_def XMM14i( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(8));
-reg_def XMM14j( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(9));
-reg_def XMM14k( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(10));
-reg_def XMM14l( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(11));
-reg_def XMM14m( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(12));
-reg_def XMM14n( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(13));
-reg_def XMM14o( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(14));
-reg_def XMM14p( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(15));
-
-reg_def XMM15 ( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg());
-reg_def XMM15b( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(1));
-reg_def XMM15c( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(2));
-reg_def XMM15d( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(3));
-reg_def XMM15e( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(4));
-reg_def XMM15f( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(5));
-reg_def XMM15g( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(6));
-reg_def XMM15h( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(7));
-reg_def XMM15i( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(8));
-reg_def XMM15j( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(9));
-reg_def XMM15k( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(10));
-reg_def XMM15l( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(11));
-reg_def XMM15m( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(12));
-reg_def XMM15n( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(13));
-reg_def XMM15o( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(14));
-reg_def XMM15p( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(15));
-
-reg_def XMM16 ( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg());
-reg_def XMM16b( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(1));
-reg_def XMM16c( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(2));
-reg_def XMM16d( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(3));
-reg_def XMM16e( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(4));
-reg_def XMM16f( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(5));
-reg_def XMM16g( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(6));
-reg_def XMM16h( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(7));
-reg_def XMM16i( SOC, SOE, Op_RegF, 16, xmm15->as_VMReg()->next(8));
-reg_def XMM16j( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(9));
-reg_def XMM16k( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(10));
-reg_def XMM16l( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(11));
-reg_def XMM16m( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(12));
-reg_def XMM16n( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(13));
-reg_def XMM16o( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(14));
-reg_def XMM16p( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(15));
-
-reg_def XMM17 ( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg());
-reg_def XMM17b( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(1));
-reg_def XMM17c( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(2));
-reg_def XMM17d( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(3));
-reg_def XMM17e( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(4));
-reg_def XMM17f( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(5));
-reg_def XMM17g( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(6));
-reg_def XMM17h( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(7));
-reg_def XMM17i( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(8));
-reg_def XMM17j( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(9));
-reg_def XMM17k( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(10));
-reg_def XMM17l( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(11));
-reg_def XMM17m( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(12));
-reg_def XMM17n( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(13));
-reg_def XMM17o( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(14));
-reg_def XMM17p( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(15));
-
-reg_def XMM18 ( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg());
-reg_def XMM18b( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(1));
-reg_def XMM18c( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(2));
-reg_def XMM18d( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(3));
-reg_def XMM18e( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(4));
-reg_def XMM18f( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(5));
-reg_def XMM18g( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(6));
-reg_def XMM18h( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(7));
-reg_def XMM18i( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(8));
-reg_def XMM18j( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(9));
-reg_def XMM18k( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(10));
-reg_def XMM18l( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(11));
-reg_def XMM18m( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(12));
-reg_def XMM18n( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(13));
-reg_def XMM18o( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(14));
-reg_def XMM18p( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(15));
-
-reg_def XMM19 ( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg());
-reg_def XMM19b( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(1));
-reg_def XMM19c( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(2));
-reg_def XMM19d( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(3));
-reg_def XMM19e( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(4));
-reg_def XMM19f( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(5));
-reg_def XMM19g( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(6));
-reg_def XMM19h( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(7));
-reg_def XMM19i( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(8));
-reg_def XMM19j( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(9));
-reg_def XMM19k( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(10));
-reg_def XMM19l( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(11));
-reg_def XMM19m( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(12));
-reg_def XMM19n( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(13));
-reg_def XMM19o( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(14));
-reg_def XMM19p( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(15));
-
-reg_def XMM20 ( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg());
-reg_def XMM20b( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(1));
-reg_def XMM20c( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(2));
-reg_def XMM20d( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(3));
-reg_def XMM20e( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(4));
-reg_def XMM20f( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(5));
-reg_def XMM20g( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(6));
-reg_def XMM20h( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(7));
-reg_def XMM20i( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(8));
-reg_def XMM20j( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(9));
-reg_def XMM20k( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(10));
-reg_def XMM20l( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(11));
-reg_def XMM20m( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(12));
-reg_def XMM20n( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(13));
-reg_def XMM20o( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(14));
-reg_def XMM20p( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(15));
-
-reg_def XMM21 ( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg());
-reg_def XMM21b( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(1));
-reg_def XMM21c( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(2));
-reg_def XMM21d( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(3));
-reg_def XMM21e( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(4));
-reg_def XMM21f( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(5));
-reg_def XMM21g( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(6));
-reg_def XMM21h( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(7));
-reg_def XMM21i( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(8));
-reg_def XMM21j( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(9));
-reg_def XMM21k( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(10));
-reg_def XMM21l( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(11));
-reg_def XMM21m( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(12));
-reg_def XMM21n( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(13));
-reg_def XMM21o( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(14));
-reg_def XMM21p( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(15));
-
-reg_def XMM22 ( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg());
-reg_def XMM22b( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(1));
-reg_def XMM22c( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(2));
-reg_def XMM22d( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(3));
-reg_def XMM22e( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(4));
-reg_def XMM22f( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(5));
-reg_def XMM22g( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(6));
-reg_def XMM22h( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(7));
-reg_def XMM22i( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(8));
-reg_def XMM22j( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(9));
-reg_def XMM22k( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(10));
-reg_def XMM22l( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(11));
-reg_def XMM22m( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(12));
-reg_def XMM22n( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(13));
-reg_def XMM22o( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(14));
-reg_def XMM22p( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(15));
-
-reg_def XMM23 ( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg());
-reg_def XMM23b( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(1));
-reg_def XMM23c( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(2));
-reg_def XMM23d( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(3));
-reg_def XMM23e( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(4));
-reg_def XMM23f( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(5));
-reg_def XMM23g( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(6));
-reg_def XMM23h( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(7));
-reg_def XMM23i( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(8));
-reg_def XMM23j( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(9));
-reg_def XMM23k( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(10));
-reg_def XMM23l( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(11));
-reg_def XMM23m( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(12));
-reg_def XMM23n( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(13));
-reg_def XMM23o( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(14));
-reg_def XMM23p( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(15));
-
-reg_def XMM24 ( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg());
-reg_def XMM24b( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(1));
-reg_def XMM24c( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(2));
-reg_def XMM24d( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(3));
-reg_def XMM24e( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(4));
-reg_def XMM24f( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(5));
-reg_def XMM24g( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(6));
-reg_def XMM24h( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(7));
-reg_def XMM24i( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(8));
-reg_def XMM24j( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(9));
-reg_def XMM24k( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(10));
-reg_def XMM24l( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(11));
-reg_def XMM24m( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(12));
-reg_def XMM24n( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(13));
-reg_def XMM24o( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(14));
-reg_def XMM24p( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(15));
-
-reg_def XMM25 ( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg());
-reg_def XMM25b( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(1));
-reg_def XMM25c( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(2));
-reg_def XMM25d( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(3));
-reg_def XMM25e( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(4));
-reg_def XMM25f( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(5));
-reg_def XMM25g( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(6));
-reg_def XMM25h( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(7));
-reg_def XMM25i( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(8));
-reg_def XMM25j( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(9));
-reg_def XMM25k( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(10));
-reg_def XMM25l( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(11));
-reg_def XMM25m( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(12));
-reg_def XMM25n( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(13));
-reg_def XMM25o( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(14));
-reg_def XMM25p( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(15));
-
-reg_def XMM26 ( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg());
-reg_def XMM26b( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(1));
-reg_def XMM26c( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(2));
-reg_def XMM26d( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(3));
-reg_def XMM26e( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(4));
-reg_def XMM26f( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(5));
-reg_def XMM26g( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(6));
-reg_def XMM26h( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(7));
-reg_def XMM26i( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(8));
-reg_def XMM26j( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(9));
-reg_def XMM26k( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(10));
-reg_def XMM26l( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(11));
-reg_def XMM26m( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(12));
-reg_def XMM26n( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(13));
-reg_def XMM26o( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(14));
-reg_def XMM26p( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(15));
-
-reg_def XMM27g( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(1));
-reg_def XMM27c( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(2));
-reg_def XMM27d( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(3));
-reg_def XMM27e( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(4));
-reg_def XMM27f( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(5));
-reg_def XMM27g( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(6));
-reg_def XMM27h( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(7));
-reg_def XMM27i( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(8));
-reg_def XMM27j( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(9));
-reg_def XMM27k( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(10));
-reg_def XMM27l( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(11));
-reg_def XMM27m( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(12));
-reg_def XMM27n( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(13));
-reg_def XMM27o( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(14));
-reg_def XMM27p( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(15));
-
-reg_def XMM28 ( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg());
-reg_def XMM28b( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(1));
-reg_def XMM28c( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(2));
-reg_def XMM28d( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(3));
-reg_def XMM28e( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(4));
-reg_def XMM28f( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(5));
-reg_def XMM28g( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(6));
-reg_def XMM28h( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(7));
-reg_def XMM28i( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(8));
-reg_def XMM28j( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(9));
-reg_def XMM28k( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(10));
-reg_def XMM28l( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(11));
-reg_def XMM28m( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(12));
-reg_def XMM28n( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(13));
-reg_def XMM28o( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(14));
-reg_def XMM28p( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(15));
-
-reg_def XMM29 ( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg());
-reg_def XMM29b( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(1));
-reg_def XMM29c( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(2));
-reg_def XMM29d( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(3));
-reg_def XMM29e( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(4));
-reg_def XMM29f( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(5));
-reg_def XMM29g( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(6));
-reg_def XMM29h( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(7));
-reg_def XMM29i( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(8));
-reg_def XMM29j( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(9));
-reg_def XMM29k( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(10));
-reg_def XMM29l( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(11));
-reg_def XMM29m( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(12));
-reg_def XMM29n( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(13));
-reg_def XMM29o( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(14));
-reg_def XMM29p( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(15));
-
-reg_def XMM30 ( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg());
-reg_def XMM30b( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(1));
-reg_def XMM30c( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(2));
-reg_def XMM30d( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(3));
-reg_def XMM30e( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(4));
-reg_def XMM30f( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(5));
-reg_def XMM30g( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(6));
-reg_def XMM30h( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(7));
-reg_def XMM30i( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(8));
-reg_def XMM30j( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(9));
-reg_def XMM30k( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(10));
-reg_def XMM30l( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(11));
-reg_def XMM30m( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(12));
-reg_def XMM30n( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(13));
-reg_def XMM30o( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(14));
-reg_def XMM30p( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(15));
-
-reg_def XMM31 ( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg());
-reg_def XMM31b( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(1));
-reg_def XMM31c( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(2));
-reg_def XMM31d( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(3));
-reg_def XMM31e( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(4));
-reg_def XMM31f( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(5));
-reg_def XMM31g( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(6));
-reg_def XMM31h( SOC, SOE, Op_RegF, 31, xmm31>-as_VMReg()->next(7));
-reg_def XMM31i( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(8));
-reg_def XMM31j( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(9));
-reg_def XMM31k( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(10));
-reg_def XMM31l( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(11));
-reg_def XMM31m( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(12));
-reg_def XMM31n( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(13));
-reg_def XMM31o( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(14));
-reg_def XMM31p( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(15));
-
-#else // _WIN64
-
 reg_def XMM6 ( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg());
 reg_def XMM6b( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(1));
 reg_def XMM6c( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(2));
@@ -1067,8 +622,6 @@
 
 #endif // _LP64
 
-#endif // _WIN64
-
 #ifdef _LP64
 reg_def RFLAGS(SOC, SOC, 0, 16, VMRegImpl::Bad());
 #else
@@ -3113,6 +2666,30 @@
   ins_pipe(pipe_slow);
 %}
 
+// a * b + c
+instruct fmaD_reg(regD a, regD b, regD c) %{
+  predicate(UseFMA);
+  match(Set c (FmaD  c (Binary a b)));
+  format %{ "fmasd $a,$b,$c\t# $c = $a * $b + $c" %}
+  ins_cost(150);
+  ins_encode %{
+    __ fmad($c$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $c$$XMMRegister);
+  %}
+  ins_pipe( pipe_slow );
+%}
+
+// a * b + c
+instruct fmaF_reg(regF a, regF b, regF c) %{
+  predicate(UseFMA);
+  match(Set c (FmaF  c (Binary a b)));
+  format %{ "fmass $a,$b,$c\t# $c = $a * $b + $c" %}
+  ins_cost(150);
+  ins_encode %{
+    __ fmaf($c$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $c$$XMMRegister);
+  %}
+  ins_pipe( pipe_slow );
+%}
+
 // ====================VECTOR INSTRUCTIONS=====================================
 
 // Load vectors (4 bytes long)
--- a/hotspot/src/cpu/x86/vm/x86_32.ad	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad	Fri Sep 30 02:52:38 2016 -0700
@@ -104,14 +104,14 @@
 //
 // Empty fill registers, which are never used, but supply alignment to xmm regs
 //
-reg_def FILL0( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(2));
-reg_def FILL1( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(3));
-reg_def FILL2( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(4));
-reg_def FILL3( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(5));
-reg_def FILL4( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(6));
-reg_def FILL5( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(7));
-reg_def FILL6( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(8));
-reg_def FILL7( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(9));
+reg_def FILL0( SOC, SOC, Op_RegF, 8, VMRegImpl::Bad());
+reg_def FILL1( SOC, SOC, Op_RegF, 9, VMRegImpl::Bad());
+reg_def FILL2( SOC, SOC, Op_RegF, 10, VMRegImpl::Bad());
+reg_def FILL3( SOC, SOC, Op_RegF, 11, VMRegImpl::Bad());
+reg_def FILL4( SOC, SOC, Op_RegF, 12, VMRegImpl::Bad());
+reg_def FILL5( SOC, SOC, Op_RegF, 13, VMRegImpl::Bad());
+reg_def FILL6( SOC, SOC, Op_RegF, 14, VMRegImpl::Bad());
+reg_def FILL7( SOC, SOC, Op_RegF, 15, VMRegImpl::Bad());
 
 // Specify priority of register selection within phases of register
 // allocation.  Highest priority is first.  A useful heuristic is to
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.amd64/src/jdk/vm/ci/amd64/AMD64.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.amd64/src/jdk/vm/ci/amd64/AMD64.java	Fri Sep 30 02:52:38 2016 -0700
@@ -205,7 +205,8 @@
         AVX512CD,
         AVX512BW,
         AVX512VL,
-        SHA
+        SHA,
+        FMA
     }
 
     private final EnumSet<CPUFeature> features;
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java	Fri Sep 30 02:52:38 2016 -0700
@@ -124,6 +124,9 @@
         if ((config.vmVersionFeatures & config.amd64SHA) != 0) {
             features.add(AMD64.CPUFeature.SHA);
         }
+        if ((config.vmVersionFeatures & config.amd64FMA) != 0) {
+            features.add(AMD64.CPUFeature.FMA);
+        }
         return features;
     }
 
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -78,4 +78,5 @@
     final long amd64AVX512BW = getConstant("VM_Version::CPU_AVX512BW", Long.class);
     final long amd64AVX512VL = getConstant("VM_Version::CPU_AVX512VL", Long.class);
     final long amd64SHA = getConstant("VM_Version::CPU_SHA", Long.class);
+    final long amd64FMA = getConstant("VM_Version::CPU_FMA", Long.class);
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java	Fri Sep 30 02:52:38 2016 -0700
@@ -26,8 +26,7 @@
 import static jdk.vm.ci.common.InitTimer.timer;
 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
+import java.lang.reflect.Executable;
 
 import jdk.vm.ci.code.BytecodeFrame;
 import jdk.vm.ci.code.InstalledCode;
@@ -385,10 +384,9 @@
     native boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type);
 
     /**
-     * Gets the method corresponding to {@code holder} and slot number {@code slot} (i.e.
-     * {@link Method#slot} or {@link Constructor#slot}).
+     * Gets the method corresponding to {@code executable}.
      */
-    native HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot(Class<?> holder, int slot);
+    native HotSpotResolvedJavaMethodImpl asResolvedJavaMethod(Executable executable);
 
     /**
      * Gets the maximum absolute offset of a PC relative call to {@code address} from any position
@@ -616,4 +614,9 @@
      */
     native int interpreterFrameSize(BytecodeFrame frame);
 
+    /**
+     * Invokes non-public method {@code java.lang.invoke.LambdaForm.compileToBytecode()} on
+     * {@code lambdaForm} (which must be a {@code java.lang.invoke.LambdaForm} instance).
+     */
+    native void compileToBytecode(Object lambdaForm);
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java	Fri Sep 30 02:52:38 2016 -0700
@@ -22,7 +22,7 @@
  */
 package jdk.vm.ci.hotspot;
 
-import java.lang.reflect.Field;
+import java.util.Map;
 
 import jdk.vm.ci.code.BailoutException;
 import jdk.vm.ci.code.BytecodeFrame;
@@ -56,16 +56,11 @@
     @Override
     public String getMarkName(Mark mark) {
         int markId = (int) mark.id;
-        Field[] fields = runtime.getConfig().getClass().getDeclaredFields();
-        for (Field f : fields) {
-            if (f.getName().startsWith("MARKID_")) {
-                f.setAccessible(true);
-                try {
-                    if (f.getInt(runtime.getConfig()) == markId) {
-                        return f.getName();
-                    }
-                } catch (Exception e) {
-                }
+        HotSpotVMConfigStore store = runtime.getConfigStore();
+        for (Map.Entry<String, Long> e : store.getConstants().entrySet()) {
+            String name = e.getKey();
+            if (name.startsWith("MARKID_") && e.getValue() == markId) {
+                return name;
             }
         }
         return CodeCacheProvider.super.getMarkName(mark);
@@ -76,17 +71,13 @@
      */
     @Override
     public String getTargetName(Call call) {
-        Field[] fields = runtime.getConfig().getClass().getDeclaredFields();
-        for (Field f : fields) {
-            if (f.getName().endsWith("Stub")) {
-                f.setAccessible(true);
-                Object address;
-                try {
-                    address = f.get(runtime.getConfig());
-                    if (address.equals(call.target)) {
-                        return f.getName() + ":0x" + Long.toHexString((Long) address);
-                    }
-                } catch (IllegalArgumentException | IllegalAccessException e) {
+        if (call.target instanceof HotSpotForeignCallTarget) {
+            long address = ((HotSpotForeignCallTarget) call.target).address;
+            HotSpotVMConfigStore store = runtime.getConfigStore();
+            for (Map.Entry<String, VMField> e : store.getFields().entrySet()) {
+                VMField field = e.getValue();
+                if (field.isStatic() && field.value != null && field.value == address) {
+                    return e.getValue() + ":0x" + Long.toHexString(address);
                 }
             }
         }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java	Fri Sep 30 02:52:38 2016 -0700
@@ -28,11 +28,10 @@
 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
 
 import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
 import java.lang.reflect.Executable;
 import java.lang.reflect.Field;
-import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.util.Objects;
 
 import jdk.vm.ci.code.CodeUtil;
 import jdk.vm.ci.code.TargetDescription;
@@ -78,35 +77,8 @@
         return new HotSpotSignature(runtime, signature);
     }
 
-    /**
-     * {@link Field} object of {@link Method#slot}.
-     */
-    private Field reflectionMethodSlot = getReflectionSlotField(Method.class);
-
-    /**
-     * {@link Field} object of {@link Constructor#slot}.
-     */
-    private Field reflectionConstructorSlot = getReflectionSlotField(Constructor.class);
-
-    private static Field getReflectionSlotField(Class<?> reflectionClass) {
-        try {
-            Field field = reflectionClass.getDeclaredField("slot");
-            field.setAccessible(true);
-            return field;
-        } catch (NoSuchFieldException | SecurityException e) {
-            throw new JVMCIError(e);
-        }
-    }
-
     public ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod) {
-        try {
-            Class<?> holder = reflectionMethod.getDeclaringClass();
-            Field slotField = reflectionMethod instanceof Constructor ? reflectionConstructorSlot : reflectionMethodSlot;
-            final int slot = slotField.getInt(reflectionMethod);
-            return runtime.getCompilerToVM().getResolvedJavaMethodAtSlot(holder, slot);
-        } catch (IllegalArgumentException | IllegalAccessException e) {
-            throw new JVMCIError(e);
-        }
+        return runtime.getCompilerToVM().asResolvedJavaMethod(Objects.requireNonNull(reflectionMethod));
     }
 
     public ResolvedJavaField lookupJavaField(Field reflectionField) {
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java	Fri Sep 30 02:52:38 2016 -0700
@@ -24,16 +24,17 @@
 
 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
-import static jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass;
+
+import java.lang.invoke.MethodHandle;
+import java.util.Objects;
+
 import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.meta.ConstantReflectionProvider;
 import jdk.vm.ci.meta.JavaConstant;
-import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.MethodHandleAccessProvider;
 import jdk.vm.ci.meta.ResolvedJavaField;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.ResolvedJavaType;
-import jdk.vm.ci.meta.Signature;
 
 public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider {
 
@@ -48,88 +49,46 @@
      * possible after the {@link HotSpotJVMCIRuntime} is fully initialized.
      */
     static class LazyInitialization {
+        static final ResolvedJavaType lambdaFormType;
         static final ResolvedJavaField methodHandleFormField;
         static final ResolvedJavaField lambdaFormVmentryField;
-        static final ResolvedJavaMethod lambdaFormCompileToBytecodeMethod;
         static final HotSpotResolvedJavaField memberNameVmtargetField;
 
-        static final ResolvedJavaType CLASS = fromObjectClass(LazyInitialization.class);
-
         /**
          * Search for an instance field with the given name in a class.
          *
-         * @param className name of the class to search in
+         * @param declaringType the type declaring the field
          * @param fieldName name of the field to be searched
          * @param fieldType resolved Java type of the field
          * @return resolved Java field
-         * @throws ClassNotFoundException
          * @throws NoSuchFieldError
          */
-        private static ResolvedJavaField findFieldInClass(String className, String fieldName, ResolvedJavaType fieldType)
-                throws ClassNotFoundException {
-            Class<?> clazz = Class.forName(className);
-            ResolvedJavaType type = runtime().fromClass(clazz);
-            ResolvedJavaField[] fields = type.getInstanceFields(false);
+        private static ResolvedJavaField findFieldInClass(ResolvedJavaType declaringType, String fieldName, ResolvedJavaType fieldType) {
+            ResolvedJavaField[] fields = declaringType.getInstanceFields(false);
             for (ResolvedJavaField field : fields) {
                 if (field.getName().equals(fieldName) && field.getType().equals(fieldType)) {
                     return field;
                 }
             }
-            throw new NoSuchFieldError(fieldType.getName() + " " + className + "." + fieldName);
+            throw new NoSuchFieldError(fieldType.getName() + " " + declaringType + "." + fieldName);
         }
 
-        private static ResolvedJavaMethod findMethodInClass(String className, String methodName,
-                ResolvedJavaType resultType, ResolvedJavaType[] parameterTypes) throws ClassNotFoundException {
-            Class<?> clazz = Class.forName(className);
-            HotSpotResolvedObjectTypeImpl type = fromObjectClass(clazz);
-            ResolvedJavaMethod result = null;
-            for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
-                if (method.getName().equals(methodName) && signatureMatches(method, resultType, parameterTypes)) {
-                    result = method;
-                }
-            }
-            if (result == null) {
-                StringBuilder sig = new StringBuilder("(");
-                for (ResolvedJavaType t : parameterTypes) {
-                    sig.append(t.getName()).append(",");
-                }
-                if (sig.length() > 1) {
-                    sig.replace(sig.length() - 1, sig.length(), ")");
-                } else {
-                    sig.append(')');
-                }
-                throw new NoSuchMethodError(resultType.getName() + " " + className + "." + methodName + sig.toString());
-            }
-            return result;
+        private static ResolvedJavaType resolveType(Class<?> c) {
+            return runtime().fromClass(c);
         }
 
-        private static boolean signatureMatches(ResolvedJavaMethod m, ResolvedJavaType resultType,
-                ResolvedJavaType[] parameterTypes) {
-            Signature s = m.getSignature();
-            if (!s.getReturnType(CLASS).equals(resultType)) {
-                return false;
-            }
-            if (s.getParameterCount(false) != parameterTypes.length) {
-                return false;
-            }
-            for (int i = 0; i < s.getParameterCount(false); ++i) {
-                if (!s.getParameterType(i, CLASS).equals(parameterTypes[i])) {
-                    return false;
-                }
-            }
-            return true;
+        private static ResolvedJavaType resolveType(String className) throws ClassNotFoundException {
+            return resolveType(Class.forName(className));
         }
 
         static {
             try {
-                methodHandleFormField = findFieldInClass("java.lang.invoke.MethodHandle", "form",
-                    fromObjectClass(Class.forName("java.lang.invoke.LambdaForm")));
-                lambdaFormVmentryField = findFieldInClass("java.lang.invoke.LambdaForm", "vmentry",
-                    fromObjectClass(Class.forName("java.lang.invoke.MemberName")));
-                lambdaFormCompileToBytecodeMethod = findMethodInClass("java.lang.invoke.LambdaForm", "compileToBytecode",
-                    new HotSpotResolvedPrimitiveType(JavaKind.Void), new ResolvedJavaType[]{});
-                memberNameVmtargetField = (HotSpotResolvedJavaField) findFieldInClass("java.lang.invoke.MemberName", "vmtarget",
-                    new HotSpotResolvedPrimitiveType(JavaKind.Long));
+                ResolvedJavaType methodHandleType = resolveType(MethodHandle.class);
+                ResolvedJavaType memberNameType = resolveType("java.lang.invoke.MemberName");
+                lambdaFormType = resolveType("java.lang.invoke.LambdaForm");
+                methodHandleFormField = findFieldInClass(methodHandleType, "form", lambdaFormType);
+                lambdaFormVmentryField = findFieldInClass(lambdaFormType, "vmentry", memberNameType);
+                memberNameVmtargetField = (HotSpotResolvedJavaField) findFieldInClass(memberNameType, "vmtarget", resolveType(long.class));
             } catch (Throwable ex) {
                 throw new JVMCIError(ex);
             }
@@ -173,12 +132,13 @@
             return null;
         }
 
-        if (forceBytecodeGeneration) {
-            /* Invoke non-public method: MemberName LambdaForm.compileToBytecode() */
-            LazyInitialization.lambdaFormCompileToBytecodeMethod.invoke(lambdaForm, new JavaConstant[0]);
+        JavaConstant memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm);
+        if (memberName.isNull() && forceBytecodeGeneration) {
+            Object lf = ((HotSpotObjectConstant) lambdaForm).asObject(LazyInitialization.lambdaFormType);
+            compilerToVM().compileToBytecode(Objects.requireNonNull(lf));
+            memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm);
+            assert memberName.isNonNull();
         }
-        /* Load non-public field: MemberName LambdaForm.vmentry */
-        JavaConstant memberName = constantReflection.readFieldValue(LazyInitialization.lambdaFormVmentryField, lambdaForm);
         return getTargetMethod(memberName);
     }
 
@@ -200,4 +160,3 @@
         return compilerToVM().getResolvedJavaMethod(object, LazyInitialization.memberNameVmtargetField.offset());
     }
 }
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotModifiers.java	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,66 @@
+/*
+ * 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 jdk.vm.ci.hotspot;
+
+import static java.lang.reflect.Modifier.ABSTRACT;
+import static java.lang.reflect.Modifier.FINAL;
+import static java.lang.reflect.Modifier.INTERFACE;
+import static java.lang.reflect.Modifier.NATIVE;
+import static java.lang.reflect.Modifier.PRIVATE;
+import static java.lang.reflect.Modifier.PROTECTED;
+import static java.lang.reflect.Modifier.PUBLIC;
+import static java.lang.reflect.Modifier.STATIC;
+import static java.lang.reflect.Modifier.STRICT;
+import static java.lang.reflect.Modifier.SYNCHRONIZED;
+import static java.lang.reflect.Modifier.TRANSIENT;
+import static java.lang.reflect.Modifier.VOLATILE;
+import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
+
+import java.lang.reflect.Modifier;
+
+/**
+ * The non-public modifiers in {@link Modifier} that need to be retrieved from
+ * {@link HotSpotVMConfig}.
+ */
+public class HotSpotModifiers {
+
+    // @formatter:off
+    public static final int ANNOTATION = config().jvmAccAnnotation;
+    public static final int ENUM       = config().jvmAccEnum;
+    public static final int VARARGS    = config().jvmAccVarargs;
+    public static final int BRIDGE     = config().jvmAccBridge;
+    public static final int SYNTHETIC  = config().jvmAccSynthetic;
+    // @formatter:on
+
+    public static int jvmClassModifiers() {
+        return PUBLIC | FINAL | INTERFACE | ABSTRACT | ANNOTATION | ENUM | SYNTHETIC;
+    }
+
+    public static int jvmMethodModifiers() {
+        return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | SYNCHRONIZED | BRIDGE | VARARGS | NATIVE | ABSTRACT | STRICT | SYNTHETIC;
+    }
+
+    public static int jvmFieldModifiers() {
+        return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | VOLATILE | TRANSIENT | ENUM | SYNTHETIC;
+    }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java	Fri Sep 30 02:52:38 2016 -0700
@@ -22,6 +22,7 @@
  */
 package jdk.vm.ci.hotspot;
 
+import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmFieldModifiers;
 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
 
 import java.lang.annotation.Annotation;
@@ -29,7 +30,6 @@
 
 import jdk.internal.vm.annotation.Stable;
 import jdk.vm.ci.meta.JavaType;
-import jdk.vm.ci.meta.ModifiersProvider;
 import jdk.vm.ci.meta.ResolvedJavaType;
 
 /**
@@ -81,7 +81,7 @@
 
     @Override
     public int getModifiers() {
-        return modifiers & ModifiersProvider.jvmFieldModifiers();
+        return modifiers & jvmFieldModifiers();
     }
 
     @Override
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java	Fri Sep 30 02:52:38 2016 -0700
@@ -24,13 +24,15 @@
 
 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.BRIDGE;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.SYNTHETIC;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.VARARGS;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmMethodModifiers;
 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Executable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.util.HashMap;
@@ -42,13 +44,11 @@
 import jdk.vm.ci.meta.ConstantPool;
 import jdk.vm.ci.meta.DefaultProfilingInfo;
 import jdk.vm.ci.meta.ExceptionHandler;
-import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaMethod;
 import jdk.vm.ci.meta.JavaType;
 import jdk.vm.ci.meta.LineNumberTable;
 import jdk.vm.ci.meta.Local;
 import jdk.vm.ci.meta.LocalVariableTable;
-import jdk.vm.ci.meta.ModifiersProvider;
 import jdk.vm.ci.meta.ProfilingInfo;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.ResolvedJavaType;
@@ -210,7 +210,7 @@
 
     @Override
     public int getModifiers() {
-        return getAllModifiers() & ModifiersProvider.jvmMethodModifiers();
+        return getAllModifiers() & jvmMethodModifiers();
     }
 
     @Override
@@ -490,6 +490,19 @@
         return javaMethod == null ? null : javaMethod.getAnnotation(annotationClass);
     }
 
+    public boolean isBridge() {
+        return (BRIDGE & getModifiers()) != 0;
+    }
+
+    @Override
+    public boolean isSynthetic() {
+        return (SYNTHETIC & getModifiers()) != 0;
+    }
+
+    public boolean isVarArgs() {
+        return (VARARGS & getModifiers()) != 0;
+    }
+
     public boolean isDefault() {
         if (isConstructor()) {
             return false;
@@ -697,27 +710,6 @@
         return (getFlags() & config().methodFlagsIntrinsicCandidate) != 0;
     }
 
-    @Override
-    public JavaConstant invoke(JavaConstant receiver, JavaConstant[] arguments) {
-        assert !isConstructor();
-        Method javaMethod = (Method) toJava();
-        javaMethod.setAccessible(true);
-
-        Object[] objArguments = new Object[arguments.length];
-        for (int i = 0; i < arguments.length; i++) {
-            objArguments[i] = HotSpotObjectConstantImpl.asBoxedValue(arguments[i]);
-        }
-        Object objReceiver = receiver != null && !receiver.isNull() ? ((HotSpotObjectConstantImpl) receiver).object() : null;
-
-        try {
-            Object objResult = javaMethod.invoke(objReceiver, objArguments);
-            return javaMethod.getReturnType() == void.class ? null : HotSpotObjectConstantImpl.forBoxedValue(getSignature().getReturnKind(), objResult);
-
-        } catch (IllegalAccessException | InvocationTargetException ex) {
-            throw new IllegalArgumentException(ex);
-        }
-    }
-
     /**
      * Allocates a compile id for this method by asking the VM for one.
      *
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java	Fri Sep 30 02:52:38 2016 -0700
@@ -26,6 +26,7 @@
 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
 import static jdk.vm.ci.hotspot.HotSpotConstantPool.isSignaturePolymorphicHolder;
 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
+import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmClassModifiers;
 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
 
@@ -49,7 +50,6 @@
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.JavaType;
-import jdk.vm.ci.meta.ModifiersProvider;
 import jdk.vm.ci.meta.ResolvedJavaField;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.ResolvedJavaType;
@@ -152,7 +152,7 @@
         if (isArray()) {
             return (getElementalType().getModifiers() & (Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED)) | Modifier.FINAL | Modifier.ABSTRACT;
         } else {
-            return getAccessFlags() & ModifiersProvider.jvmClassModifiers();
+            return getAccessFlags() & jvmClassModifiers();
         }
     }
 
@@ -507,7 +507,7 @@
     synchronized HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags) {
         HotSpotResolvedJavaField result = null;
 
-        final int flags = rawFlags & ModifiersProvider.jvmFieldModifiers();
+        final int flags = rawFlags & HotSpotModifiers.jvmFieldModifiers();
 
         final long id = offset + ((long) flags << 32);
 
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -117,8 +117,12 @@
     final int jvmAccFieldHasGenericSignature = getConstant("JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE", Integer.class);
     final int jvmAccIsCloneableFast = getConstant("JVM_ACC_IS_CLONEABLE_FAST", Integer.class);
 
-    // Modifier.SYNTHETIC is not public so we get it via vmStructs.
+    // These modifiers are not public in Modifier so we get them via vmStructs.
     final int jvmAccSynthetic = getConstant("JVM_ACC_SYNTHETIC", Integer.class);
+    final int jvmAccAnnotation = getConstant("JVM_ACC_ANNOTATION", Integer.class);
+    final int jvmAccBridge = getConstant("JVM_ACC_BRIDGE", Integer.class);
+    final int jvmAccVarargs = getConstant("JVM_ACC_VARARGS", Integer.class);
+    final int jvmAccEnum = getConstant("JVM_ACC_ENUM", Integer.class);
 
     // This is only valid on AMD64.
     final int runtimeCallStackSize = getConstant("frame::arg_reg_save_area_bytes", Integer.class, osArch.equals("amd64") ? null : 0);
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java	Fri Sep 30 02:52:38 2016 -0700
@@ -22,8 +22,6 @@
  */
 package jdk.vm.ci.hotspot;
 
-import java.lang.reflect.Field;
-
 import jdk.internal.misc.Unsafe;
 
 /**
@@ -31,21 +29,5 @@
  */
 class UnsafeAccess {
 
-    static final Unsafe UNSAFE = initUnsafe();
-
-    private static Unsafe initUnsafe() {
-        try {
-            // Fast path when we are trusted.
-            return Unsafe.getUnsafe();
-        } catch (SecurityException se) {
-            // Slow path when we are not trusted.
-            try {
-                Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
-                theUnsafe.setAccessible(true);
-                return (Unsafe) theUnsafe.get(Unsafe.class);
-            } catch (Exception e) {
-                throw new RuntimeException("exception while trying to get Unsafe", e);
-            }
-        }
-    }
+    static final Unsafe UNSAFE = Unsafe.getUnsafe();
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MetaUtil.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MetaUtil.java	Fri Sep 30 02:52:38 2016 -0700
@@ -22,9 +22,6 @@
  */
 package jdk.vm.ci.meta;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
 /**
  * Miscellaneous collection of utility methods used by {@code jdk.vm.ci.meta} and its clients.
  */
@@ -226,17 +223,4 @@
         }
         return obj.getClass().getName() + "@" + System.identityHashCode(obj);
     }
-
-    /**
-     * Used to lookup constants from {@link Modifier} that are not public (VARARGS, SYNTHETIC etc.).
-     */
-    static int getNonPublicModifierStaticField(String name) {
-        try {
-            Field field = Modifier.class.getDeclaredField(name);
-            field.setAccessible(true);
-            return field.getInt(null);
-        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
-            throw new InternalError(e);
-        }
-    }
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ModifiersProvider.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ModifiersProvider.java	Fri Sep 30 02:52:38 2016 -0700
@@ -22,18 +22,9 @@
  */
 package jdk.vm.ci.meta;
 
-import static java.lang.reflect.Modifier.ABSTRACT;
-import static java.lang.reflect.Modifier.FINAL;
-import static java.lang.reflect.Modifier.INTERFACE;
-import static java.lang.reflect.Modifier.NATIVE;
 import static java.lang.reflect.Modifier.PRIVATE;
 import static java.lang.reflect.Modifier.PROTECTED;
 import static java.lang.reflect.Modifier.PUBLIC;
-import static java.lang.reflect.Modifier.STATIC;
-import static java.lang.reflect.Modifier.STRICT;
-import static java.lang.reflect.Modifier.SYNCHRONIZED;
-import static java.lang.reflect.Modifier.TRANSIENT;
-import static java.lang.reflect.Modifier.VOLATILE;
 
 import java.lang.reflect.Modifier;
 
@@ -42,17 +33,9 @@
  * language {@linkplain #getModifiers() modifiers}.
  */
 public interface ModifiersProvider {
-    int BRIDGE = MetaUtil.getNonPublicModifierStaticField("BRIDGE");
-    int VARARGS = MetaUtil.getNonPublicModifierStaticField("VARARGS");
-    int SYNTHETIC = MetaUtil.getNonPublicModifierStaticField("SYNTHETIC");
-    int ANNOTATION = MetaUtil.getNonPublicModifierStaticField("ANNOTATION");
-    int ENUM = MetaUtil.getNonPublicModifierStaticField("ENUM");
-    int MANDATED = MetaUtil.getNonPublicModifierStaticField("MANDATED");
 
     /**
-     * Returns the Java Virtual Machine modifiers for this element. Note that this can differ from
-     * standard Java Reflection modifiers. For example at the JVM level, classes (
-     * {@link ResolvedJavaType}) can not be private or protected.
+     * Returns the modifiers for this element.
      */
     int getModifiers();
 
@@ -161,17 +144,4 @@
     default boolean isConcrete() {
         return !isAbstract();
     }
-
-    static int jvmClassModifiers() {
-        // no SUPER
-        return PUBLIC | FINAL | INTERFACE | ABSTRACT | ANNOTATION | ENUM | SYNTHETIC;
-    }
-
-    static int jvmMethodModifiers() {
-        return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | SYNCHRONIZED | BRIDGE | VARARGS | NATIVE | ABSTRACT | STRICT | SYNTHETIC;
-    }
-
-    static int jvmFieldModifiers() {
-        return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | VOLATILE | TRANSIENT | ENUM | SYNTHETIC;
-    }
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java	Fri Sep 30 02:52:38 2016 -0700
@@ -26,7 +26,6 @@
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Array;
 import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 
 /**
@@ -72,14 +71,6 @@
      */
     int getMaxStackSize();
 
-    /**
-     * {@inheritDoc}
-     * <p>
-     * Only the {@linkplain Modifier#methodModifiers() method flags} specified in the JVM
-     * specification will be included in the returned mask.
-     */
-    int getModifiers();
-
     default boolean isFinal() {
         return ModifiersProvider.super.isFinalFlagSet();
     }
@@ -88,9 +79,7 @@
      * Determines if this method is a synthetic method as defined by the Java Language
      * Specification.
      */
-    default boolean isSynthetic() {
-        return (SYNTHETIC & getModifiers()) == SYNTHETIC;
-    }
+    boolean isSynthetic();
 
     /**
      * Checks that the method is a
@@ -99,9 +88,7 @@
      *
      * @return whether the method is a varargs method
      */
-    default boolean isVarArgs() {
-        return (VARARGS & getModifiers()) == VARARGS;
-    }
+    boolean isVarArgs();
 
     /**
      * Checks that the method is a
@@ -110,9 +97,7 @@
      *
      * @return whether the method is a bridge method
      */
-    default boolean isBridge() {
-        return (BRIDGE & getModifiers()) == BRIDGE;
-    }
+    boolean isBridge();
 
     /**
      * Returns {@code true} if this method is a default method; returns {@code false} otherwise.
@@ -228,18 +213,6 @@
     LocalVariableTable getLocalVariableTable();
 
     /**
-     * Invokes the underlying method represented by this object, on the specified object with the
-     * specified parameters. This method is similar to a reflective method invocation by
-     * {@link Method#invoke}.
-     *
-     * @param receiver The receiver for the invocation, or {@code null} if it is a static method.
-     * @param arguments The arguments for the invocation.
-     * @return The value returned by the method invocation, or {@code null} if the return type is
-     *         {@code void}.
-     */
-    JavaConstant invoke(JavaConstant receiver, JavaConstant[] arguments);
-
-    /**
      * Gets the encoding of (that is, a constant representing the value of) this method.
      *
      * @return a constant representing a reference to this method
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java	Fri Sep 30 02:52:38 2016 -0700
@@ -68,15 +68,6 @@
      */
     boolean isPrimitive();
 
-    /**
-     * {@inheritDoc}
-     * <p>
-     * Only the flags specified in the JVM specification will be included in the returned mask. This
-     * method is identical to {@link Class#getModifiers()} in terms of the value return for this
-     * type.
-     */
-    int getModifiers();
-
     /*
      * The setting of the final bit for types is a bit confusing since arrays are marked as final.
      * This method provides a semantically equivalent test that appropriate for types.
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -2366,7 +2366,9 @@
   if (Interpreter::contains(pc)) {
     *fr = os::fetch_frame_from_context((void*)exceptionInfo->ContextRecord);
     if (!fr->is_first_java_frame()) {
-      assert(fr->safe_for_sender(thread), "Safety check");
+      // get_frame_at_stack_banging_point() is only called when we
+      // have well defined stacks so java_sender() calls do not need
+      // to assert safe_for_sender() first.
       *fr = fr->java_sender();
     }
   } else {
@@ -2383,7 +2385,7 @@
       // has been pushed on the stack
       *fr = frame(fr->sp() + 1, fr->fp(), (address)*(fr->sp()));
       if (!fr->is_java_frame()) {
-        assert(fr->safe_for_sender(thread), "Safety check");
+        // See java_sender() comment above.
         *fr = fr->java_sender();
       }
     }
--- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -378,7 +378,9 @@
     // method returns the Java sender of the current frame.
     *fr = os::fetch_frame_from_ucontext(thread, uc);
     if (!fr->is_first_java_frame()) {
-      assert(fr->safe_for_sender(thread), "Safety check");
+      // get_frame_at_stack_banging_point() is only called when we
+      // have well defined stacks so java_sender() calls do not need
+      // to assert safe_for_sender() first.
       *fr = fr->java_sender();
     }
   } else {
@@ -395,7 +397,7 @@
       // has been pushed on the stack
       *fr = frame(fr->sp() + 1, fr->fp(), (address)*(fr->sp()));
       if (!fr->is_java_frame()) {
-        assert(fr->safe_for_sender(thread), "Safety check");
+        // See java_sender() comment above.
         *fr = fr->java_sender();
       }
     }
--- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -191,7 +191,9 @@
     // method returns the Java sender of the current frame.
     *fr = os::fetch_frame_from_ucontext(thread, uc);
     if (!fr->is_first_java_frame()) {
-      assert(fr->safe_for_sender(thread), "Safety check");
+      // get_frame_at_stack_banging_point() is only called when we
+      // have well defined stacks so java_sender() calls do not need
+      // to assert safe_for_sender() first.
       *fr = fr->java_sender();
     }
   } else {
@@ -209,8 +211,8 @@
       intptr_t* sp = os::Linux::ucontext_get_sp(uc);
       *fr = frame(sp + 1, fp, (address)*sp);
       if (!fr->is_java_frame()) {
-        assert(fr->safe_for_sender(thread), "Safety check");
         assert(!fr->is_first_frame(), "Safety check");
+        // See java_sender() comment above.
         *fr = fr->java_sender();
       }
     }
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -255,7 +255,9 @@
     // method returns the Java sender of the current frame.
     *fr = os::fetch_frame_from_ucontext(thread, uc);
     if (!fr->is_first_java_frame()) {
-      assert(fr->safe_for_sender(thread), "Safety check");
+      // get_frame_at_stack_banging_point() is only called when we
+      // have well defined stacks so java_sender() calls do not need
+      // to assert safe_for_sender() first.
       *fr = fr->java_sender();
     }
   } else {
@@ -273,7 +275,7 @@
       intptr_t* sp = os::Solaris::ucontext_get_sp(uc);
       *fr = frame(sp + 1, fp, (address)*sp);
       if (!fr->is_java_frame()) {
-        assert(fr->safe_for_sender(thread), "Safety check");
+        // See java_sender() comment above.
         *fr = fr->java_sender();
       }
     }
--- a/hotspot/src/share/vm/adlc/formssel.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/adlc/formssel.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1245,6 +1245,7 @@
       this != short_branch &&   // Don't match myself
       !is_short_branch() &&     // Don't match another short branch variant
       reduce_result() != NULL &&
+      strstr(_ident, "restoreMask") == NULL && // Don't match side effects
       strcmp(reduce_result(), short_branch->reduce_result()) == 0 &&
       _matrule->equivalent(AD.globalNames(), short_branch->_matrule)) {
     // The instructions are equivalent.
@@ -4037,6 +4038,8 @@
         strcmp(opType,"EncodeP")==0 ||
         strcmp(opType,"EncodePKlass")==0 ||
         strcmp(opType,"DecodeNKlass")==0 ||
+        strcmp(opType,"FmaD") == 0 ||
+        strcmp(opType,"FmaF") == 0 ||
         strcmp(opType,"RoundDouble")==0 ||
         strcmp(opType,"RoundFloat")==0 ||
         strcmp(opType,"ReverseBytesI")==0 ||
--- a/hotspot/src/share/vm/c1/c1_Compiler.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -162,6 +162,8 @@
   case vmIntrinsics::_dlog10:
   case vmIntrinsics::_dexp:
   case vmIntrinsics::_dpow:
+  case vmIntrinsics::_fmaD:
+  case vmIntrinsics::_fmaF:
   case vmIntrinsics::_getObject:
   case vmIntrinsics::_getBoolean:
   case vmIntrinsics::_getByte:
--- a/hotspot/src/share/vm/c1/c1_LIR.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/c1/c1_LIR.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -666,7 +666,9 @@
 
 // LIR_Op3
     case lir_idiv:
-    case lir_irem: {
+    case lir_irem:
+    case lir_fmad:
+    case lir_fmaf: {
       assert(op->as_Op3() != NULL, "must be");
       LIR_Op3* op3= (LIR_Op3*)op;
 
@@ -1663,6 +1665,8 @@
      // LIR_Op3
      case lir_idiv:                  s = "idiv";          break;
      case lir_irem:                  s = "irem";          break;
+     case lir_fmad:                  s = "fmad";          break;
+     case lir_fmaf:                  s = "fmaf";          break;
      // LIR_OpJavaCall
      case lir_static_call:           s = "static";        break;
      case lir_optvirtual_call:       s = "optvirtual";    break;
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -956,6 +956,8 @@
   , begin_op3
       , lir_idiv
       , lir_irem
+      , lir_fmad
+      , lir_fmaf
   , end_op3
   , begin_opJavaCall
       , lir_static_call
@@ -2149,6 +2151,8 @@
 
   void abs (LIR_Opr from, LIR_Opr to, LIR_Opr tmp)                { append(new LIR_Op2(lir_abs , from, tmp, to)); }
   void sqrt(LIR_Opr from, LIR_Opr to, LIR_Opr tmp)                { append(new LIR_Op2(lir_sqrt, from, tmp, to)); }
+  void fmad(LIR_Opr from, LIR_Opr from1, LIR_Opr from2, LIR_Opr to) { append(new LIR_Op3(lir_fmad, from, from1, from2, to)); }
+  void fmaf(LIR_Opr from, LIR_Opr from1, LIR_Opr from2, LIR_Opr to) { append(new LIR_Op3(lir_fmaf, from, from1, from2, to)); }
   void log10 (LIR_Opr from, LIR_Opr to, LIR_Opr tmp)              { append(new LIR_Op2(lir_log10, from, LIR_OprFact::illegalOpr, to, tmp)); }
   void tan (LIR_Opr from, LIR_Opr to, LIR_Opr tmp1, LIR_Opr tmp2) { append(new LIR_Op2(lir_tan , from, tmp1, to, tmp2)); }
 
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -3181,6 +3181,9 @@
   case vmIntrinsics::_dpow :          do_MathIntrinsic(x); break;
   case vmIntrinsics::_arraycopy:      do_ArrayCopy(x);     break;
 
+  case vmIntrinsics::_fmaD:           do_FmaIntrinsic(x); break;
+  case vmIntrinsics::_fmaF:           do_FmaIntrinsic(x); break;
+
   // java.nio.Buffer.checkIndex
   case vmIntrinsics::_checkIndex:     do_NIOCheckIndex(x); break;
 
@@ -3244,14 +3247,14 @@
       Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
       int start = 0;
       int stop = data->is_CallTypeData() ? ((ciCallTypeData*)data)->number_of_arguments() : ((ciVirtualCallTypeData*)data)->number_of_arguments();
-      if (x->inlined() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) {
+      if (x->callee()->is_loaded() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) {
         // first argument is not profiled at call (method handle invoke)
         assert(x->method()->raw_code_at_bci(bci) == Bytecodes::_invokehandle, "invokehandle expected");
         start = 1;
       }
       ciSignature* callee_signature = x->callee()->signature();
       // method handle call to virtual method
-      bool has_receiver = x->inlined() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc);
+      bool has_receiver = x->callee()->is_loaded() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc);
       ciSignatureStream callee_signature_stream(callee_signature, has_receiver ? x->callee()->holder() : NULL);
 
       bool ignored_will_link;
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -245,6 +245,7 @@
   void do_isPrimitive(Intrinsic* x);
   void do_getClass(Intrinsic* x);
   void do_currentThread(Intrinsic* x);
+  void do_FmaIntrinsic(Intrinsic* x);
   void do_MathIntrinsic(Intrinsic* x);
   void do_LibmIntrinsic(Intrinsic* x);
   void do_ArrayCopy(Intrinsic* x);
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -85,6 +85,7 @@
 typedef jzentry* (JNICALL *GetNextEntry_t)(jzfile *zip, jint n);
 typedef jboolean (JNICALL *ZipInflateFully_t)(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg);
 typedef jint     (JNICALL *Crc32_t)(jint crc, const jbyte *buf, jint len);
+typedef void     (JNICALL *FreeEntry_t)(jzfile *zip, jzentry *entry);
 
 static ZipOpen_t         ZipOpen            = NULL;
 static ZipClose_t        ZipClose           = NULL;
@@ -95,6 +96,7 @@
 static canonicalize_fn_t CanonicalizeEntry  = NULL;
 static ZipInflateFully_t ZipInflateFully    = NULL;
 static Crc32_t           Crc32              = NULL;
+static FreeEntry_t       FreeEntry          = NULL;
 
 // Entry points for jimage.dll for loading jimage file entries
 
@@ -150,6 +152,7 @@
 GrowableArray<char*>* ClassLoader::_boot_modules_array = NULL;
 GrowableArray<char*>* ClassLoader::_platform_modules_array = NULL;
 SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL;
+int  ClassLoader::_num_patch_mod_prefixes = 0;
 #endif
 
 // helper routines
@@ -319,6 +322,20 @@
   FREE_C_HEAP_ARRAY(char, _zip_name);
 }
 
+bool ClassPathZipEntry::stream_exists(const char* name) {
+  // enable call to C land
+  JavaThread* thread = JavaThread::current();
+  ThreadToNativeFromVM ttn(thread);
+  // check whether zip archive contains name
+  jint name_len, filesize;
+  jzentry* entry = (*FindEntry)(_zip, name, &filesize, &name_len);
+  if (entry != NULL) {
+    (*FreeEntry)(_zip, entry);
+    return true;
+  }
+  return false;
+}
+
 u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) {
     // enable call to C land
   JavaThread* thread = JavaThread::current();
@@ -640,7 +657,7 @@
 
   struct stat st;
   if (os::stat(path, &st) == 0) {
-    if ((st.st_mode & S_IFREG) != S_IFREG) { // is directory
+    if ((st.st_mode & S_IFMT) != S_IFREG) { // is not a regular file
       if (!os::dir_is_empty(path)) {
         tty->print_cr("Error: non-empty directory '%s'", path);
         exit_with_path_failure("CDS allows only empty directories in archived classpaths", NULL);
@@ -693,8 +710,6 @@
   GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
   int num_of_entries = patch_mod_args->length();
 
-  assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with --patch-module");
-  assert(!UseSharedSpaces, "UseSharedSpaces not supported with --patch-module");
 
   // Set up the boot loader's _patch_mod_entries list
   _patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
@@ -851,7 +866,7 @@
                                                      bool is_boot_append, TRAPS) {
   JavaThread* thread = JavaThread::current();
   ClassPathEntry* new_entry = NULL;
-  if ((st->st_mode & S_IFREG) == S_IFREG) {
+  if ((st->st_mode & S_IFMT) == S_IFREG) {
     ResourceMark rm(thread);
     // Regular file, should be a zip or jimage file
     // Canonicalized filename
@@ -914,7 +929,7 @@
   // check for a regular file
   struct stat st;
   if (os::stat(path, &st) == 0) {
-    if ((st.st_mode & S_IFREG) == S_IFREG) {
+    if ((st.st_mode & S_IFMT) == S_IFREG) {
       char canonical_path[JVM_MAXPATHLEN];
       if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
         char* error_msg = NULL;
@@ -1068,6 +1083,7 @@
   GetNextEntry = CAST_TO_FN_PTR(GetNextEntry_t, os::dll_lookup(handle, "ZIP_GetNextEntry"));
   ZipInflateFully = CAST_TO_FN_PTR(ZipInflateFully_t, os::dll_lookup(handle, "ZIP_InflateFully"));
   Crc32        = CAST_TO_FN_PTR(Crc32_t, os::dll_lookup(handle, "ZIP_CRC32"));
+  FreeEntry    = CAST_TO_FN_PTR(FreeEntry_t, os::dll_lookup(handle, "ZIP_FreeEntry"));
 
   // ZIP_Close is not exported on Windows in JDK5.0 so don't abort if ZIP_Close is NULL
   if (ZipOpen == NULL || FindEntry == NULL || ReadEntry == NULL ||
@@ -1395,6 +1411,57 @@
   return NULL;
 }
 
+#if INCLUDE_CDS
+// The following function is only used during CDS dump time.
+// It checks if a class can be found in the jar entries of the _patch_mod_entries.
+// It does not support non-jar entries.
+bool ClassLoader::is_in_patch_module(const char* const file_name) {
+  assert(DumpSharedSpaces, "dump time only");
+  if (_patch_mod_entries == NULL) {
+    return false;
+  }
+
+  int num_of_entries = _patch_mod_entries->length();
+  char* class_module_name = NULL;
+  ResourceMark rm;
+  const char *pkg_name = package_from_name(file_name);
+  // Using the jimage to obtain the class' module name.
+  // The ModuleEntryTable cannot be used at this point during dump time
+  // because the module system hasn't been initialized yet.
+  if (pkg_name != NULL) {
+    JImageFile *jimage = _jrt_entry->jimage();
+    class_module_name = (char*)(*JImagePackageToModule)(jimage, pkg_name);
+  }
+
+  if (class_module_name == NULL) {
+    return false;
+  }
+
+  // Loop through all the patch module entries looking for module
+  for (int i = 0; i < num_of_entries; i++) {
+    ModuleClassPathList* module_cpl = _patch_mod_entries->at(i);
+    Symbol* module_cpl_name = module_cpl->module_name();
+
+    if (strcmp(module_cpl_name->as_C_string(), class_module_name) == 0) {
+      // Class' module has been located, attempt to locate
+      // the class from the module's ClassPathEntry list.
+      ClassPathEntry* e = module_cpl->module_first_entry();
+      while (e != NULL) {
+        if (e->is_jar_file()) {
+          if (e->stream_exists(file_name)) {
+            return true;
+          } else {
+            e = e->next();
+          }
+        }
+      }
+    }
+  }
+
+  return false;
+}
+#endif // INCLUDE_CDS
+
 instanceKlassHandle ClassLoader::load_class(Symbol* name, bool search_append_only, TRAPS) {
   assert(name != NULL, "invariant");
   assert(THREAD->is_Java_thread(), "must be a JavaThread");
@@ -1420,8 +1487,8 @@
 
   // If DumpSharedSpaces is true boot loader visibility boundaries are set to:
   //   - [jimage] + [_first_append_entry to _last_append_entry] (all path entries).
-  // No --patch-module entries or exploded module builds are included since CDS
-  // is not supported if --patch-module or exploded module builds are used.
+  // If a class is found in the --patch-module entries, the class will not be included in the
+  // CDS archive. Also, CDS is not supported if exploded module builds are used.
   //
   // If search_append_only is true, boot loader visibility boundaries are
   // set to be _first_append_entry to the end. This includes:
@@ -1444,8 +1511,17 @@
   // found within its module specification, the search should continue to Load Attempt #2.
   // Note: The --patch-module entries are never searched if the boot loader's
   //       visibility boundary is limited to only searching the append entries.
-  if (_patch_mod_entries != NULL && !search_append_only && !DumpSharedSpaces) {
-    stream = search_module_entries(_patch_mod_entries, class_name, file_name, CHECK_NULL);
+  if (_patch_mod_entries != NULL && !search_append_only) {
+    if (!DumpSharedSpaces) {
+      stream = search_module_entries(_patch_mod_entries, class_name, file_name, CHECK_NULL);
+    } else {
+#if INCLUDE_CDS
+      if (is_in_patch_module(file_name)) {
+        tty->print_cr("Preload Warning: Skip archiving class %s found in --patch-module entry", class_name);
+        return NULL;
+      }
+#endif
+    }
   }
 
   // Load Attempt #2: [jimage | exploded build]
@@ -1596,8 +1672,57 @@
 }
 
 #if INCLUDE_CDS
+// Capture all the --patch-module entries specified during CDS dump time.
+// It also captures the non-existing path(s) and the required file(s) during inspecting
+// the entries.
+void ClassLoader::setup_patch_mod_path() {
+  assert(DumpSharedSpaces, "only used with -Xshare:dump");
+  ResourceMark rm;
+  GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
+  if (patch_mod_args != NULL) {
+    int num_of_entries = patch_mod_args->length();
+    for (int i = 0; i < num_of_entries; i++) {
+      const char* module_name = (patch_mod_args->at(i))->module_name();
+      const char* module_path = (patch_mod_args->at(i))->path_string();
+      int path_len = (int)strlen(module_path);
+      int name_len = (int)strlen(module_name);
+      int buf_len = name_len + path_len + 2; // add 2 for the '=' and NULL terminator
+      int end = 0;
+      char* buf = NEW_C_HEAP_ARRAY(char, buf_len, mtInternal);
+      // Iterate over the module's class path entries
+      for (int start = 0; start < path_len; start = end) {
+        while (module_path[end] && module_path[end] != os::path_separator()[0]) {
+          end++;
+        }
+        strncpy(buf, &module_path[start], end - start);
+        buf[end - start] = '\0';
+        struct stat st;
+        if (os::stat(buf, &st) != 0) {
+          // File not found
+          _shared_paths_misc_info->add_nonexist_path(buf);
+        } else {
+          if ((st.st_mode & S_IFMT) != S_IFREG) { // is not a regular file
+            vm_exit_during_initialization(
+              "--patch-module requires a regular file during dumping", buf);
+          } else {
+            _shared_paths_misc_info->add_required_file(buf);
+          }
+        }
+        while (module_path[end] == os::path_separator()[0]) {
+          end++;
+        }
+      };
+      jio_snprintf(buf, buf_len, "%s=%s", module_name, module_path);
+      _shared_paths_misc_info->add_patch_mod_classpath((const char*)buf);
+      _num_patch_mod_prefixes++;
+      FREE_C_HEAP_ARRAY(char, buf);
+    }
+  }
+}
+
 void ClassLoader::initialize_shared_path() {
   if (DumpSharedSpaces) {
+    setup_patch_mod_path();
     ClassLoaderExt::setup_search_paths();
     _shared_paths_misc_info->write_jint(0); // see comments in SharedPathsMiscInfo::check()
   }
--- a/hotspot/src/share/vm/classfile/classLoader.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/classfile/classLoader.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -69,6 +69,7 @@
   // Attempt to locate file_name through this class path entry.
   // Returns a class file parsing stream if successfull.
   virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0;
+  virtual bool stream_exists(const char* name) = 0;
   // Debugging
   NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;)
 };
@@ -83,6 +84,7 @@
   JImageFile* jimage() const { return NULL; }
   ClassPathDirEntry(const char* dir);
   ClassFileStream* open_stream(const char* name, TRAPS);
+  bool stream_exists(const char* name) { return false; }
   // Debugging
   NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
 };
@@ -126,6 +128,7 @@
   ClassFileStream* open_stream(const char* name, TRAPS);
   void contents_do(void f(const char* name, void* context), void* context);
   bool is_multiple_versioned(TRAPS) NOT_CDS_RETURN_(false);
+  bool stream_exists(const char* name);
   // Debugging
   NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
 };
@@ -145,6 +148,7 @@
   ClassPathImageEntry(JImageFile* jimage, const char* name);
   ~ClassPathImageEntry();
   ClassFileStream* open_stream(const char* name, TRAPS);
+  bool stream_exists(const char* name) { return false; }
 
   // Debugging
   NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
@@ -255,6 +259,7 @@
 
   // Info used by CDS
   CDS_ONLY(static SharedPathsMiscInfo * _shared_paths_misc_info;)
+  CDS_ONLY(static int _num_patch_mod_prefixes;)
 
   // Initialization:
   //   - setup the boot loader's system class path
@@ -427,6 +432,9 @@
   static void initialize_module_loader_map(JImageFile* jimage);
   static s2 classloader_type(Symbol* class_name, ClassPathEntry* e,
                              int classpath_index, TRAPS);
+  static bool is_in_patch_module(const char* const file_name);
+  static void setup_patch_mod_path(); // Only when -Xshare:dump
+  static int num_patch_mod_prefixes() { return _num_patch_mod_prefixes; }
 #endif
 
   static void  trace_class_path(const char* msg, const char* name = NULL);
--- a/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -86,6 +86,9 @@
   case REQUIRED:
     out->print("Expecting that file %s must exist and is not altered", path);
     break;
+  case PATCH_MOD:
+    out->print("Expecting --patch-module=%s", path);
+    break;
   default:
     ShouldNotReachHere();
   }
@@ -146,6 +149,9 @@
           // But we want it to not exist -> fail
           return fail("File must not exist");
         }
+        if ((st.st_mode & S_IFMT) != S_IFREG) {
+          return fail("Did not get a regular file as expected.");
+        }
         time_t    timestamp;
         long      filesize;
 
@@ -161,7 +167,26 @@
       }
     }
     break;
-
+  case PATCH_MOD:
+    {
+      GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
+      if (patch_mod_args != NULL) {
+        int num_of_entries = patch_mod_args->length();
+        for (int i = 0; i < num_of_entries; i++) {
+          const char* module_name = (patch_mod_args->at(i))->module_name();
+          const char* path_string = (patch_mod_args->at(i))->path_string();
+          size_t n = strlen(module_name);
+          // path contains the module name, followed by '=', and one or more entries.
+          // E.g.: "java.base=foo" or "java.naming=dir1:dir2:dir3"
+          if ((strncmp(module_name, path, n) != 0) ||
+              (path[n] != '=') ||
+              (strcmp(path + n + 1, path_string) != 0)) {
+            return fail("--patch-module mismatch, path not found in run time: ", path);
+          }
+        }
+      }
+    }
+    break;
   default:
     return fail("Corrupted archive file header");
   }
--- a/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -104,10 +104,28 @@
     add_path(path, NON_EXIST);
   }
 
+  // The path must exist and have required size and modification time
+  void add_required_file(const char* path) {
+    add_path(path, REQUIRED);
+
+    struct stat st;
+    if (os::stat(path, &st) != 0) {
+      assert(0, "sanity");
+#if INCLUDE_CDS
+      ClassLoader::exit_with_path_failure("failed to os::stat(%s)", path); // should not happen
+#endif
+    }
+    write_time(st.st_mtime);
+    write_long(st.st_size);
+  }
+
   // The path must exist, and must contain exactly <num_entries> files/dirs
   void add_boot_classpath(const char* path) {
     add_path(path, BOOT);
   }
+  void add_patch_mod_classpath(const char* path) {
+    add_path(path, PATCH_MOD);
+  }
   int write_jint(jint num) {
     write(&num, sizeof(num));
     return 0;
@@ -129,7 +147,8 @@
   enum {
     BOOT      = 1,
     NON_EXIST = 2,
-    REQUIRED  = 3
+    REQUIRED  = 3,
+    PATCH_MOD = 4
   };
 
   virtual const char* type_name(int type) {
@@ -137,6 +156,7 @@
     case BOOT:      return "BOOT";
     case NON_EXIST: return "NON_EXIST";
     case REQUIRED:  return "REQUIRED";
+    case PATCH_MOD: return "PATCH_MOD";
     default:        ShouldNotReachHere(); return "?";
     }
   }
--- a/hotspot/src/share/vm/classfile/symbolTable.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -710,53 +710,3 @@
     return 0;
   }
 }
-
-#ifndef PRODUCT
-// Internal test of TempNewSymbol
-void Test_TempNewSymbol() {
-  // Assert messages assume these symbols are unique, and the refcounts start at
-  // one, but code does not rely on this.
-  Thread* THREAD = Thread::current();
-  Symbol* abc = SymbolTable::new_symbol("abc", CATCH);
-  int abccount = abc->refcount();
-  TempNewSymbol ss = abc;
-  assert(ss->refcount() == abccount, "only one abc");
-  assert(ss->refcount() == abc->refcount(), "should match TempNewSymbol");
-
-  Symbol* efg = SymbolTable::new_symbol("efg", CATCH);
-  Symbol* hij = SymbolTable::new_symbol("hij", CATCH);
-  int efgcount = efg->refcount();
-  int hijcount = hij->refcount();
-
-  TempNewSymbol s1 = efg;
-  TempNewSymbol s2 = hij;
-  assert(s1->refcount() == efgcount, "one efg");
-  assert(s2->refcount() == hijcount, "one hij");
-
-  // Assignment operator
-  s1 = s2;
-  assert(hij->refcount() == hijcount + 1, "should be two hij");
-  assert(efg->refcount() == efgcount - 1, "should be no efg");
-
-  s1 = ss;  // s1 is abc
-  assert(s1->refcount() == abccount + 1, "should be two abc (s1 and ss)");
-  assert(hij->refcount() == hijcount, "should only have one hij now (s2)");
-
-  s1 = s1; // self assignment
-  assert(s1->refcount() == abccount + 1, "should still be two abc (s1 and ss)");
-
-  TempNewSymbol s3;
-  Symbol* klm = SymbolTable::new_symbol("klm", CATCH);
-  int klmcount = klm->refcount();
-  s3 = klm;   // assignment
-  assert(s3->refcount() == klmcount, "only one klm now");
-
-  Symbol* xyz = SymbolTable::new_symbol("xyz", CATCH);
-  int xyzcount = xyz->refcount();
-  { // inner scope
-     TempNewSymbol s_inner = xyz;
-  }
-  assert(xyz->refcount() == (xyzcount - 1),
-         "Should have been decremented by dtor in inner scope");
-}
-#endif // PRODUCT
--- a/hotspot/src/share/vm/classfile/vmSymbols.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -355,6 +355,8 @@
   case vmIntrinsics::_updateBytesCRC32:
   case vmIntrinsics::_updateByteBufferCRC32:
   case vmIntrinsics::_vectorizedMismatch:
+  case vmIntrinsics::_fmaD:
+  case vmIntrinsics::_fmaF:
     return true;
   default:
     return false;
@@ -388,6 +390,8 @@
   case vmIntrinsics::_updateBytesCRC32:
   case vmIntrinsics::_updateByteBufferCRC32:
   case vmIntrinsics::_vectorizedMismatch:
+  case vmIntrinsics::_fmaD:
+  case vmIntrinsics::_fmaF:
     return false;
   default:
     return true;
@@ -536,6 +540,10 @@
   case vmIntrinsics::_doubleToLongBits:
     if (!InlineMathNatives) return true;
     break;
+  case vmIntrinsics::_fmaD:
+  case vmIntrinsics::_fmaF:
+    if (!InlineMathNatives || !UseFMA) return true;
+    break;
   case vmIntrinsics::_arraycopy:
     if (!InlineArrayCopy) return true;
     break;
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -755,8 +755,10 @@
   do_class(java_lang_Math,                "java/lang/Math")                                                             \
   do_class(java_lang_StrictMath,          "java/lang/StrictMath")                                                       \
   do_signature(double2_double_signature,  "(DD)D")                                                                      \
+  do_signature(double3_double_signature,  "(DDD)D")                                                                     \
+  do_signature(float3_float_signature,    "(FFF)F")                                                                     \
   do_signature(int2_int_signature,        "(II)I")                                                                      \
-  do_signature(long2_long_signature,      "(JJ)J")                                                                         \
+  do_signature(long2_long_signature,      "(JJ)J")                                                                      \
                                                                                                                         \
   /* here are the math names, all together: */                                                                          \
   do_name(abs_name,"abs")       do_name(sin_name,"sin")         do_name(cos_name,"cos")                                 \
@@ -770,6 +772,7 @@
   do_name(multiplyExact_name,"multiplyExact")                                                                           \
   do_name(negateExact_name,"negateExact")                                                                               \
   do_name(subtractExact_name,"subtractExact")                                                                           \
+  do_name(fma_name, "fma")                                                                                              \
                                                                                                                         \
   do_intrinsic(_dabs,                     java_lang_Math,         abs_name,   double_double_signature,           F_S)   \
   do_intrinsic(_dsin,                     java_lang_Math,         sin_name,   double_double_signature,           F_S)   \
@@ -795,6 +798,8 @@
   do_intrinsic(_negateExactL,             java_lang_Math,         negateExact_name, long_long_signature,         F_S)   \
   do_intrinsic(_subtractExactI,           java_lang_Math,         subtractExact_name, int2_int_signature,        F_S)   \
   do_intrinsic(_subtractExactL,           java_lang_Math,         subtractExact_name, long2_long_signature,      F_S)   \
+  do_intrinsic(_fmaD,                     java_lang_Math,         fma_name,           double3_double_signature,  F_S)   \
+  do_intrinsic(_fmaF,                     java_lang_Math,         fma_name,           float3_float_signature,    F_S)   \
                                                                                                                         \
   do_intrinsic(_floatToRawIntBits,        java_lang_Float,        floatToRawIntBits_name,   float_int_signature, F_S)   \
    do_name(     floatToRawIntBits_name,                          "floatToRawIntBits")                                   \
--- a/hotspot/src/share/vm/gc/cms/cmsOopClosures.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/cms/cmsOopClosures.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -258,16 +258,15 @@
 // the closure ParMarkFromRootsClosure.
 class ParPushOrMarkClosure: public MetadataAwareOopClosure {
  private:
-  CMSCollector*    _collector;
-  MemRegion        _whole_span;
-  MemRegion        _span;        // local chunk
-  CMSBitMap*       _bit_map;
-  OopTaskQueue*    _work_queue;
-  CMSMarkStack*    _overflow_stack;
-  HeapWord*  const _finger;
-  HeapWord** const _global_finger_addr;
-  ParMarkFromRootsClosure* const
-                   _parent;
+  CMSCollector*                  _collector;
+  MemRegion                      _whole_span;
+  MemRegion                      _span;       // local chunk
+  CMSBitMap*                     _bit_map;
+  OopTaskQueue*                  _work_queue;
+  CMSMarkStack*                  _overflow_stack;
+  HeapWord*  const               _finger;
+  HeapWord* volatile* const      _global_finger_addr;
+  ParMarkFromRootsClosure* const _parent;
  protected:
   DO_OOP_WORK_DEFN
  public:
@@ -277,7 +276,7 @@
                        OopTaskQueue* work_queue,
                        CMSMarkStack* mark_stack,
                        HeapWord* finger,
-                       HeapWord** global_finger_addr,
+                       HeapWord* volatile* global_finger_addr,
                        ParMarkFromRootsClosure* parent);
   virtual void do_oop(oop* p);
   virtual void do_oop(narrowOop* p);
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -3025,14 +3025,14 @@
 
 // MT Concurrent Marking Task
 class CMSConcMarkingTask: public YieldingFlexibleGangTask {
-  CMSCollector* _collector;
-  uint          _n_workers;       // requested/desired # workers
-  bool          _result;
-  CompactibleFreeListSpace*  _cms_space;
-  char          _pad_front[64];   // padding to ...
-  HeapWord*     _global_finger;   // ... avoid sharing cache line
-  char          _pad_back[64];
-  HeapWord*     _restart_addr;
+  CMSCollector*             _collector;
+  uint                      _n_workers;      // requested/desired # workers
+  bool                      _result;
+  CompactibleFreeListSpace* _cms_space;
+  char                      _pad_front[64];   // padding to ...
+  HeapWord* volatile        _global_finger;   // ... avoid sharing cache line
+  char                      _pad_back[64];
+  HeapWord*                 _restart_addr;
 
   //  Exposed here for yielding support
   Mutex* const _bit_map_lock;
@@ -3068,7 +3068,7 @@
 
   OopTaskQueue* work_queue(int i) { return task_queues()->queue(i); }
 
-  HeapWord** global_finger_addr() { return &_global_finger; }
+  HeapWord* volatile* global_finger_addr() { return &_global_finger; }
 
   CMSConcMarkingTerminator* terminator() { return &_term; }
 
@@ -6554,7 +6554,7 @@
 
   // Note: the local finger doesn't advance while we drain
   // the stack below, but the global finger sure can and will.
-  HeapWord** gfa = _task->global_finger_addr();
+  HeapWord* volatile* gfa = _task->global_finger_addr();
   ParPushOrMarkClosure pushOrMarkClosure(_collector,
                                          _span, _bit_map,
                                          _work_queue,
@@ -6721,7 +6721,7 @@
                                            OopTaskQueue* work_queue,
                                            CMSMarkStack*  overflow_stack,
                                            HeapWord* finger,
-                                           HeapWord** global_finger_addr,
+                                           HeapWord* volatile* global_finger_addr,
                                            ParMarkFromRootsClosure* parent) :
   MetadataAwareOopClosure(collector->ref_processor()),
   _collector(collector),
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -540,7 +540,7 @@
 
   // Overflow list of grey objects, threaded through mark-word
   // Manipulated with CAS in the parallel/multi-threaded case.
-  oop _overflow_list;
+  oopDesc* volatile _overflow_list;
   // The following array-pair keeps track of mark words
   // displaced for accommodating overflow list above.
   // This code will likely be revisited under RFE#4922830.
@@ -724,12 +724,12 @@
   // Support for parallelizing young gen rescan in CMS remark phase
   ParNewGeneration* _young_gen;
 
-  HeapWord** _top_addr;    // ... Top of Eden
-  HeapWord** _end_addr;    // ... End of Eden
-  Mutex*     _eden_chunk_lock;
-  HeapWord** _eden_chunk_array; // ... Eden partitioning array
-  size_t     _eden_chunk_index; // ... top (exclusive) of array
-  size_t     _eden_chunk_capacity;  // ... max entries in array
+  HeapWord* volatile* _top_addr;    // ... Top of Eden
+  HeapWord**          _end_addr;    // ... End of Eden
+  Mutex*              _eden_chunk_lock;
+  HeapWord**          _eden_chunk_array; // ... Eden partitioning array
+  size_t              _eden_chunk_index; // ... top (exclusive) of array
+  size_t              _eden_chunk_capacity;  // ... max entries in array
 
   // Support for parallelizing survivor space rescan
   HeapWord** _survivor_chunk_array;
--- a/hotspot/src/share/vm/gc/cms/parNewGeneration.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/cms/parNewGeneration.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -323,7 +323,7 @@
   // A list of from-space images of to-be-scanned objects, threaded through
   // klass-pointers (klass information already copied to the forwarded
   // image.)  Manipulated with CAS.
-  oop _overflow_list;
+  oopDesc* volatile _overflow_list;
   NOT_PRODUCT(ssize_t _num_par_pushes;)
 
   // This closure is used by the reference processor to filter out
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -2474,8 +2474,16 @@
 }
 
 jlong G1CollectedHeap::millis_since_last_gc() {
-  // assert(false, "NYI");
-  return 0;
+  // See the notes in GenCollectedHeap::millis_since_last_gc()
+  // for more information about the implementation.
+  jlong ret_val = (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) -
+    _g1_policy->collection_pause_end_millis();
+  if (ret_val < 0) {
+    log_warning(gc)("millis_since_last_gc() would return : " JLONG_FORMAT
+      ". returning zero instead.", ret_val);
+    return 0;
+  }
+  return ret_val;
 }
 
 void G1CollectedHeap::prepare_for_verify() {
--- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -66,7 +66,8 @@
   _phase_times(new G1GCPhaseTimes(ParallelGCThreads)),
   _tenuring_threshold(MaxTenuringThreshold),
   _max_survivor_regions(0),
-  _survivors_age_table(true) { }
+  _survivors_age_table(true),
+  _collection_pause_end_millis(os::javaTimeNanos() / NANOSECS_PER_MILLISEC) { }
 
 G1DefaultPolicy::~G1DefaultPolicy() {
   delete _ihop_control;
@@ -575,6 +576,8 @@
 
   record_pause(young_gc_pause_kind(), end_time_sec - pause_time_ms / 1000.0, end_time_sec);
 
+  _collection_pause_end_millis = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
+
   last_pause_included_initial_mark = collector_state()->during_initial_mark_pause();
   if (last_pause_included_initial_mark) {
     record_concurrent_mark_init_end(0.0);
--- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -64,6 +64,8 @@
 
   double _full_collection_start_sec;
 
+  jlong _collection_pause_end_millis;
+
   uint _young_list_target_length;
   uint _young_list_fixed_length;
 
@@ -237,6 +239,8 @@
 
   double reclaimable_bytes_perc(size_t reclaimable_bytes) const;
 
+  jlong collection_pause_end_millis() { return _collection_pause_end_millis; }
+
 private:
   // Sets up marking if proper conditions are met.
   void maybe_start_marking();
--- a/hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -81,47 +81,6 @@
   _last_marking_length_s(0.0) {
 }
 
-#ifndef PRODUCT
-static void test_update(G1IHOPControl* ctrl, double alloc_time, size_t alloc_amount, size_t young_size, double mark_time) {
-  for (int i = 0; i < 100; i++) {
-    ctrl->update_allocation_info(alloc_time, alloc_amount, young_size);
-    ctrl->update_marking_length(mark_time);
-  }
-}
-
-void G1StaticIHOPControl::test() {
-  size_t const initial_ihop = 45;
-
-  G1StaticIHOPControl ctrl(initial_ihop);
-  ctrl.update_target_occupancy(100);
-
-  size_t threshold = ctrl.get_conc_mark_start_threshold();
-  assert(threshold == initial_ihop,
-         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
-  ctrl.update_allocation_info(100.0, 100, 100);
-  threshold = ctrl.get_conc_mark_start_threshold();
-  assert(threshold == initial_ihop,
-         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
-  ctrl.update_marking_length(1000.0);
-  threshold = ctrl.get_conc_mark_start_threshold();
-  assert(threshold == initial_ihop,
-         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
-  // Whatever we pass, the IHOP value must stay the same.
-  test_update(&ctrl, 2, 10, 10, 3);
-  threshold = ctrl.get_conc_mark_start_threshold();
-  assert(threshold == initial_ihop,
-         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
-  test_update(&ctrl, 12, 10, 10, 3);
-  threshold = ctrl.get_conc_mark_start_threshold();
-  assert(threshold == initial_ihop,
-         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-}
-#endif
-
 G1AdaptiveIHOPControl::G1AdaptiveIHOPControl(double ihop_percent,
                                              G1Predictions const* predictor,
                                              size_t heap_reserve_percent,
@@ -224,79 +183,3 @@
                                           _predictor->get_new_prediction(&_marking_times_s),
                                           have_enough_data_for_prediction());
 }
-
-#ifndef PRODUCT
-void G1AdaptiveIHOPControl::test() {
-  size_t const initial_threshold = 45;
-  size_t const young_size = 10;
-  size_t const target_size = 100;
-
-  // The final IHOP value is always
-  // target_size - (young_size + alloc_amount/alloc_time * marking_time)
-
-  G1Predictions pred(0.95);
-  G1AdaptiveIHOPControl ctrl(initial_threshold, &pred, 0, 0);
-  ctrl.update_target_occupancy(target_size);
-
-  // First "load".
-  size_t const alloc_time1 = 2;
-  size_t const alloc_amount1 = 10;
-  size_t const marking_time1 = 2;
-  size_t const settled_ihop1 = target_size - (young_size + alloc_amount1/alloc_time1 * marking_time1);
-
-  size_t threshold;
-  threshold = ctrl.get_conc_mark_start_threshold();
-  assert(threshold == initial_threshold,
-         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_threshold, threshold);
-  for (size_t i = 0; i < G1AdaptiveIHOPNumInitialSamples - 1; i++) {
-    ctrl.update_allocation_info(alloc_time1, alloc_amount1, young_size);
-    ctrl.update_marking_length(marking_time1);
-    // Not enough data yet.
-    threshold = ctrl.get_conc_mark_start_threshold();
-    assert(threshold == initial_threshold,
-           "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_threshold, threshold);
-  }
-
-  test_update(&ctrl, alloc_time1, alloc_amount1, young_size, marking_time1);
-
-  threshold = ctrl.get_conc_mark_start_threshold();
-  assert(threshold == settled_ihop1,
-         "Expected IHOP threshold to settle at " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop1, threshold);
-
-  // Second "load". A bit higher allocation rate.
-  size_t const alloc_time2 = 2;
-  size_t const alloc_amount2 = 30;
-  size_t const marking_time2 = 2;
-  size_t const settled_ihop2 = target_size - (young_size + alloc_amount2/alloc_time2 * marking_time2);
-
-  test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
-
-  threshold = ctrl.get_conc_mark_start_threshold();
-  assert(threshold < settled_ihop1,
-         "Expected IHOP threshold to settle at a value lower than " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop1, threshold);
-
-  // Third "load". Very high (impossible) allocation rate.
-  size_t const alloc_time3 = 1;
-  size_t const alloc_amount3 = 50;
-  size_t const marking_time3 = 2;
-  size_t const settled_ihop3 = 0;
-
-  test_update(&ctrl, alloc_time3, alloc_amount3, young_size, marking_time3);
-  threshold = ctrl.get_conc_mark_start_threshold();
-
-  assert(threshold == settled_ihop3,
-         "Expected IHOP threshold to settle at " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop3, threshold);
-
-  // And back to some arbitrary value.
-  test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
-
-  threshold = ctrl.get_conc_mark_start_threshold();
-  assert(threshold > settled_ihop3,
-         "Expected IHOP threshold to settle at value larger than " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop3, threshold);
-}
-
-void IHOP_test() {
-  G1StaticIHOPControl::test();
-  G1AdaptiveIHOPControl::test();
-}
-#endif
--- a/hotspot/src/share/vm/gc/g1/g1IHOPControl.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1IHOPControl.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -99,10 +99,6 @@
    assert(marking_length_s > 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
     _last_marking_length_s = marking_length_s;
   }
-
-#ifndef PRODUCT
-  static void test();
-#endif
 };
 
 // This algorithm tries to return a concurrent mark starting occupancy value that
@@ -148,9 +144,6 @@
 
   virtual void print();
   virtual void send_trace_event(G1NewTracer* tracer);
-#ifndef PRODUCT
-  static void test();
-#endif
 };
 
 #endif // SHARE_VM_GC_G1_G1IHOPCONTROL_HPP
--- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -119,6 +119,8 @@
   virtual void record_full_collection_start() = 0;
   virtual void record_full_collection_end() = 0;
 
+  virtual jlong collection_pause_end_millis() = 0;
+
   // Must currently be called while the world is stopped.
   virtual void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) = 0;
 
--- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -668,20 +668,18 @@
   // fail arbitrarily). We tell the iteration code to perform this
   // filtering when it has been determined that there has been an actual
   // allocation in this region and making it safe to check the young type.
-  bool filter_young = true;
 
-  HeapWord* stop_point =
+  bool card_processed =
     r->oops_on_card_seq_iterate_careful(dirtyRegion,
                                         &filter_then_update_rs_oop_cl,
-                                        filter_young,
                                         card_ptr);
 
-  // If stop_point is non-null, then we encountered an unallocated region
-  // (perhaps the unfilled portion of a TLAB.)  For now, we'll dirty the
-  // card and re-enqueue: if we put off the card until a GC pause, then the
-  // unallocated portion will be filled in.  Alternatively, we might try
-  // the full complexity of the technique used in "regular" precleaning.
-  if (stop_point != NULL) {
+  // If unable to process the card then we encountered an unparsable
+  // part of the heap (e.g. a partially allocated object).  Redirty
+  // and re-enqueue: if we put off the card until a GC pause, then the
+  // allocation will have completed.
+  if (!card_processed) {
+    assert(!_g1->is_gc_active(), "Unparsable heap during GC");
     // The card might have gotten re-dirtied and re-enqueued while we
     // worked.  (In fact, it's pretty likely.)
     if (*card_ptr != CardTableModRefBS::dirty_card_val()) {
--- a/hotspot/src/share/vm/gc/g1/heapRegion.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/heapRegion.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -352,19 +352,10 @@
   _prev_marked_bytes = marked_bytes;
 }
 
-HeapWord*
-HeapRegion::
-oops_on_card_seq_iterate_careful(MemRegion mr,
-                                 FilterOutOfRegionClosure* cl,
-                                 bool filter_young,
-                                 jbyte* card_ptr) {
-  // Currently, we should only have to clean the card if filter_young
-  // is true and vice versa.
-  if (filter_young) {
-    assert(card_ptr != NULL, "pre-condition");
-  } else {
-    assert(card_ptr == NULL, "pre-condition");
-  }
+bool HeapRegion::oops_on_card_seq_iterate_careful(MemRegion mr,
+                                                  FilterOutOfRegionClosure* cl,
+                                                  jbyte* card_ptr) {
+  assert(card_ptr != NULL, "pre-condition");
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 
   // If we're within a stop-world GC, then we might look at a card in a
@@ -375,7 +366,9 @@
   } else {
     mr = mr.intersection(used_region());
   }
-  if (mr.is_empty()) return NULL;
+  if (mr.is_empty()) {
+    return true;
+  }
   // Otherwise, find the obj that extends onto mr.start().
 
   // The intersection of the incoming mr (for the card) and the
@@ -384,27 +377,21 @@
   // G1CollectedHeap.cpp that allocates a new region sets the
   // is_young tag on the region before allocating. Thus we
   // safely know if this region is young.
-  if (is_young() && filter_young) {
-    return NULL;
+  if (is_young()) {
+    return true;
   }
 
-  assert(!is_young(), "check value of filter_young");
-
   // We can only clean the card here, after we make the decision that
-  // the card is not young. And we only clean the card if we have been
-  // asked to (i.e., card_ptr != NULL).
-  if (card_ptr != NULL) {
-    *card_ptr = CardTableModRefBS::clean_card_val();
-    // We must complete this write before we do any of the reads below.
-    OrderAccess::storeload();
-  }
+  // the card is not young.
+  *card_ptr = CardTableModRefBS::clean_card_val();
+  // We must complete this write before we do any of the reads below.
+  OrderAccess::storeload();
 
   // Cache the boundaries of the memory region in some const locals
   HeapWord* const start = mr.start();
   HeapWord* const end = mr.end();
 
-  // We used to use "block_start_careful" here.  But we're actually happy
-  // to update the BOT while we do this...
+  // Update BOT as needed while finding start of (potential) object.
   HeapWord* cur = block_start(start);
   assert(cur <= start, "Postcondition");
 
@@ -416,7 +403,9 @@
     obj = oop(cur);
     if (obj->klass_or_null() == NULL) {
       // Ran into an unparseable point.
-      return cur;
+      assert(!g1h->is_gc_active(),
+             "Unparsable heap during GC at " PTR_FORMAT, p2i(cur));
+      return false;
     }
     // Otherwise...
     next = cur + block_size(cur);
@@ -433,7 +422,9 @@
     assert((cur + block_size(cur)) > (HeapWord*)obj, "Loop invariant");
     if (obj->klass_or_null() == NULL) {
       // Ran into an unparseable point.
-      return cur;
+      assert(!g1h->is_gc_active(),
+             "Unparsable heap during GC at " PTR_FORMAT, p2i(cur));
+      return false;
     }
 
     // Advance the current pointer. "obj" still points to the object to iterate.
@@ -452,7 +443,7 @@
     }
   } while (cur < end);
 
-  return NULL;
+  return true;
 }
 
 // Code roots support
--- a/hotspot/src/share/vm/gc/g1/heapRegion.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/heapRegion.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -653,16 +653,17 @@
     }
   }
 
-  // filter_young: if true and the region is a young region then we
-  // skip the iteration.
-  // card_ptr: if not NULL, and we decide that the card is not young
-  // and we iterate over it, we'll clean the card before we start the
-  // iteration.
-  HeapWord*
-  oops_on_card_seq_iterate_careful(MemRegion mr,
-                                   FilterOutOfRegionClosure* cl,
-                                   bool filter_young,
-                                   jbyte* card_ptr);
+  // Iterate over the card in the card designated by card_ptr,
+  // applying cl to all references in the region.
+  // mr: the memory region covered by the card.
+  // card_ptr: if we decide that the card is not young and we iterate
+  // over it, we'll clean the card before we start the iteration.
+  // Returns true if card was successfully processed, false if an
+  // unparsable part of the heap was encountered, which should only
+  // happen when invoked concurrently with the mutator.
+  bool oops_on_card_seq_iterate_careful(MemRegion mr,
+                                        FilterOutOfRegionClosure* cl,
+                                        jbyte* card_ptr);
 
   size_t recorded_rs_length() const        { return _recorded_rs_length; }
   double predicted_elapsed_time_ms() const { return _predicted_elapsed_time_ms; }
--- a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -482,8 +482,9 @@
 HeapRegionClaimer::HeapRegionClaimer(uint n_workers) :
     _n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm._allocated_heapregions_length), _claims(NULL) {
   assert(n_workers > 0, "Need at least one worker.");
-  _claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
-  memset(_claims, Unclaimed, sizeof(*_claims) * _n_regions);
+  uint* new_claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
+  memset(new_claims, Unclaimed, sizeof(*_claims) * _n_regions);
+  _claims = new_claims;
 }
 
 HeapRegionClaimer::~HeapRegionClaimer() {
--- a/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -259,9 +259,9 @@
 // The HeapRegionClaimer is used during parallel iteration over heap regions,
 // allowing workers to claim heap regions, gaining exclusive rights to these regions.
 class HeapRegionClaimer : public StackObj {
-  uint  _n_workers;
-  uint  _n_regions;
-  uint* _claims;
+  uint           _n_workers;
+  uint           _n_regions;
+  volatile uint* _claims;
 
   static const uint Unclaimed = 0;
   static const uint Claimed   = 1;
@@ -285,4 +285,3 @@
   bool claim_region(uint region_index);
 };
 #endif // SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
-
--- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -56,7 +56,7 @@
   PerRegionTable * _collision_list_next;
 
   // Global free list of PRTs
-  static PerRegionTable* _free_list;
+  static PerRegionTable* volatile _free_list;
 
 protected:
   // We need access in order to union things into the base table.
@@ -249,7 +249,7 @@
   static void test_fl_mem_size();
 };
 
-PerRegionTable* PerRegionTable::_free_list = NULL;
+PerRegionTable* volatile PerRegionTable::_free_list = NULL;
 
 size_t OtherRegionsTable::_max_fine_entries = 0;
 size_t OtherRegionsTable::_mod_max_fine_entries_mask = 0;
--- a/hotspot/src/share/vm/gc/g1/sparsePRT.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/sparsePRT.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -283,7 +283,7 @@
 
 // ----------------------------------------------------------------------
 
-SparsePRT* SparsePRT::_head_expanded_list = NULL;
+SparsePRT* volatile SparsePRT::_head_expanded_list = NULL;
 
 void SparsePRT::add_to_expanded_list(SparsePRT* sprt) {
   // We could expand multiple times in a pause -- only put on list once.
--- a/hotspot/src/share/vm/gc/g1/sparsePRT.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/g1/sparsePRT.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -250,7 +250,7 @@
 
   bool should_be_on_expanded_list();
 
-  static SparsePRT* _head_expanded_list;
+  static SparsePRT* volatile _head_expanded_list;
 
 public:
   SparsePRT(HeapRegion* hr);
--- a/hotspot/src/share/vm/gc/parallel/mutableSpace.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/parallel/mutableSpace.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -51,7 +51,7 @@
   MemRegion _last_setup_region;
   size_t _alignment;
  protected:
-  HeapWord* _top;
+  HeapWord* volatile _top;
 
   MutableSpaceMangler* mangler() { return _mangler; }
 
@@ -69,7 +69,7 @@
   HeapWord* top() const                    { return _top;    }
   virtual void set_top(HeapWord* value)    { _top = value;   }
 
-  HeapWord** top_addr()                    { return &_top; }
+  HeapWord* volatile* top_addr()           { return &_top; }
   HeapWord** end_addr()                    { return &_end; }
 
   virtual void set_bottom(HeapWord* value) { _bottom = value; }
--- a/hotspot/src/share/vm/gc/parallel/parallelScavengeHeap.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/parallel/parallelScavengeHeap.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -175,7 +175,7 @@
 
   bool supports_inline_contig_alloc() const { return !UseNUMA; }
 
-  HeapWord** top_addr() const { return !UseNUMA ? young_gen()->top_addr() : (HeapWord**)-1; }
+  HeapWord* volatile* top_addr() const { return !UseNUMA ? young_gen()->top_addr() : (HeapWord* volatile*)-1; }
   HeapWord** end_addr() const { return !UseNUMA ? young_gen()->end_addr() : (HeapWord**)-1; }
 
   void ensure_parsability(bool retire_tlabs);
--- a/hotspot/src/share/vm/gc/parallel/psYoungGen.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/parallel/psYoungGen.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -162,7 +162,7 @@
     return result;
   }
 
-  HeapWord** top_addr() const   { return eden_space()->top_addr(); }
+  HeapWord* volatile* top_addr() const   { return eden_space()->top_addr(); }
   HeapWord** end_addr() const   { return eden_space()->end_addr(); }
 
   // Iteration.
--- a/hotspot/src/share/vm/gc/parallel/vmStructs_parallelgc.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/parallel/vmStructs_parallelgc.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
 #define SHARE_VM_GC_PARALLEL_VMSTRUCTS_PARALLELGC_HPP
 
 #define VM_STRUCTS_PARALLELGC(nonstatic_field, \
-                   static_field) \
+                              volatile_nonstatic_field, \
+                              static_field) \
                                                                                                                                      \
   /**********************/                                                                                                           \
   /* Parallel GC fields */                                                                                                           \
@@ -40,7 +41,7 @@
   nonstatic_field(ImmutableSpace,              _bottom,                                       HeapWord*)                             \
   nonstatic_field(ImmutableSpace,              _end,                                          HeapWord*)                             \
                                                                                                                                      \
-  nonstatic_field(MutableSpace,                _top,                                          HeapWord*)                             \
+  volatile_nonstatic_field(MutableSpace,       _top,                                          HeapWord*)                             \
                                                                                                                                      \
   nonstatic_field(PSYoungGen,                  _reserved,                                     MemRegion)                             \
   nonstatic_field(PSYoungGen,                  _virtual_space,                                PSVirtualSpace*)                       \
--- a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -512,7 +512,7 @@
 }
 
 
-HeapWord** DefNewGeneration::top_addr() const { return eden()->top_addr(); }
+HeapWord* volatile* DefNewGeneration::top_addr() const { return eden()->top_addr(); }
 HeapWord** DefNewGeneration::end_addr() const { return eden()->end_addr(); }
 
 void DefNewGeneration::object_iterate(ObjectClosure* blk) {
--- a/hotspot/src/share/vm/gc/serial/defNewGeneration.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -225,7 +225,7 @@
   size_t max_survivor_size() const          { return _max_survivor_size; }
 
   bool supports_inline_contig_alloc() const { return true; }
-  HeapWord** top_addr() const;
+  HeapWord* volatile* top_addr() const;
   HeapWord** end_addr() const;
 
   // Thread-local allocation buffers
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -350,7 +350,7 @@
   // These functions return the addresses of the fields that define the
   // boundaries of the contiguous allocation area.  (These fields should be
   // physically near to one another.)
-  virtual HeapWord** top_addr() const {
+  virtual HeapWord* volatile* top_addr() const {
     guarantee(false, "inline contiguous allocation not supported");
     return NULL;
   }
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -721,7 +721,7 @@
   return _young_gen->supports_inline_contig_alloc();
 }
 
-HeapWord** GenCollectedHeap::top_addr() const {
+HeapWord* volatile* GenCollectedHeap::top_addr() const {
   return _young_gen->top_addr();
 }
 
@@ -1256,21 +1256,20 @@
 };
 
 jlong GenCollectedHeap::millis_since_last_gc() {
-  // We need a monotonically non-decreasing time in ms but
-  // os::javaTimeMillis() does not guarantee monotonicity.
+  // javaTimeNanos() is guaranteed to be monotonically non-decreasing
+  // provided the underlying platform provides such a time source
+  // (and it is bug free). So we still have to guard against getting
+  // back a time later than 'now'.
   jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
   GenTimeOfLastGCClosure tolgc_cl(now);
   // iterate over generations getting the oldest
   // time that a generation was collected
   generation_iterate(&tolgc_cl, false);
 
-  // javaTimeNanos() is guaranteed to be monotonically non-decreasing
-  // provided the underlying platform provides such a time source
-  // (and it is bug free). So we still have to guard against getting
-  // back a time later than 'now'.
   jlong retVal = now - tolgc_cl.time();
   if (retVal < 0) {
-    NOT_PRODUCT(log_warning(gc)("time warp: " JLONG_FORMAT, retVal);)
+    log_warning(gc)("millis_since_last_gc() would return : " JLONG_FORMAT
+       ". returning zero instead.", retVal);
     return 0;
   }
   return retVal;
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -184,7 +184,7 @@
   // We may support a shared contiguous allocation area, if the youngest
   // generation does.
   bool supports_inline_contig_alloc() const;
-  HeapWord** top_addr() const;
+  HeapWord* volatile* top_addr() const;
   HeapWord** end_addr() const;
 
   // Perform a full collection of the heap; intended for use in implementing
--- a/hotspot/src/share/vm/gc/shared/generation.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/shared/generation.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -263,7 +263,7 @@
   // These functions return the addresses of the fields that define the
   // boundaries of the contiguous allocation area.  (These fields should be
   // physically near to one another.)
-  virtual HeapWord** top_addr() const { return NULL; }
+  virtual HeapWord* volatile* top_addr() const { return NULL; }
   virtual HeapWord** end_addr() const { return NULL; }
 
   // Thread-local allocation buffers
--- a/hotspot/src/share/vm/gc/shared/workgroup.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/shared/workgroup.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -472,23 +472,21 @@
 }
 
 bool SequentialSubTasksDone::is_task_claimed(uint& t) {
-  uint* n_claimed_ptr = &_n_claimed;
-  t = *n_claimed_ptr;
+  t = _n_claimed;
   while (t < _n_tasks) {
-    jint res = Atomic::cmpxchg(t+1, n_claimed_ptr, t);
+    jint res = Atomic::cmpxchg(t+1, &_n_claimed, t);
     if (res == (jint)t) {
       return false;
     }
-    t = *n_claimed_ptr;
+    t = res;
   }
   return true;
 }
 
 bool SequentialSubTasksDone::all_tasks_completed() {
-  uint* n_completed_ptr = &_n_completed;
-  uint  complete        = *n_completed_ptr;
+  uint complete = _n_completed;
   while (true) {
-    uint res = Atomic::cmpxchg(complete+1, n_completed_ptr, complete);
+    uint res = Atomic::cmpxchg(complete+1, &_n_completed, complete);
     if (res == complete) {
       break;
     }
--- a/hotspot/src/share/vm/gc/shared/workgroup.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -318,9 +318,9 @@
 // enumeration type.
 
 class SubTasksDone: public CHeapObj<mtInternal> {
-  uint* _tasks;
+  volatile uint* _tasks;
   uint _n_tasks;
-  uint _threads_completed;
+  volatile uint _threads_completed;
 #ifdef ASSERT
   volatile uint _claimed;
 #endif
@@ -363,11 +363,11 @@
 class SequentialSubTasksDone : public StackObj {
 protected:
   uint _n_tasks;     // Total number of tasks available.
-  uint _n_claimed;   // Number of tasks claimed.
+  volatile uint _n_claimed;   // Number of tasks claimed.
   // _n_threads is used to determine when a sub task is done.
   // See comments on SubTasksDone::_n_threads
   uint _n_threads;   // Total number of parallel threads.
-  uint _n_completed; // Number of completed threads.
+  volatile uint _n_completed; // Number of completed threads.
 
   void clear();
 
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -194,6 +194,13 @@
                                 return java_lang_ref_reference_get;
   }
 
+  if (UseFMA) {
+    switch (m->intrinsic_id()) {
+      case vmIntrinsics::_fmaD: return java_lang_math_fmaD;
+      case vmIntrinsics::_fmaF: return java_lang_math_fmaF;
+    }
+  }
+
   // Accessor method?
   if (m->is_getter()) {
     // TODO: We should have used ::is_accessor above, but fast accessors in Zero expect only getters.
@@ -281,6 +288,8 @@
     case java_lang_math_sqrt    : tty->print("java_lang_math_sqrt"    ); break;
     case java_lang_math_log     : tty->print("java_lang_math_log"     ); break;
     case java_lang_math_log10   : tty->print("java_lang_math_log10"   ); break;
+    case java_lang_math_fmaD    : tty->print("java_lang_math_fmaD"    ); break;
+    case java_lang_math_fmaF    : tty->print("java_lang_math_fmaF"    ); break;
     case java_util_zip_CRC32_update           : tty->print("java_util_zip_CRC32_update"); break;
     case java_util_zip_CRC32_updateBytes      : tty->print("java_util_zip_CRC32_updateBytes"); break;
     case java_util_zip_CRC32_updateByteBuffer : tty->print("java_util_zip_CRC32_updateByteBuffer"); break;
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -76,6 +76,8 @@
     java_lang_math_log10,                                       // implementation of java.lang.Math.log10 (x)
     java_lang_math_pow,                                         // implementation of java.lang.Math.pow   (x,y)
     java_lang_math_exp,                                         // implementation of java.lang.Math.exp   (x)
+    java_lang_math_fmaF,                                        // implementation of java.lang.Math.fma   (x, y, z)
+    java_lang_math_fmaD,                                        // implementation of java.lang.Math.fma   (x, y, z)
     java_lang_ref_reference_get,                                // implementation of java.lang.ref.Reference.get()
     java_util_zip_CRC32_update,                                 // implementation of java.util.zip.CRC32.update()
     java_util_zip_CRC32_updateBytes,                            // implementation of java.util.zip.CRC32.updateBytes()
--- a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -239,6 +239,10 @@
       method_entry(java_lang_math_log10)
       method_entry(java_lang_math_exp  )
       method_entry(java_lang_math_pow  )
+      if (UseFMA) {
+        method_entry(java_lang_math_fmaF)
+        method_entry(java_lang_math_fmaD)
+      }
       method_entry(java_lang_ref_reference_get)
 
       AbstractInterpreter::initialize_method_handle_entries();
@@ -445,7 +449,9 @@
   case Interpreter::java_lang_math_log10   : // fall thru
   case Interpreter::java_lang_math_sqrt    : // fall thru
   case Interpreter::java_lang_math_pow     : // fall thru
-  case Interpreter::java_lang_math_exp     : entry_point = generate_math_entry(kind);      break;
+  case Interpreter::java_lang_math_exp     : // fall thru
+  case Interpreter::java_lang_math_fmaD    : // fall thru
+  case Interpreter::java_lang_math_fmaF     : entry_point = generate_math_entry(kind);      break;
   case Interpreter::java_lang_ref_reference_get
                                            : entry_point = generate_Reference_get_entry(); break;
   case Interpreter::java_util_zip_CRC32_update
--- a/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -114,11 +114,11 @@
   JVMCIRuntime::bootstrap_finished(CHECK);
 }
 
-#define CHECK_ABORT THREAD); \
+#define CHECK_EXIT THREAD); \
 if (HAS_PENDING_EXCEPTION) { \
   char buf[256]; \
   jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
-  JVMCICompiler::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
+  JVMCICompiler::exit_on_pending_exception(PENDING_EXCEPTION, buf); \
   return; \
 } \
 (void)(0
@@ -133,10 +133,10 @@
       return;
   }
 
-  JVMCIRuntime::initialize_well_known_classes(CHECK_ABORT);
+  JVMCIRuntime::initialize_well_known_classes(CHECK_EXIT);
 
   HandleMark hm;
-  Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT);
+  Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_EXIT);
 
   JavaValue method_result(T_OBJECT);
   JavaCallArguments args;
@@ -202,23 +202,22 @@
   return level;
 }
 
-/**
- * Aborts the VM due to an unexpected exception.
- */
-void JVMCICompiler::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
-  Thread* THREAD = Thread::current();
+void JVMCICompiler::exit_on_pending_exception(Handle exception, const char* message) {
+  JavaThread* THREAD = JavaThread::current();
   CLEAR_PENDING_EXCEPTION;
 
-  java_lang_Throwable::java_printStackTrace(exception, THREAD);
+  static volatile int report_error = 0;
+  if (!report_error && Atomic::cmpxchg(1, &report_error, 0) == 0) {
+    // Only report an error once
+    tty->print_raw_cr(message);
+    java_lang_Throwable::java_printStackTrace(exception, THREAD);
+  } else {
+    // Allow error reporting thread to print the stack trace.
+    os::sleep(THREAD, 200, false);
+  }
 
-  // Give other aborting threads to also print their stack traces.
-  // This can be very useful when debugging class initialization
-  // failures.
-  assert(THREAD->is_Java_thread(), "compiler threads should be Java threads");
-  const bool interruptible = true;
-  os::sleep(THREAD, 200, interruptible);
-
-  vm_abort(dump_core);
+  before_exit(THREAD);
+  vm_exit(-1);
 }
 
 // Compilation entry point for methods
--- a/hotspot/src/share/vm/jvmci/jvmciCompiler.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/jvmciCompiler.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -47,7 +47,10 @@
 
   static elapsedTimer _codeInstallTimer;
 
-  static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false);
+  /**
+   * Exits the VM due to an unexpected exception.
+   */
+  static void exit_on_pending_exception(Handle exception, const char* message);
 
 public:
   JVMCICompiler();
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -112,7 +112,7 @@
 
 bool       CompilerToVM::Data::_supports_inline_contig_alloc;
 HeapWord** CompilerToVM::Data::_heap_end_addr;
-HeapWord** CompilerToVM::Data::_heap_top_addr;
+HeapWord* volatile* CompilerToVM::Data::_heap_top_addr;
 int CompilerToVM::Data::_max_oop_map_stack_offset;
 
 jbyte* CompilerToVM::Data::cardtable_start_address;
@@ -153,7 +153,7 @@
 
   _supports_inline_contig_alloc = Universe::heap()->supports_inline_contig_alloc();
   _heap_end_addr = _supports_inline_contig_alloc ? Universe::heap()->end_addr() : (HeapWord**) -1;
-  _heap_top_addr = _supports_inline_contig_alloc ? Universe::heap()->top_addr() : (HeapWord**) -1;
+  _heap_top_addr = _supports_inline_contig_alloc ? Universe::heap()->top_addr() : (HeapWord* volatile*) -1;
 
   _max_oop_map_stack_offset = (OopMapValue::register_mask - VMRegImpl::stack2reg(0)->value()) * VMRegImpl::stack_slot_size;
   int max_oop_map_stack_index = _max_oop_map_stack_offset / VMRegImpl::stack_slot_size;
@@ -473,9 +473,20 @@
   return (jlong) (address) method->exception_table_start();
 C2V_END
 
-C2V_VMENTRY(jobject, getResolvedJavaMethodAtSlot, (JNIEnv *, jobject, jclass holder_handle, jint slot))
-  oop java_class = JNIHandles::resolve(holder_handle);
-  Klass* holder = java_lang_Class::as_Klass(java_class);
+C2V_VMENTRY(jobject, asResolvedJavaMethod, (JNIEnv *, jobject, jobject executable_handle))
+  oop executable = JNIHandles::resolve(executable_handle);
+  oop mirror = NULL;
+  int slot = 0;
+
+  if (executable->klass() == SystemDictionary::reflect_Constructor_klass()) {
+    mirror = java_lang_reflect_Constructor::clazz(executable);
+    slot = java_lang_reflect_Constructor::slot(executable);
+  } else {
+    assert(executable->klass() == SystemDictionary::reflect_Method_klass(), "wrong type");
+    mirror = java_lang_reflect_Method::clazz(executable);
+    slot = java_lang_reflect_Method::slot(executable);
+  }
+  Klass* holder = java_lang_Class::as_Klass(mirror);
   methodHandle method = InstanceKlass::cast(holder)->method_with_idnum(slot);
   oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL);
   return JNIHandles::make_local(THREAD, result);
@@ -1518,6 +1529,17 @@
   return size + Deoptimization::last_frame_adjust(0, callee_locals) * BytesPerWord;
 C2V_END
 
+C2V_VMENTRY(void, compileToBytecode, (JNIEnv*, jobject, jobject lambda_form_handle))
+  Handle lambda_form = JNIHandles::resolve_non_null(lambda_form_handle);
+  if (lambda_form->is_a(SystemDictionary::LambdaForm_klass())) {
+    TempNewSymbol compileToBytecode = SymbolTable::new_symbol("compileToBytecode", CHECK);
+    JavaValue result(T_VOID);
+    JavaCalls::call_special(&result, lambda_form, SystemDictionary::LambdaForm_klass(), compileToBytecode, vmSymbols::void_method_signature(), CHECK);
+  } else {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+                err_msg("Unexpected type: %s", lambda_form->klass()->external_name()));
+  }
+C2V_END
 
 #define CC (char*)  /*cast a literal from (const char*)*/
 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
@@ -1525,6 +1547,7 @@
 #define STRING                "Ljava/lang/String;"
 #define OBJECT                "Ljava/lang/Object;"
 #define CLASS                 "Ljava/lang/Class;"
+#define EXECUTABLE            "Ljava/lang/reflect/Executable;"
 #define STACK_TRACE_ELEMENT   "Ljava/lang/StackTraceElement;"
 #define INSTALLED_CODE        "Ljdk/vm/ci/code/InstalledCode;"
 #define TARGET_DESCRIPTION    "Ljdk/vm/ci/code/TargetDescription;"
@@ -1572,7 +1595,7 @@
   {CC "getClassInitializer",                          CC "(" HS_RESOLVED_KLASS ")" HS_RESOLVED_METHOD,                                      FN_PTR(getClassInitializer)},
   {CC "hasFinalizableSubclass",                       CC "(" HS_RESOLVED_KLASS ")Z",                                                        FN_PTR(hasFinalizableSubclass)},
   {CC "getMaxCallTargetOffset",                       CC "(J)J",                                                                            FN_PTR(getMaxCallTargetOffset)},
-  {CC "getResolvedJavaMethodAtSlot",                  CC "(" CLASS "I)" HS_RESOLVED_METHOD,                                                 FN_PTR(getResolvedJavaMethodAtSlot)},
+  {CC "asResolvedJavaMethod",                         CC "(" EXECUTABLE ")" HS_RESOLVED_METHOD,                                             FN_PTR(asResolvedJavaMethod)},
   {CC "getResolvedJavaMethod",                        CC "(Ljava/lang/Object;J)" HS_RESOLVED_METHOD,                                        FN_PTR(getResolvedJavaMethod)},
   {CC "getConstantPool",                              CC "(Ljava/lang/Object;)" HS_CONSTANT_POOL,                                           FN_PTR(getConstantPool)},
   {CC "getResolvedJavaType",                          CC "(Ljava/lang/Object;JZ)" HS_RESOLVED_KLASS,                                        FN_PTR(getResolvedJavaType)},
@@ -1599,9 +1622,9 @@
   {CC "flushDebugOutput",                             CC "()V",                                                                             FN_PTR(flushDebugOutput)},
   {CC "methodDataProfileDataSize",                    CC "(JI)I",                                                                           FN_PTR(methodDataProfileDataSize)},
   {CC "interpreterFrameSize",                         CC "(" BYTECODE_FRAME ")I",                                                           FN_PTR(interpreterFrameSize)},
+  {CC "compileToBytecode",                            CC "(" OBJECT ")V",                                                                   FN_PTR(compileToBytecode)},
 };
 
 int CompilerToVM::methods_count() {
   return sizeof(methods) / sizeof(JNINativeMethod);
 }
-
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -58,7 +58,7 @@
 
     static bool _supports_inline_contig_alloc;
     static HeapWord** _heap_end_addr;
-    static HeapWord** _heap_top_addr;
+    static HeapWord* volatile* _heap_top_addr;
     static int _max_oop_map_stack_offset;
 
     static jbyte* cardtable_start_address;
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -817,16 +817,6 @@
   }
 JVM_END
 
-#define CHECK_WARN_ABORT_(message) THREAD); \
-  if (HAS_PENDING_EXCEPTION) { \
-    warning(message); \
-    char buf[512]; \
-    jio_snprintf(buf, 512, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
-    JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
-    return; \
-  } \
-  (void)(0
-
 void JVMCIRuntime::shutdown(TRAPS) {
   if (_HotSpotJVMCIRuntime_instance != NULL) {
     _shutdown_called = true;
--- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -69,7 +69,7 @@
                                                                                                                                      \
   static_field(CompilerToVM::Data,             _supports_inline_contig_alloc,          bool)                                         \
   static_field(CompilerToVM::Data,             _heap_end_addr,                         HeapWord**)                                   \
-  static_field(CompilerToVM::Data,             _heap_top_addr,                         HeapWord**)                                   \
+  static_field(CompilerToVM::Data,             _heap_top_addr,                         HeapWord* volatile*)                          \
                                                                                                                                      \
   static_field(CompilerToVM::Data,             _max_oop_map_stack_offset,              int)                                          \
                                                                                                                                      \
@@ -327,8 +327,11 @@
   declare_constant(JVM_ACC_FIELD_INTERNAL)                                \
   declare_constant(JVM_ACC_FIELD_STABLE)                                  \
   declare_constant(JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE)                   \
+  declare_preprocessor_constant("JVM_ACC_VARARGS", JVM_ACC_VARARGS)       \
+  declare_preprocessor_constant("JVM_ACC_BRIDGE", JVM_ACC_BRIDGE)         \
+  declare_preprocessor_constant("JVM_ACC_ANNOTATION", JVM_ACC_ANNOTATION) \
+  declare_preprocessor_constant("JVM_ACC_ENUM", JVM_ACC_ENUM)             \
   declare_preprocessor_constant("JVM_ACC_SYNTHETIC", JVM_ACC_SYNTHETIC)   \
-  declare_preprocessor_constant("JVM_RECOGNIZED_FIELD_MODIFIERS", JVM_RECOGNIZED_FIELD_MODIFIERS) \
                                                                           \
   declare_constant(JVM_CONSTANT_Utf8)                                     \
   declare_constant(JVM_CONSTANT_Unicode)                                  \
@@ -660,7 +663,8 @@
 #define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
   declare_preprocessor_constant("VM_Version::CPU_AVX512BW", CPU_AVX512BW) \
   declare_preprocessor_constant("VM_Version::CPU_AVX512VL", CPU_AVX512VL) \
-  declare_preprocessor_constant("VM_Version::CPU_SHA", CPU_SHA)
+  declare_preprocessor_constant("VM_Version::CPU_SHA", CPU_SHA)           \
+  declare_preprocessor_constant("VM_Version::CPU_FMA", CPU_FMA)
 
 #endif
 
--- a/hotspot/src/share/vm/memory/filemap.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/memory/filemap.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -179,6 +179,7 @@
   _classpath_entry_table_size = mapinfo->_classpath_entry_table_size;
   _classpath_entry_table = mapinfo->_classpath_entry_table;
   _classpath_entry_size = mapinfo->_classpath_entry_size;
+  _num_patch_mod_prefixes = ClassLoader::num_patch_mod_prefixes();
 
   // The following fields are for sanity checks for whether this archive
   // will function correctly with this JVM and the bootclasspath it's
@@ -911,11 +912,6 @@
     return false;
   }
 
-  if (Arguments::get_patch_mod_prefix() != NULL) {
-    FileMapInfo::fail_continue("The shared archive file cannot be used with --patch-module.");
-    return false;
-  }
-
   if (!Arguments::has_jimage()) {
     FileMapInfo::fail_continue("The shared archive file cannot be used with an exploded module build.");
     return false;
@@ -952,6 +948,23 @@
     return false;
   }
 
+  // Check if there is a mismatch in --patch-module entry counts between dump time and run time.
+  // More checks will be performed on individual --patch-module entry in the
+  // SharedPathsMiscInfo::check() function.
+  GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
+  if (patch_mod_args != NULL) {
+    if (_num_patch_mod_prefixes == 0) {
+      FileMapInfo::fail_stop("--patch-module found in run time but none was specified in dump time");
+    }
+    if (patch_mod_args->length() != _num_patch_mod_prefixes) {
+      FileMapInfo::fail_stop("mismatched --patch-module entry counts between dump time and run time");
+    }
+  } else {
+    if (_num_patch_mod_prefixes > 0) {
+      FileMapInfo::fail_stop("--patch-module specified in dump time but none was specified in run time");
+    }
+  }
+
   return true;
 }
 
--- a/hotspot/src/share/vm/memory/filemap.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/memory/filemap.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -155,6 +155,7 @@
     // loading failures during runtime.
     int _classpath_entry_table_size;
     size_t _classpath_entry_size;
+    int    _num_patch_mod_prefixes;   // number of --patch-module entries
     SharedClassPathEntry* _classpath_entry_table;
 
     char* region_addr(int idx);
--- a/hotspot/src/share/vm/oops/arrayOop.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, 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 "oops/arrayOop.hpp"
-#include "oops/oop.inline.hpp"
-#include "utilities/globalDefinitions.hpp"
-
-bool arrayOopDesc::check_max_length_overflow(BasicType type) {
-  julong length = max_array_length(type);
-  julong bytes_per_element = type2aelembytes(type);
-  julong bytes = length * bytes_per_element + header_size_in_bytes();
-  return (julong)(size_t)bytes == bytes;
-}
-
-static void test_max_array_length() {
-  assert(arrayOopDesc::check_max_length_overflow(T_BOOLEAN), "size_t overflow for boolean array");
-  assert(arrayOopDesc::check_max_length_overflow(T_CHAR), "size_t overflow for char array");
-  assert(arrayOopDesc::check_max_length_overflow(T_FLOAT), "size_t overflow for float array");
-  assert(arrayOopDesc::check_max_length_overflow(T_DOUBLE), "size_t overflow for double array");
-  assert(arrayOopDesc::check_max_length_overflow(T_BYTE), "size_t overflow for byte array");
-  assert(arrayOopDesc::check_max_length_overflow(T_SHORT), "size_t overflow for short array");
-  assert(arrayOopDesc::check_max_length_overflow(T_INT), "size_t overflow for int array");
-  assert(arrayOopDesc::check_max_length_overflow(T_LONG), "size_t overflow for long array");
-  assert(arrayOopDesc::check_max_length_overflow(T_OBJECT), "size_t overflow for object array");
-  assert(arrayOopDesc::check_max_length_overflow(T_ARRAY), "size_t overflow for array array");
-  assert(arrayOopDesc::check_max_length_overflow(T_NARROWOOP), "size_t overflow for narrowOop array");
-
-  // T_VOID and T_ADDRESS are not supported by max_array_length()
-}
-
-void arrayOopDesc_test() {
-  test_max_array_length();
-}
-
-#endif //PRODUCT
--- a/hotspot/src/share/vm/oops/arrayOop.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/oops/arrayOop.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -41,6 +41,7 @@
 
 class arrayOopDesc : public oopDesc {
   friend class VMStructs;
+  friend class arrayOopDescTest;
 
   // Interpreter/Compiler offsets
 
@@ -124,10 +125,6 @@
     return (int32_t)max_elements_per_size_t;
   }
 
-// for unit testing
-#ifndef PRODUCT
-  static bool check_max_length_overflow(BasicType type);
-#endif
 };
 
 #endif // SHARE_VM_OOPS_ARRAYOOP_HPP
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -517,7 +517,11 @@
 
 bool InstanceKlass::link_class_impl(
     instanceKlassHandle this_k, bool throw_verifyerror, TRAPS) {
-  // check for error state
+  // 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()) {
     ResourceMark rm(THREAD);
     THROW_MSG_(vmSymbols::java_lang_NoClassDefFoundError(),
@@ -670,36 +674,21 @@
 
 // Eagerly initialize superinterfaces that declare default methods (concrete instance: any access)
 void InstanceKlass::initialize_super_interfaces(instanceKlassHandle this_k, TRAPS) {
-  if (this_k->has_default_methods()) {
-    for (int i = 0; i < this_k->local_interfaces()->length(); ++i) {
-      Klass* iface = this_k->local_interfaces()->at(i);
-      InstanceKlass* ik = InstanceKlass::cast(iface);
-      if (ik->should_be_initialized()) {
-        if (ik->has_default_methods()) {
-          ik->initialize_super_interfaces(ik, THREAD);
-        }
-        // Only initialize() interfaces that "declare" concrete methods.
-        // has_default_methods drives searching superinterfaces since it
-        // means has_default_methods in its superinterface hierarchy
-        if (!HAS_PENDING_EXCEPTION && ik->declares_default_methods()) {
-          ik->initialize(THREAD);
-        }
-        if (HAS_PENDING_EXCEPTION) {
-          Handle e(THREAD, PENDING_EXCEPTION);
-          CLEAR_PENDING_EXCEPTION;
-          {
-            EXCEPTION_MARK;
-            // Locks object, set state, and notify all waiting threads
-            this_k->set_initialization_state_and_notify(
-                initialization_error, THREAD);
-
-            // ignore any exception thrown, superclass initialization error is
-            // thrown below
-            CLEAR_PENDING_EXCEPTION;
-          }
-          THROW_OOP(e());
-        }
-      }
+  assert (this_k->has_default_methods(), "caller should have checked this");
+  for (int i = 0; i < this_k->local_interfaces()->length(); ++i) {
+    Klass* iface = this_k->local_interfaces()->at(i);
+    InstanceKlass* ik = InstanceKlass::cast(iface);
+
+    // Initialization is depth first search ie. we start with top of the inheritance tree
+    // has_default_methods drives searching superinterfaces since it
+    // means has_default_methods in its superinterface hierarchy
+    if (ik->has_default_methods()) {
+      ik->initialize_super_interfaces(ik, CHECK);
+    }
+
+    // Only initialize() interfaces that "declare" concrete methods.
+    if (ik->should_be_initialized() && ik->declares_default_methods()) {
+      ik->initialize(CHECK);
     }
   }
 }
@@ -765,32 +754,36 @@
   }
 
   // Step 7
-  Klass* super_klass = this_k->super();
-  if (super_klass != NULL && !this_k->is_interface() && super_klass->should_be_initialized()) {
-    super_klass->initialize(THREAD);
-
+  // Next, if C is a class rather than an interface, initialize it's super class and super
+  // interfaces.
+  if (!this_k->is_interface()) {
+    Klass* super_klass = this_k->super();
+    if (super_klass != NULL && super_klass->should_be_initialized()) {
+      super_klass->initialize(THREAD);
+    }
+    // If C implements any interfaces that declares a non-abstract, non-static method,
+    // the initialization of C triggers initialization of its super interfaces.
+    // Only need to recurse if has_default_methods which includes declaring and
+    // inheriting default methods
+    if (!HAS_PENDING_EXCEPTION && this_k->has_default_methods()) {
+      this_k->initialize_super_interfaces(this_k, THREAD);
+    }
+
+    // If any exceptions, complete abruptly, throwing the same exception as above.
     if (HAS_PENDING_EXCEPTION) {
       Handle e(THREAD, PENDING_EXCEPTION);
       CLEAR_PENDING_EXCEPTION;
       {
         EXCEPTION_MARK;
-        this_k->set_initialization_state_and_notify(initialization_error, THREAD); // Locks object, set state, and notify all waiting threads
-        CLEAR_PENDING_EXCEPTION;   // ignore any exception thrown, superclass initialization error is thrown below
+        // Locks object, set state, and notify all waiting threads
+        this_k->set_initialization_state_and_notify(initialization_error, THREAD);
+        CLEAR_PENDING_EXCEPTION;
       }
       DTRACE_CLASSINIT_PROBE_WAIT(super__failed, this_k(), -1,wait);
       THROW_OOP(e());
     }
   }
 
-  // If C is an interface that declares a non-abstract, non-static method,
-  // the initialization of a class (not an interface) that implements C directly or
-  // indirectly.
-  // Recursively initialize any superinterfaces that declare default methods
-  // Only need to recurse if has_default_methods which includes declaring and
-  // inheriting default methods
-  if (!this_k->is_interface() && this_k->has_default_methods()) {
-    this_k->initialize_super_interfaces(this_k, CHECK);
-  }
 
   // Step 8
   {
@@ -852,10 +845,15 @@
 
 void InstanceKlass::set_initialization_state_and_notify_impl(instanceKlassHandle this_k, ClassState state, TRAPS) {
   oop init_lock = this_k->init_lock();
-  ObjectLocker ol(init_lock, THREAD, init_lock != NULL);
-  this_k->set_init_state(state);
-  this_k->fence_and_clear_init_lock();
-  ol.notify_all(CHECK);
+  if (init_lock != NULL) {
+    ObjectLocker ol(init_lock, THREAD);
+    this_k->set_init_state(state);
+    this_k->fence_and_clear_init_lock();
+    ol.notify_all(CHECK);
+  } else {
+    assert(init_lock != NULL, "The initialization state should never be set twice");
+    this_k->set_init_state(state);
+  }
 }
 
 // The embedded _implementor field can only record one implementor.
--- a/hotspot/src/share/vm/oops/klass.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/oops/klass.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -734,27 +734,3 @@
 }
 
 #endif
-
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-class TestKlass {
- public:
-  static void test_oop_is_instanceClassLoader() {
-    Klass* klass = SystemDictionary::ClassLoader_klass();
-    guarantee(klass->is_instance_klass(), "assert");
-    guarantee(InstanceKlass::cast(klass)->is_class_loader_instance_klass(), "test failed");
-
-    klass = SystemDictionary::String_klass();
-    guarantee(!klass->is_instance_klass() ||
-              !InstanceKlass::cast(klass)->is_class_loader_instance_klass(),
-              "test failed");
-  }
-};
-
-void TestKlass_test() {
-  TestKlass::test_oop_is_instanceClassLoader();
-}
-
-#endif  // PRODUCT
--- a/hotspot/src/share/vm/oops/oop.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/oops/oop.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -83,6 +83,7 @@
 
   inline Klass* klass() const;
   inline Klass* klass_or_null() const volatile;
+  inline Klass* klass_or_null_acquire() const volatile;
   inline Klass** klass_addr();
   inline narrowKlass* compressed_klass_addr();
 
--- a/hotspot/src/share/vm/oops/oop.inline.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/oops/oop.inline.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -109,7 +109,6 @@
 }
 
 Klass* oopDesc::klass_or_null() const volatile {
-  // can be NULL in CMS
   if (UseCompressedClassPointers) {
     return Klass::decode_klass(_metadata._compressed_klass);
   } else {
@@ -117,6 +116,17 @@
   }
 }
 
+Klass* oopDesc::klass_or_null_acquire() const volatile {
+  if (UseCompressedClassPointers) {
+    // Workaround for non-const load_acquire parameter.
+    const volatile narrowKlass* addr = &_metadata._compressed_klass;
+    volatile narrowKlass* xaddr = const_cast<volatile narrowKlass*>(addr);
+    return Klass::decode_klass(OrderAccess::load_acquire(xaddr));
+  } else {
+    return (Klass*)OrderAccess::load_ptr_acquire(&_metadata._klass);
+  }
+}
+
 Klass** oopDesc::klass_addr() {
   // Only used internally and with CMS and will not work with
   // UseCompressedOops
--- a/hotspot/src/share/vm/opto/c2compiler.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -416,6 +416,12 @@
   case vmIntrinsics::_onSpinWait:
     if (!Matcher::match_rule_supported(Op_OnSpinWait)) return false;
     break;
+  case vmIntrinsics::_fmaD:
+    if (!UseFMA || !Matcher::match_rule_supported(Op_FmaD)) return false;
+    break;
+  case vmIntrinsics::_fmaF:
+    if (!UseFMA || !Matcher::match_rule_supported(Op_FmaF)) return false;
+    break;
   case vmIntrinsics::_hashCode:
   case vmIntrinsics::_identityHashCode:
   case vmIntrinsics::_getClass:
--- a/hotspot/src/share/vm/opto/classes.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/opto/classes.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -151,6 +151,8 @@
 macro(EncodePKlass)
 macro(FastLock)
 macro(FastUnlock)
+macro(FmaD)
+macro(FmaF)
 macro(Goto)
 macro(Halt)
 macro(HasNegatives)
--- a/hotspot/src/share/vm/opto/library_call.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -320,6 +320,7 @@
   bool inline_montgomeryMultiply();
   bool inline_montgomerySquare();
   bool inline_vectorizedMismatch();
+  bool inline_fma(vmIntrinsics::ID id);
 
   bool inline_profileBoolean();
   bool inline_isCompileConstant();
@@ -829,6 +830,10 @@
   case vmIntrinsics::_hasNegatives:
     return inline_hasNegatives();
 
+  case vmIntrinsics::_fmaD:
+  case vmIntrinsics::_fmaF:
+    return inline_fma(intrinsic_id());
+
   default:
     // If you get here, it may be that someone has added a new intrinsic
     // to the list in vmSymbols.hpp without implementing it here.
@@ -6698,6 +6703,35 @@
   return instof_false;  // even if it is NULL
 }
 
+//-------------inline_fma-----------------------------------
+bool LibraryCallKit::inline_fma(vmIntrinsics::ID id) {
+  Node *a = NULL;
+  Node *b = NULL;
+  Node *c = NULL;
+  Node* result = NULL;
+  switch (id) {
+  case vmIntrinsics::_fmaD:
+    assert(callee()->signature()->size() == 6, "fma has 3 parameters of size 2 each.");
+    // no receiver since it is static method
+    a = round_double_node(argument(0));
+    b = round_double_node(argument(2));
+    c = round_double_node(argument(4));
+    result = _gvn.transform(new FmaDNode(control(), a, b, c));
+    break;
+  case vmIntrinsics::_fmaF:
+    assert(callee()->signature()->size() == 3, "fma has 3 parameters of size 1 each.");
+    a = argument(0);
+    b = argument(1);
+    c = argument(2);
+    result = _gvn.transform(new FmaFNode(control(), a, b, c));
+    break;
+  default:
+    fatal_unexpected_iid(id);  break;
+  }
+  set_result(result);
+  return true;
+}
+
 bool LibraryCallKit::inline_profileBoolean() {
   Node* counts = argument(1);
   const TypeAryPtr* ary = NULL;
--- a/hotspot/src/share/vm/opto/matcher.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/opto/matcher.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -2117,6 +2117,8 @@
       case Op_StrInflatedCopy:
       case Op_StrCompressedCopy:
       case Op_EncodeISOArray:
+      case Op_FmaD:
+      case Op_FmaF:
         set_shared(n); // Force result into register (it will be anyways)
         break;
       case Op_ConP: {  // Convert pointers above the centerline to NUL
@@ -2305,6 +2307,15 @@
         n->del_req(4);
         break;
       }
+      case Op_FmaD:
+      case Op_FmaF: {
+        // Restructure into a binary tree for Matching.
+        Node* pair = new BinaryNode(n->in(1), n->in(2));
+        n->set_req(2, pair);
+        n->set_req(1, n->in(3));
+        n->del_req(3);
+        break;
+      }
       default:
         break;
       }
--- a/hotspot/src/share/vm/opto/mulnode.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/opto/mulnode.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1343,3 +1343,47 @@
 
   return TypeLong::LONG;                // Give up
 }
+
+//=============================================================================
+//------------------------------Value------------------------------------------
+const Type* FmaDNode::Value(PhaseGVN* phase) const {
+  const Type *t1 = phase->type(in(1));
+  if (t1 == Type::TOP) return Type::TOP;
+  if (t1->base() != Type::DoubleCon) return Type::DOUBLE;
+  const Type *t2 = phase->type(in(2));
+  if (t2 == Type::TOP) return Type::TOP;
+  if (t2->base() != Type::DoubleCon) return Type::DOUBLE;
+  const Type *t3 = phase->type(in(3));
+  if (t3 == Type::TOP) return Type::TOP;
+  if (t3->base() != Type::DoubleCon) return Type::DOUBLE;
+#ifndef __STDC_IEC_559__
+  return Type::DOUBLE;
+#else
+  double d1 = t1->getd();
+  double d2 = t2->getd();
+  double d3 = t3->getd();
+  return TypeD::make(fma(d1, d2, d3));
+#endif
+}
+
+//=============================================================================
+//------------------------------Value------------------------------------------
+const Type* FmaFNode::Value(PhaseGVN* phase) const {
+  const Type *t1 = phase->type(in(1));
+  if (t1 == Type::TOP) return Type::TOP;
+  if (t1->base() != Type::FloatCon) return Type::FLOAT;
+  const Type *t2 = phase->type(in(2));
+  if (t2 == Type::TOP) return Type::TOP;
+  if (t2->base() != Type::FloatCon) return Type::FLOAT;
+  const Type *t3 = phase->type(in(3));
+  if (t3 == Type::TOP) return Type::TOP;
+  if (t3->base() != Type::FloatCon) return Type::FLOAT;
+#ifndef __STDC_IEC_559__
+  return Type::FLOAT;
+#else
+  float f1 = t1->getf();
+  float f2 = t2->getf();
+  float f3 = t3->getf();
+  return TypeF::make(fma(f1, f2, f3));
+#endif
+}
--- a/hotspot/src/share/vm/opto/mulnode.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/opto/mulnode.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -263,4 +263,26 @@
   virtual uint ideal_reg() const { return Op_RegL; }
 };
 
+//------------------------------FmaDNode--------------------------------------
+// fused-multiply-add double
+class FmaDNode : public Node {
+public:
+  FmaDNode(Node *c, Node *in1, Node *in2, Node *in3) : Node(c, in1, in2, in3) {}
+  virtual int Opcode() const;
+  const Type *bottom_type() const { return Type::DOUBLE; }
+  virtual uint ideal_reg() const { return Op_RegD; }
+  virtual const Type* Value(PhaseGVN* phase) const;
+};
+
+//------------------------------FmaFNode--------------------------------------
+// fused-multiply-add float
+class FmaFNode : public Node {
+public:
+  FmaFNode(Node *c, Node *in1, Node *in2, Node *in3) : Node(c, in1, in2, in3) {}
+  virtual int Opcode() const;
+  const Type *bottom_type() const { return Type::FLOAT; }
+  virtual uint ideal_reg() const { return Op_RegF; }
+  virtual const Type* Value(PhaseGVN* phase) const;
+};
+
 #endif // SHARE_VM_OPTO_MULNODE_HPP
--- a/hotspot/src/share/vm/prims/jvm.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -562,8 +562,8 @@
   }
 
   Handle stackStream_h(THREAD, JNIHandles::resolve_non_null(stackStream));
-  return StackWalk::moreFrames(stackStream_h, mode, anchor, frame_count,
-                               start_index, frames_array_h, THREAD);
+  return StackWalk::fetchNextBatch(stackStream_h, mode, anchor, frame_count,
+                                   start_index, frames_array_h, THREAD);
 JVM_END
 
 JVM_ENTRY(void, JVM_ToStackTraceElement(JNIEnv *env, jobject frame, jobject stack))
--- a/hotspot/src/share/vm/prims/jvmti.xml	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/prims/jvmti.xml	Fri Sep 30 02:52:38 2016 -0700
@@ -21,7 +21,6 @@
  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.
-
 -->
 
 <!DOCTYPE specification [
--- a/hotspot/src/share/vm/prims/jvmtiEnter.xsl	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/prims/jvmtiEnter.xsl	Fri Sep 30 02:52:38 2016 -0700
@@ -487,8 +487,8 @@
 </xsl:text>
     <xsl:if test="$trace='Trace'">
       <xsl:text>    if (trace_flags) {
-          log_trace(jvmti)("[-] %s %s",  func_name, 
-                    JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE));
+          log_trace(jvmti)("[-] %s %s(%d)", func_name,
+                    JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE), JvmtiEnv::get_phase());
     }
 </xsl:text>
     </xsl:if>
--- a/hotspot/src/share/vm/prims/jvmtiH.xsl	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/prims/jvmtiH.xsl	Fri Sep 30 02:52:38 2016 -0700
@@ -95,7 +95,7 @@
   </xsl:template>
 
   <xsl:template name="intro">
-  <xsl:call-template name="includeHeader"/>
+  <xsl:call-template name="include_GPL_CP_Header"/>
   <xsl:text>
     /* Include file for the Java(tm) Virtual Machine Tool Interface */
 
--- a/hotspot/src/share/vm/prims/jvmtiLib.xsl	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/prims/jvmtiLib.xsl	Fri Sep 30 02:52:38 2016 -0700
@@ -43,13 +43,56 @@
     <xsl:call-template name="microversion"/>
   </xsl:template>
 
+  <xsl:variable name="GPL_header">
+    <!-- The Copyright comment from jvmti.xml -->
+    <xsl:value-of select="/comment()[position()=1]"/>
+  </xsl:variable>
+
+  <xsl:variable name="GPL_CP_header_body">
+    <xsl:text> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.&#xA;</xsl:text>
+    <xsl:text> *&#xA;</xsl:text>
+    <xsl:text> * This code is free software; you can redistribute it and/or modify it&#xA;</xsl:text>
+    <xsl:text> * under the terms of the GNU General Public License version 2 only, as&#xA;</xsl:text>
+    <xsl:text> * published by the Free Software Foundation.  Oracle designates this&#xA;</xsl:text>
+    <xsl:text> * particular file as subject to the "Classpath" exception as provided&#xA;</xsl:text>
+    <xsl:text> * by Oracle in the LICENSE file that accompanied this code.&#xA;</xsl:text>
+    <xsl:text> *&#xA;</xsl:text>
+    <xsl:text> * This code is distributed in the hope that it will be useful, but WITHOUT&#xA;</xsl:text>
+    <xsl:text> * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or&#xA;</xsl:text>
+    <xsl:text> * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License&#xA;</xsl:text>
+    <xsl:text> * version 2 for more details (a copy is included in the LICENSE file that&#xA;</xsl:text>
+    <xsl:text> * accompanied this code).&#xA;</xsl:text>
+    <xsl:text> *&#xA;</xsl:text>
+    <xsl:text> * You should have received a copy of the GNU General Public License version&#xA;</xsl:text>
+    <xsl:text> * 2 along with this work; if not, write to the Free Software Foundation,&#xA;</xsl:text>
+    <xsl:text> * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.&#xA;</xsl:text>
+    <xsl:text> *&#xA;</xsl:text>
+    <xsl:text> * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA&#xA;</xsl:text>
+    <xsl:text> * or visit www.oracle.com if you need additional information or have any&#xA;</xsl:text>
+    <xsl:text> * questions.&#xA;</xsl:text>
+  </xsl:variable>
+
   <xsl:template name="copyrightComment">
     <xsl:text>/*</xsl:text>
-    <!-- Copy the Copyright comment from jvmti.xml -->
-    <xsl:value-of select="/comment()[position()=1]"/>
+    <!-- The Copyright comment from jvmti.xml -->
+    <xsl:value-of select="$GPL_header"/>
     <xsl:text> */&#xA;&#xA;</xsl:text>
   </xsl:template>
 
+  <xsl:template name="GPL_CP_copyrightComment">
+    <xsl:text>/*&#xA; *</xsl:text>
+    <!-- The Copyright year from jvmti.xml -->
+    <xsl:value-of select="substring-after(substring-before($GPL_header, ' DO NOT ALTER'), '&#xA;')"/>
+    <!-- The GPL+CP Copyright header body -->
+    <xsl:value-of select="$GPL_CP_header_body"/>
+    <xsl:text> */&#xA;&#xA;</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="include_GPL_CP_Header">
+    <xsl:call-template name="GPL_CP_copyrightComment"/>
+    <xsl:text> /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */&#xA;</xsl:text>    
+  </xsl:template>
+
   <xsl:template name="includeHeader">
     <xsl:call-template name="copyrightComment"/>
     <xsl:text> /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */&#xA;</xsl:text>    
--- a/hotspot/src/share/vm/prims/stackwalk.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/prims/stackwalk.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -37,42 +37,47 @@
 #include "utilities/globalDefinitions.hpp"
 
 // setup and cleanup actions
-void JavaFrameStream::setup_magic_on_entry(objArrayHandle frames_array) {
+void BaseFrameStream::setup_magic_on_entry(objArrayHandle frames_array) {
   frames_array->obj_at_put(magic_pos, _thread->threadObj());
   _anchor = address_value();
   assert(check_magic(frames_array), "invalid magic");
 }
 
-bool JavaFrameStream::check_magic(objArrayHandle frames_array) {
+bool BaseFrameStream::check_magic(objArrayHandle frames_array) {
   oop   m1 = frames_array->obj_at(magic_pos);
   jlong m2 = _anchor;
   if (m1 == _thread->threadObj() && m2 == address_value())  return true;
   return false;
 }
 
-bool JavaFrameStream::cleanup_magic_on_exit(objArrayHandle frames_array) {
+bool BaseFrameStream::cleanup_magic_on_exit(objArrayHandle frames_array) {
   bool ok = check_magic(frames_array);
   frames_array->obj_at_put(magic_pos, NULL);
   _anchor = 0L;
   return ok;
 }
 
-// Returns JavaFrameStream for the current stack being traversed.
+JavaFrameStream::JavaFrameStream(JavaThread* thread, int mode)
+  : BaseFrameStream(thread), _vfst(thread) {
+  _need_method_info = StackWalk::need_method_info(mode);
+}
+
+// Returns the BaseFrameStream for the current stack being traversed.
 //
 // Parameters:
 //  thread         Current Java thread.
 //  magic          Magic value used for each stack walking
 //  frames_array   User-supplied buffers.  The 0th element is reserved
-//                 to this JavaFrameStream to use
+//                 for this BaseFrameStream to use
 //
-JavaFrameStream* JavaFrameStream::from_current(JavaThread* thread, jlong magic,
+BaseFrameStream* BaseFrameStream::from_current(JavaThread* thread, jlong magic,
                                                objArrayHandle frames_array)
 {
   assert(thread != NULL && thread->is_Java_thread(), "");
   oop m1 = frames_array->obj_at(magic_pos);
   if (m1 != thread->threadObj())      return NULL;
   if (magic == 0L)                    return NULL;
-  JavaFrameStream* stream = (JavaFrameStream*) (intptr_t) magic;
+  BaseFrameStream* stream = (BaseFrameStream*) (intptr_t) magic;
   if (!stream->is_valid_in(thread, frames_array))   return NULL;
   return stream;
 }
@@ -85,7 +90,7 @@
 //
 // Parameters:
 //   mode             Restrict which frames to be decoded.
-//   JavaFrameStream  stream of javaVFrames
+//   BaseFrameStream  stream of frames
 //   max_nframes      Maximum number of frames to be filled.
 //   start_index      Start index to the user-supplied buffers.
 //   frames_array     Buffer to store Class or StackFrame in, starting at start_index.
@@ -96,7 +101,7 @@
 //
 // Returns the number of frames whose information was transferred into the buffers.
 //
-int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream,
+int StackWalk::fill_in_frames(jlong mode, BaseFrameStream& stream,
                               int max_nframes, int start_index,
                               objArrayHandle  frames_array,
                               int& end_index, TRAPS) {
@@ -110,7 +115,6 @@
   int frames_decoded = 0;
   for (; !stream.at_end(); stream.next()) {
     Method* method = stream.method();
-    int bci = stream.bci();
 
     if (method == NULL) continue;
 
@@ -129,35 +133,42 @@
     int index = end_index++;
     if (TraceStackWalk) {
       tty->print("  %d: frame method: ", index); method->print_short_name();
-      tty->print_cr(" bci=%d", bci);
+      tty->print_cr(" bci=%d", stream.bci());
     }
 
+    if (!need_method_info(mode) && get_caller_class(mode) &&
+          index == start_index && method->caller_sensitive()) {
+      ResourceMark rm(THREAD);
+      THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(),
+        err_msg("StackWalker::getCallerClass called from @CallerSensitive %s method",
+                method->name_and_sig_as_C_string()));
+    }
     // fill in StackFrameInfo and initialize MemberName
-    if (live_frame_info(mode)) {
-      assert (use_frames_array(mode), "Bad mode for get live frame");
-      Handle stackFrame(frames_array->obj_at(index));
-      fill_live_stackframe(stackFrame, method, bci, stream.java_frame(), CHECK_0);
-    } else if (need_method_info(mode)) {
-      assert (use_frames_array(mode), "Bad mode for get stack frame");
-      Handle stackFrame(frames_array->obj_at(index));
-      fill_stackframe(stackFrame, method, bci);
-    } else {
-      assert (use_frames_array(mode) == false, "Bad mode for filling in Class object");
-      if (get_caller_class(mode) && index == start_index && method->caller_sensitive()) {
-        ResourceMark rm(THREAD);
-        THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(),
-          err_msg("StackWalker::getCallerClass called from @CallerSensitive %s method",
-                  method->name_and_sig_as_C_string()));
-      }
-
-      frames_array->obj_at_put(index, method->method_holder()->java_mirror());
-    }
+    stream.fill_frame(index, frames_array, method, CHECK_0);
     if (++frames_decoded >= max_nframes)  break;
   }
   return frames_decoded;
 }
 
-static oop create_primitive_value_instance(StackValueCollection* values, int i, TRAPS) {
+// Fill in the LiveStackFrameInfo at the given index in frames_array
+void LiveFrameStream::fill_frame(int index, objArrayHandle  frames_array,
+                                 const methodHandle& method, TRAPS) {
+  Handle stackFrame(THREAD, frames_array->obj_at(index));
+  fill_live_stackframe(stackFrame, method, CHECK);
+}
+
+// Fill in the StackFrameInfo at the given index in frames_array
+void JavaFrameStream::fill_frame(int index, objArrayHandle  frames_array,
+                                 const methodHandle& method, TRAPS) {
+  if (_need_method_info) {
+    Handle stackFrame(THREAD, frames_array->obj_at(index));
+    fill_stackframe(stackFrame, method);
+  } else {
+    frames_array->obj_at_put(index, method->method_holder()->java_mirror());
+  }
+}
+
+oop LiveFrameStream::create_primitive_value_instance(StackValueCollection* values, int i, TRAPS) {
   Klass* k = SystemDictionary::resolve_or_null(vmSymbols::java_lang_LiveStackFrameInfo(), CHECK_NULL);
   instanceKlassHandle ik (THREAD, k);
 
@@ -228,7 +239,7 @@
   return (instanceOop) result.get_jobject();
 }
 
-static objArrayHandle values_to_object_array(StackValueCollection* values, TRAPS) {
+objArrayHandle LiveFrameStream::values_to_object_array(StackValueCollection* values, TRAPS) {
   objArrayHandle empty;
   int length = values->size();
   objArrayOop array_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(),
@@ -243,7 +254,7 @@
   return array_h;
 }
 
-static objArrayHandle monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors, TRAPS) {
+objArrayHandle LiveFrameStream::monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors, TRAPS) {
   int length = monitors->length();
   objArrayOop array_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(),
                                                    length, CHECK_(objArrayHandle()));
@@ -256,19 +267,19 @@
 }
 
 // Fill StackFrameInfo with declaringClass and bci and initialize memberName
-void StackWalk::fill_stackframe(Handle stackFrame, const methodHandle& method, int bci) {
+void BaseFrameStream::fill_stackframe(Handle stackFrame, const methodHandle& method) {
   java_lang_StackFrameInfo::set_declaringClass(stackFrame(), method->method_holder()->java_mirror());
-  java_lang_StackFrameInfo::set_method_and_bci(stackFrame(), method, bci);
+  java_lang_StackFrameInfo::set_method_and_bci(stackFrame(), method, bci());
 }
 
 // Fill LiveStackFrameInfo with locals, monitors, and expressions
-void StackWalk::fill_live_stackframe(Handle stackFrame, const methodHandle& method,
-                                     int bci, javaVFrame* jvf, TRAPS) {
-  fill_stackframe(stackFrame, method, bci);
-  if (jvf != NULL) {
-    StackValueCollection* locals = jvf->locals();
-    StackValueCollection* expressions = jvf->expressions();
-    GrowableArray<MonitorInfo*>* monitors = jvf->monitors();
+void LiveFrameStream::fill_live_stackframe(Handle stackFrame,
+                                           const methodHandle& method, TRAPS) {
+  fill_stackframe(stackFrame, method);
+  if (_jvf != NULL) {
+    StackValueCollection* locals = _jvf->locals();
+    StackValueCollection* expressions = _jvf->expressions();
+    GrowableArray<MonitorInfo*>* monitors = _jvf->monitors();
 
     if (!locals->is_empty()) {
       objArrayHandle locals_h = values_to_object_array(locals, CHECK);
@@ -315,15 +326,28 @@
     THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", NULL);
   }
 
-  Klass* stackWalker_klass = SystemDictionary::StackWalker_klass();
-  Klass* abstractStackWalker_klass = SystemDictionary::AbstractStackWalker_klass();
+  // Setup traversal onto my stack.
+  if (live_frame_info(mode)) {
+    assert (use_frames_array(mode), "Bad mode for get live frame");
+    RegisterMap regMap(jt, true);
+    LiveFrameStream stream(jt, &regMap);
+    return fetchFirstBatch(stream, stackStream, mode, skip_frames, frame_count,
+                           start_index, frames_array, THREAD);
+  } else {
+    JavaFrameStream stream(jt, mode);
+    return fetchFirstBatch(stream, stackStream, mode, skip_frames, frame_count,
+                           start_index, frames_array, THREAD);
+  }
+}
 
+oop StackWalk::fetchFirstBatch(BaseFrameStream& stream, Handle stackStream,
+                               jlong mode, int skip_frames, int frame_count,
+                               int start_index, objArrayHandle frames_array, TRAPS) {
   methodHandle m_doStackWalk(THREAD, Universe::do_stack_walk_method());
 
-  // Setup traversal onto my stack.
-  RegisterMap regMap(jt, true);
-  JavaFrameStream stream(jt, &regMap);
   {
+    Klass* stackWalker_klass = SystemDictionary::StackWalker_klass();
+    Klass* abstractStackWalker_klass = SystemDictionary::AbstractStackWalker_klass();
     while (!stream.at_end()) {
       InstanceKlass* ik = stream.method()->method_holder();
       if (ik != stackWalker_klass &&
@@ -341,10 +365,7 @@
     // from the stack frame at depth == skip_frames.
     for (int n=0; n < skip_frames && !stream.at_end(); stream.next(), n++) {
       if (TraceStackWalk) {
-        tty->print("  skip "); stream.method()->print_short_name();
-        tty->print_cr(" frame id: " PTR_FORMAT " pc: " PTR_FORMAT,
-                      p2i(stream.java_frame()->fr().id()),
-                      p2i(stream.java_frame()->fr().pc()));
+        tty->print("  skip "); stream.method()->print_short_name(); tty->cr();
       }
     }
   }
@@ -402,13 +423,13 @@
 //
 // Returns the end index of frame filled in the buffer.
 //
-jint StackWalk::moreFrames(Handle stackStream, jlong mode, jlong magic,
-                           int frame_count, int start_index,
-                           objArrayHandle frames_array,
-                           TRAPS)
+jint StackWalk::fetchNextBatch(Handle stackStream, jlong mode, jlong magic,
+                               int frame_count, int start_index,
+                               objArrayHandle frames_array,
+                               TRAPS)
 {
   JavaThread* jt = (JavaThread*)THREAD;
-  JavaFrameStream* existing_stream = JavaFrameStream::from_current(jt, magic, frames_array);
+  BaseFrameStream* existing_stream = BaseFrameStream::from_current(jt, magic, frames_array);
   if (existing_stream == NULL) {
     THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers", 0L);
   }
@@ -418,7 +439,7 @@
   }
 
   if (TraceStackWalk) {
-    tty->print_cr("StackWalk::moreFrames frame_count %d existing_stream " PTR_FORMAT " start %d frames %d",
+    tty->print_cr("StackWalk::fetchNextBatch frame_count %d existing_stream " PTR_FORMAT " start %d frames %d",
                   frame_count, p2i(existing_stream), start_index, frames_array->length());
   }
   int end_index = start_index;
@@ -429,7 +450,7 @@
   int count = frame_count + start_index;
   assert (frames_array->length() >= count, "not enough space in buffers");
 
-  JavaFrameStream& stream = (*existing_stream);
+  BaseFrameStream& stream = (*existing_stream);
   if (!stream.at_end()) {
     stream.next(); // advance past the last frame decoded in previous batch
     if (!stream.at_end()) {
--- a/hotspot/src/share/vm/prims/stackwalk.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/prims/stackwalk.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -29,31 +29,34 @@
 #include "oops/oop.hpp"
 #include "runtime/vframe.hpp"
 
-//
-// JavaFrameStream is used by StackWalker to iterate through Java stack frames
-// on the given JavaThread.
-//
-class JavaFrameStream : public StackObj {
+// BaseFrameStream is an abstract base class for encapsulating the VM-side
+// implementation of the StackWalker API.  There are two concrete subclasses:
+// - JavaFrameStream:
+//     -based on vframeStream; used in most instances
+// - LiveFrameStream:
+//     -based on javaVFrame; used for retrieving locals/monitors/operands for
+//      LiveStackFrame
+class BaseFrameStream : public StackObj {
 private:
   enum {
     magic_pos = 0
   };
 
   JavaThread*           _thread;
-  javaVFrame*           _jvf;
   jlong                 _anchor;
+protected:
+  void fill_stackframe(Handle stackFrame, const methodHandle& method);
 public:
-  JavaFrameStream(JavaThread* thread, RegisterMap* rm)
-    : _thread(thread), _anchor(0L) {
-    _jvf = _thread->last_java_vframe(rm);
-  }
+  BaseFrameStream(JavaThread* thread) : _thread(thread), _anchor(0L) {}
+
+  virtual void    next()=0;
+  virtual bool    at_end()=0;
 
-  javaVFrame*     java_frame()        { return _jvf; }
-  void            next()              { _jvf = _jvf->java_sender(); }
-  bool            at_end()            { return _jvf == NULL; }
+  virtual Method* method()=0;
+  virtual int     bci()=0;
 
-  Method* method()                    { return _jvf->method(); }
-  int bci()                           { return _jvf->bci(); }
+  virtual void    fill_frame(int index, objArrayHandle  frames_array,
+                             const methodHandle& method, TRAPS)=0;
 
   void setup_magic_on_entry(objArrayHandle frames_array);
   bool check_magic(objArrayHandle frames_array);
@@ -67,35 +70,72 @@
     return (jlong) castable_address(this);
   }
 
-  static JavaFrameStream* from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array);
+  static BaseFrameStream* from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array);
+};
+
+class JavaFrameStream : public BaseFrameStream {
+private:
+  vframeStream          _vfst;
+  bool                  _need_method_info;
+public:
+  JavaFrameStream(JavaThread* thread, int mode);
+
+  void next()      { _vfst.next();}
+  bool at_end()    { return _vfst.at_end(); }
+
+  Method* method() { return _vfst.method(); }
+  int bci()        { return _vfst.bci(); }
+
+  void fill_frame(int index, objArrayHandle  frames_array,
+                  const methodHandle& method, TRAPS);
+};
+
+class LiveFrameStream : public BaseFrameStream {
+private:
+  javaVFrame*           _jvf;
+
+  void fill_live_stackframe(Handle stackFrame, const methodHandle& method, TRAPS);
+  static oop create_primitive_value_instance(StackValueCollection* values,
+                                             int i, TRAPS);
+  static objArrayHandle monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors,
+                                                 TRAPS);
+  static objArrayHandle values_to_object_array(StackValueCollection* values, TRAPS);
+public:
+  LiveFrameStream(JavaThread* thread, RegisterMap* rm) : BaseFrameStream(thread) {
+    _jvf = thread->last_java_vframe(rm);
+  }
+
+  void next()      { _jvf = _jvf->java_sender(); }
+  bool at_end()    { return _jvf == NULL; }
+
+  Method* method() { return _jvf->method(); }
+  int bci()        { return _jvf->bci(); }
+
+  void fill_frame(int index, objArrayHandle  frames_array,
+                  const methodHandle& method, TRAPS);
 };
 
 class StackWalk : public AllStatic {
 private:
-  static int fill_in_frames(jlong mode, JavaFrameStream& stream,
+  static int fill_in_frames(jlong mode, BaseFrameStream& stream,
                             int max_nframes, int start_index,
                             objArrayHandle frames_array,
                             int& end_index, TRAPS);
 
-  static void fill_stackframe(Handle stackFrame, const methodHandle& method, int bci);
-
-  static void fill_live_stackframe(Handle stackFrame, const methodHandle& method, int bci,
-                                   javaVFrame* jvf, TRAPS);
-
   static inline bool get_caller_class(int mode) {
     return (mode & JVM_STACKWALK_GET_CALLER_CLASS) != 0;
   }
   static inline bool skip_hidden_frames(int mode) {
     return (mode & JVM_STACKWALK_SHOW_HIDDEN_FRAMES) == 0;
   }
-  static inline bool need_method_info(int mode) {
-    return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
-  }
   static inline bool live_frame_info(int mode) {
     return (mode & JVM_STACKWALK_FILL_LIVE_STACK_FRAMES) != 0;
   }
 
 public:
+  static inline bool need_method_info(int mode) {
+    return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
+  }
   static inline bool use_frames_array(int mode) {
     return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
   }
@@ -104,9 +144,12 @@
                   objArrayHandle frames_array,
                   TRAPS);
 
-  static jint moreFrames(Handle stackStream, jlong mode, jlong magic,
-                         int frame_count, int start_index,
-                         objArrayHandle frames_array,
-                         TRAPS);
+  static oop fetchFirstBatch(BaseFrameStream& stream, Handle stackStream,
+                             jlong mode, int skip_frames, int frame_count,
+                             int start_index, objArrayHandle frames_array, TRAPS);
+
+  static jint fetchNextBatch(Handle stackStream, jlong mode, jlong magic,
+                             int frame_count, int start_index,
+                             objArrayHandle frames_array, TRAPS);
 };
 #endif // SHARE_VM_PRIMS_STACKWALK_HPP
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -3897,10 +3897,6 @@
 
 void Arguments::set_shared_spaces_flags() {
   if (DumpSharedSpaces) {
-    if (Arguments::get_patch_mod_prefix() != NULL) {
-      vm_exit_during_initialization(
-        "Cannot use the following option when dumping the shared archive: --patch-module");
-    }
 
     if (RequireSharedSpaces) {
       warning("Cannot dump shared archive while using shared archive");
--- a/hotspot/src/share/vm/runtime/globals.hpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Fri Sep 30 02:52:38 2016 -0700
@@ -659,6 +659,9 @@
   product(bool, UseAES, false,                                              \
           "Control whether AES instructions can be used on x86/x64")        \
                                                                             \
+  product(bool, UseFMA, false,                                              \
+          "Control whether FMA instructions can be used")                   \
+                                                                            \
   product(bool, UseSHA, false,                                              \
           "Control whether SHA instructions can be used "                   \
           "on SPARC, on ARM and on x86")                                    \
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -2103,6 +2103,8 @@
   declare_c2_type(OverflowAddLNode, OverflowLNode)                        \
   declare_c2_type(OverflowSubLNode, OverflowLNode)                        \
   declare_c2_type(OverflowMulLNode, OverflowLNode)                        \
+  declare_c2_type(FmaDNode, Node)                                         \
+  declare_c2_type(FmaFNode, Node)                                         \
                                                                           \
   /*********************/                                                 \
   /* Adapter Blob Entries */                                              \
@@ -2970,6 +2972,7 @@
 
 #if INCLUDE_ALL_GCS
   VM_STRUCTS_PARALLELGC(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
+                        GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
                         GENERATE_STATIC_VM_STRUCT_ENTRY)
 
   VM_STRUCTS_CMS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
@@ -2982,7 +2985,7 @@
 
 #if INCLUDE_TRACE
   VM_STRUCTS_TRACE(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
-                GENERATE_STATIC_VM_STRUCT_ENTRY)
+                   GENERATE_STATIC_VM_STRUCT_ENTRY)
 #endif
 
   VM_STRUCTS_EXT(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
@@ -3168,11 +3171,12 @@
 
 #if INCLUDE_ALL_GCS
   VM_STRUCTS_PARALLELGC(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
-             CHECK_STATIC_VM_STRUCT_ENTRY);
+                        CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
+                        CHECK_STATIC_VM_STRUCT_ENTRY);
 
   VM_STRUCTS_CMS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
-             CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
-             CHECK_STATIC_VM_STRUCT_ENTRY);
+                 CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
+                 CHECK_STATIC_VM_STRUCT_ENTRY);
 
   VM_STRUCTS_G1(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
                 CHECK_STATIC_VM_STRUCT_ENTRY);
@@ -3181,7 +3185,7 @@
 
 #if INCLUDE_TRACE
   VM_STRUCTS_TRACE(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
-                CHECK_STATIC_VM_STRUCT_ENTRY);
+                   CHECK_STATIC_VM_STRUCT_ENTRY);
 #endif
 
   VM_STRUCTS_EXT(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
@@ -3293,6 +3297,7 @@
                         CHECK_NO_OP));
 #if INCLUDE_ALL_GCS
   debug_only(VM_STRUCTS_PARALLELGC(ENSURE_FIELD_TYPE_PRESENT,
+                                   ENSURE_FIELD_TYPE_PRESENT,
                                    ENSURE_FIELD_TYPE_PRESENT));
   debug_only(VM_STRUCTS_CMS(ENSURE_FIELD_TYPE_PRESENT,
                             ENSURE_FIELD_TYPE_PRESENT,
--- a/hotspot/src/share/vm/utilities/chunkedList.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "utilities/chunkedList.hpp"
-#include "utilities/debug.hpp"
-
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-template <typename T>
-class TestChunkedList {
-  typedef ChunkedList<T, mtOther> ChunkedListT;
-
- public:
-  static void testEmpty() {
-    ChunkedListT buffer;
-    assert(buffer.size() == 0, "assert");
-  }
-
-  static void testFull() {
-    ChunkedListT buffer;
-    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
-      buffer.push((T)i);
-    }
-    assert(buffer.size() == ChunkedListT::BufferSize, "assert");
-    assert(buffer.is_full(), "assert");
-  }
-
-  static void testSize() {
-    ChunkedListT buffer;
-    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
-      assert(buffer.size() == i, "assert");
-      buffer.push((T)i);
-      assert(buffer.size() == i + 1, "assert");
-    }
-  }
-
-  static void testClear() {
-    ChunkedListT buffer;
-
-    buffer.clear();
-    assert(buffer.size() == 0, "assert");
-
-    for (uintptr_t i = 0; i < ChunkedListT::BufferSize / 2; i++) {
-      buffer.push((T)i);
-    }
-    buffer.clear();
-    assert(buffer.size() == 0, "assert");
-
-    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
-      buffer.push((T)i);
-    }
-    buffer.clear();
-    assert(buffer.size() == 0, "assert");
-  }
-
-  static void testAt() {
-    ChunkedListT buffer;
-
-    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
-      buffer.push((T)i);
-      assert(buffer.at(i) == (T)i, "assert");
-    }
-
-    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
-      assert(buffer.at(i) == (T)i, "assert");
-    }
-  }
-
-  static void test() {
-    testEmpty();
-    testFull();
-    testSize();
-    testClear();
-    testAt();
-  }
-};
-
-class Metadata;
-
-void TestChunkedList_test() {
-  TestChunkedList<Metadata*>::test();
-  TestChunkedList<size_t>::test();
-}
-
-#endif
--- a/hotspot/src/share/vm/utilities/internalVMTests.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -52,19 +52,14 @@
   run_unit_test(TestVirtualSpaceNode_test);
   run_unit_test(TestGlobalDefinitions_test);
   run_unit_test(GCTimer_test);
-  run_unit_test(arrayOopDesc_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(TestKlass_test);
   run_unit_test(TestBitMap_test);
   run_unit_test(TestResourcehash_test);
   run_unit_test(ObjectMonitor_test);
-  run_unit_test(Test_linked_list);
-  run_unit_test(TestChunkedList_test);
-  run_unit_test(JSON_test);
   run_unit_test(Test_log_tag_combinations_limit);
   run_unit_test(Test_logtarget);
   run_unit_test(Test_logstream);
@@ -82,7 +77,6 @@
   run_unit_test(Test_invalid_log_file);
   run_unit_test(Test_multiline_logging);
   run_unit_test(DirectivesParser_test);
-  run_unit_test(Test_TempNewSymbol);
 #if INCLUDE_VM_STRUCTS
   run_unit_test(VMStructs_test);
 #endif
@@ -91,7 +85,6 @@
   run_unit_test(TestBufferingOopClosure_test);
   if (UseG1GC) {
     run_unit_test(FreeRegionList_test);
-    run_unit_test(IHOP_test);
   }
   run_unit_test(WorkerDataArray_test);
   run_unit_test(ParallelCompact_test);
--- a/hotspot/src/share/vm/utilities/json.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/src/share/vm/utilities/json.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -686,286 +686,3 @@
   }
 }
 
-#ifndef PRODUCT
-class JSONTest : public JSON {
- public:
-  static void test();
-
- private:
-  JSONTest(const char* text);
-  static void test(const char* json, bool valid);
-
-  void log(uint level, const char* format, ...) ATTRIBUTE_PRINTF(3, 4);
-
-  bool callback(JSON_TYPE t, JSON_VAL* v, uint level);
-  JSON_TYPE prev;
-};
-
-void JSON_test() {
-  JSONTest::test();
-}
-
-void JSONTest::test(const char* text, bool should_pass) {
-  JSONTest json(text);
-  if (should_pass) {
-    assert(json.valid() == true, "failed on a valid json string");
-    if (VerboseInternalVMTests) {
-      tty->print_cr("-- json test passed as expected --");
-    }
-  } else {
-    assert(json.valid() == false, "succeeded on an invalid json string");
-    if (VerboseInternalVMTests) {
-      tty->print_cr("-- json test failed as expected --");
-    }
-  }
-}
-
-JSONTest::JSONTest(const char* text) : JSON(text, !VerboseInternalVMTests, tty) {
-  prev = JSON_NONE;
-  parse();
-}
-
-void JSONTest::test() {
-  JSONTest::test("{}", true);
-  JSONTest::test("[]", true);
-  JSONTest::test("  {  }  ", true);
-  JSONTest::test("  [  ]  ", true);
-
-  JSONTest::test("\"error\"", false);
-  JSONTest::test("error", false);
-  JSONTest::test("1", false);
-  JSONTest::test("1.2", false);
-  JSONTest::test("true", false);
-  JSONTest::test("false", false);
-  JSONTest::test("null", false);
-
-  JSONTest::test("[ 1 ]", true);
-  JSONTest::test("[ 1, ]", true);
-  JSONTest::test("[ true ]", true);
-  JSONTest::test("[ true, ]", true);
-  JSONTest::test("[ false ]", true);
-  JSONTest::test("[ false, ]", true);
-  JSONTest::test("[ null ]", true);
-  JSONTest::test("[ null, ]", true);
-  JSONTest::test("[ \"\" ]", true);
-  JSONTest::test("[ \"\", ]", true);
-  JSONTest::test("[ \"elem1\" ]", true);
-  JSONTest::test("[ \"elem1\", ]", true);
-  JSONTest::test("[ \"elem1\", ]", true);
-  JSONTest::test("[ \"elem1\" ]", true);
-  JSONTest::test("[ \"elem1\", \"elem2\" ]", true);
-  JSONTest::test("[ \"elem1\", \"elem2\", ]", true);
-
-
-  JSONTest::test("[ \"elem1\" ] { }", false);
-  JSONTest::test("[ elem1, \"elem2\" ]", false);
-  JSONTest::test("[ \"elem1\"", false);
-  JSONTest::test("[ \"elem1 ]", false);
-  JSONTest::test("[ \"elem1\", \"elem2\"", false);
-  JSONTest::test("[ truefoo ]", false);
-  JSONTest::test("[ falsefoo ]", false);
-  JSONTest::test("[ nullfoo ]", false);
-
-  JSONTest::test("{ key : 1 }", true);
-  JSONTest::test("{ key : 1, }", true);
-  JSONTest::test("{ key : true }", true);
-  JSONTest::test("{ key : true, }", true);
-  JSONTest::test("{ key : false }", true);
-  JSONTest::test("{ key : false, }", true);
-  JSONTest::test("{ key : null }", true);
-  JSONTest::test("{ key : null, }", true);
-  JSONTest::test("{ \"\" : \"\" }", true);
-  JSONTest::test("{ \"\" : \"\", }", true);
-  JSONTest::test("{ \"key1\" : \"val1\" }", true);
-  JSONTest::test("{ \"key1\" : \"val1\", }", true);
-  JSONTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\" }", true);
-  JSONTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\", }", true);
-
-  JSONTest::test("{ \"key\" : \"val\" } [ \"error\" ]", false);
-  JSONTest::test("{ \"key\" : \"val\" ", false);
-
-  JSONTest::test("/**/ { }", true);
-  JSONTest::test("/* */ { }", true);
-  JSONTest::test("/*foo*/ { }", true);
-  JSONTest::test("/* *foo */ { }", true);
-  JSONTest::test("/* *foo* */ { }", true);
-  JSONTest::test("/* /*foo */ { }", true);
-  JSONTest::test("{ } /* foo */", true);
-  JSONTest::test("{ } /* foo */ ", true);
-  JSONTest::test("{ } //", true);
-  JSONTest::test("{ } // ", true);
-  JSONTest::test("{ } // foo", true);
-
-  JSONTest::test("/* * / { }", false);
-  JSONTest::test("/ * */ { }", false);
-  JSONTest::test("// { }", false);
-  JSONTest::test("/* { } */", false);
-  JSONTest::test("/* { } */ ", false);
-  JSONTest::test("/* { } ", false);
-  JSONTest::test("{ } /* ", false);
-  JSONTest::test("/* { } *", false);
-  JSONTest::test("{ /* } */", false);
-  JSONTest::test("[ /* ] */", false);
-  JSONTest::test("{ key : \"val\", /* } */", false);
-  JSONTest::test("[ \"val\", /* ] */", false);
-
-  JSONTest::test("/* comment */{ key1 : { \"key2\" : { \"key3\" : [ \"elem1\", \"elem2\", { \"key4\" : null }, 3 , 2 , 1 , 0 , -1 , -2 , -3 , true, false, null, ] }, \"key5\" : true }, \"key6\" : [ \"☃\" ], key7 : \"val\",}", true);
-  JSONTest::test("/* comment */ { \"key1\" : { \"key2\" : { \"key3\" : [ \"elem1\", \"elem2\", { \"key4\" : null }, 3 , 2 , 1 , 0 , -1 , -2 , -3 , true, false, null, ] }, \"key5\" : true }, \"key6\" : [ \"☃\" ], key7 : \"val\",}", true);
-  JSONTest::test("/*comment*/{\"ff1 fsd\":{\"☃\":{\"☃\":[\"☃\",\"☃\"]},\"☃\":true},\"☃\":[\"☃\"],\"foo\":\"☃\",}", true);
-  JSONTest::test("/* comment */ { key1 error : { \"☃\" : { \"☃\" : [ \"☃\", \"☃\" ] }, \"☃\" : true }, \"baz\" : [ \"☃\" ], foo : \"☃\",}", false); // first key needs to be quoted since it contains a space
-
-
-  JSONTest::test("[\n]", true);
-
-  JSONTest::test(
-      "[" "\n"
-      "   {"
-      "         // pattern to match against class+method+signature" "\n"
-      "         // leading and trailing wildcard (*) allowed" "\n"
-      "         match: \"foo.bar.*\"," "\n"
-      " " "\n"
-      "         // override defaults for specified compiler" "\n"
-      "         // we may differentiate between levels too. TBD." "\n"
-      "         c1:  {" "\n"
-      "           //override c1 presets " "\n"
-      "           array_bounds_check_removal: false" "\n"
-      "         }," "\n"
-      "" "\n"
-      "         c2: {" "\n"
-      "           // control inlining of method" "\n"
-      "           // + force inline, - dont inline" "\n"
-      "           inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
-      "         }," "\n"
-      "" "\n"
-      "         // directives outside a specific preset applies to all compilers" "\n"
-      "         inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
-      "         print_assembly: true," "\n"
-      "         verify_oopmaps: true," "\n"
-      "         max_loop_unrolling: 5" "\n"
-      "   }," "\n"
-      "   {" "\n"
-      "         // matching several patterns require an array" "\n"
-      "         match: [\"baz.*\",\"frob*\"]," "\n"
-      "" "\n"
-      "         // only enable c1 for this directive" "\n"
-      "         // all enabled by default. Command disables all not listed" "\n"
-      "         enable: \"c1\"," "\n"
-      "" "\n"
-      "         // applies to all compilers" "\n"
-      "         // + force inline, - dont inline" "\n"
-      "         inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
-      "         print_inlining: true," "\n"
-      "" "\n"
-      "         // force matching compiles to be blocking/syncronous" "\n"
-      "         blocking_compile: true" "\n"
-      "   }," "\n"
-      "]" "\n", true);
-}
-
-void JSONTest::log(uint indent, const char* format, ...) {
-  if (VerboseInternalVMTests) {
-    if (prev != JSON_KEY) {
-      for (uint i = 0; i < indent; i++) {
-        _st->print("  ");
-      }
-    }
-    va_list args;
-    va_start(args, format);
-    _st->vprint(format, args);
-    va_end(args);
-  }
-}
-
-bool JSONTest::callback(JSON_TYPE t, JSON_VAL* v, uint rlevel) {
-  switch (t) {
-  case JSON_OBJECT_BEGIN:
-    log(rlevel, "{\n");
-    prev = JSON_NONE; // Only care about JSON_KEY, to indent correctly
-    return true;
-
-  case JSON_OBJECT_END:
-    log(rlevel, "},\n");
-    prev = JSON_NONE;
-    return true;
-
-  case JSON_ARRAY_BEGIN:
-    log(rlevel, "[\n");
-    prev = JSON_NONE;
-    return true;
-
-  case JSON_ARRAY_END:
-    log(rlevel, "],\n");
-    prev = JSON_NONE;
-    return true;
-
-  case JSON_KEY:
-    if (VerboseInternalVMTests) {
-      for (uint i = 0; i < rlevel; i++) {
-        _st->print("  ");
-      }
-      _st->print("<key>");
-      for (size_t i = 0; i < v->str.length; i++) {
-        u_char c = v->str.start[i];
-        assert(c != 0, "string overrun");
-        if (c == 0) {
-          return false;
-        }
-        _st->print("%c", c);
-      }
-      _st->print(" : ");
-    }
-    prev = JSON_KEY;
-    return true;
-
-  case JSON_STRING:
-    if (VerboseInternalVMTests) {
-      if (prev != JSON_KEY) {
-        for (uint i = 0; i < rlevel; i++) {
-          _st->print("  ");
-        }
-      }
-      _st->print("<str>");
-      for (size_t i = 0; i < v->str.length; i++) {
-        u_char c = v->str.start[i];
-        assert(c != 0, "string overrun");
-        if (c == 0) {
-          return false;
-        }
-        _st->print("%c", c);
-      }
-      _st->print(",\n");
-    }
-    prev = JSON_NONE;
-    return true;
-
-  case JSON_NUMBER_INT:
-    log(rlevel, "<int>%" PRId64 ",\n", v->int_value);
-    prev = JSON_NONE;
-    return true;
-
-  case JSON_NUMBER_FLOAT:
-    log(rlevel, "<double>%lf,\n", v->double_value);
-    prev = JSON_NONE;
-    return true;
-
-  case JSON_TRUE:
-    log(rlevel, "<true>,\n");
-    prev = JSON_NONE;
-    return true;
-
-  case JSON_FALSE:
-    log(rlevel, "<false>,\n");
-    prev = JSON_NONE;
-    return true;
-
-  case JSON_NULL:
-    log(rlevel, "<null>,\n");
-    prev = JSON_NONE;
-    return true;
-
-  default:
-    error(INTERNAL_ERROR, "unknown JSON type");
-    return false;
-  }
-}
-#endif
--- a/hotspot/src/share/vm/utilities/linkedlist.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +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/linkedlist.hpp"
-#include "memory/allocation.hpp"
-#include "memory/allocation.inline.hpp"
-
-class Integer : public StackObj {
- private:
-  int  _value;
- public:
-  Integer(int i) : _value(i) { }
-
-  int   value() const { return _value; }
-  bool  equals(const Integer& i) const {
-   return _value == i.value();
-  }
-};
-
-int compare_Integer(const Integer& i1, const Integer& i2) {
-  return i1.value() - i2.value();
-}
-
-void check_list_values(const int* expected, const LinkedList<Integer>* list) {
-  LinkedListNode<Integer>* head = list->head();
-  int index = 0;
-  while (head != NULL) {
-    assert(head->peek()->value() == expected[index], "Unexpected value");
-    head = head->next();
-    index ++;
-  }
-}
-
-void Test_linked_list() {
-  LinkedListImpl<Integer, ResourceObj::C_HEAP, mtTest>  ll;
-
-
-  // Test regular linked list
-  assert(ll.is_empty(), "Start with empty list");
-  Integer one(1), two(2), three(3), four(4), five(5), six(6);
-
-  ll.add(six);
-  assert(!ll.is_empty(), "Should not be empty");
-
-  Integer* i = ll.find(six);
-  assert(i != NULL, "Should find it");
-
-  i = ll.find(three);
-  assert(i == NULL, "Not in the list");
-
-  LinkedListNode<Integer>* node = ll.find_node(six);
-  assert(node != NULL, "6 is in the list");
-
-  ll.insert_after(three, node);
-  ll.insert_before(one, node);
-  int expected[3] = {1, 6, 3};
-  check_list_values(expected, &ll);
-
-  ll.add(two);
-  ll.add(four);
-  ll.add(five);
-
-  // Test sorted linked list
-  SortedLinkedList<Integer, compare_Integer, ResourceObj::C_HEAP, mtTest> sl;
-  assert(sl.is_empty(), "Start with empty list");
-
-  size_t ll_size = ll.size();
-  sl.move(&ll);
-  size_t sl_size = sl.size();
-
-  assert(ll_size == sl_size, "Should be the same size");
-  assert(ll.is_empty(), "No more entires");
-
-  // sorted result
-  int sorted_result[] = {1, 2, 3, 4, 5, 6};
-  check_list_values(sorted_result, &sl);
-
-  node = sl.find_node(four);
-  assert(node != NULL, "4 is in the list");
-  sl.remove_before(node);
-  sl.remove_after(node);
-  int remains[] = {1, 2, 4, 6};
-  check_list_values(remains, &sl);
-}
-#endif // PRODUCT
-
--- a/hotspot/test/TEST.groups	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/TEST.groups	Fri Sep 30 02:52:38 2016 -0700
@@ -351,16 +351,29 @@
 
 hotspot_fast_runtime = \
   runtime/ \
+ -runtime/6626217/Test6626217.sh \
+ -runtime/7100935 \
+ -runtime/7158988/FieldMonitor.java \
+ -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \
+ -runtime/CommandLine/PrintGCApplicationConcurrentTime.java \
+ -runtime/ConstantPool/IntfMethod.java \
+ -runtime/ErrorHandling/CreateCoredumpOnCrash.java \
  -runtime/ErrorHandling/ErrorHandler.java \
- -runtime/RedefineObject/TestRedefineObject.java \
- -runtime/MirrorFrame/Test8003720.java \
+ -runtime/logging/MonitorMismatchTest.java \
+ -runtime/memory/ReserveMemory.java \
+ -runtime/memory/RunUnitTestsConcurrently.java \
  -runtime/Metaspace/FragmentMetaspace.java \
  -runtime/Metaspace/FragmentMetaspaceSimple.java \
- -runtime/Thread/TestThreadDumpMonitorContention.java \
- -runtime/SharedArchiveFile/SharedBaseAddress.java \
- -runtime/memory/ReserveMemory.java \
- -runtime/memory/RunUnitTestsConcurrently.java \
- -runtime/Unsafe/RangeCheck.java \
+ -runtime/MirrorFrame/Test8003720.java \
+ -runtime/modules/LoadUnloadModuleStress.java \
+ -runtime/modules/ModuleStress/ExportModuleStressTest.java \
+ -runtime/modules/ModuleStress/ModuleStressGC.java \
+ -runtime/NMT \
+ -runtime/RedefineObject/TestRedefineObject.java \
+ -runtime/RedefineTests/RedefinePreviousVersions.java \
+ -runtime/RedefineTests/RedefineRunningMethods.java \
+ -runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java \
+ -runtime/ReservedStack \
  -runtime/SelectionResolution/AbstractMethodErrorTest.java \
  -runtime/SelectionResolution/IllegalAccessErrorTest.java \
  -runtime/SelectionResolution/InvokeInterfaceICCE.java \
@@ -372,14 +385,14 @@
  -runtime/SelectionResolution/InvokeVirtualSuccessTest.java \
  -runtime/SharedArchiveFile/CdsSameObjectAlignment.java \
  -runtime/SharedArchiveFile/DefaultUseWithClient.java \
+ -runtime/SharedArchiveFile/SharedBaseAddress.java \
  -runtime/Thread/CancellableThreadTest.java \
- -runtime/7158988/FieldMonitor.java \
- -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \
+ -runtime/Thread/TestThreadDumpMonitorContention.java \
+ -runtime/Unsafe/RangeCheck.java \
   sanity/ \
   testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java
 
 hotspot_fast_serviceability = \
-  sanity/ExecuteInternalVMTests.java \
   serviceability/dcmd/compiler \
   serviceability/logging
 
@@ -398,6 +411,8 @@
 hotspot_runtime_tier2 = \
   runtime/ \
   serviceability/ \
+ -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \
+ -runtime/Thread/TestThreadDumpMonitorContention.java \
  -:hotspot_fast_runtime \
  -:hotspot_fast_serviceability \
  -:hotspot_runtime_tier2_platform_agnostic
@@ -405,6 +420,14 @@
 hotspot_runtime_tier2_platform_agnostic = \
   runtime/SelectionResolution \
  -:hotspot_fast_runtime
+ 
+hotspot_runtime_tier3 = \
+  runtime/ \
+  serviceability/ \
+ -:hotspot_fast_runtime \
+ -:hotspot_fast_serviceability \
+ -:hotspot_runtime_tier2_platform_agnostic \
+ -:hotspot_runtime_tier2
 
 hotspot_runtime_minimalvm = \
   runtime/MinimalVM \
--- a/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java	Fri Sep 30 02:52:38 2016 -0700
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  *
- * @ignore 8071905
+ * @ignore 8166554
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java	Fri Sep 30 02:52:38 2016 -0700
@@ -74,7 +74,7 @@
         if (loggedMethods.isEmpty()) {
             return;
         }
-        matchTasks(getScanner());
+        matchTasks();
     }
 
     /*
@@ -95,19 +95,21 @@
      * Parses for &lt;task method='java.lang.String indexOf (I)I' &gt;
      * and finds if there is a compilation log for this task
      */
-    private void matchTasks(Scanner scanner) {
-        String task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
-        while (task != null) {
-            String element = scanner.findWithinHorizon(ANY_ELEMENT, 0);
-            if (Pattern.matches(TASK_DONE_ELEMENT, element)
-                    || Pattern.matches(TASK_END_ELEMENT, element)) {
-                /* If there is nothing between <task> and </task>
-                   except <task done /> then compilation log is empty.
-                   Check the method in this task should not be logged */
-                Asserts.assertFalse(matchMethod(task), "Compilation log "
-                        + "expected. Met: " + element);
-            }
-            task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
+    private void matchTasks() {
+        try (Scanner scanner = getScanner()) {
+          String task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
+          while (task != null) {
+              String element = scanner.findWithinHorizon(ANY_ELEMENT, 0);
+              if (Pattern.matches(TASK_DONE_ELEMENT, element)
+                      || Pattern.matches(TASK_END_ELEMENT, element)) {
+                  /* If there is nothing between <task> and </task>
+                     except <task done /> then compilation log is empty.
+                     Check the method in this task should not be logged */
+                  Asserts.assertFalse(matchMethod(task), "Compilation log "
+                          + "expected. Met: " + element);
+              }
+              task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
+          }
         }
     }
 
--- a/hotspot/test/compiler/jsr292/NullConstantReceiver.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/jsr292/NullConstantReceiver.java	Fri Sep 30 02:52:38 2016 -0700
@@ -23,10 +23,11 @@
 
 /**
  * @test
- * @bug 8059556 8158639
+ * @bug 8059556 8158639 8164508
  *
  * @run main/othervm -Xbatch compiler.jsr292.NullConstantReceiver
  * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::run compiler.jsr292.NullConstantReceiver
+ * @run main/othervm -Xbatch -XX:CompileCommand=compileonly,*::run compiler.jsr292.NullConstantReceiver
  */
 
 package compiler.jsr292;
--- a/hotspot/test/compiler/jvmci/common/CTVMUtilities.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/jvmci/common/CTVMUtilities.java	Fri Sep 30 02:52:38 2016 -0700
@@ -57,18 +57,7 @@
         if (!(method instanceof Method || method instanceof Constructor)) {
             throw new Error("wrong executable type " + method.getClass());
         }
-        Field slotField;
-        int slot;
-        try {
-            slotField = method.getClass().getDeclaredField("slot");
-            boolean old = slotField.isAccessible();
-            slotField.setAccessible(true);
-            slot = slotField.getInt(method);
-            slotField.setAccessible(old);
-        } catch (ReflectiveOperationException e) {
-            throw new Error("TEST BUG: Can't get slot field", e);
-        }
-        return CompilerToVMHelper.getResolvedJavaMethodAtSlot(cls, slot);
+        return CompilerToVMHelper.asResolvedJavaMethod(method);
     }
 
     public static HotSpotResolvedJavaMethod getResolvedMethod(
--- a/hotspot/test/compiler/jvmci/common/patches/jdk.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/jvmci/common/patches/jdk.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java	Fri Sep 30 02:52:38 2016 -0700
@@ -28,6 +28,7 @@
 import jdk.vm.ci.code.TargetDescription;
 import jdk.vm.ci.meta.ConstantPool;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
+import java.lang.reflect.Executable;
 
 /**
  * A simple "proxy" class to get test access to CompilerToVM package-private methods
@@ -171,9 +172,9 @@
         return CTVM.hasFinalizableSubclass((HotSpotResolvedObjectTypeImpl) type);
     }
 
-    public static HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot(
-            Class<?> holder, int slot) {
-        return CTVM.getResolvedJavaMethodAtSlot(holder, slot);
+    public static HotSpotResolvedJavaMethodImpl asResolvedJavaMethod(
+            Executable executable) {
+        return CTVM.asResolvedJavaMethod(executable);
     }
 
     public static long getMaxCallTargetOffset(long address) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/AsResolvedJavaMethodTest.java	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2015, 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 8136421
+ * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
+ * @library /test/lib /
+ * @library ../common/patches
+ * @modules java.base/jdk.internal.misc
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ *          java.base/jdk.internal.org.objectweb.asm.tree
+ *          jdk.vm.ci/jdk.vm.ci.hotspot
+ *          jdk.vm.ci/jdk.vm.ci.code
+ *          jdk.vm.ci/jdk.vm.ci.meta
+ * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
+ *                   compiler.jvmci.compilerToVM.AsResolvedJavaMethodTest
+ */
+
+package compiler.jvmci.compilerToVM;
+
+import jdk.test.lib.Asserts;
+import jdk.vm.ci.hotspot.CompilerToVMHelper;
+import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
+
+import java.lang.reflect.Executable;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AsResolvedJavaMethodTest {
+
+    private static class A {
+        {
+            System.out.println("Dummy");
+        }
+        public void f1() {}
+        public int f2() { return 0; }
+        public String f3() { return ""; }
+    }
+
+
+    private static class S {
+        static {
+            System.out.println("Dummy static");
+        }
+        public S() {}
+        public void f1() {}
+        public int f2() { return 0; }
+        public String f3() { return ""; }
+    }
+
+    private class B extends A {
+        public void f4() {}
+    }
+
+    private interface I {
+        void f1();
+        int f2();
+        String f3();
+    }
+
+    public static void main(String[] args) {
+        List<Class<?>> testCases = getTestCases();
+        testCases.forEach(AsResolvedJavaMethodTest::test);
+    }
+
+    private static List<Class<?>> getTestCases() {
+        List<Class<?>> testCases = new ArrayList<>();
+        testCases.add(A.class);
+        testCases.add(S.class);
+        testCases.add(I.class);
+        testCases.add(B.class);
+        return testCases;
+    }
+
+    private static void test(Class<?> aClass) {
+        testCorrectMethods(aClass);
+    }
+
+    private static void testCorrectMethods(Class<?> holder) {
+        List<Executable> executables = new ArrayList<>();
+        executables.addAll(Arrays.asList(holder.getDeclaredMethods()));
+        executables.addAll(Arrays.asList(holder.getDeclaredConstructors()));
+        for (Executable executable : executables) {
+            HotSpotResolvedJavaMethod method = CompilerToVMHelper
+                    .asResolvedJavaMethod(executable);
+            Asserts.assertNotNull(method, "could not convert " + method);
+        }
+    }
+}
--- a/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java	Fri Sep 30 02:52:38 2016 -0700
@@ -74,45 +74,37 @@
     private static Set<TestCase> createTestCases() {
         Set<TestCase> result = new HashSet<>();
         // a public method
-        result.add(new TestCase(true, SingleSubclass.class,
-                SingleSubclass.class, "usualMethod"));
+        result.add(new TestCase(true, SingleSubclass.class, "usualMethod"));
         // overriden method
-        result.add(new TestCase(true, SingleSubclass.class,
-                SingleSubclass.class, "overridenMethod"));
+        result.add(new TestCase(true, SingleSubclass.class, "overridenMethod"));
         // private method
-        result.add(new TestCase(true, SingleSubclass.class,
-                SingleSubclass.class, "privateMethod"));
+        result.add(new TestCase(true, SingleSubclass.class, "privateMethod"));
         // protected method
-        result.add(new TestCase(true, SingleSubclass.class,
-                SingleSubclass.class, "protectedMethod"));
+        result.add(new TestCase(true, SingleSubclass.class, "protectedMethod"));
         // default(package-private) method
-        result.add(new TestCase(true, SingleSubclass.class,
-                SingleSubclass.class, "defaultAccessMethod"));
+        result.add(new TestCase(true, SingleSubclass.class, "defaultAccessMethod"));
         // default interface method redefined in implementer
-        result.add(new TestCase(true, MultipleImplementer1.class,
-                MultipleImplementer1.class, "defaultMethod"));
+        result.add(new TestCase(true, MultipleImplementer1.class, "defaultMethod"));
         // interface method
-        result.add(new TestCase(true, MultipleImplementer1.class,
-                MultipleImplementer1.class, "testMethod"));
+        result.add(new TestCase(true, MultipleImplementer1.class, "testMethod"));
         // default interface method not redefined in implementer
-        result.add(new TestCase(true, SingleImplementer.class,
-                SingleImplementerInterface.class, "defaultMethod"));
+        // result.add(new TestCase(true, SingleImplementer.class,
+        //                         SingleImplementerInterface.class, "defaultMethod"));
         // static method
-        result.add(new TestCase(false, SingleSubclass.class,
-                SingleSubclass.class, "staticMethod"));
+        result.add(new TestCase(false, SingleSubclass.class, "staticMethod"));
         // interface method
         result.add(new TestCase(false, MultipleSuperImplementers.class,
-                                DuplicateSimpleSingleImplementerInterface.class, "interfaceMethod", false));
+                                DuplicateSimpleSingleImplementerInterface.class, "interfaceMethod"));
         result.add(new TestCase(false, MultipleSuperImplementers.class,
-                                SimpleSingleImplementerInterface.class, "interfaceMethod", false));
+                                SimpleSingleImplementerInterface.class, "interfaceMethod"));
         return result;
     }
 
     private void runTest(TestCase tcase) throws NoSuchMethodException {
         System.out.println(tcase);
         Method method = tcase.holder.getDeclaredMethod(tcase.methodName);
-        HotSpotResolvedJavaMethod testMethod = CTVMUtilities
-            .getResolvedMethod(tcase.methodFromReceiver ? tcase.receiver : tcase.holder, method);
+        HotSpotResolvedJavaMethod testMethod = CTVMUtilities.getResolvedMethod(method);
+
         HotSpotResolvedObjectType resolvedType = CompilerToVMHelper
                 .lookupType(Utils.toJVMTypeSignature(tcase.receiver), getClass(),
                 /* resolve = */ true);
@@ -127,25 +119,23 @@
         public final Class<?> holder;
         public final String methodName;
         public final boolean isPositive;
-        public final boolean methodFromReceiver;
 
         public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder,
-                        String methodName, boolean methodFromReceiver) {
+                        String methodName) {
             this.receiver = clazz;
             this.methodName = methodName;
             this.isPositive = isPositive;
             this.holder = holder;
-            this.methodFromReceiver = methodFromReceiver;
         }
 
-        public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder, String methodName) {
-            this(isPositive, clazz, holder, methodName, true);
+        public TestCase(boolean isPositive, Class<?> clazz, String methodName) {
+            this(isPositive, clazz, clazz, methodName);
         }
 
         @Override
         public String toString() {
-            return String.format("CASE: receiver=%s, holder=%s, method=%s, isPositive=%s, methodFromReceiver=%s",
-                                 receiver.getName(), holder.getName(), methodName, isPositive, methodFromReceiver);
+            return String.format("CASE: receiver=%s, holder=%s, method=%s, isPositive=%s",
+                                 receiver.getName(), holder.getName(), methodName, isPositive);
         }
     }
 }
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java	Thu Sep 29 17:23:47 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2015, 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 8136421
- * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
- * @library /test/lib /
- * @library ../common/patches
- * @modules java.base/jdk.internal.misc
- * @modules java.base/jdk.internal.org.objectweb.asm
- *          java.base/jdk.internal.org.objectweb.asm.tree
- *          jdk.vm.ci/jdk.vm.ci.hotspot
- *          jdk.vm.ci/jdk.vm.ci.code
- *          jdk.vm.ci/jdk.vm.ci.meta
- * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
- * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
- *                   compiler.jvmci.compilerToVM.GetResolvedJavaMethodAtSlotTest
- */
-
-package compiler.jvmci.compilerToVM;
-
-import jdk.test.lib.Asserts;
-import jdk.vm.ci.hotspot.CompilerToVMHelper;
-import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class GetResolvedJavaMethodAtSlotTest {
-
-    private static class A {
-        {
-            System.out.println("Dummy");
-        }
-        public void f1() {}
-        public int f2() { return 0; }
-        public String f3() { return ""; }
-    }
-
-
-    private static class S {
-        static {
-            System.out.println("Dummy static");
-        }
-        public S() {}
-        public void f1() {}
-        public int f2() { return 0; }
-        public String f3() { return ""; }
-    }
-
-    private class B extends A {
-        public void f4() {}
-    }
-
-    private interface I {
-        void f1();
-        int f2();
-        String f3();
-    }
-
-    public static void main(String[] args) {
-        Map<Class<?>, Integer> testCases = getTestCases();
-        testCases.forEach(GetResolvedJavaMethodAtSlotTest::test);
-    }
-
-    private static Map<Class<?>, Integer> getTestCases() {
-        Map<Class<?>, Integer> testCases = new HashMap<>();
-        testCases.put(A.class, 5); // ctor, init, f1, f2, f3
-        testCases.put(S.class, 5); // ctor, cinit, f1, f2, f3
-        testCases.put(I.class, 3); // f1, f2, f3
-        testCases.put(B.class, 2); // ctor, f4
-        return testCases;
-    }
-
-    private static void test(Class<?> aClass, int methodNumber) {
-        testSlotBigger(aClass);
-        testCorrectMethods(aClass, methodNumber);
-    }
-
-    private static void testSlotBigger(Class<?> holder) {
-        HotSpotResolvedJavaMethod method
-                = CompilerToVMHelper.getResolvedJavaMethodAtSlot(holder, 50);
-        Asserts.assertNull(method, "Got method for non existing slot 50 in "
-                + holder);
-    }
-
-    private static void testCorrectMethods(Class<?> holder, int methodsNumber) {
-        for (int i = 0; i < methodsNumber; i++) {
-            String caseName = String.format("slot %d in %s",
-                    i, holder.getCanonicalName());
-            HotSpotResolvedJavaMethod method = CompilerToVMHelper
-                    .getResolvedJavaMethodAtSlot(holder, i);
-            Asserts.assertNotNull(method, caseName + " did not got method");
-            Asserts.assertEQ(holder,
-                    CompilerToVMHelper.getMirror(method.getDeclaringClass()),
-                    caseName + " : unexpected declaring class");
-        }
-    }
-}
--- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java	Fri Sep 30 02:52:38 2016 -0700
@@ -51,6 +51,7 @@
 import sun.hotspot.WhiteBox;
 
 import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 
 public class GetResolvedJavaMethodTest {
     private static enum TestCase {
@@ -64,9 +65,7 @@
         JAVA_METHOD_BASE {
             @Override
             HotSpotResolvedJavaMethod getResolvedJavaMethod() {
-                HotSpotResolvedJavaMethod methodInstance
-                        = CompilerToVMHelper.getResolvedJavaMethodAtSlot(
-                                TEST_CLASS, 0);
+                HotSpotResolvedJavaMethod methodInstance = TEST_METHOD;
                 try {
                     METASPACE_METHOD_FIELD.set(methodInstance,
                             getPtrToMethod());
@@ -81,9 +80,7 @@
             @Override
             HotSpotResolvedJavaMethod getResolvedJavaMethod() {
                 long ptr = getPtrToMethod();
-                HotSpotResolvedJavaMethod methodInstance
-                        = CompilerToVMHelper.getResolvedJavaMethodAtSlot(
-                        TEST_CLASS, 0);
+                HotSpotResolvedJavaMethod methodInstance = TEST_METHOD;
                 try {
                     METASPACE_METHOD_FIELD.set(methodInstance, ptr / 2L);
                 } catch (ReflectiveOperationException e) {
@@ -97,9 +94,7 @@
             @Override
             HotSpotResolvedJavaMethod getResolvedJavaMethod() {
                 long ptr = getPtrToMethod();
-                HotSpotResolvedJavaMethod methodInstance
-                        = CompilerToVMHelper.getResolvedJavaMethodAtSlot(
-                        TEST_CLASS, 0);
+                HotSpotResolvedJavaMethod methodInstance = TEST_METHOD;
                 try {
                     METASPACE_METHOD_FIELD.set(methodInstance, 0L);
                 } catch (ReflectiveOperationException e) {
@@ -117,16 +112,21 @@
     private static final WhiteBox WB = WhiteBox.getWhiteBox();
     private static final Field METASPACE_METHOD_FIELD;
     private static final Class<?> TEST_CLASS = GetResolvedJavaMethodTest.class;
+    private static final HotSpotResolvedJavaMethod TEST_METHOD;
     private static final long PTR;
     static  {
-        HotSpotResolvedJavaMethod method
-                = CompilerToVMHelper.getResolvedJavaMethodAtSlot(TEST_CLASS, 0);
+        try {
+            Method method = TEST_CLASS.getDeclaredMethod("test", TestCase.class);
+            TEST_METHOD = CompilerToVMHelper.asResolvedJavaMethod(method);
+        } catch (NoSuchMethodException e) {
+            throw new Error("TESTBUG : " + e, e);
+        }
         try {
             // jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl.metaspaceMethod
-            METASPACE_METHOD_FIELD = method.getClass()
+            METASPACE_METHOD_FIELD = TEST_METHOD.getClass()
                     .getDeclaredField("metaspaceMethod");
             METASPACE_METHOD_FIELD.setAccessible(true);
-            PTR = (long) METASPACE_METHOD_FIELD.get(method);
+            PTR = (long) METASPACE_METHOD_FIELD.get(TEST_METHOD);
         } catch (ReflectiveOperationException e) {
             throw new Error("TESTBUG : " + e, e);
         }
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java	Fri Sep 30 02:52:38 2016 -0700
@@ -23,6 +23,10 @@
 
 package jdk.vm.ci.hotspot.test;
 
+import java.lang.reflect.Field;
+
+import org.testng.annotations.DataProvider;
+
 import jdk.internal.misc.Unsafe;
 import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider;
@@ -32,27 +36,14 @@
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.runtime.JVMCI;
-import org.testng.annotations.DataProvider;
-
-import java.lang.reflect.Field;
 
 public class MemoryAccessProviderData {
-    private static final Unsafe UNSAFE = getUnsafe();
+    private static final Unsafe UNSAFE = Unsafe.getUnsafe();
     private static final HotSpotConstantReflectionProvider CONSTANT_REFLECTION = (HotSpotConstantReflectionProvider) JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection();
     private static final TestClass TEST_OBJECT = new TestClass();
     private static final JavaConstant TEST_CONSTANT = CONSTANT_REFLECTION.forObject(TEST_OBJECT);
     private static final JavaConstant TEST_CLASS_CONSTANT = CONSTANT_REFLECTION.forObject(TestClass.class);
 
-    private static Unsafe getUnsafe() {
-        try {
-            Field f = Unsafe.class.getDeclaredField("theUnsafe");
-            f.setAccessible(true);
-            return (Unsafe) f.get(null);
-        } catch (NoSuchFieldException | IllegalAccessException e) {
-            throw new RuntimeException("Unable to get Unsafe instance.", e);
-        }
-    }
-
     @DataProvider(name = "positiveObject")
     public static Object[][] getPositiveObjectJavaKind() {
         HotSpotJVMCIRuntimeProvider runtime = (HotSpotJVMCIRuntimeProvider) JVMCI.getRuntime();
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java	Fri Sep 30 02:52:38 2016 -0700
@@ -438,7 +438,6 @@
 
     // @formatter:off
     private static final String[] untestedApiMethods = {
-        "invoke",
         "newInstance",
         "getDeclaringClass",
         "getEncoding",
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java	Fri Sep 30 02:52:38 2016 -0700
@@ -35,16 +35,18 @@
 
 package jdk.vm.ci.runtime.test;
 
-import jdk.internal.reflect.ConstantPool;
-import jdk.vm.ci.common.JVMCIError;
-import jdk.vm.ci.meta.Assumptions.AssumptionResult;
-import jdk.vm.ci.meta.JavaConstant;
-import jdk.vm.ci.meta.JavaKind;
-import jdk.vm.ci.meta.ModifiersProvider;
-import jdk.vm.ci.meta.ResolvedJavaField;
-import jdk.vm.ci.meta.ResolvedJavaMethod;
-import jdk.vm.ci.meta.ResolvedJavaType;
-import org.junit.Test;
+import static java.lang.reflect.Modifier.isAbstract;
+import static java.lang.reflect.Modifier.isFinal;
+import static java.lang.reflect.Modifier.isPrivate;
+import static java.lang.reflect.Modifier.isProtected;
+import static java.lang.reflect.Modifier.isPublic;
+import static java.lang.reflect.Modifier.isStatic;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
@@ -57,18 +59,16 @@
 import java.util.Map;
 import java.util.Set;
 
-import static java.lang.reflect.Modifier.isAbstract;
-import static java.lang.reflect.Modifier.isFinal;
-import static java.lang.reflect.Modifier.isPrivate;
-import static java.lang.reflect.Modifier.isProtected;
-import static java.lang.reflect.Modifier.isPublic;
-import static java.lang.reflect.Modifier.isStatic;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+import jdk.internal.reflect.ConstantPool;
+import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.meta.Assumptions.AssumptionResult;
+import jdk.vm.ci.meta.JavaConstant;
+import jdk.vm.ci.meta.JavaKind;
+import jdk.vm.ci.meta.ResolvedJavaField;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.meta.ResolvedJavaType;
 
 /**
  * Tests for {@link ResolvedJavaType}.
@@ -146,8 +146,9 @@
     public void getModifiersTest() {
         for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
-            int expected = c.getModifiers() & ModifiersProvider.jvmClassModifiers();
-            int actual = type.getModifiers() & ModifiersProvider.jvmClassModifiers();
+            int mask = Modifier.classModifiers() & ~Modifier.STATIC;
+            int expected = c.getModifiers() & mask;
+            int actual = type.getModifiers() & mask;
             Class<?> elementalType = c;
             while (elementalType.isArray()) {
                 elementalType = elementalType.getComponentType();
--- a/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java	Fri Sep 30 02:52:38 2016 -0700
@@ -25,6 +25,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.process.ExitCode;
 import jdk.test.lib.cli.CommandLineOptionTest;
@@ -66,7 +67,7 @@
             boolean isExperimental, String defaultValue,
             String[] correctValues, String[] incorrectValues,
             String warningMessage) {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()),
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()),
                 optionName, isBoolean, isExperimental, defaultValue);
         this.correctValues = correctValues;
         this.incorrectValues = incorrectValues;
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -42,6 +42,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.cli.CommandLineOptionTest;
 import jdk.test.lib.cli.predicate.AndPredicate;
@@ -49,7 +50,7 @@
 public class TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig
         extends TestPrintPreciseRTMLockingStatisticsBase {
     private TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig() {
-        super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -42,6 +42,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.cli.predicate.AndPredicate;
 import jdk.test.lib.cli.predicate.NotPredicate;
@@ -49,8 +50,8 @@
 public class TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig
         extends TestPrintPreciseRTMLockingStatisticsBase {
     private TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig() {
-        super(new NotPredicate(new AndPredicate(new SupportedCPU(),
-                new SupportedVM())));
+        super(new NotPredicate(
+                new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())));
     }
 
     public static void main(String args[]) throws Throwable {
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -42,6 +42,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.cli.predicate.AndPredicate;
 import jdk.test.lib.cli.predicate.NotPredicate;
@@ -51,8 +52,8 @@
     private static final String DEFAULT_VALUE = "50";
 
     private TestRTMAbortRatioOptionOnUnsupportedConfig() {
-        super(new NotPredicate(new AndPredicate(new SupportedVM(),
-                        new SupportedCPU())),
+        super(new NotPredicate(
+                new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())),
                 "RTMAbortRatio", false, true,
                 TestRTMAbortRatioOptionOnUnsupportedConfig.DEFAULT_VALUE,
                 "0", "10", "100", "200");
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -42,6 +42,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.cli.predicate.AndPredicate;
 import jdk.test.lib.cli.predicate.NotPredicate;
@@ -51,8 +52,8 @@
     private static final String DEFAULT_VALUE = "64";
 
     private TestRTMTotalCountIncrRateOptionOnUnsupportedConfig() {
-        super(new NotPredicate(new AndPredicate(new SupportedCPU(),
-                        new SupportedVM())),
+        super(new NotPredicate(
+                new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())),
                 "RTMTotalCountIncrRate", false, true,
                 TestRTMTotalCountIncrRateOptionOnUnsupportedConfig
                         .DEFAULT_VALUE,
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -42,6 +42,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.process.ExitCode;
 import jdk.test.lib.cli.CommandLineOptionTest;
@@ -52,7 +53,7 @@
     private static final String DEFAULT_VALUE = "false";
 
     private TestUseRTMDeoptOptionOnSupportedConfig() {
-        super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -42,6 +42,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.cli.CommandLineOptionTest;
 import jdk.test.lib.cli.predicate.AndPredicate;
@@ -52,8 +53,8 @@
     private static final String DEFAULT_VALUE = "false";
 
     private TestUseRTMDeoptOptionOnUnsupportedConfig() {
-        super(new NotPredicate(new AndPredicate(new SupportedCPU(),
-                        new SupportedVM())),
+        super(new NotPredicate(
+                new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())),
                 "UseRTMDeopt", true, false,
                 TestUseRTMDeoptOptionOnUnsupportedConfig.DEFAULT_VALUE,
                 "true");
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -42,6 +42,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.process.ExitCode;
 import jdk.test.lib.cli.CommandLineOptionTest;
@@ -52,7 +53,7 @@
     private static final String DEFAULT_VALUE = "false";
 
     private TestUseRTMForStackLocksOptionOnSupportedConfig() {
-        super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -42,6 +42,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.process.ExitCode;
 import jdk.test.lib.cli.CommandLineOptionTest;
@@ -53,8 +54,8 @@
     private static final String DEFAULT_VALUE = "false";
 
     private TestUseRTMForStackLocksOptionOnUnsupportedConfig() {
-        super(new NotPredicate(new AndPredicate(new SupportedCPU(),
-                        new SupportedVM())),
+        super(new NotPredicate(
+                new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())),
                 "UseRTMForStackLocks", true, true,
                 TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
                 "true");
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java	Fri Sep 30 02:52:38 2016 -0700
@@ -42,6 +42,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.process.ExitCode;
 import jdk.test.lib.cli.CommandLineOptionTest;
@@ -52,7 +53,7 @@
     private static final String DEFAULT_VALUE = "false";
 
     private TestUseRTMLockingOptionOnSupportedConfig() {
-        super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java	Fri Sep 30 02:52:38 2016 -0700
@@ -42,6 +42,7 @@
 package compiler.rtm.cli;
 
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.process.ExitCode;
 import jdk.test.lib.cli.CommandLineOptionTest;
@@ -50,7 +51,7 @@
 public class TestUseRTMLockingOptionWithBiasedLocking
         extends CommandLineOptionTest {
     private TestUseRTMLockingOptionWithBiasedLocking() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java	Fri Sep 30 02:52:38 2016 -0700
@@ -45,6 +45,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.internal.misc.Unsafe;
 import jdk.test.lib.Asserts;
@@ -60,7 +61,7 @@
  */
 public class TestRTMAbortRatio extends CommandLineOptionTest {
     private TestRTMAbortRatio() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java	Fri Sep 30 02:52:38 2016 -0700
@@ -45,6 +45,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -59,7 +60,7 @@
  */
 public class TestRTMAbortThreshold extends CommandLineOptionTest {
     private TestRTMAbortThreshold() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java	Fri Sep 30 02:52:38 2016 -0700
@@ -47,6 +47,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.internal.misc.Unsafe;
 import jdk.test.lib.Asserts;
@@ -86,7 +87,7 @@
     private static final String RANGE_CHECK = "range_check";
 
     private TestRTMAfterNonRTMDeopt() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java	Fri Sep 30 02:52:38 2016 -0700
@@ -45,6 +45,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -66,7 +67,7 @@
             = AbortProvoker.DEFAULT_ITERATIONS / 2L;
 
     private TestRTMDeoptOnHighAbortRatio() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java	Fri Sep 30 02:52:38 2016 -0700
@@ -44,6 +44,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.internal.misc.Unsafe;
 import jdk.test.lib.Asserts;
@@ -66,7 +67,7 @@
     private static final long ABORT_THRESHOLD = LOCKING_THRESHOLD / 2L;
 
     private TestRTMDeoptOnLowAbortRatio() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java	Fri Sep 30 02:52:38 2016 -0700
@@ -44,6 +44,7 @@
 import compiler.testlibrary.rtm.AbortType;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -58,7 +59,7 @@
     private static final boolean INFLATE_MONITOR = true;
 
     private TestRTMLockingCalculationDelay() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java	Fri Sep 30 02:52:38 2016 -0700
@@ -45,6 +45,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.internal.misc.Unsafe;
 import jdk.test.lib.Asserts;
@@ -60,7 +61,7 @@
  */
 public class TestRTMLockingThreshold extends CommandLineOptionTest {
     private TestRTMLockingThreshold() {
-        super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     /**
--- a/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java	Fri Sep 30 02:52:38 2016 -0700
@@ -44,6 +44,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -64,7 +65,7 @@
     private static final boolean INFLATE_MONITOR = true;
 
     private TestRTMRetryCount() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java	Fri Sep 30 02:52:38 2016 -0700
@@ -45,6 +45,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -66,7 +67,7 @@
             = new int[] { 0, 100, 1_000, 1_000_000, 10_000_000 };
 
     private TestRTMSpinLoopCount() {
-        super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java	Fri Sep 30 02:52:38 2016 -0700
@@ -45,6 +45,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.internal.misc.Unsafe;
 import jdk.test.lib.Asserts;
@@ -64,7 +65,7 @@
  */
 public class TestRTMTotalCountIncrRate extends CommandLineOptionTest {
     private TestRTMTotalCountIncrRate() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java	Fri Sep 30 02:52:38 2016 -0700
@@ -45,6 +45,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -73,7 +74,7 @@
             = 2L * AbortProvoker.DEFAULT_ITERATIONS;
 
     private TestUseRTMAfterLockInflation() {
-        super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java	Fri Sep 30 02:52:38 2016 -0700
@@ -44,6 +44,7 @@
 import compiler.testlibrary.rtm.AbortType;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -56,7 +57,7 @@
  */
 public class TestUseRTMDeopt extends CommandLineOptionTest {
     private TestUseRTMDeopt() {
-        super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java	Fri Sep 30 02:52:38 2016 -0700
@@ -43,6 +43,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -63,7 +64,7 @@
  */
 public class TestUseRTMForInflatedLocks extends CommandLineOptionTest {
     private TestUseRTMForInflatedLocks() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java	Fri Sep 30 02:52:38 2016 -0700
@@ -44,6 +44,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -66,7 +67,7 @@
     private static final boolean INFLATE_MONITOR = false;
 
     private TestUseRTMForStackLocks() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java	Fri Sep 30 02:52:38 2016 -0700
@@ -46,6 +46,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -62,7 +63,7 @@
     private final static int LOCKING_TIME = 5000;
 
     private TestUseRTMXendForLockBusy() {
-        super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java	Fri Sep 30 02:52:38 2016 -0700
@@ -45,6 +45,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -62,7 +63,7 @@
  */
 public class TestNoRTMLockElidingOption extends CommandLineOptionTest {
     private TestNoRTMLockElidingOption() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java	Fri Sep 30 02:52:38 2016 -0700
@@ -46,6 +46,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -68,7 +69,7 @@
  */
 public class TestUseRTMLockElidingOption extends CommandLineOptionTest {
     private TestUseRTMLockElidingOption() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java	Fri Sep 30 02:52:38 2016 -0700
@@ -48,6 +48,7 @@
 import compiler.testlibrary.rtm.RTMLockingStatistics;
 import compiler.testlibrary.rtm.RTMTestBase;
 import compiler.testlibrary.rtm.predicate.SupportedCPU;
+import compiler.testlibrary.rtm.predicate.SupportedOS;
 import compiler.testlibrary.rtm.predicate.SupportedVM;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -67,7 +68,7 @@
 public class TestPrintPreciseRTMLockingStatistics
         extends CommandLineOptionTest {
     private TestPrintPreciseRTMLockingStatistics() {
-        super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+        super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
     }
 
     @Override
--- a/hotspot/test/compiler/stringopts/TestStringObjectInitialization.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/stringopts/TestStringObjectInitialization.java	Fri Sep 30 02:52:38 2016 -0700
@@ -67,6 +67,11 @@
         add(s + Arrays.toString(sArray) + " const ");
     }
 
+    public void reset() {
+        // Reset string to avoid OOMEs
+        myString = "";
+    }
+
     private static class Runner implements Runnable {
         private TestStringObjectInitialization test;
 
@@ -76,8 +81,9 @@
 
         public void run() {
             String[] array = {"a", "b", "c"};
-            for (int i = 0; i < 10000; ++i) {
+            for (int i = 0; i < 100_000; ++i) {
                 test.run("a", array);
+                test.reset();
             }
         }
     }
--- a/hotspot/test/compiler/testlibrary/rtm/RTMTestBase.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/RTMTestBase.java	Fri Sep 30 02:52:38 2016 -0700
@@ -241,7 +241,8 @@
                 "-XX:-TieredCompilation", "-XX:+UseRTMLocking",
                 CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
                 CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
-                "-Xbootclasspath/a:.", "-XX:+WhiteBoxAPI");
+                "-Xbootclasspath/a:.", "-XX:+WhiteBoxAPI",
+                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED");
 
         if (test != null) {
             for (String method : test.getMethodsToCompileNames()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedOS.java	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,48 @@
+/*
+ * 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.testlibrary.rtm.predicate;
+
+import jdk.test.lib.Platform;
+
+import java.util.function.BooleanSupplier;
+
+public class SupportedOS implements BooleanSupplier {
+    @Override
+    public boolean getAsBoolean() {
+        if (Platform.isAix()) {
+            // Actually, this works since AIX 7.1.3.30, but os.version property
+            // is set to 7.1.
+            return (Platform.getOsVersionMajor()  > 7) ||
+                   (Platform.getOsVersionMajor() == 7 && Platform.getOsVersionMinor() > 1);
+
+        } else if (Platform.isLinux()) {
+            if (Platform.isPPC()) {
+                return (Platform.getOsVersionMajor()  > 4) ||
+                       (Platform.getOsVersionMajor() == 4 && Platform.getOsVersionMinor() > 1);
+            }
+        }
+        return true;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/classfile/test_symbolTable.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,77 @@
+/*
+ * 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 "runtime/interfaceSupport.hpp"
+#include "classfile/symbolTable.hpp"
+#include "unittest.hpp"
+
+TEST(SymbolTable, temp_new_symbol) {
+  // Assert messages assume these symbols are unique, and the refcounts start at
+  // one, but code does not rely on this.
+  JavaThread* THREAD = JavaThread::current();
+  // the thread should be in vm to use locks
+  ThreadInVMfromNative ThreadInVMfromNative(THREAD);
+
+  Symbol* abc = SymbolTable::new_symbol("abc", CATCH);
+  int abccount = abc->refcount();
+  TempNewSymbol ss = abc;
+  ASSERT_EQ(ss->refcount(), abccount) << "only one abc";
+  ASSERT_EQ(ss->refcount(), abc->refcount()) << "should match TempNewSymbol";
+
+  Symbol* efg = SymbolTable::new_symbol("efg", CATCH);
+  Symbol* hij = SymbolTable::new_symbol("hij", CATCH);
+  int efgcount = efg->refcount();
+  int hijcount = hij->refcount();
+
+  TempNewSymbol s1 = efg;
+  TempNewSymbol s2 = hij;
+  ASSERT_EQ(s1->refcount(), efgcount) << "one efg";
+  ASSERT_EQ(s2->refcount(), hijcount) << "one hij";
+
+  // Assignment operator
+  s1 = s2;
+  ASSERT_EQ(hij->refcount(), hijcount + 1) << "should be two hij";
+  ASSERT_EQ(efg->refcount(), efgcount - 1) << "should be no efg";
+
+  s1 = ss; // s1 is abc
+  ASSERT_EQ(s1->refcount(), abccount + 1) << "should be two abc (s1 and ss)";
+  ASSERT_EQ(hij->refcount(), hijcount) << "should only have one hij now (s2)";
+
+  s1 = s1; // self assignment
+  ASSERT_EQ(s1->refcount(), abccount + 1) << "should still be two abc (s1 and ss)";
+
+  TempNewSymbol s3;
+  Symbol* klm = SymbolTable::new_symbol("klm", CATCH);
+  int klmcount = klm->refcount();
+  s3 = klm; // assignment
+  ASSERT_EQ(s3->refcount(), klmcount) << "only one klm now";
+
+  Symbol* xyz = SymbolTable::new_symbol("xyz", CATCH);
+  int xyzcount = xyz->refcount();
+  { // inner scope
+    TempNewSymbol s_inner = xyz;
+  }
+  ASSERT_EQ(xyz->refcount(), xyzcount - 1)
+          << "Should have been decremented by dtor in inner scope";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/gc/g1/test_g1IHOPControl.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,149 @@
+/*
+ * 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/g1CollectedHeap.inline.hpp"
+#include "gc/g1/g1IHOPControl.hpp"
+#include "gc/g1/g1Predictions.hpp"
+#include "unittest.hpp"
+
+static void test_update(G1IHOPControl* ctrl, double alloc_time,
+                        size_t alloc_amount, size_t young_size,
+                        double mark_time) {
+  for (int i = 0; i < 100; i++) {
+    ctrl->update_allocation_info(alloc_time, alloc_amount, young_size);
+    ctrl->update_marking_length(mark_time);
+  }
+}
+
+// @requires UseG1GC
+TEST_VM(G1StaticIHOPControl, simple) {
+  // Test requires G1
+  if (!UseG1GC) {
+    return;
+  }
+
+  const size_t initial_ihop = 45;
+
+  G1StaticIHOPControl ctrl(initial_ihop);
+  ctrl.update_target_occupancy(100);
+
+  size_t threshold = ctrl.get_conc_mark_start_threshold();
+  EXPECT_EQ(initial_ihop, threshold);
+
+  ctrl.update_allocation_info(100.0, 100, 100);
+  threshold = ctrl.get_conc_mark_start_threshold();
+  EXPECT_EQ(initial_ihop, threshold);
+
+  ctrl.update_marking_length(1000.0);
+  threshold = ctrl.get_conc_mark_start_threshold();
+  EXPECT_EQ(initial_ihop, threshold);
+
+  // Whatever we pass, the IHOP value must stay the same.
+  test_update(&ctrl, 2, 10, 10, 3);
+  threshold = ctrl.get_conc_mark_start_threshold();
+
+  EXPECT_EQ(initial_ihop, threshold);
+
+  test_update(&ctrl, 12, 10, 10, 3);
+  threshold = ctrl.get_conc_mark_start_threshold();
+
+  EXPECT_EQ(initial_ihop, threshold);
+}
+
+// @requires UseG1GC
+TEST_VM(G1AdaptiveIHOPControl, simple) {
+  // Test requires G1
+  if (!UseG1GC) {
+    return;
+  }
+
+  const size_t initial_threshold = 45;
+  const size_t young_size = 10;
+  const size_t target_size = 100;
+
+  // The final IHOP value is always
+  // target_size - (young_size + alloc_amount/alloc_time * marking_time)
+
+  G1Predictions pred(0.95);
+  G1AdaptiveIHOPControl ctrl(initial_threshold, &pred, 0, 0);
+  ctrl.update_target_occupancy(target_size);
+
+  // First "load".
+  const size_t alloc_time1 = 2;
+  const size_t alloc_amount1 = 10;
+  const size_t marking_time1 = 2;
+  const size_t settled_ihop1 = target_size
+          - (young_size + alloc_amount1 / alloc_time1 * marking_time1);
+
+  size_t threshold;
+  threshold = ctrl.get_conc_mark_start_threshold();
+
+  EXPECT_EQ(initial_threshold, threshold);
+
+  for (size_t i = 0; i < G1AdaptiveIHOPNumInitialSamples - 1; i++) {
+    ctrl.update_allocation_info(alloc_time1, alloc_amount1, young_size);
+    ctrl.update_marking_length(marking_time1);
+    // Not enough data yet.
+    threshold = ctrl.get_conc_mark_start_threshold();
+
+    ASSERT_EQ(initial_threshold, threshold) << "on step " << i;
+  }
+
+  test_update(&ctrl, alloc_time1, alloc_amount1, young_size, marking_time1);
+
+  threshold = ctrl.get_conc_mark_start_threshold();
+
+  EXPECT_EQ(settled_ihop1, threshold);
+
+  // Second "load". A bit higher allocation rate.
+  const size_t alloc_time2 = 2;
+  const size_t alloc_amount2 = 30;
+  const size_t marking_time2 = 2;
+  const size_t settled_ihop2 = target_size
+          - (young_size + alloc_amount2 / alloc_time2 * marking_time2);
+
+  test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
+
+  threshold = ctrl.get_conc_mark_start_threshold();
+
+  EXPECT_LT(threshold, settled_ihop1);
+
+  // Third "load". Very high (impossible) allocation rate.
+  const size_t alloc_time3 = 1;
+  const size_t alloc_amount3 = 50;
+  const size_t marking_time3 = 2;
+  const size_t settled_ihop3 = 0;
+
+  test_update(&ctrl, alloc_time3, alloc_amount3, young_size, marking_time3);
+  threshold = ctrl.get_conc_mark_start_threshold();
+
+  EXPECT_EQ(settled_ihop3, threshold);
+
+  // And back to some arbitrary value.
+  test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
+
+  threshold = ctrl.get_conc_mark_start_threshold();
+
+  EXPECT_GT(threshold, settled_ihop3);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/oops/test_arrayOop.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 1997, 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 "oops/arrayOop.hpp"
+#include "oops/oop.inline.hpp"
+#include "unittest.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+class arrayOopDescTest {
+ public:
+
+  static int header_size_in_bytes() {
+    return arrayOopDesc::header_size_in_bytes();
+  }
+};
+
+static bool check_max_length_overflow(BasicType type) {
+  julong length = arrayOopDesc::max_array_length(type);
+  julong bytes_per_element = type2aelembytes(type);
+  julong bytes = length * bytes_per_element
+          + arrayOopDescTest::header_size_in_bytes();
+  return (julong) (size_t) bytes == bytes;
+}
+
+TEST(arrayOopDesc, boolean) {
+  ASSERT_PRED1(check_max_length_overflow, T_BOOLEAN);
+}
+
+TEST(arrayOopDesc, char) {
+  ASSERT_PRED1(check_max_length_overflow, T_CHAR);
+}
+
+TEST(arrayOopDesc, float) {
+  ASSERT_PRED1(check_max_length_overflow, T_FLOAT);
+}
+
+TEST(arrayOopDesc, double) {
+  ASSERT_PRED1(check_max_length_overflow, T_DOUBLE);
+}
+
+TEST(arrayOopDesc, byte) {
+  ASSERT_PRED1(check_max_length_overflow, T_BYTE);
+}
+
+TEST(arrayOopDesc, short) {
+  ASSERT_PRED1(check_max_length_overflow, T_SHORT);
+}
+
+TEST(arrayOopDesc, int) {
+  ASSERT_PRED1(check_max_length_overflow, T_INT);
+}
+
+TEST(arrayOopDesc, long) {
+  ASSERT_PRED1(check_max_length_overflow, T_LONG);
+}
+
+TEST(arrayOopDesc, object) {
+  ASSERT_PRED1(check_max_length_overflow, T_OBJECT);
+}
+
+TEST(arrayOopDesc, array) {
+  ASSERT_PRED1(check_max_length_overflow, T_ARRAY);
+}
+
+TEST(arrayOopDesc, narrowOop) {
+  ASSERT_PRED1(check_max_length_overflow, T_NARROWOOP);
+}
+// T_VOID and T_ADDRESS are not supported by max_array_length()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/oops/test_instanceKlass.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,47 @@
+/*
+ * 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 "classfile/symbolTable.hpp"
+#include "classfile/systemDictionary.hpp"
+#include "memory/resourceArea.hpp"
+#include "oops/instanceKlass.hpp"
+#include "unittest.hpp"
+
+// Tests InstanceKlass::package_from_name()
+TEST_VM(InstanceKlass, null_symbol) {
+  ResourceMark rm;
+  TempNewSymbol package_sym = InstanceKlass::package_from_name(NULL, NULL);
+  ASSERT_TRUE(package_sym == NULL) << "Wrong package for NULL symbol";
+}
+
+// Tests for InstanceKlass::is_class_loader_instance_klass() function
+TEST_VM(InstanceKlass, class_loader_class) {
+  InstanceKlass* klass = SystemDictionary::ClassLoader_klass();
+  ASSERT_TRUE(klass->is_class_loader_instance_klass());
+}
+
+TEST_VM(InstanceKlass, string_klass) {
+  InstanceKlass* klass = SystemDictionary::String_klass();
+  ASSERT_TRUE(!klass->is_class_loader_instance_klass());
+}
--- a/hotspot/test/native/runtime/test_instanceKlass.cpp	Thu Sep 29 17:23:47 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * 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 "classfile/symbolTable.hpp"
-#include "memory/resourceArea.hpp"
-#include "oops/instanceKlass.hpp"
-#include "unittest.hpp"
-
-// Tests InstanceKlass::package_from_name()
-TEST_VM(instanceKlass, null_symbol) {
-  ResourceMark rm;
-  TempNewSymbol package_sym = InstanceKlass::package_from_name(NULL, NULL);
-  ASSERT_TRUE(package_sym == NULL) << "Wrong package for NULL symbol";
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/utilities/test_chunkedList.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,130 @@
+/*
+ * 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
+ * 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 "unittest.hpp"
+#include "utilities/chunkedList.hpp"
+
+class Metadata;
+
+template <typename T>
+class TestChunkedList {
+  typedef ChunkedList<T, mtOther> ChunkedListT;
+
+ public:
+
+  static void testEmpty() {
+    ChunkedListT buffer;
+    ASSERT_EQ((size_t) 0, buffer.size());
+  }
+
+  static void testFull() {
+    ChunkedListT buffer;
+    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+      buffer.push((T) i);
+    }
+    ASSERT_EQ((size_t) ChunkedListT::BufferSize, buffer.size());
+    ASSERT_TRUE(buffer.is_full());
+  }
+
+  static void testSize() {
+    ChunkedListT buffer;
+    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+      ASSERT_EQ((size_t) i, buffer.size());
+      buffer.push((T) i);
+      ASSERT_EQ((size_t) (i + 1), buffer.size());
+    }
+  }
+
+  static void testClear() {
+    ChunkedListT buffer;
+
+    buffer.clear();
+    ASSERT_EQ((size_t) 0, buffer.size());
+
+    for (uintptr_t i = 0; i < ChunkedListT::BufferSize / 2; i++) {
+      buffer.push((T) i);
+    }
+    buffer.clear();
+    ASSERT_EQ((size_t) 0, buffer.size());
+
+    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+      buffer.push((T) i);
+    }
+    buffer.clear();
+    ASSERT_EQ((size_t) 0, buffer.size());
+  }
+
+  static void testAt() {
+    ChunkedListT buffer;
+
+    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+      buffer.push((T) i);
+      ASSERT_EQ((T) i, buffer.at(i));
+    }
+
+    for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
+      ASSERT_EQ((T) i, buffer.at(i));
+    }
+  }
+};
+
+TEST(ChunkedList, metadata_empty) {
+  TestChunkedList<Metadata*>::testEmpty();
+}
+
+TEST(ChunkedList, metadata_full) {
+  TestChunkedList<Metadata*>::testFull();
+}
+
+TEST(ChunkedList, metadata_size) {
+  TestChunkedList<Metadata*>::testSize();
+}
+
+TEST(ChunkedList, metadata_clear) {
+  TestChunkedList<Metadata*>::testSize();
+}
+
+TEST(ChunkedList, metadata_at) {
+  TestChunkedList<Metadata*>::testAt();
+}
+
+TEST(ChunkedList, size_t_empty) {
+  TestChunkedList<size_t>::testEmpty();
+}
+
+TEST(ChunkedList, size_t_full) {
+  TestChunkedList<size_t>::testFull();
+}
+
+TEST(ChunkedList, size_t_size) {
+  TestChunkedList<size_t>::testSize();
+}
+
+TEST(ChunkedList, size_t_clear) {
+  TestChunkedList<size_t>::testSize();
+}
+
+TEST(ChunkedList, size_t_at) {
+  TestChunkedList<size_t>::testAt();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/utilities/test_json.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,515 @@
+/*
+ * 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 "prims/jvm.h"
+#include "utilities/json.hpp"
+#include "unittest.hpp"
+
+class JSON_GTest : public JSON {
+public:
+    static void test(const char* json, bool valid);
+
+private:
+    JSON_GTest(const char* text);
+
+    void log(uint level, const char* format, ...) ATTRIBUTE_PRINTF(3, 4);
+
+    bool callback(JSON_TYPE t, JSON_VAL* v, uint level);
+    JSON_TYPE prev;
+};
+
+void JSON_GTest::test(const char* text, bool should_pass) {
+    JSON_GTest json(text);
+    if (should_pass) {
+        ASSERT_TRUE(json.valid()) << "failed on a valid json string";
+    } else {
+        ASSERT_FALSE(json.valid()) << "succeeded on an invalid json string";
+    }
+}
+
+JSON_GTest::JSON_GTest(const char* text) : JSON(text, false, tty) {
+    prev = JSON_NONE;
+    parse();
+}
+
+TEST(utilities, json_curly_braces) {
+    JSON_GTest::test("{}", true);
+}
+
+TEST(utilities, json_brackets) {
+    JSON_GTest::test("[]", true);
+}
+
+TEST(utilities, json_space_braces) {
+    JSON_GTest::test("  {  }  ", true);
+}
+
+TEST(utilities, json_space_bracketes) {
+    JSON_GTest::test("  [  ]  ", true);
+}
+
+TEST(utilities, json_quoted_error) {
+    JSON_GTest::test("\"error\"", false);
+}
+
+TEST(utilities, json_error_string) {
+    JSON_GTest::test("error", false);
+}
+
+TEST(utilities, json_simple_integer) {
+    JSON_GTest::test("1", false);
+}
+
+TEST(utilities, json_siple_float) {
+    JSON_GTest::test("1.2", false);
+}
+
+TEST(utilities, json_simple_boolean_true) {
+    JSON_GTest::test("true", false);
+}
+
+TEST(utilities, json_simple_boolean_false) {
+    JSON_GTest::test("false", false);
+}
+
+TEST(utilities, json_simple_null) {
+    JSON_GTest::test("null", false);
+}
+
+TEST(utilities, json_one_element_int_array) {
+    JSON_GTest::test("[ 1 ]", true);
+}
+
+TEST(utilities, json_int_array) {
+    JSON_GTest::test("[ 1, ]", true);
+}
+
+TEST(utilities, json_one_element_bool_array) {
+    JSON_GTest::test("[ true ]", true);
+}
+
+TEST(utilities, json_bool_array) {
+    JSON_GTest::test("[ true, ]", true);
+}
+
+TEST(utilities, json_one_element_false_array) {
+    JSON_GTest::test("[ false ]", true);
+}
+
+TEST(utilities, json_false_bool_array) {
+    JSON_GTest::test("[ false, ]", true);
+}
+
+TEST(utilities, json_one_null_array) {
+    JSON_GTest::test("[ null ]", true);
+}
+
+TEST(utilities, json_null_array) {
+    JSON_GTest::test("[ null, ]", true);
+}
+
+TEST(utilities, json_one_empty_string_array) {
+    JSON_GTest::test("[ \"\" ]", true);
+}
+
+TEST(utilities, json_empty_string_array) {
+    JSON_GTest::test("[ \"\", ]", true);
+}
+
+TEST(utilities, json_single_string_array) {
+    JSON_GTest::test("[ \"elem1\" ]", true);
+}
+
+TEST(utilities, json_string_comma_arrray) {
+    JSON_GTest::test("[ \"elem1\", ]", true);
+}
+
+TEST(utilities, json_two_strings_array) {
+    JSON_GTest::test("[ \"elem1\", \"elem2\" ]", true);
+}
+
+TEST(utilities, json_two_strings_comma_array) {
+    JSON_GTest::test("[ \"elem1\", \"elem2\", ]", true);
+}
+
+TEST(utilities, json_curly_braces_outside) {
+    JSON_GTest::test("[ \"elem1\" ] { }", false);
+}
+
+TEST(utilities, json_element_in_array) {
+    JSON_GTest::test("[ elem1, \"elem2\" ]", false);
+}
+
+TEST(utilities, json_incorrect_end_array) {
+    JSON_GTest::test("[ \"elem1\"", false);
+}
+
+TEST(utilities, json_incorrect_string_end) {
+    JSON_GTest::test("[ \"elem1 ]", false);
+}
+
+TEST(utilities, json_incorrect_end_of_two_elements_array) {
+    JSON_GTest::test("[ \"elem1\", \"elem2\"", false);
+}
+
+TEST(utilities, json_incorrect_bool_true_array) {
+    JSON_GTest::test("[ truefoo ]", false);
+}
+
+TEST(utilities, json_incorrect_bool_false_array) {
+    JSON_GTest::test("[ falsefoo ]", false);
+}
+
+TEST(utilities, json_incorrect_null_array) {
+    JSON_GTest::test("[ nullfoo ]", false);
+}
+
+TEST(utilities, json_key_pair) {
+    JSON_GTest::test("{ key : 1 }", true);
+}
+
+TEST(utilities, json_key_pair_comma) {
+    JSON_GTest::test("{ key : 1, }", true);
+}
+
+TEST(utilities, json_bool_true_key) {
+    JSON_GTest::test("{ key : true }", true);
+}
+
+TEST(utilities, json_bool_true_key_comma) {
+    JSON_GTest::test("{ key : true, }", true);
+}
+
+TEST(utilities, json_bool_false_key) {
+    JSON_GTest::test("{ key : false }", true);
+}
+
+TEST(utilities, json_bool_false_key_comma) {
+    JSON_GTest::test("{ key : false, }", true);
+}
+
+TEST(utilities, json_null_key) {
+    JSON_GTest::test("{ key : null }", true);
+}
+
+TEST(utilities, json_null_key_comma) {
+    JSON_GTest::test("{ key : null, }", true);
+}
+
+TEST(utilities, json_pair_of_empty_strings) {
+    JSON_GTest::test("{ \"\" : \"\" }", true);
+}
+
+TEST(utilities, json_pair_of_empty_strings_comma) {
+    JSON_GTest::test("{ \"\" : \"\", }", true);
+}
+
+TEST(utilities, json_pair_of_strings) {
+    JSON_GTest::test("{ \"key1\" : \"val1\" }", true);
+}
+
+TEST(utilities, json_pair_of_strings_comma) {
+    JSON_GTest::test("{ \"key1\" : \"val1\", }", true);
+}
+
+TEST(utilities, json_two_pairs_of_strings) {
+    JSON_GTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\" }", true);
+}
+
+TEST(utilities, json_two_pairs_of_strings_comma) {
+    JSON_GTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\", }", true);
+}
+
+TEST(utilities, json_array_outside) {
+    JSON_GTest::test("{ \"key\" : \"val\" } [ \"error\" ]", false);
+}
+
+TEST(utilities, json_incorrect_object_end) {
+    JSON_GTest::test("{ \"key\" : \"val\" ", false);
+}
+
+TEST(utilities, json_empty_comment) {
+    JSON_GTest::test("/**/ { }", true);
+}
+
+TEST(utilities, json_space_comment) {
+    JSON_GTest::test("/* */ { }", true);
+}
+
+TEST(utilities, json_comment) {
+    JSON_GTest::test("/*foo*/ { }", true);
+}
+
+TEST(utilities, json_star_comment) {
+    JSON_GTest::test("/* *foo */ { }", true);
+}
+
+TEST(utilities, json_stars_comment) {
+    JSON_GTest::test("/* *foo* */ { }", true);
+}
+
+TEST(utilities, json_special_comment) {
+    JSON_GTest::test("/* /*foo */ { }", true);
+}
+
+TEST(utilities, json_comment_after) {
+    JSON_GTest::test("{ } /* foo */", true);
+}
+
+TEST(utilities, json_comment_after_and_space) {
+    JSON_GTest::test("{ } /* foo */ ", true);
+}
+
+TEST(utilities, json_one_line_empty_comment_after) {
+    JSON_GTest::test("{ } //", true);
+}
+
+TEST(utilities, json_one_line_space_comment_after) {
+    JSON_GTest::test("{ } // ", true);
+}
+
+TEST(utilities, json_one_line_comment_after) {
+    JSON_GTest::test("{ } // foo", true);
+}
+
+TEST(utilities, json_incorrect_multiline_comment) {
+    JSON_GTest::test("/* * / { }", false);
+}
+
+TEST(utilities, json_incorrect_multiline_comment_begin) {
+    JSON_GTest::test("/ * */ { }", false);
+}
+
+TEST(utilities, json_oneline_comment_only) {
+    JSON_GTest::test("// { }", false);
+}
+
+TEST(utilities, json_multiline_comment_only) {
+    JSON_GTest::test("/* { } */", false);
+}
+
+TEST(utilities, json_multiline_comment_2) {
+    JSON_GTest::test("/* { } */ ", false);
+}
+
+TEST(utilities, json_incorrectly_commented_object) {
+    JSON_GTest::test("/* { } ", false);
+}
+
+TEST(utilities, json_missing_multiline_end) {
+    JSON_GTest::test("{ } /* ", false);
+}
+
+TEST(utilities, json_missing_multiline_slash) {
+    JSON_GTest::test("/* { } *", false);
+}
+
+TEST(utilities, json_commented_object_end) {
+    JSON_GTest::test("{ /* } */", false);
+}
+
+TEST(utilities, json_commented_array_end) {
+    JSON_GTest::test("[ /* ] */", false);
+}
+
+TEST(utilities, json_missing_object_end) {
+    JSON_GTest::test("{ key : \"val\", /* } */", false);
+}
+
+TEST(utilities, json_missing_array_end) {
+    JSON_GTest::test("[ \"val\", /* ] */", false);
+}
+
+TEST(utilities, json_key_values_1) {
+    JSON_GTest::test("/* comment */{ key1 : { \"key2\" : { \"key3\" : [ \"elem1\", \"elem2\","
+            "{ \"key4\" : null }, 3 , 2 , 1 , 0 , -1 , -2 , -3 , true, false, null, ] }, \"key5\""
+            " : true }, \"key6\" : [ \"☃\" ], key7 : \"val\",}", true);
+}
+
+TEST(utilities, json_key_values_2) {
+    JSON_GTest::test("/* comment */ { \"key1\" : { \"key2\" : { \"key3\" : [ \"elem1\", \"elem2\","
+            "{ \"key4\" : null }, 3 , 2 , 1 , 0 , -1 , -2 , -3 , true, false, null, ] }, \"key5\""
+            " : true }, \"key6\" : [ \"☃\" ], key7 : \"val\",}", true);
+}
+
+TEST(utilities, json_quoted_symbols) {
+    JSON_GTest::test("/*comment*/{\"ff1 fsd\":{\"☃\":{\"☃\":[\"☃\",\"☃\"]},"
+            "\"☃\":true},\"☃\":[\"☃\"],\"foo\":\"☃\",}", true);
+}
+
+TEST(utilities, json_incorrect_key) {
+    JSON_GTest::test("/* comment */ { key1 error : { \"☃\" : { \"☃\" : [ \"☃\","
+            " \"☃\" ] }, \"☃\" : true }, \"baz\" : [ \"☃\" ], foo : \"☃\",}",
+            false); // first key needs to be quoted since it contains a space
+}
+
+TEST(utilities, json_array_with_newline) {
+    JSON_GTest::test("[\n]", true);
+}
+
+TEST(utilities, json_directives_file) {
+    JSON_GTest::test(
+            "[" "\n"
+            "   {"
+            "         // pattern to match against class+method+signature" "\n"
+            "         // leading and trailing wildcard (*) allowed" "\n"
+            "         match: \"foo.bar.*\"," "\n"
+            " " "\n"
+            "         // override defaults for specified compiler" "\n"
+            "         // we may differentiate between levels too. TBD." "\n"
+            "         c1:  {" "\n"
+            "           //override c1 presets " "\n"
+            "           array_bounds_check_removal: false" "\n"
+            "         }," "\n"
+            "" "\n"
+            "         c2: {" "\n"
+            "           // control inlining of method" "\n"
+            "           // + force inline, - dont inline" "\n"
+            "           inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
+            "         }," "\n"
+            "" "\n"
+            "         // directives outside a specific preset applies to all compilers" "\n"
+            "         inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
+            "         print_assembly: true," "\n"
+            "         verify_oopmaps: true," "\n"
+            "         max_loop_unrolling: 5" "\n"
+            "   }," "\n"
+            "   {" "\n"
+            "         // matching several patterns require an array" "\n"
+            "         match: [\"baz.*\",\"frob*\"]," "\n"
+            "" "\n"
+            "         // only enable c1 for this directive" "\n"
+            "         // all enabled by default. Command disables all not listed" "\n"
+            "         enable: \"c1\"," "\n"
+            "" "\n"
+            "         // applies to all compilers" "\n"
+            "         // + force inline, - dont inline" "\n"
+            "         inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
+            "         print_inlining: true," "\n"
+            "" "\n"
+            "         // force matching compiles to be blocking/syncronous" "\n"
+            "         blocking_compile: true" "\n"
+            "   }," "\n"
+            "]" "\n", true);
+}
+
+void JSON_GTest::log(uint indent, const char* format, ...) {
+    if (prev != JSON_KEY) {
+        for (uint i = 0; i < indent; i++) {
+            _st->print("  ");
+        }
+    }
+    va_list args;
+    va_start(args, format);
+    _st->vprint(format, args);
+    va_end(args);
+}
+
+bool JSON_GTest::callback(JSON_TYPE t, JSON_VAL* v, uint rlevel) {
+    switch (t) {
+        case JSON_OBJECT_BEGIN:
+            log(rlevel, "{\n");
+            prev = JSON_NONE; // Only care about JSON_KEY, to indent correctly
+            return true;
+
+        case JSON_OBJECT_END:
+            log(rlevel, "},\n");
+            prev = JSON_NONE;
+            return true;
+
+        case JSON_ARRAY_BEGIN:
+            log(rlevel, "[\n");
+            prev = JSON_NONE;
+            return true;
+
+        case JSON_ARRAY_END:
+            log(rlevel, "],\n");
+            prev = JSON_NONE;
+            return true;
+
+        case JSON_KEY:
+            for (uint i = 0; i < rlevel; i++) {
+                _st->print("  ");
+            }
+            _st->print("<key>");
+            for (size_t i = 0; i < v->str.length; i++) {
+                u_char c = v->str.start[i];
+                if (c == 0) {
+                    return false;
+                }
+                _st->print("%c", c);
+            }
+            _st->print(" : ");
+            prev = JSON_KEY;
+            return true;
+
+        case JSON_STRING:
+            if (prev != JSON_KEY) {
+                for (uint i = 0; i < rlevel; i++) {
+                    _st->print("  ");
+                }
+            }
+            _st->print("<str>");
+            for (size_t i = 0; i < v->str.length; i++) {
+                u_char c = v->str.start[i];
+                if (c == 0) {
+                    return false;
+                }
+                _st->print("%c", c);
+            }
+            _st->print(",\n");
+            prev = JSON_NONE;
+            return true;
+
+        case JSON_NUMBER_INT:
+            log(rlevel, "<int>%" PRId64 ",\n", v->int_value);
+            prev = JSON_NONE;
+            return true;
+
+        case JSON_NUMBER_FLOAT:
+            log(rlevel, "<double>%lf,\n", v->double_value);
+            prev = JSON_NONE;
+            return true;
+
+        case JSON_TRUE:
+            log(rlevel, "<true>,\n");
+            prev = JSON_NONE;
+            return true;
+
+        case JSON_FALSE:
+            log(rlevel, "<false>,\n");
+            prev = JSON_NONE;
+            return true;
+
+        case JSON_NULL:
+            log(rlevel, "<null>,\n");
+            prev = JSON_NONE;
+            return true;
+
+        default:
+            error(INTERNAL_ERROR, "unknown JSON type");
+            return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/native/utilities/test_linkedlist.cpp	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,121 @@
+/*
+ * 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 "unittest.hpp"
+#include "utilities/linkedlist.hpp"
+
+class Integer : public StackObj {
+ private:
+  int _value;
+ public:
+
+  Integer(int i) : _value(i) {
+  }
+
+  int value() const {
+    return _value;
+  }
+
+  bool equals(const Integer& i) const {
+    return _value == i.value();
+  }
+
+  static int compare(const Integer& i1, const Integer& i2) {
+    return i1.value() - i2.value();
+  }
+};
+
+static void check_list_values(const int* expected, const LinkedList<Integer>* list) {
+  LinkedListNode<Integer>* head = list->head();
+  int index = 0;
+  while (head != NULL) {
+    ASSERT_EQ(expected[index], head->peek()->value())
+            << "Unexpected value at index " << index;
+    head = head->next();
+    index++;
+  }
+}
+
+const Integer one(1), two(2), three(3), four(4), five(5), six(6);
+
+// Test regular linked list
+TEST(LinkedList, simple) {
+  LinkedListImpl<Integer, ResourceObj::C_HEAP, mtTest> ll;
+
+  ASSERT_TRUE(ll.is_empty()) << "Start with empty list";
+
+  ll.add(six);
+  ASSERT_TRUE(!ll.is_empty()) << "Should not be empty";
+
+  Integer* i = ll.find(six);
+  ASSERT_TRUE(i != NULL) << "Should find it";
+  ASSERT_EQ(six.value(), i->value()) << "Should be 6";
+
+  i = ll.find(three);
+  ASSERT_EQ(NULL, i) << "Not in the list";
+
+  LinkedListNode<Integer>* node = ll.find_node(six);
+  ASSERT_TRUE(node != NULL) << "6 is in the list";
+
+  ll.insert_after(three, node);
+  ll.insert_before(one, node);
+  int expected[3] = {1, 6, 3};
+  check_list_values(expected, &ll);
+}
+
+// Test sorted linked list
+TEST(SortedLinkedList, simple) {
+  LinkedListImpl<Integer, ResourceObj::C_HEAP, mtTest> ll;
+  ll.add(one);
+  ll.add(six);
+  ll.add(three);
+  ll.add(two);
+  ll.add(four);
+  ll.add(five);
+
+  SortedLinkedList<Integer, Integer::compare, ResourceObj::C_HEAP, mtTest> sl;
+  ASSERT_TRUE(sl.is_empty()) << "Start with empty list";
+
+  size_t ll_size = ll.size();
+  sl.move(&ll);
+  size_t sl_size = sl.size();
+
+  ASSERT_EQ(ll_size, sl_size) << "Should be the same size";
+  ASSERT_TRUE(ll.is_empty()) << "No more entries";
+
+  // sorted result
+  int sorted_result[] = {1, 2, 3, 4, 5, 6};
+  check_list_values(sorted_result, &sl);
+  if (HasFatalFailure()) {
+    return;
+  }
+
+  LinkedListNode<Integer>* node = sl.find_node(four);
+  ASSERT_TRUE(node != NULL) << "4 is in the list";
+  sl.remove_before(node);
+  sl.remove_after(node);
+  int remains[] = {1, 2, 4, 6};
+  check_list_values(remains, &sl);
+}
--- a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java	Fri Sep 30 02:52:38 2016 -0700
@@ -34,14 +34,17 @@
  *          jdk.hotspot.agent/sun.jvm.hotspot.runtime
  *          jdk.hotspot.agent/sun.jvm.hotspot.tools
  *          java.management
- * @build SASymbolTableTestAgent SASymbolTableTestAttachee
+ * @build SASymbolTableTestAgent
  * @run main SASymbolTableTest
  */
 
+import java.util.Arrays;
+import java.util.List;
 import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.JDKToolFinder;
 import jdk.test.lib.Platform;
+import jdk.test.lib.apps.LingeredApp;
 
 /*
  * The purpose of this test is to validate that we can use SA to
@@ -53,6 +56,7 @@
  */
 public class SASymbolTableTest {
     static String jsaName = "./SASymbolTableTest.jsa";
+    private static LingeredApp theApp = null;
 
     public static void main(String[] args) throws Exception {
         if (!Platform.shouldSAAttach()) {
@@ -78,50 +82,44 @@
     private static void run(boolean useArchive) throws Exception {
         String flag = useArchive ? "auto" : "off";
 
-        // (1) Launch the attachee process
-        ProcessBuilder attachee = ProcessTools.createJavaProcessBuilder(
-            "-XX:+UnlockDiagnosticVMOptions",
-            "-XX:SharedArchiveFile=" + jsaName,
-            "-Xshare:" + flag,
-            "-showversion",                // so we can see "sharing" in the output
-            "SASymbolTableTestAttachee");
+        try {
+            // (1) Launch the attachee process
+            System.out.println("Starting LingeredApp");
+            List<String> vmOpts = Arrays.asList(
+                    "-XX:+UnlockDiagnosticVMOptions",
+                    "-XX:SharedArchiveFile=" + jsaName,
+                    "-Xshare:" + flag,
+                    "-showversion");                // so we can see "sharing" in the output
 
-        final Process p = attachee.start();
+            theApp = LingeredApp.startApp(vmOpts);
 
-        // (2) Launch the agent process
-        long pid = p.getPid();
-        System.out.println("Attaching agent " + pid);
-        ProcessBuilder tool = ProcessTools.createJavaProcessBuilder(
-            "--add-modules=jdk.hotspot.agent",
-            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
-            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
-            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
-            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
-            "SASymbolTableTestAgent",
-            Long.toString(pid));
-        OutputAnalyzer output = ProcessTools.executeProcess(tool);
-        System.out.println(output.getOutput());
-        output.shouldHaveExitValue(0);
-
-        Thread t = new Thread() {
-                public void run() {
-                    try {
-                        OutputAnalyzer output = new OutputAnalyzer(p);
-                        System.out.println("STDOUT[");
-                        System.out.print(output.getStdout());
-                        System.out.println("]");
-                        System.out.println("STDERR[");
-                        System.out.print(output.getStderr());
-                        System.out.println("]");
-                    } catch (Throwable t) {
-                        t.printStackTrace();
-                    }
-                }
-            };
-        t.start();
-
-        Thread.sleep(2 * 1000);
-        p.destroy();
-        t.join();
+            // (2) Launch the agent process
+            long pid = theApp.getPid();
+            System.out.println("Attaching agent to " + pid );
+            ProcessBuilder tool = ProcessTools.createJavaProcessBuilder(
+                    "--add-modules=jdk.hotspot.agent",
+                    "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
+                    "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
+                    "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
+                    "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
+                    "SASymbolTableTestAgent",
+                    Long.toString(pid));
+            OutputAnalyzer output = ProcessTools.executeProcess(tool);
+            System.out.println("STDOUT[");
+            System.out.println(output.getOutput());
+            if (output.getStdout().contains("connected too early")) {
+                System.out.println("SymbolTable not created by VM - test skipped");
+                return;
+            }
+            System.out.println("]");
+            System.out.println("STDERR[");
+            System.out.print(output.getStderr());
+            System.out.println("]");
+            output.shouldHaveExitValue(0);
+        } catch (Exception ex) {
+            throw new RuntimeException("Test ERROR " + ex, ex);
+        } finally {
+            LingeredApp.stopApp(theApp);
+        }
     }
 }
--- a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java	Fri Sep 30 02:52:38 2016 -0700
@@ -112,31 +112,35 @@
 
     public void run() {
         System.out.println("SASymbolTableTestAgent: starting");
-        VM vm = VM.getVM();
-        SymbolTable table = vm.getSymbolTable();
+        try {
+            VM vm = VM.getVM();
+            SymbolTable table = vm.getSymbolTable();
 
-        // (a) These are names that are likely to exist in the symbol table
-        //     of a JVM after start-up. They were taken from vmSymbols.hpp
-        //     during the middle of JDK9 development.
-        //
-        //     The purpose is not to check that each name must exist (a future
-        //     version of JDK may not preload some of the classes).
-        //
-        //     The purpose of this loops is to ensure that we check a lot of symbols,
-        //     so we will (most likely) hit on both VALUE_ONLY_BUCKET_TYPE and normal bucket type
-        //     in CompactHashTable.probe().
-        for (String n : commonNames) {
-            Symbol s = table.probe(n);
-            System.out.format("%-40s = %s\n", n, s);
-        }
+            // (a) These are names that are likely to exist in the symbol table
+            //     of a JVM after start-up. They were taken from vmSymbols.hpp
+            //     during the middle of JDK9 development.
+            //
+            //     The purpose is not to check that each name must exist (a future
+            //     version of JDK may not preload some of the classes).
+            //
+            //     The purpose of this loops is to ensure that we check a lot of symbols,
+            //     so we will (most likely) hit on both VALUE_ONLY_BUCKET_TYPE and normal bucket type
+            //     in CompactHashTable.probe().
+            for (String n : commonNames) {
+                Symbol s = table.probe(n);
+                System.out.format("%-40s = %s\n", n, s);
+            }
 
-        System.out.println("======================================================================");
+            System.out.println("======================================================================");
 
-        // (b) Also test a few strings that are known to not exist in the table. This will
-        //     both the compact table (if it exists) and the regular table to be walked.
-        for (String n : badNames) {
-            Symbol s = table.probe(n);
-            System.out.format("%-40s = %s\n", n, s);
+            // (b) Also test a few strings that are known to not exist in the table. This will
+            //     both the compact table (if it exists) and the regular table to be walked.
+            for (String n : badNames) {
+                Symbol s = table.probe(n);
+                System.out.format("%-40s = %s\n", n, s);
+            }
+        } catch (NullPointerException e) {
+            System.out.println("connected too early -- please try again");
         }
     }
 }
--- a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAttachee.java	Thu Sep 29 17:23:47 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * This class is launched in a sub-process by the main test,
- * SASymbolTableTest.java.
- *
- * This class does nothing in particular. It just sleeps for 120
- * seconds so SASymbolTableTestAgent can have a chance to examine its
- * SymbolTable. This process should be killed by the parent process
- * after SASymbolTableTestAgent has completed testing.
- */
-public class SASymbolTableTestAttachee {
-    public static void main(String args[]) throws Throwable {
-        System.out.println("SASymbolTableTestAttachee: sleeping to wait for SA tool to attach ...");
-        Thread.sleep(120 * 1000);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/lambda-features/CyclicInterfaceInit.java	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,80 @@
+/*
+ * 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 8163969
+ * @summary Interface initialization was crashing on this because the wrong class was getting
+ * initialization error.
+ * @run main CyclicInterfaceInit
+ */
+/**
+ * This snippet crashes with
+ * - Java(TM) SE Runtime Environment (8.0_101-b13) (build 1.8.0_101-b13)
+ */
+public class CyclicInterfaceInit {
+
+    interface Base {
+        static final Object CONST = new Target(){}.someMethod();
+
+        default void important() {
+            // Super interfaces with default methods get initialized (JLS 12.4.1)
+        }
+    }
+
+   static boolean out(String c) {
+       System.out.println("initializing " + c);
+       return true;
+    }
+
+    interface Target extends Base {
+        boolean v = CyclicInterfaceInit.out("Target");
+        default Object someMethod() {
+            throw new RuntimeException();
+        }
+        // Target can be fully initialized before initializating Base because Target doesn't
+        // initiate the initialization of Base.
+    }
+
+    static class InnerBad implements Target {}
+
+    public static void main(String[] args) {
+        try {
+          new Target() {};  // Creates inner class that causes initialization of super interfaces
+        } catch (ExceptionInInitializerError e) {
+          System.out.println("ExceptionInInitializerError thrown as expected");
+        }
+        // Try again, InnerBad instantiation should throw NoClassdefFoundError
+        // because Base is marked erroneous due to previous exception during initialization
+        try {
+          InnerBad ig = new InnerBad();
+          throw new RuntimeException("FAILED- initialization of InnerBad should throw NCDFE");
+        } catch (NoClassDefFoundError e) {
+          System.out.println("NoClassDefFoundError thrown as expected");
+        }
+        // Target is already initialized.
+        System.out.println("Target.v is " + Target.v);
+        // shouldn't throw any exceptions.
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/lambda-features/InterfaceInitializationStates.java	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,202 @@
+/*
+ * 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 8163969
+ * @summary Test interface initialization states and when certain interfaces are initialized
+ * in the presence of initialization errors.
+ * @run main InterfaceInitializationStates
+ */
+
+import java.util.List;
+import java.util.Arrays;
+import java.util.ArrayList;
+
+public class InterfaceInitializationStates {
+
+    static List<Class<?>> cInitOrder = new ArrayList<>();
+
+    // K interface with a default method has an initialization error
+    interface K {
+        boolean v = InterfaceInitializationStates.out(K.class);
+        static final Object CONST = InterfaceInitializationStates.someMethod();
+        default int method() { return 2; }
+    }
+
+    // I is initialized when CONST is used, and doesn't trigger initialization of K,
+    // I also doesn't get an initialization error just because K has an initialization error.
+    interface I extends K {
+        boolean v = InterfaceInitializationStates.out(I.class);
+        static final Object CONST = InterfaceInitializationStates.someMethod();
+    }
+
+    // L can be fully initialized even though it extends an interface that has an
+    // initialization error
+    interface L extends K {
+        boolean v = InterfaceInitializationStates.out(L.class);
+        default void lx() {}
+        static void func() {
+            System.out.println("Calling function on interface with bad super interface.");
+        }
+    }
+
+    // Another interface needing initialization.
+    // Initialization of this interface does not occur with ClassLIM because K throws
+    // an initialization error, so the interface initialization is abandoned
+    interface M {
+        boolean v = InterfaceInitializationStates.out(M.class);
+        default void mx() {}
+    }
+
+    static class ClassLIM implements L, I, M {
+        boolean v = InterfaceInitializationStates.out(ClassLIM.class);
+        int callMethodInK() { return method(); }
+        static {
+            // Since interface initialization of K fails, this should never be called
+            System.out.println("Initializing C, but L is still good");
+            L.func();
+        }
+    }
+
+    // Finally initialize M
+    static class ClassM implements M {
+        boolean v = InterfaceInitializationStates.out(ClassM.class);
+    }
+
+    // Iunlinked is testing initialization like interface I, except interface I is linked when
+    // ClassLIM is linked.
+    // Iunlinked is not linked already when K gets an initialization error.  Linking Iunlinked
+    // should succeed and not get NoClassDefFoundError because it does not depend on the
+    // initialization state of K for linking.  There's bug now where it gets this error.
+    // See: https://bugs.openjdk.java.net/browse/JDK-8166203.
+    interface Iunlinked extends K {
+        boolean v = InterfaceInitializationStates.out(Iunlinked.class);
+    }
+
+    // More tests.  What happens if we use K for parameters and return types?
+    // K is a symbolic reference in the constant pool and the initialization error only
+    // matters when it's used.
+    interface Iparams {
+        boolean v = InterfaceInitializationStates.out(Iparams.class);
+        K the_k = null;
+        K m(K k); // abstract
+        default K method() { return new K(){}; }
+    }
+
+    static class ClassIparams implements Iparams {
+        boolean v = InterfaceInitializationStates.out(ClassIparams.class);
+        public K m(K k) { return k; }
+    }
+
+    public static void main(java.lang.String[] unused) {
+        // The rule this tests is the last sentence of JLS 12.4.1:
+
+        // When a class is initialized, its superclasses are initialized (if they have not
+        // been previously initialized), as well as any superinterfaces (s8.1.5) that declare any
+        // default methods (s9.4.3) (if they have not been previously initialized). Initialization
+        // of an interface does not, of itself, cause initialization of any of its superinterfaces.
+
+        // Trigger initialization.
+        // Now L is fully_initialized even though K should
+        // throw an error during initialization.
+        boolean v = L.v;
+        L.func();
+
+        try {
+            ClassLIM c  = new ClassLIM();  // is K initialized, with a perfectly good L in the middle
+            // was bug: this used to succeed and be able to callMethodInK().
+            throw new RuntimeException("FAIL exception not thrown for class");
+        } catch (ExceptionInInitializerError e) {
+            System.out.println("ExceptionInInitializerError thrown as expected");
+        }
+
+        // Test that K already has initialization error so gets ClassNotFoundException because
+        // initialization was attempted with ClassLIM.
+        try {
+            Class.forName("InterfaceInitializationStates$K", true, InterfaceInitializationStates.class.getClassLoader());
+            throw new RuntimeException("FAIL exception not thrown for forName(K)");
+        } catch(ClassNotFoundException e) {
+            throw new RuntimeException("ClassNotFoundException should not be thrown");
+        } catch(NoClassDefFoundError e) {
+            System.out.println("NoClassDefFoundError thrown as expected");
+        }
+
+        new ClassM();
+
+        // Initialize I, which doesn't cause K (super interface) to be initialized.
+        // Since the initialization of I does _not_ cause K to be initialized, it does
+        // not get NoClassDefFoundError because K is erroneous.
+        // But the initialization of I throws RuntimeException, so we expect
+        // ExceptionInInitializerError.
+        try {
+            Object ii = I.CONST;
+            throw new RuntimeException("FAIL exception not thrown for I's initialization");
+        } catch (ExceptionInInitializerError e) {
+            System.out.println("ExceptionInInitializerError as expected");
+        }
+
+        // Initialize Iunlinked. This should not get NoClassDefFoundError because K
+        // (its super interface) is in initialization_error state.
+        // This is a bug.  It does now.
+        try {
+            boolean bb = Iunlinked.v;
+            throw new RuntimeException("FAIL exception not thrown for Iunlinked initialization");
+        } catch(NoClassDefFoundError e) {
+            System.out.println("NoClassDefFoundError thrown because of bug");
+        }
+
+        // This should be okay
+        boolean value = Iparams.v;
+        System.out.println("value is " + value);
+
+        ClassIparams p = new ClassIparams();
+        try {
+            // Now we get an error because K got an initialization_error
+            K kk = p.method();
+            throw new RuntimeException("FAIL exception not thrown for calling method for K");
+        } catch(NoClassDefFoundError e) {
+            System.out.println("NoClassDefFoundError thrown as expected");
+        }
+
+         // Check expected class initialization order
+        List<Class<?>> expectedCInitOrder = Arrays.asList(L.class, K.class, M.class, ClassM.class,
+                                                          I.class, Iparams.class,
+                                                          ClassIparams.class);
+        if (!cInitOrder.equals(expectedCInitOrder)) {
+            throw new RuntimeException(
+                String.format("Class initialization array %s not equal to expected array %s",
+                              cInitOrder, expectedCInitOrder));
+        }
+    }
+
+    static boolean out(Class c) {
+        System.out.println("#: initializing " + c.getName());
+        cInitOrder.add(c);
+        return true;
+    }
+    static Object someMethod() {
+        throw new RuntimeException();
+    }
+}
--- a/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java	Thu Sep 29 17:23:47 2016 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java	Fri Sep 30 02:52:38 2016 -0700
@@ -23,41 +23,83 @@
 
 /*
  * @test
+ * @summary test that --patch-module works with CDS
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
+ *          jdk.jartool/sun.tools.jar
+ * @build PatchModuleMain
  * @run main PatchModuleCDS
  */
 
 import java.io.File;
+import jdk.test.lib.InMemoryJavaCompiler;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 
 public class PatchModuleCDS {
 
     public static void main(String args[]) throws Throwable {
-        System.out.println("Test that --patch-module and -Xshare:dump are incompatibable");
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", "-Xshare:dump");
-        OutputAnalyzer output = new OutputAnalyzer(pb.start());
-        output.shouldContain("Cannot use the following option when dumping the shared archive: --patch-module");
 
-        System.out.println("Test that --patch-module and -Xshare:on are incompatibable");
+        // Case 1: Test that --patch-module and -Xshare:dump are compatible
         String filename = "patch_module.jsa";
-        pb = ProcessTools.createJavaProcessBuilder(
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
             "-XX:+UnlockDiagnosticVMOptions",
             "-XX:SharedArchiveFile=" + filename,
-            "-Xshare:dump");
-        output = new OutputAnalyzer(pb.start());
-        output.shouldContain("ro space:"); // Make sure archive got created.
+            "-Xshare:dump",
+            "--patch-module=java.naming=no/such/directory",
+            "-Xlog:class+path=info",
+            "-version");
+        new OutputAnalyzer(pb.start())
+            .shouldContain("ro space:"); // Make sure archive got created.
+
+       // Case 2: Test that only jar file in --patch-module is supported for CDS dumping
+        // Create a class file in the module java.base.
+        String source = "package javax.naming.spi; "                +
+                        "public class NamingManager { "             +
+                        "    static { "                             +
+                        "        System.out.println(\"I pass!\"); " +
+                        "    } "                                    +
+                        "}";
+
+        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
+             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
+             System.getProperty("test.classes"));
 
         pb = ProcessTools.createJavaProcessBuilder(
             "-XX:+UnlockDiagnosticVMOptions",
             "-XX:SharedArchiveFile=" + filename,
-            "-Xshare:on",
-            "--patch-module=java.naming=mods/java.naming",
+            "-Xshare:dump",
+            "--patch-module=java.base=" + System.getProperty("test.classes"),
+            "-Xlog:class+path=info",
             "-version");
-        output = new OutputAnalyzer(pb.start());
-        output.shouldContain("The shared archive file cannot be used with --patch-module");
+        new OutputAnalyzer(pb.start())
+            .shouldContain("--patch-module requires a regular file during dumping");
 
-        output.shouldHaveExitValue(1);
+        // Case 3a: Test CDS dumping with jar file in --patch-module
+        BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager");
+        String moduleJar = BasicJarBuilder.getTestJar("javanaming.jar");
+        pb = ProcessTools.createJavaProcessBuilder(
+            "-XX:+UnlockDiagnosticVMOptions",
+            "-XX:SharedArchiveFile=" + filename,
+            "-Xshare:dump",
+            "--patch-module=java.naming=" + moduleJar,
+            "-Xlog:class+load",
+            "-Xlog:class+path=info",
+            "PatchModuleMain", "javax.naming.spi.NamingManager");
+        new OutputAnalyzer(pb.start())
+            .shouldContain("ro space:"); // Make sure archive got created.
+
+        // Case 3b: Test CDS run with jar file in --patch-module
+        pb = ProcessTools.createJavaProcessBuilder(
+            "-XX:+UnlockDiagnosticVMOptions",
+            "-XX:SharedArchiveFile=" + filename,
+            "-Xshare:auto",
+            "--patch-module=java.naming=" + moduleJar,
+            "-Xlog:class+load",
+            "-Xlog:class+path=info",
+            "PatchModuleMain", "javax.naming.spi.NamingManager");
+        new OutputAnalyzer(pb.start())
+            .shouldContain("I pass!")
+            .shouldHaveExitValue(0);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ClassFileLoadHook/MAAClassFileLoadHook.java	Fri Sep 30 02:52:38 2016 -0700
@@ -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.
+ */
+
+/**
+ * @test
+ * @run main/othervm/native -agentlib:MAAClassFileLoadHook MAAClassFileLoadHook
+ * @run main/othervm/native -agentlib:MAAClassFileLoadHook=with_early_vmstart MAAClassFileLoadHook
+ * @run main/othervm/native -agentlib:MAAClassFileLoadHook=with_early_class_hook MAAClassFileLoadHook
+ * @run main/othervm/native -agentlib:MAAClassFileLoadHook=with_early_vmstart,with_early_class_hook MAAClassFileLoadHook
+ */
+
+public class MAAClassFileLoadHook {
+
+    static {
+        try {
+            System.loadLibrary("MAAClassFileLoadHook");
+        } catch (UnsatisfiedLinkError ule) {
+            System.err.println("Could not load MAAClassFileLoadHook library");
+            System.err.println("java.library.path: "
+                + System.getProperty("java.library.path"));
+            throw ule;
+        }
+    }
+
+    native static int check();
+
+    public static void main(String args[]) {
+        int status = check();
+        if (status != 0) {
+            throw new RuntimeException("Non-zero status returned from the agent: " + status);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ClassFileLoadHook/libMAAClassFileLoadHook.c	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,278 @@
+/*
+ * 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 <stdio.h>
+#include <string.h>
+#include "jvmti.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JNI_ENV_ARG
+
+#ifdef __cplusplus
+#define JNI_ENV_ARG(x, y) y
+#define JNI_ENV_PTR(x) x
+#else
+#define JNI_ENV_ARG(x,y) x, y
+#define JNI_ENV_PTR(x) (*x)
+#endif
+
+#endif
+
+#define TranslateError(err) "JVMTI error"
+
+#define PASSED 0
+#define FAILED 2
+
+static const char *EXPECTED_NAME = "java/util/Collections";
+static const char *EXC_CNAME = "java/lang/Exception";
+
+static jvmtiEnv *jvmti = NULL;
+static jint result = PASSED;
+static jboolean printdump = JNI_FALSE;
+
+static jboolean with_early_vm_start_capability = JNI_FALSE;
+static jboolean with_early_class_hook_capability = JNI_FALSE;
+
+static jboolean found_class_in_vm_start = JNI_FALSE;
+static jboolean found_class_in_primordial = JNI_FALSE;
+static jboolean found_class_in_cflh_events = JNI_FALSE;
+
+static int cflh_events_primordial_count = 0;
+static int cflh_events_vm_start_count = 0;
+
+static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
+
+JNIEXPORT
+jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
+    return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) {
+    return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
+    return JNI_VERSION_9;
+}
+
+static
+jint throw_exc(JNIEnv *env, char *msg) {
+    jclass exc_class = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, EXC_CNAME));
+
+    if (exc_class == NULL) {
+        printf("throw_exc: Error in FindClass(env, %s)\n", EXC_CNAME);
+        return -1;
+    }
+    return JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG(env, exc_class), msg);
+}
+
+static void JNICALL
+Callback_ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *env,
+                           jclass class_being_redefined,
+                           jobject loader, const char* name, jobject protection_domain,
+                           jint class_data_len, const unsigned char* class_data,
+                           jint *new_class_data_len, unsigned char** new_class_data) {
+    jvmtiPhase phase;
+    jvmtiError err;
+
+    err = (*jvmti)->GetPhase(jvmti_env, &phase);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("ClassFileLoadHook event: GetPhase error: %s (%d)\n", TranslateError(err), err);
+        result = FAILED;
+        return;
+    }
+
+    if (phase == JVMTI_PHASE_PRIMORDIAL || phase == JVMTI_PHASE_START) {
+        if (phase == JVMTI_PHASE_START) {
+            cflh_events_vm_start_count++;
+            if(strcmp(name, EXPECTED_NAME) == 0) {
+                found_class_in_vm_start = JNI_TRUE;
+            }
+        } else {
+            cflh_events_primordial_count++;
+            if(strcmp(name, EXPECTED_NAME) == 0) {
+                found_class_in_primordial = JNI_TRUE;
+            }
+        }
+    }
+
+    if(strcmp(name, EXPECTED_NAME) == 0) {
+        found_class_in_cflh_events = JNI_TRUE;
+    }
+
+    if (printdump == JNI_TRUE) {
+        printf(">>>    ClassFileLoadHook event: phase(%d), class name %s\n", phase, name);
+    }
+}
+
+static
+jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
+    jint res, size;
+    jvmtiCapabilities caps;
+    jvmtiEventCallbacks callbacks;
+    jvmtiError err;
+
+    if (options != NULL) {
+        if (strstr(options, "with_early_vmstart") != NULL) {
+            with_early_vm_start_capability = JNI_TRUE;
+        }
+        if (strstr(options, "with_early_class_hook") != NULL) {
+            with_early_class_hook_capability = JNI_TRUE;
+        }
+        if (strstr(options, "printdump") != NULL) {
+            printdump = JNI_TRUE;
+        }
+    }
+
+    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
+        JVMTI_VERSION_9);
+    if (res != JNI_OK || jvmti == NULL) {
+        printf("    Error: wrong result of a valid call to GetEnv!\n");
+        return JNI_ERR;
+    }
+
+    printf("Enabling following capabilities: can_generate_all_class_hook_events");
+    memset(&caps, 0, sizeof(caps));
+    caps.can_generate_all_class_hook_events = 1;
+    if (with_early_vm_start_capability == JNI_TRUE) {
+        printf(", can_generate_early_vmstart");
+        caps.can_generate_early_vmstart = 1;
+    }
+    if (with_early_class_hook_capability == JNI_TRUE) {
+        printf(", can_generate_early_class_hook_events");
+        caps.can_generate_early_class_hook_events = 1;
+    }
+    printf("\n");
+
+    err = (*jvmti)->AddCapabilities(jvmti, &caps);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("    Error in AddCapabilites: %s (%d)\n", TranslateError(err), err);
+        return JNI_ERR;
+    }
+
+    size = (jint)sizeof(callbacks);
+
+    memset(&callbacks, 0, sizeof(callbacks));
+    callbacks.ClassFileLoadHook = Callback_ClassFileLoadHook;
+
+    err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, size);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("    Error in SetEventCallbacks: %s (%d)\n", TranslateError(err), err);
+        return JNI_ERR;
+    }
+
+    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("    Error in SetEventNotificationMode: %s (%d)\n", TranslateError(err), err);
+        return JNI_ERR;
+    }
+
+    return JNI_OK;
+}
+
+JNIEXPORT jint JNICALL
+Java_MAAClassFileLoadHook_check(JNIEnv *env, jclass cls) {
+    jobject loader = NULL;
+
+    if (jvmti == NULL) {
+        throw_exc(env, "JVMTI client was not properly loaded!\n");
+        return FAILED;
+    }
+
+    /*
+     * Expecting that we always get ClassFileLoadHook events in the VM Start phase.
+     */
+    if (cflh_events_vm_start_count == 0) {
+        throw_exc(env, "Didn't get ClassFileLoadHook events in start phase!\n");
+        return FAILED;
+    }
+
+    if (with_early_class_hook_capability == JNI_TRUE) {
+       /*
+        * Expecting that we get ClassFileLoadHook events in the Primordial phase
+        * when can_generate_all_class_hook_events and can_generate_early_class_hook_events
+        * capabilities are enabled.
+        */
+        if (cflh_events_primordial_count == 0) {
+            throw_exc(env, "Didn't get ClassFileLoadHook events in primordial phase!\n");
+            return FAILED;
+        }
+    } else {
+       /*
+        * Expecting that we don't get ClassFileLoadHook events in the Primordial phase
+        * when can_generate_early_class_hook_events capability is disabled.
+        */
+        if (cflh_events_primordial_count != 0) {
+            throw_exc(env, "Get ClassFileLoadHook events in primordial phase!\n");
+            return FAILED;
+        }
+    }
+
+
+    if (with_early_vm_start_capability == JNI_TRUE) {
+        /*
+         * Expecting that "java/util/Collections" class from java.base module is present in the
+         * ClassFileLoadHook events during VM Start phase when can_generate_early_vmstart
+         * capability is enabled.
+         */
+        printf("Expecting to find '%s' class in ClassFileLoadHook events during VM early start phase.\n", EXPECTED_NAME);
+        if (found_class_in_vm_start == JNI_FALSE) {
+            throw_exc(env, "Unable to find expected class in ClassLoad events during VM early start phase!\n");
+            return FAILED;
+        }
+    } else if (with_early_class_hook_capability == JNI_TRUE) {
+        /*
+         * Expecting that "java/util/Collections" class from java.base module is present in the
+         * ClassFileLoadHook events during Primordial phase when can_generate_all_class_hook_events
+         * and can_generate_early_class_hook_events capabilities are enabled and can_generate_early_vmstart
+         * capability is disabled.
+         */
+        printf("Expecting to find '%s' class in ClassFileLoadHook events during VM primordial phase.\n", EXPECTED_NAME);
+        if (found_class_in_primordial == JNI_FALSE) {
+            throw_exc(env, "Unable to find expected class in ClassFileLoadHook events during primordial phase!\n");
+            return FAILED;
+        }
+    } else {
+        /*
+         * Expecting that "java/util/Collections" class from java.base module is not present in the
+         * ClassFileLoadHook events when can_generate_all_class_hook_events, can_generate_early_class_hook_events
+         * and can_generate_early_vmstart capabilities are disabled.
+         */
+        printf("Expecting that '%s' class is absent in ClassLoadHook events.\n", EXPECTED_NAME);
+        if (found_class_in_cflh_events == JNI_TRUE) {
+            throw_exc(env, "Class is found in ClassFileLoadHook events!\n");
+            return FAILED;
+        }
+    }
+
+    return result;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ClassLoadPrepare/MAAClassLoadPrepare.java	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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 8165681
+ * @summary Verify ClassLoad and ClassPrepare JVMTI event with
+ * and without can_generate_early_vmstart capability
+ * @run main/othervm/native -agentlib:MAAClassLoadPrepare MAAClassLoadPrepare
+ * @run main/othervm/native -agentlib:MAAClassLoadPrepare=with_early_vmstart MAAClassLoadPrepare
+ */
+
+public class MAAClassLoadPrepare {
+
+    static {
+        try {
+            System.loadLibrary("MAAClassLoadPrepare");
+        } catch (UnsatisfiedLinkError ule) {
+            System.err.println("Could not load MAAClassLoadPrepare library");
+            System.err.println("java.library.path: "
+                + System.getProperty("java.library.path"));
+            throw ule;
+        }
+    }
+
+    native static int check();
+
+    public static void main(String args[]) {
+        int status = check();
+        if (status != 0) {
+            throw new RuntimeException("Non-zero status returned from the agent: " + status);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ClassLoadPrepare/libMAAClassLoadPrepare.c	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,319 @@
+/*
+ * 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 <stdio.h>
+#include <string.h>
+#include "jvmti.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JNI_ENV_ARG
+
+#ifdef __cplusplus
+#define JNI_ENV_ARG(x, y) y
+#define JNI_ENV_PTR(x) x
+#else
+#define JNI_ENV_ARG(x,y) x, y
+#define JNI_ENV_PTR(x) (*x)
+#endif
+
+#endif
+
+#define TranslateError(err) "JVMTI error"
+
+#define PASSED 0
+#define FAILED 2
+
+static const char *EXPECTED_SIGNATURE = "Ljava/util/Collections;";
+static const char *EXC_CNAME = "java/lang/Exception";
+
+static jvmtiEnv *jvmti = NULL;
+static jint result = PASSED;
+static jboolean printdump = JNI_FALSE;
+
+static jboolean with_early_vm_start_capability = JNI_FALSE;
+
+static jboolean class_in_class_load_events_vm_start = JNI_FALSE;
+static jboolean class_in_class_load_events_vm_live = JNI_FALSE;
+static jboolean class_in_class_prepare_events_vm_start = JNI_FALSE;
+static jboolean class_in_class_prepare_events_vm_live = JNI_FALSE;
+
+static int class_load_events_vm_start_count = 0;
+static int class_prepare_events_vm_start_count = 0;
+
+static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
+
+JNIEXPORT
+jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
+    return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) {
+    return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
+    return JNI_VERSION_9;
+}
+
+static
+jint throw_exc(JNIEnv *env, char *msg) {
+    jclass exc_class = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, EXC_CNAME));
+
+    if (exc_class == NULL) {
+        printf("throw_exc: Error in FindClass(env, %s)\n", EXC_CNAME);
+        return -1;
+    }
+    return JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG(env, exc_class), msg);
+}
+
+static void JNICALL
+Callback_ClassFileLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) {
+    jvmtiPhase phase;
+    char *sig, *generic;
+    jvmtiError err;
+
+    err = (*jvmti)->GetPhase(jvmti_env,&phase);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("ClassLoad event: GetPhase error: %s (%d)\n", TranslateError(err), err);
+        result = FAILED;
+        return;
+    }
+
+    if (phase == JVMTI_PHASE_START || phase == JVMTI_PHASE_LIVE) {
+
+        err = (*jvmti)->GetClassSignature(jvmti_env, klass, &sig, &generic);
+
+        if (err != JVMTI_ERROR_NONE) {
+            printf("ClassLoad event: GetClassSignature error: %s (%d)\n", TranslateError(err), err);
+            result = FAILED;
+            return;
+        }
+
+        if (phase == JVMTI_PHASE_START) {
+            class_load_events_vm_start_count++;
+            if(strcmp(sig, EXPECTED_SIGNATURE) == 0) {
+                class_in_class_load_events_vm_start = JNI_TRUE;
+            }
+        } else {
+            if(strcmp(sig, EXPECTED_SIGNATURE) == 0) {
+                class_in_class_load_events_vm_live = JNI_TRUE;
+            }
+        }
+
+        if (printdump == JNI_TRUE) {
+            printf(">>>    ClassLoad event: phase(%d), class signature %s\n", phase, sig == NULL ? "null": sig);
+        }
+    } else {
+        printf("ClassLoad event: get event in unexpected phase(%d)\n", phase);
+        result = FAILED;
+    }
+}
+
+static void JNICALL
+Callback_ClassFilePrepare(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) {
+    jvmtiPhase phase;
+    char *sig, *generic;
+    jvmtiError err;
+
+    err = (*jvmti)->GetPhase(jvmti_env,&phase);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("ClassPrepare event: GetPhase error: %s (%d)\n", TranslateError(err), err);
+        result = FAILED;
+        return;
+    }
+
+    if (phase == JVMTI_PHASE_START || phase == JVMTI_PHASE_LIVE) {
+
+        err = (*jvmti)->GetClassSignature(jvmti_env, klass, &sig, &generic);
+
+        if (err != JVMTI_ERROR_NONE) {
+            printf("ClassPrepare event: GetClassSignature error: %s (%d)\n", TranslateError(err), err);
+            result = FAILED;
+            return;
+        }
+
+        if (phase == JVMTI_PHASE_START) {
+            class_prepare_events_vm_start_count++;
+            if(strcmp(sig, EXPECTED_SIGNATURE) == 0) {
+                class_in_class_prepare_events_vm_start = JNI_TRUE;
+            }
+        } else {
+            if(strcmp(sig, EXPECTED_SIGNATURE) == 0) {
+                class_in_class_prepare_events_vm_live = JNI_TRUE;
+            }
+        }
+
+        if (printdump == JNI_TRUE) {
+            printf(">>>    ClassPrepare event: phase(%d), class signature %s\n", phase, sig == NULL ? "null": sig);
+        }
+    } else {
+        printf("ClassPrepare event: get event in unexpected phase(%d)\n", phase);
+        result = FAILED;
+    }
+}
+
+static
+jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
+    jint res, size;
+    jvmtiCapabilities caps;
+    jvmtiEventCallbacks callbacks;
+    jvmtiError err;
+
+    if (options != NULL) {
+        if (strstr(options, "with_early_vmstart") != NULL) {
+            with_early_vm_start_capability = JNI_TRUE;
+        }
+        if (strstr(options, "printdump") != NULL) {
+            printdump = JNI_TRUE;
+        }
+    }
+
+    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
+        JVMTI_VERSION_9);
+    if (res != JNI_OK || jvmti == NULL) {
+        printf("    Error: wrong result of a valid call to GetEnv!\n");
+        return JNI_ERR;
+    }
+
+    if (with_early_vm_start_capability == JNI_TRUE) {
+        printf("Enabling following capability: can_generate_early_vmstart\n");
+        memset(&caps, 0, sizeof(caps));
+        caps.can_generate_early_vmstart = 1;
+
+        err = (*jvmti)->AddCapabilities(jvmti, &caps);
+        if (err != JVMTI_ERROR_NONE) {
+            printf("    Error in AddCapabilites: %s (%d)\n", TranslateError(err), err);
+            return JNI_ERR;
+        }
+    }
+
+    size = (jint)sizeof(callbacks);
+
+    memset(&callbacks, 0, sizeof(callbacks));
+    callbacks.ClassLoad = Callback_ClassFileLoad;
+    callbacks.ClassPrepare = Callback_ClassFilePrepare;
+
+    err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, size);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("    Error in SetEventCallbacks: %s (%d)\n", TranslateError(err), err);
+        return JNI_ERR;
+    }
+
+    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("    Error in SetEventNotificationMode: %s (%d)\n", TranslateError(err), err);
+        return JNI_ERR;
+    }
+
+    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL);
+
+    if (err != JVMTI_ERROR_NONE) {
+        printf("    Error in SetEventNotificationMode: %s (%d)\n", TranslateError(err), err);
+        return JNI_ERR;
+    }
+
+    return JNI_OK;
+}
+
+JNIEXPORT jint JNICALL
+Java_MAAClassLoadPrepare_check(JNIEnv *env, jclass cls) {
+    jobject loader = NULL;
+
+    if (jvmti == NULL) {
+        throw_exc(env, "JVMTI client was not properly loaded!\n");
+        return FAILED;
+    }
+
+    if (with_early_vm_start_capability == JNI_TRUE) {
+        /*
+         * Expecting that "java/util/Collections" class from java.base module is present in the
+         * ClassLoad and ClassPrepare events during VM Start phase when can_generate_early_vmstart
+         * capability is enabled.
+         * Expecting that ClassLoad and ClassPrepare events are sent in the VM early start phase
+         * when can_generate_early_vmstart is enabled(JDK-8165681).
+         */
+        if (class_load_events_vm_start_count == 0) {
+            throw_exc(env, "Didn't get ClassLoad events in start phase!\n");
+            return FAILED;
+        }
+
+        printf("Expecting to find '%s' class in ClassLoad events during VM early start phase.\n", EXPECTED_SIGNATURE);
+        if (class_in_class_load_events_vm_start == JNI_FALSE) {
+            throw_exc(env, "Unable to find expected class in ClassLoad events during early start phase!\n");
+            return FAILED;
+        }
+
+        if (class_prepare_events_vm_start_count == 0) {
+            throw_exc(env, "Didn't get ClassPrepare events in start phase!\n");
+            return FAILED;
+        }
+
+        printf("Expecting to find '%s' class in ClassPrepare events during VM early start phase.\n", EXPECTED_SIGNATURE);
+        if (class_in_class_prepare_events_vm_start == JNI_FALSE) {
+            throw_exc(env, "Unable to find expected class in ClassPrepare events during early start phase!\n");
+            return FAILED;
+        }
+    } else {
+        /*
+         * Expecting that "java/util/Collections" class from java.base module is not present in the
+         * ClassLoad and ClassPrepare events during VM Start phase when can_generate_early_vmstart
+         * capability is disabled.
+         */
+        printf("Expecting that '%s' class is absent in ClassLoad events during normal VM start phase.\n", EXPECTED_SIGNATURE);
+        if (class_in_class_prepare_events_vm_start == JNI_TRUE) {
+            throw_exc(env, "Class is found in ClassLoad events during normal VM start phase!\n");
+            return FAILED;
+        }
+
+        printf("Expecting that '%s' class is absent in ClassPrepare events during normal VM start phase.\n", EXPECTED_SIGNATURE);
+        if (class_in_class_prepare_events_vm_start == JNI_TRUE) {
+            throw_exc(env, "Class is found in ClassPrepare events during normal VM start phase!\n");
+            return FAILED;
+        }
+    }
+
+    /*
+     * In any case, we not expect to see "java/util/Collections" class from java.base module
+     * in the ClassLoad and ClassPrepare events during VM Live phase.
+     */
+    if (class_in_class_prepare_events_vm_live == JNI_TRUE) {
+        throw_exc(env, "Class is found in ClassLoad events during VM Live phase!\n");
+        return FAILED;
+    }
+
+    if (class_in_class_prepare_events_vm_live == JNI_TRUE) {
+        throw_exc(env, "Class is found in ClassPrepare events during VM Live phase!\n");
+        return FAILED;
+    }
+
+    return result;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java	Fri Sep 30 02:52:38 2016 -0700
@@ -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
+ * @summary Verify ThreadStart JVMTI event with can_generate_early_vmstart capability
+ * @run main/othervm/native -agentlib:MAAThreadStart MAAThreadStart
+ */
+
+public class MAAThreadStart {
+
+    static {
+        try {
+            System.loadLibrary("MAAThreadStart");
+        } catch (UnsatisfiedLinkError ule) {
+            System.err.println("Could not load MAAThreadStart library");
+            System.err.println("java.library.path: "
+                + System.getProperty("java.library.path"));
+            throw ule;
+        }
+    }
+
+    native static int check();
+
+    public static void main(String args[]) {
+        int status = check();
+        if (status != 0) {
+            throw new RuntimeException("Non-zero status returned from the agent: " + status);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/ModuleAwareAgents/ThreadStart/libMAAThreadStart.c	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,177 @@
+/*
+ * 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 <stdio.h>
+#include <string.h>
+#include "jvmti.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JNI_ENV_ARG
+
+#ifdef __cplusplus
+#define JNI_ENV_ARG(x, y) y
+#define JNI_ENV_PTR(x) x
+#else
+#define JNI_ENV_ARG(x,y) x, y
+#define JNI_ENV_PTR(x) (*x)
+#endif
+
+#endif
+
+#define TranslateError(err) "JVMTI error"
+
+#define PASSED 0
+#define FAILED 2
+
+static const char *EXC_CNAME = "java/lang/Exception";
+
+static jvmtiEnv *jvmti = NULL;
+static jint result = PASSED;
+static jboolean printdump = JNI_FALSE;
+
+static int thread_start_events_vm_start = 0;
+
+static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
+
+JNIEXPORT
+jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
+    return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) {
+    return Agent_Initialize(jvm, options, reserved);
+}
+
+JNIEXPORT
+jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
+    return JNI_VERSION_9;
+}
+
+static
+jint throw_exc(JNIEnv *env, char *msg) {
+    jclass exc_class = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, EXC_CNAME));
+
+    if (exc_class == NULL) {
+        printf("throw_exc: Error in FindClass(env, %s)\n", EXC_CNAME);
+        return -1;
+    }
+    return JNI_ENV_PTR(env)->ThrowNew(JNI_ENV_ARG(env, exc_class), msg);
+}
+
+
+void JNICALL Callback_ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
+    jvmtiError err;
+    jvmtiPhase phase;
+
+    err = (*jvmti)->GetPhase(jvmti_env,&phase);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("ThreadStart event: GetPhase error: %s (%d)\n", TranslateError(err), err);
+        result = FAILED;
+        return;
+    }
+
+    if (phase == JVMTI_PHASE_START) {
+        thread_start_events_vm_start++;
+    }
+
+    if (printdump == JNI_TRUE) {
+        printf(">>>    ThreadStart event: phase(%d)\n", phase);
+    }
+}
+
+static
+jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
+    jint res, size;
+    jvmtiCapabilities caps;
+    jvmtiEventCallbacks callbacks;
+    jvmtiError err;
+
+    if (options != NULL && strcmp(options, "printdump") == 0) {
+        printdump = JNI_TRUE;
+    }
+
+    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
+        JVMTI_VERSION_9);
+    if (res != JNI_OK || jvmti == NULL) {
+        printf("    Error: wrong result of a valid call to GetEnv!\n");
+        return JNI_ERR;
+    }
+
+    printf("Enabling following capability: can_generate_early_vmstart\n");
+    memset(&caps, 0, sizeof(caps));
+    caps.can_generate_early_vmstart = 1;
+
+    err = (*jvmti)->AddCapabilities(jvmti, &caps);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("    Error in AddCapabilites: %s (%d)\n", TranslateError(err), err);
+        return JNI_ERR;
+    }
+
+    size = (jint)sizeof(callbacks);
+
+    memset(&callbacks, 0, sizeof(callbacks));
+    callbacks.ThreadStart = Callback_ThreadStart;
+
+    err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, size);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("    Error in SetEventCallbacks: %s (%d)\n", TranslateError(err), err);
+        return JNI_ERR;
+    }
+
+    err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("    Error in SetEventNotificationMode: %s (%d)\n", TranslateError(err), err);
+        return JNI_ERR;
+    }
+
+    return JNI_OK;
+}
+
+JNIEXPORT jint JNICALL
+Java_MAAThreadStart_check(JNIEnv *env, jclass cls) {
+    jobject loader = NULL;
+
+    if (jvmti == NULL) {
+        throw_exc(env, "JVMTI client was not properly loaded!\n");
+        return FAILED;
+    }
+
+    /*
+     * Expecting that ThreadStart events are sent during VM Start phase when
+     * can_generate_early_vmstart capability is enabled.
+     */
+    if (thread_start_events_vm_start == 0) {
+        throw_exc(env, "Didn't get ThreadStart events in VM early start phase!\n");
+        return FAILED;
+    }
+
+    return result;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/sa/LingeredAppWithDefaultMethods.java	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2005, 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 jdk.test.lib.apps.LingeredApp;
+
+interface Language {
+    static final long nbrOfWords = 99999;
+    public abstract long getNbrOfWords();
+    default boolean hasScript() {
+        return true;
+    }
+}
+
+class ParselTongue implements Language {
+    public long getNbrOfWords() {
+        return nbrOfWords * 4;
+    }
+}
+
+class SlytherinSpeak extends ParselTongue {
+    public boolean hasScript() {
+        return false;
+    }
+}
+
+public class LingeredAppWithDefaultMethods extends LingeredApp {
+
+    public static void main(String args[]) {
+        ParselTongue lang = new ParselTongue();
+        SlytherinSpeak slang = new SlytherinSpeak();
+        System.out.println(lang.hasScript() || slang.hasScript());
+
+        LingeredApp.main(args);
+    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/sa/TestDefaultMethods.java	Fri Sep 30 02:52:38 2016 -0700
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2015, 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.ArrayList;
+import java.util.List;
+
+import sun.jvm.hotspot.HotSpotAgent;
+import sun.jvm.hotspot.utilities.SystemDictionaryHelper;
+import sun.jvm.hotspot.oops.InstanceKlass;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.oops.Method;
+import sun.jvm.hotspot.utilities.MethodArray;
+
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.Platform;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.Utils;
+import jdk.test.lib.Asserts;
+
+/*
+ * @test
+ * @library /test/lib
+ * @requires os.family != "mac"
+ * @modules java.base/jdk.internal.misc
+ *          jdk.hotspot.agent/sun.jvm.hotspot
+ *          jdk.hotspot.agent/sun.jvm.hotspot.utilities
+ *          jdk.hotspot.agent/sun.jvm.hotspot.oops
+ *          jdk.hotspot.agent/sun.jvm.hotspot.debugger
+ * @run main/othervm TestDefaultMethods
+ */
+
+public class TestDefaultMethods {
+
+    private static LingeredAppWithDefaultMethods theApp = null;
+
+    private static void printDefaultMethods(String pid,
+                                            String[] instanceKlassNames) {
+        HotSpotAgent agent = new HotSpotAgent();
+        try {
+            agent.attach(Integer.parseInt(pid));
+        }
+        catch (DebuggerException e) {
+            System.out.println(e.getMessage());
+            System.err.println("Unable to connect to process ID: " + pid);
+
+            agent.detach();
+            e.printStackTrace();
+        }
+
+        for (String instanceKlassName : instanceKlassNames) {
+            InstanceKlass iKlass = SystemDictionaryHelper.findInstanceKlass(instanceKlassName);
+            MethodArray methods = iKlass.getMethods();
+            MethodArray defaultMethods = iKlass.getDefaultMethods();
+            for (int i = 0; i < methods.length(); i++) {
+                Method m = methods.at(i);
+                System.out.println("Method: " + m.getName().asString() +
+                                   " in instance klass: " + instanceKlassName);
+            }
+            if (defaultMethods != null) {
+                for (int j = 0; j < defaultMethods.length(); j++) {
+                    Method dm = defaultMethods.at(j);
+                    System.out.println("Default method: " + dm.getName().asString() +
+                                       " in instance klass: " + instanceKlassName);
+                }
+            } else {
+                System.out.println("No default methods in " + instanceKlassName);
+            }
+
+        }
+        agent.detach();
+    }
+
+    private static void createAnotherToAttach(
+                            String[] instanceKlassNames,
+                            long lingeredAppPid) throws Exception {
+
+        String[] toolArgs = {
+            "--add-modules=jdk.hotspot.agent",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED",
+            "TestDefaultMethods",
+            Long.toString(lingeredAppPid)
+        };
+
+        // Start a new process to attach to the lingered app
+        ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(toolArgs);
+        OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder);
+        SAOutput.shouldHaveExitValue(0);
+        System.out.println(SAOutput.getOutput());
+
+        SAOutput.shouldContain(
+            "Default method: hasScript in instance klass: " + instanceKlassNames[1]);
+        SAOutput.shouldContain(
+            "No default methods in " + instanceKlassNames[0]);
+        SAOutput.shouldContain(
+            "Method: hasScript in instance klass: " + instanceKlassNames[0]);
+        SAOutput.shouldContain(
+            "No default methods in " + instanceKlassNames[2]);
+    }
+
+    public static void main (String... args) throws Exception {
+
+        String[] instanceKlassNames = new String[] {
+                                          "Language",
+                                          "ParselTongue",
+                                          "SlytherinSpeak"
+                                      };
+
+        if (!Platform.shouldSAAttach()) {
+            System.out.println(
+               "SA attach not expected to work - test skipped.");
+            return;
+        }
+
+        if (args == null || args.length == 0) {
+            try {
+                List<String> vmArgs = new ArrayList<String>();
+                vmArgs.add("-XX:+UsePerfData");
+                vmArgs.addAll(Utils.getVmOptions());
+
+                theApp = new LingeredAppWithDefaultMethods();
+                LingeredApp.startApp(vmArgs, theApp);
+                createAnotherToAttach(instanceKlassNames,
+                                      theApp.getPid());
+            } finally {
+                LingeredApp.stopApp(theApp);
+            }
+        } else {
+            printDefaultMethods(args[0], instanceKlassNames);
+        }
+    }
+}