Merge JDK-8145252-TLS13-branch
authorwetmore
Mon, 04 Jun 2018 14:59:53 -0700
branchJDK-8145252-TLS13-branch
changeset 56664 8ff60b603991
parent 56663 e522520c2eb3 (current diff)
parent 50390 f4c4a86d1c12 (diff)
child 56672 ec5537b61038
Merge
test/hotspot/jtreg/runtime/appcds/jigsaw/limitmods/LimitModsHelper.java
test/hotspot/jtreg/runtime/appcds/jigsaw/limitmods/LimitModsTests.java
test/hotspot/jtreg/runtime/appcds/test-classes/jdk/dynalink/DynamicLinker.jasm
--- a/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Mon Jun 04 04:08:12 2018 +0000
+++ b/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Mon Jun 04 14:59:53 2018 -0700
@@ -103,7 +103,7 @@
 $(GENSRC_DIR)/_gensrc_proc_done: $(PROC_SRCS) $(PROCESSOR_JARS)
 	$(call MakeDir, $(@D))
 	$(eval $(call ListPathsSafely,PROC_SRCS,$(@D)/_gensrc_proc_files))
-	$(JAVA_SMALL) $(NEW_JAVAC) \
+	$(JAVA) $(NEW_JAVAC) \
 	    -XDignore.symbol.file \
 	    --upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none \
 	    $(ADD_EXPORTS) \
--- a/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_CodeStubs.hpp"
 #include "c1/c1_FrameMap.hpp"
 #include "c1/c1_LIRAssembler.hpp"
--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "asm/assembler.hpp"
 #include "c1/c1_CodeStubs.hpp"
 #include "c1/c1_Compilation.hpp"
--- a/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Compilation.hpp"
 #include "c1/c1_FrameMap.hpp"
 #include "c1/c1_Instruction.hpp"
--- a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -29,6 +29,7 @@
 #include "gc/g1/c1/g1BarrierSetC1.hpp"
 #include "gc/g1/g1BarrierSet.hpp"
 #include "gc/g1/g1BarrierSetAssembler.hpp"
+#include "gc/g1/g1BarrierSetRuntime.hpp"
 #include "gc/g1/g1CardTable.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/heapRegion.hpp"
@@ -60,9 +61,9 @@
       __ mov(c_rarg1, count);
     }
     if (UseCompressedOops) {
-      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry), 2);
+      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_narrow_oop_entry), 2);
     } else {
-      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry), 2);
+      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_oop_entry), 2);
     }
     __ pop(saved_regs, sp);
   }
@@ -78,7 +79,7 @@
   __ lsr(scratch, scratch, LogBytesPerHeapOop);  // convert to element count
   __ mov(c_rarg0, start);
   __ mov(c_rarg1, scratch);
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry), 2);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry), 2);
   __ pop(saved_regs, sp);
 }
 
@@ -161,9 +162,9 @@
 
   if (expand_call) {
     assert(pre_val != c_rarg1, "smashed arg");
-    __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), pre_val, thread);
+    __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), pre_val, thread);
   } else {
-    __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), pre_val, thread);
+    __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), pre_val, thread);
   }
 
   __ pop(saved, sp);
@@ -245,7 +246,7 @@
   // save the live input values
   RegSet saved = RegSet::of(store_addr, new_val);
   __ push(saved, sp);
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), card_addr, thread);
   __ pop(saved, sp);
 
   __ bind(done);
@@ -398,7 +399,7 @@
   __ bind(runtime);
   __ push_call_clobbered_registers();
   __ load_parameter(0, pre_val);
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), pre_val, thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), pre_val, thread);
   __ pop_call_clobbered_registers();
   __ bind(done);
 
@@ -468,7 +469,7 @@
 
   __ bind(runtime);
   __ push_call_clobbered_registers();
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), card_addr, thread);
   __ pop_call_clobbered_registers();
   __ bind(done);
   __ epilogue();
--- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "gc/shared/barrierSet.hpp"
 #include "gc/shared/barrierSetAssembler.hpp"
 #include "interp_masm_aarch64.hpp"
--- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -27,7 +27,6 @@
 #define CPU_AARCH64_VM_INTERP_MASM_AARCH64_64_HPP
 
 #include "asm/macroAssembler.hpp"
-#include "asm/macroAssembler.inline.hpp"
 #include "interpreter/invocationCounter.hpp"
 #include "runtime/frame.hpp"
 
--- a/src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "interpreter/interp_masm.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
--- a/src/hotspot/cpu/aarch64/register_definitions_aarch64.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/register_definitions_aarch64.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -25,6 +25,7 @@
 
 #include "precompiled.hpp"
 #include "asm/assembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "asm/register.hpp"
 #include "register_aarch64.hpp"
 # include "interp_masm_aarch64.hpp"
--- a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,7 +24,7 @@
  */
 
 #include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "gc/shared/barrierSetAssembler.hpp"
 #include "interpreter/bytecodeHistogram.hpp"
 #include "interpreter/interpreter.hpp"
--- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,7 +24,7 @@
  */
 
 #include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "gc/shared/barrierSetAssembler.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
--- a/src/hotspot/cpu/aarch64/vtableStubs_aarch64.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/aarch64/vtableStubs_aarch64.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -24,7 +24,7 @@
  */
 
 #include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "assembler_aarch64.inline.hpp"
 #include "code/vtableStubs.hpp"
 #include "interp_masm_aarch64.hpp"
--- a/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,7 +23,7 @@
  */
 
 #include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_CodeStubs.hpp"
 #include "c1/c1_FrameMap.hpp"
 #include "c1/c1_LIRAssembler.hpp"
--- a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Compilation.hpp"
 #include "c1/c1_LIRAssembler.hpp"
 #include "c1/c1_MacroAssembler.hpp"
--- a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Compilation.hpp"
 #include "c1/c1_FrameMap.hpp"
 #include "c1/c1_Instruction.hpp"
--- a/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,7 +23,7 @@
  */
 
 #include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Defs.hpp"
 #include "c1/c1_LIRAssembler.hpp"
 #include "c1/c1_MacroAssembler.hpp"
--- a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -26,6 +26,7 @@
 #include "asm/macroAssembler.inline.hpp"
 #include "gc/g1/g1BarrierSet.hpp"
 #include "gc/g1/g1BarrierSetAssembler.hpp"
+#include "gc/g1/g1BarrierSetRuntime.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/g1CardTable.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
@@ -74,7 +75,7 @@
       __ mov(R0, addr);
     }
 #ifdef AARCH64
-    __ zero_extend(R1, count, 32); // G1BarrierSet::write_ref_array_pre_*_entry takes size_t
+    __ zero_extend(R1, count, 32); // G1BarrierSetRuntime::write_ref_array_pre_*_entry takes size_t
 #else
     if (count != R1) {
       __ mov(R1, count);
@@ -82,9 +83,9 @@
 #endif // AARCH64
 
     if (UseCompressedOops) {
-      __ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry));
+      __ call(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_narrow_oop_entry));
     } else {
-      __ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry));
+      __ call(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_oop_entry));
     }
 
 #ifdef AARCH64
@@ -106,7 +107,7 @@
     __ mov(R0, addr);
   }
 #ifdef AARCH64
-  __ zero_extend(R1, count, 32); // G1BarrierSet::write_ref_array_post_entry takes size_t
+  __ zero_extend(R1, count, 32); // G1BarrierSetRuntime::write_ref_array_post_entry takes size_t
 #else
   if (count != R1) {
     __ mov(R1, count);
@@ -120,7 +121,7 @@
   __ push(R9);
 #endif // !R9_IS_SCRATCHED
 #endif // !AARCH64
-  __ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry));
+  __ call(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry));
 #ifndef AARCH64
 #if R9_IS_SCRATCHED
   __ pop(R9);
@@ -205,7 +206,7 @@
   }
   __ mov(R1, Rthread);
 
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), R0, R1);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), R0, R1);
 
 #ifdef AARCH64
   if (store_addr != noreg) {
@@ -296,7 +297,7 @@
     __ mov(R0, card_addr);
   }
   __ mov(R1, Rthread);
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), R0, R1);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), R0, R1);
 
   __ bind(done);
 }
@@ -467,7 +468,7 @@
 
   assert(r_pre_val_0 == c_rarg0, "pre_val should be in R0");
   __ mov(c_rarg1, Rthread);
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), c_rarg0, c_rarg1);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), c_rarg0, c_rarg1);
 
   __ restore_live_registers_without_return();
 
@@ -574,7 +575,7 @@
 
   assert(r_card_addr_0 == c_rarg0, "card_addr should be in R0");
   __ mov(c_rarg1, Rthread);
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), c_rarg0, c_rarg1);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), c_rarg0, c_rarg1);
 
   __ restore_live_registers_without_return();
 
--- a/src/hotspot/cpu/arm/interp_masm_arm.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/interp_masm_arm.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "jvm.h"
+#include "asm/macroAssembler.inline.hpp"
 #include "gc/shared/barrierSet.hpp"
 #include "gc/shared/cardTable.hpp"
 #include "gc/shared/cardTableBarrierSet.inline.hpp"
--- a/src/hotspot/cpu/arm/interp_masm_arm.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/interp_masm_arm.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, 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,6 @@
 #define CPU_ARM_VM_INTERP_MASM_ARM_HPP
 
 #include "asm/macroAssembler.hpp"
-#include "asm/macroAssembler.inline.hpp"
 #include "interpreter/invocationCounter.hpp"
 #include "runtime/frame.hpp"
 #include "prims/jvmtiExport.hpp"
--- a/src/hotspot/cpu/arm/interpreterRT_arm.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/interpreterRT_arm.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "interpreter/interp_masm.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
--- a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "asm/assembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "interpreter/bytecodeHistogram.hpp"
 #include "interpreter/interp_masm.hpp"
 #include "interpreter/interpreter.hpp"
--- a/src/hotspot/cpu/arm/templateTable_arm.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/templateTable_arm.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,7 +23,7 @@
  */
 
 #include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "gc/shared/barrierSetAssembler.hpp"
 #include "interpreter/interp_masm.hpp"
 #include "interpreter/interpreter.hpp"
--- a/src/hotspot/cpu/arm/vtableStubs_arm.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/arm/vtableStubs_arm.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "asm/assembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "assembler_arm.inline.hpp"
 #include "code/vtableStubs.hpp"
 #include "interp_masm_arm.hpp"
--- a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_CodeStubs.hpp"
 #include "c1/c1_FrameMap.hpp"
 #include "c1/c1_LIRAssembler.hpp"
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Compilation.hpp"
 #include "c1/c1_LIRAssembler.hpp"
 #include "c1/c1_MacroAssembler.hpp"
--- a/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Compilation.hpp"
 #include "c1/c1_FrameMap.hpp"
 #include "c1/c1_Instruction.hpp"
--- a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -27,6 +27,7 @@
 #include "asm/macroAssembler.inline.hpp"
 #include "gc/g1/g1BarrierSet.hpp"
 #include "gc/g1/g1BarrierSetAssembler.hpp"
+#include "gc/g1/g1BarrierSetRuntime.hpp"
 #include "gc/g1/g1CardTable.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/heapRegion.hpp"
@@ -72,9 +73,9 @@
     if (preserve2 != noreg) { __ std(preserve2, frame_size - (++slot_nr) * wordSize, R1_SP); }
 
     if (UseCompressedOops) {
-      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry), to, count);
+      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_narrow_oop_entry), to, count);
     } else {
-      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry), to, count);
+      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_oop_entry), to, count);
     }
 
     slot_nr = 0;
@@ -98,7 +99,7 @@
   __ save_LR_CR(R0);
   __ push_frame(frame_size, R0);
   if (preserve != noreg) { __ std(preserve, frame_size - 1 * wordSize, R1_SP); }
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry), addr, count);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry), addr, count);
   if (preserve != noreg) { __ ld(preserve, frame_size - 1 * wordSize, R1_SP); }
   __ addi(R1_SP, R1_SP, frame_size); // pop_frame();
   __ restore_LR_CR(R0);
@@ -191,7 +192,7 @@
   }
 
   if (pre_val->is_volatile() && preloaded) { __ mr(nv_save, pre_val); } // Save pre_val across C call if it was preloaded.
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), pre_val, R16_thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), pre_val, R16_thread);
   if (pre_val->is_volatile() && preloaded) { __ mr(pre_val, nv_save); } // restore
 
   if (needs_frame) {
@@ -272,7 +273,7 @@
   __ bind(runtime);
 
   // Save the live input values.
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), Rcard_addr, R16_thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), Rcard_addr, R16_thread);
 
   __ bind(filtered);
 }
--- a/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_CodeStubs.hpp"
 #include "c1/c1_FrameMap.hpp"
 #include "c1/c1_LIRAssembler.hpp"
--- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Compilation.hpp"
 #include "c1/c1_LIRAssembler.hpp"
 #include "c1/c1_MacroAssembler.hpp"
--- a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_MacroAssembler.hpp"
 #include "c1/c1_Runtime1.hpp"
 #include "classfile/systemDictionary.hpp"
--- a/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Defs.hpp"
 #include "c1/c1_MacroAssembler.hpp"
 #include "c1/c1_Runtime1.hpp"
--- a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -29,6 +29,7 @@
 #include "gc/g1/g1CardTable.hpp"
 #include "gc/g1/g1BarrierSet.hpp"
 #include "gc/g1/g1BarrierSetAssembler.hpp"
+#include "gc/g1/g1BarrierSetRuntime.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "interpreter/interp_masm.hpp"
@@ -66,9 +67,9 @@
     RegisterSaver::save_live_registers(masm, RegisterSaver::arg_registers); // Creates frame.
 
     if (UseCompressedOops) {
-      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry), addr, count);
+      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_narrow_oop_entry), addr, count);
     } else {
-      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry), addr, count);
+      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_oop_entry), addr, count);
     }
 
     RegisterSaver::restore_live_registers(masm, RegisterSaver::arg_registers);
@@ -79,7 +80,7 @@
 
 void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
                                                              Register addr, Register count, bool do_return) {
-  address entry_point = CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry);
+  address entry_point = CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry);
   if (!do_return) {
     assert_different_registers(addr,  Z_R0_scratch);  // would be destroyed by push_frame()
     assert_different_registers(count, Z_R0_scratch);  // would be destroyed by push_frame()
@@ -234,7 +235,7 @@
   __ push_frame_abi160(0); // Will use Z_R0 as tmp.
 
   // Rpre_val may be destroyed by push_frame().
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), Rpre_save, Z_thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), Rpre_save, Z_thread);
 
   __ pop_frame();
   __ restore_return_pc();
@@ -359,7 +360,7 @@
   }
 
   // Save the live input values.
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), Rcard_addr, Z_thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), Rcard_addr, Z_thread);
 
   if (needs_frame) {
     __ pop_frame();
--- a/src/hotspot/cpu/sparc/c1_CodeStubs_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/c1_CodeStubs_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_CodeStubs.hpp"
 #include "c1/c1_FrameMap.hpp"
 #include "c1/c1_LIRAssembler.hpp"
--- a/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Compilation.hpp"
 #include "c1/c1_LIRAssembler.hpp"
 #include "c1/c1_MacroAssembler.hpp"
--- a/src/hotspot/cpu/sparc/c1_LIRGenerator_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/c1_LIRGenerator_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Compilation.hpp"
 #include "c1/c1_FrameMap.hpp"
 #include "c1/c1_Instruction.hpp"
--- a/src/hotspot/cpu/sparc/c1_MacroAssembler_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/c1_MacroAssembler_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_MacroAssembler.hpp"
 #include "c1/c1_Runtime1.hpp"
 #include "classfile/systemDictionary.hpp"
--- a/src/hotspot/cpu/sparc/c1_Runtime1_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/c1_Runtime1_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "c1/c1_Defs.hpp"
 #include "c1/c1_MacroAssembler.hpp"
 #include "c1/c1_Runtime1.hpp"
--- a/src/hotspot/cpu/sparc/gc/g1/g1BarrierSetAssembler_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/gc/g1/g1BarrierSetAssembler_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -26,6 +26,7 @@
 #include "asm/macroAssembler.inline.hpp"
 #include "gc/g1/g1BarrierSet.hpp"
 #include "gc/g1/g1BarrierSetAssembler.hpp"
+#include "gc/g1/g1BarrierSetRuntime.hpp"
 #include "gc/g1/g1CardTable.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/heapRegion.hpp"
@@ -68,8 +69,8 @@
     }
     __ mov(addr->after_save(), O0);
     // Get the count into O1
-    address slowpath = UseCompressedOops ? CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry)
-                                         : CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry);
+    address slowpath = UseCompressedOops ? CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_narrow_oop_entry)
+                                         : CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_oop_entry);
     __ call(slowpath);
     __ delayed()->mov(count->after_save(), O1);
     if (addr->is_global()) {
@@ -90,7 +91,7 @@
   // Get some new fresh output registers.
   __ save_frame(0);
   __ mov(addr->after_save(), O0);
-  __ call(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry));
+  __ call(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry));
   __ delayed()->mov(count->after_save(), O1);
   __ restore();
 }
--- a/src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/gc/shared/barrierSetAssembler_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "gc/shared/barrierSetAssembler.hpp"
 #include "interpreter/interp_masm.hpp"
 #include "runtime/jniHandles.hpp"
--- a/src/hotspot/cpu/sparc/interp_masm_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/interp_masm_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "interp_masm_sparc.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
--- a/src/hotspot/cpu/sparc/interp_masm_sparc.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/interp_masm_sparc.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -25,7 +25,7 @@
 #ifndef CPU_SPARC_VM_INTERP_MASM_SPARC_HPP
 #define CPU_SPARC_VM_INTERP_MASM_SPARC_HPP
 
-#include "asm/macroAssembler.inline.hpp"
+#include "asm/macroAssembler.hpp"
 #include "interpreter/invocationCounter.hpp"
 
 // This file specializes the assember with interpreter-specific macros
--- a/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -3338,6 +3338,12 @@
   _masm->bind(_label);
 }
 
+void MacroAssembler::bang_stack_with_offset(int offset) {
+  // stack grows down, caller passes positive offset
+  assert(offset > 0, "must bang with negative offset");
+  set((-offset)+STACK_BIAS, G3_scratch);
+  st(G0, SP, G3_scratch);
+}
 
 // Writes to stack successive pages until offset reached to check for
 // stack overflow + shadow pages.  This clobbers tsp and scratch.
--- a/src/hotspot/cpu/sparc/macroAssembler_sparc.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1303,7 +1303,7 @@
   // Stack overflow checking
 
   // Note: this clobbers G3_scratch
-  inline void bang_stack_with_offset(int offset);
+  void bang_stack_with_offset(int offset);
 
   // Writes to stack successive pages until offset reached to check for
   // stack overflow + shadow pages.  Clobbers tsp and scratch registers.
--- a/src/hotspot/cpu/sparc/macroAssembler_sparc.inline.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.inline.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -724,12 +724,4 @@
   if (a.has_index()) { assert(offset == 0, ""); swap(a.base(), a.index(), d        ); }
   else               {                          swap(a.base(), a.disp() + offset, d); }
 }
-
-inline void MacroAssembler::bang_stack_with_offset(int offset) {
-  // stack grows down, caller passes positive offset
-  assert(offset > 0, "must bang with negative offset");
-  set((-offset)+STACK_BIAS, G3_scratch);
-  st(G0, SP, G3_scratch);
-}
-
 #endif // CPU_SPARC_VM_MACROASSEMBLER_SPARC_INLINE_HPP
--- a/src/hotspot/cpu/sparc/memset_with_concurrent_readers_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/memset_with_concurrent_readers_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 
+#include "asm/macroAssembler.inline.hpp"
 #include "gc/shared/memset_with_concurrent_readers.hpp"
 #include "runtime/prefetch.inline.hpp"
 #include "utilities/align.hpp"
--- a/src/hotspot/cpu/sparc/methodHandles_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/methodHandles_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -24,7 +24,7 @@
 
 #include "precompiled.hpp"
 #include "jvm.h"
-#include "asm/macroAssembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "classfile/javaClasses.inline.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interp_masm.hpp"
--- a/src/hotspot/cpu/sparc/relocInfo_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/relocInfo_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, 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
@@ -23,7 +23,7 @@
  */
 
 #include "precompiled.hpp"
-#include "asm/assembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "code/relocInfo.hpp"
 #include "nativeInst_sparc.hpp"
 #include "oops/compressedOops.inline.hpp"
--- a/src/hotspot/cpu/sparc/templateInterpreterGenerator_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/templateInterpreterGenerator_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,7 +23,7 @@
  */
 
 #include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "gc/shared/barrierSetAssembler.hpp"
 #include "interpreter/bytecodeHistogram.hpp"
 #include "interpreter/interpreter.hpp"
--- a/src/hotspot/cpu/sparc/templateTable_sparc.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/sparc/templateTable_sparc.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/macroAssembler.inline.hpp"
 #include "gc/shared/barrierSetAssembler.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
--- a/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -26,6 +26,7 @@
 #include "asm/macroAssembler.inline.hpp"
 #include "gc/g1/g1BarrierSet.hpp"
 #include "gc/g1/g1BarrierSetAssembler.hpp"
+#include "gc/g1/g1BarrierSetRuntime.hpp"
 #include "gc/g1/g1CardTable.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/heapRegion.hpp"
@@ -80,12 +81,12 @@
       __ movptr(c_rarg1, count);
     }
     if (UseCompressedOops) {
-      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_narrow_oop_entry), 2);
+      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_narrow_oop_entry), 2);
     } else {
-      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry), 2);
+      __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_oop_entry), 2);
     }
 #else
-    __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_pre_oop_entry),
+    __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_pre_oop_entry),
                     addr, count);
 #endif
     __ popa();
@@ -107,9 +108,9 @@
     __ mov(c_rarg0, addr);
     __ mov(c_rarg1, count);
   }
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry), 2);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry), 2);
 #else
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSet::write_ref_array_post_entry),
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry),
                   addr, count);
 #endif
   __ popa();
@@ -238,9 +239,9 @@
     __ push(thread);
     __ push(pre_val);
 #endif
-    __ MacroAssembler::call_VM_leaf_base(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), 2);
+    __ MacroAssembler::call_VM_leaf_base(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), 2);
   } else {
-    __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), pre_val, thread);
+    __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), pre_val, thread);
   }
 
   NOT_LP64( __ pop(thread); )
@@ -333,10 +334,10 @@
   __ push(store_addr);
   __ push(new_val);
 #ifdef _LP64
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, r15_thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), card_addr, r15_thread);
 #else
   __ push(thread);
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), card_addr, thread);
   __ pop(thread);
 #endif
   __ pop(new_val);
@@ -500,7 +501,7 @@
 
   // load the pre-value
   __ load_parameter(0, rcx);
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), rcx, thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), rcx, thread);
 
   __ restore_live_registers(true);
 
@@ -577,7 +578,7 @@
 
   __ save_live_registers_no_oop_map(true);
 
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), card_addr, thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), card_addr, thread);
 
   __ restore_live_registers(true);
 
--- a/src/hotspot/cpu/x86/interp_masm_x86.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/x86/interp_masm_x86.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -26,7 +26,6 @@
 #define CPU_X86_VM_INTERP_MASM_X86_HPP
 
 #include "asm/macroAssembler.hpp"
-#include "asm/macroAssembler.inline.hpp"
 #include "interpreter/invocationCounter.hpp"
 #include "runtime/frame.hpp"
 
--- a/src/hotspot/cpu/zero/interp_masm_zero.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/zero/interp_masm_zero.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -26,7 +26,8 @@
 #ifndef CPU_ZERO_VM_INTERP_MASM_ZERO_HPP
 #define CPU_ZERO_VM_INTERP_MASM_ZERO_HPP
 
-#include "assembler_zero.inline.hpp"
+#include "asm/codeBuffer.hpp"
+#include "asm/macroAssembler.hpp"
 #include "interpreter/invocationCounter.hpp"
 
 // This file specializes the assember with interpreter-specific macros
--- a/src/hotspot/cpu/zero/relocInfo_zero.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/zero/relocInfo_zero.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2009, 2010, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -24,8 +24,7 @@
  */
 
 #include "precompiled.hpp"
-#include "asm/assembler.inline.hpp"
-#include "assembler_zero.inline.hpp"
+#include "asm/codeBuffer.hpp"
 #include "code/relocInfo.hpp"
 #include "nativeInst_zero.hpp"
 #include "oops/oop.inline.hpp"
--- a/src/hotspot/cpu/zero/vtableStubs_zero.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/cpu/zero/vtableStubs_zero.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -24,18 +24,8 @@
  */
 
 #include "precompiled.hpp"
-#include "asm/assembler.hpp"
-#include "assembler_zero.inline.hpp"
 #include "code/vtableStubs.hpp"
-#include "interp_masm_zero.hpp"
-#include "memory/resourceArea.hpp"
-#include "oops/instanceKlass.hpp"
-#include "oops/klassVtable.hpp"
-#include "runtime/sharedRuntime.hpp"
-#include "vmreg_zero.inline.hpp"
-#ifdef COMPILER2
-#include "opto/runtime.hpp"
-#endif
+#include "utilities/debug.hpp"
 
 VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
   ShouldNotCallThis();
--- a/src/hotspot/share/c1/c1_LIRAssembler.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/c1/c1_LIRAssembler.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/assembler.inline.hpp"
 #include "c1/c1_Compilation.hpp"
 #include "c1/c1_Instruction.hpp"
 #include "c1/c1_InstructionPrinter.hpp"
--- a/src/hotspot/share/c1/c1_MacroAssembler.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/c1/c1_MacroAssembler.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -26,7 +26,6 @@
 #define SHARE_VM_C1_C1_MACROASSEMBLER_HPP
 
 #include "asm/macroAssembler.hpp"
-#include "asm/macroAssembler.inline.hpp"
 #include "utilities/macros.hpp"
 
 class CodeEmitInfo;
--- a/src/hotspot/share/classfile/javaClasses.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/classfile/javaClasses.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -310,7 +310,8 @@
   Handle h_obj = basic_create(length, is_latin1, CHECK_NH);
   if (length > 0) {
     if (!has_multibyte) {
-      strncpy((char*)value(h_obj())->byte_at_addr(0), utf8_str, length);
+      const jbyte* src = reinterpret_cast<const jbyte*>(utf8_str);
+      ArrayAccess<>::arraycopy_from_native(src, value(h_obj()), typeArrayOopDesc::element_offset<jbyte>(0), length);
     } else if (is_latin1) {
       UTF8::convert_to_unicode(utf8_str, value(h_obj())->byte_at_addr(0), length);
     } else {
@@ -356,7 +357,8 @@
   Handle h_obj = basic_create(length, is_latin1, CHECK_NH);
   if (length > 0) {
     if (!has_multibyte) {
-      strncpy((char*)value(h_obj())->byte_at_addr(0), utf8_str, length);
+      const jbyte* src = reinterpret_cast<const jbyte*>(utf8_str);
+      ArrayAccess<>::arraycopy_from_native(src, value(h_obj()), typeArrayOopDesc::element_offset<jbyte>(0), length);
     } else if (is_latin1) {
       UTF8::convert_to_unicode(utf8_str, value(h_obj())->byte_at_addr(0), length);
     } else {
--- a/src/hotspot/share/classfile/moduleEntry.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/classfile/moduleEntry.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -25,7 +25,7 @@
 #include "precompiled.hpp"
 #include "jni.h"
 #include "classfile/classLoaderData.inline.hpp"
-#include "classfile/javaClasses.hpp"
+#include "classfile/javaClasses.inline.hpp"
 #include "classfile/moduleEntry.hpp"
 #include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
@@ -236,10 +236,17 @@
   // The java.lang.Module for this loader's
   // corresponding unnamed module can be found in the java.lang.ClassLoader object.
   oop module = java_lang_ClassLoader::unnamedModule(cld->class_loader());
+
+  // Ensure that the unnamed module was correctly set when the class loader was constructed.
+  // Guarantee will cause a recognizable crash if the user code has circumvented calling the ClassLoader constructor.
+  ResourceMark rm;
+  guarantee(java_lang_Module::is_instance(module),
+            "The unnamed module for ClassLoader %s, is null or not an instance of java.lang.Module. The class loader has not been initialized correctly.",
+            cld->loader_name());
+
   ModuleEntry* unnamed_module = new_unnamed_module_entry(Handle(Thread::current(), module), cld);
 
-  // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module
-  // object.
+  // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
   java_lang_Module::set_module_entry(module, unnamed_module);
 
   return unnamed_module;
--- a/src/hotspot/share/classfile/systemDictionaryShared.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -87,8 +87,8 @@
     assert(src != NULL, "No Manifest data");
     typeArrayOop buf = oopFactory::new_byteArray(size, CHECK_NH);
     typeArrayHandle bufhandle(THREAD, buf);
-    char* dst = (char*)(buf->byte_at_addr(0));
-    memcpy(dst, src, (size_t)size);
+    ArrayAccess<>::arraycopy_from_native(reinterpret_cast<const jbyte*>(src),
+                                         buf, typeArrayOopDesc::element_offset<jbyte>(0), size);
 
     Handle bais = JavaCalls::construct_new_instance(SystemDictionary::ByteArrayInputStream_klass(),
                       vmSymbols::byte_array_void_signature(),
--- a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "gc/g1/c2/g1BarrierSetC2.hpp"
 #include "gc/g1/g1BarrierSet.hpp"
+#include "gc/g1/g1BarrierSetRuntime.hpp"
 #include "gc/g1/g1CardTable.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/heapRegion.hpp"
@@ -33,10 +34,9 @@
 #include "opto/idealKit.hpp"
 #include "opto/macro.hpp"
 #include "opto/type.hpp"
-#include "runtime/sharedRuntime.hpp"
 #include "utilities/macros.hpp"
 
-const TypeFunc *G1BarrierSetC2::g1_wb_pre_Type() {
+const TypeFunc *G1BarrierSetC2::write_ref_field_pre_entry_Type() {
   const Type **fields = TypeTuple::fields(2);
   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value
   fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread
@@ -49,7 +49,7 @@
   return TypeFunc::make(domain, range);
 }
 
-const TypeFunc *G1BarrierSetC2::g1_wb_post_Type() {
+const TypeFunc *G1BarrierSetC2::write_ref_field_post_entry_Type() {
   const Type **fields = TypeTuple::fields(2);
   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL;  // Card addr
   fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL;  // thread
@@ -264,8 +264,8 @@
       } __ else_(); {
 
         // logging buffer is full, call the runtime
-        const TypeFunc *tf = g1_wb_pre_Type();
-        __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), "g1_wb_pre", pre_val, tls);
+        const TypeFunc *tf = write_ref_field_pre_entry_Type();
+        __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), "write_ref_field_pre_entry", pre_val, tls);
       } __ end_if();  // (!index)
     } __ end_if();  // (pre_val != NULL)
   } __ end_if();  // (!marking)
@@ -364,7 +364,7 @@
     __ store(__ ctrl(), index_adr, next_index, TypeX_X->basic_type(), Compile::AliasIdxRaw, MemNode::unordered);
 
   } __ else_(); {
-    __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), "g1_wb_post", card_adr, __ thread());
+    __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), "write_ref_field_post_entry", card_adr, __ thread());
   } __ end_if();
 
 }
@@ -419,7 +419,7 @@
   Node* dirty_card = __ ConI((jint)G1CardTable::dirty_card_val());
   Node* zeroX = __ ConX(0);
 
-  const TypeFunc *tf = g1_wb_post_Type();
+  const TypeFunc *tf = write_ref_field_post_entry_Type();
 
   // Offsets into the thread
   const int index_offset  = in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset());
@@ -652,7 +652,7 @@
     return false;
   }
 
-  return strcmp(call->_name, "g1_wb_pre") == 0 || strcmp(call->_name, "g1_wb_post") == 0;
+  return strcmp(call->_name, "write_ref_field_pre_entry") == 0 || strcmp(call->_name, "write_ref_field_post_entry") == 0;
 }
 
 void G1BarrierSetC2::eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const {
@@ -747,7 +747,7 @@
           if (r->in(j) != NULL && r->in(j)->is_Proj() &&
               r->in(j)->in(0) != NULL &&
               r->in(j)->in(0)->Opcode() == Op_CallLeaf &&
-              r->in(j)->in(0)->as_Call()->entry_point() == CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post)) {
+              r->in(j)->in(0)->as_Call()->entry_point() == CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry)) {
             Node* call = r->in(j)->in(0);
             c = c->in(i == 1 ? 2 : 1);
             if (c != NULL) {
--- a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -79,8 +79,8 @@
   // Unsafe.getObject should be recorded in an SATB log buffer.
   void insert_pre_barrier(GraphKit* kit, Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar) const;
 
-  static const TypeFunc* g1_wb_pre_Type();
-  static const TypeFunc* g1_wb_post_Type();
+  static const TypeFunc* write_ref_field_pre_entry_Type();
+  static const TypeFunc* write_ref_field_post_entry_Type();
 
   virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const;
 
--- a/src/hotspot/share/gc/g1/g1BarrierSet.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/gc/g1/g1BarrierSet.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -72,21 +72,6 @@
   }
 }
 
-void G1BarrierSet::write_ref_array_pre_oop_entry(oop* dst, size_t length) {
-  G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
-  bs->write_ref_array_pre(dst, length, false);
-}
-
-void G1BarrierSet::write_ref_array_pre_narrow_oop_entry(narrowOop* dst, size_t length) {
-  G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
-  bs->write_ref_array_pre(dst, length, false);
-}
-
-void G1BarrierSet::write_ref_array_post_entry(HeapWord* dst, size_t length) {
-  G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
-  bs->G1BarrierSet::write_ref_array(dst, length);
-}
-
 template <class T> void
 G1BarrierSet::write_ref_array_pre_work(T* dst, size_t count) {
   if (!_satb_mark_queue_set.is_active()) return;
--- a/src/hotspot/share/gc/g1/g1BarrierSet.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/gc/g1/g1BarrierSet.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -56,10 +56,6 @@
   virtual void write_ref_array_pre(oop* dst, size_t count, bool dest_uninitialized);
   virtual void write_ref_array_pre(narrowOop* dst, size_t count, bool dest_uninitialized);
 
-  static void write_ref_array_pre_oop_entry(oop* dst, size_t length);
-  static void write_ref_array_pre_narrow_oop_entry(narrowOop* dst, size_t length);
-  static void write_ref_array_post_entry(HeapWord* dst, size_t length);
-
   template <DecoratorSet decorators, typename T>
   void write_ref_field_pre(T* field);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/g1/g1BarrierSetRuntime.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2018, 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/g1BarrierSet.inline.hpp"
+#include "gc/g1/g1BarrierSetRuntime.hpp"
+#include "gc/g1/g1ThreadLocalData.hpp"
+#include "runtime/interfaceSupport.inline.hpp"
+#include "utilities/macros.hpp"
+
+void G1BarrierSetRuntime::write_ref_array_pre_oop_entry(oop* dst, size_t length) {
+  G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
+  bs->write_ref_array_pre(dst, length, false);
+}
+
+void G1BarrierSetRuntime::write_ref_array_pre_narrow_oop_entry(narrowOop* dst, size_t length) {
+  G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
+  bs->write_ref_array_pre(dst, length, false);
+}
+
+void G1BarrierSetRuntime::write_ref_array_post_entry(HeapWord* dst, size_t length) {
+  G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
+  bs->G1BarrierSet::write_ref_array(dst, length);
+}
+
+// G1 pre write barrier slowpath
+JRT_LEAF(void, G1BarrierSetRuntime::write_ref_field_pre_entry(oopDesc* orig, JavaThread *thread))
+  if (orig == NULL) {
+    assert(false, "should be optimized out");
+    return;
+  }
+  assert(oopDesc::is_oop(orig, true /* ignore mark word */), "Error");
+  // store the original value that was in the field reference
+  G1ThreadLocalData::satb_mark_queue(thread).enqueue(orig);
+JRT_END
+
+// G1 post write barrier slowpath
+JRT_LEAF(void, G1BarrierSetRuntime::write_ref_field_post_entry(void* card_addr, JavaThread* thread))
+  G1ThreadLocalData::dirty_card_queue(thread).enqueue(card_addr);
+JRT_END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/g1/g1BarrierSetRuntime.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_GC_G1_G1BARRIERSETRUNTIME_HPP
+#define SHARE_GC_G1_G1BARRIERSETRUNTIME_HPP
+
+#include "memory/allocation.hpp"
+#include "oops/oopsHierarchy.hpp"
+#include "utilities/globalDefinitions.hpp"
+#include "utilities/macros.hpp"
+
+class oopDesc;
+class JavaThread;
+
+class G1BarrierSetRuntime: public AllStatic {
+public:
+  // Arraycopy stub generator
+  static void write_ref_array_pre_oop_entry(oop* dst, size_t length);
+  static void write_ref_array_pre_narrow_oop_entry(narrowOop* dst, size_t length);
+  static void write_ref_array_post_entry(HeapWord* dst, size_t length);
+
+  // C2 slow-path runtime calls.
+  static void write_ref_field_pre_entry(oopDesc* orig, JavaThread *thread);
+  static void write_ref_field_post_entry(void* card_addr, JavaThread* thread);
+};
+
+#endif // SHARE_GC_G1_G1BARRIERSETRUNTIME_HPP
--- a/src/hotspot/share/gc/shared/barrierSet.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/gc/shared/barrierSet.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -213,8 +213,12 @@
     }
 
     template <typename T>
-    static void arraycopy_in_heap(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
-      Raw::arraycopy(src_obj, dst_obj, src, dst, length);
+    static void arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                                  arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                  size_t length) {
+      Raw::arraycopy(src_obj, src_offset_in_bytes, src_raw,
+                     dst_obj, dst_offset_in_bytes, dst_raw,
+                     length);
     }
 
     // Heap oop accesses. These accessors get resolved when
@@ -257,8 +261,12 @@
     }
 
     template <typename T>
-    static bool oop_arraycopy_in_heap(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
-      return Raw::oop_arraycopy(src_obj, dst_obj, src, dst, length);
+    static bool oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                                      arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                      size_t length) {
+      return Raw::oop_arraycopy(src_obj, src_offset_in_bytes, src_raw,
+                                dst_obj, dst_offset_in_bytes, dst_raw,
+                                length);
     }
 
     // Off-heap oop accesses. These accessors get resolved when
--- a/src/hotspot/share/gc/shared/modRefBarrierSet.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/gc/shared/modRefBarrierSet.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -83,7 +83,9 @@
     static oop oop_atomic_xchg_in_heap(oop new_value, T* addr);
 
     template <typename T>
-    static bool oop_arraycopy_in_heap(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
+    static bool oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                                      arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                      size_t length);
 
     static void clone_in_heap(oop src, oop dst, size_t size);
 
--- a/src/hotspot/share/gc/shared/modRefBarrierSet.inline.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/gc/shared/modRefBarrierSet.inline.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -91,35 +91,41 @@
 template <DecoratorSet decorators, typename BarrierSetT>
 template <typename T>
 inline bool ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT>::
-oop_arraycopy_in_heap(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
+oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                      arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                      size_t length) {
   BarrierSetT *bs = barrier_set_cast<BarrierSetT>(barrier_set());
 
+  src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
+  dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
+
   if (!HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value) {
     // Optimized covariant case
-    bs->write_ref_array_pre(dst, length,
+    bs->write_ref_array_pre(dst_raw, length,
                             HasDecorator<decorators, AS_DEST_NOT_INITIALIZED>::value);
-    Raw::oop_arraycopy(src_obj, dst_obj, src, dst, length);
-    bs->write_ref_array((HeapWord*)dst, length);
+    Raw::oop_arraycopy(NULL, 0, src_raw, NULL, 0, dst_raw, length);
+    bs->write_ref_array((HeapWord*)dst_raw, length);
   } else {
+    assert(dst_obj != NULL, "better have an actual oop");
     Klass* bound = objArrayOop(dst_obj)->element_klass();
-    T* from = src;
+    T* from = const_cast<T*>(src_raw);
     T* end = from + length;
-    for (T* p = dst; from < end; from++, p++) {
+    for (T* p = dst_raw; from < end; from++, p++) {
       T element = *from;
       if (oopDesc::is_instanceof_or_null(CompressedOops::decode(element), bound)) {
         bs->template write_ref_field_pre<decorators>(p);
         *p = element;
       } else {
         // We must do a barrier to cover the partial copy.
-        const size_t pd = pointer_delta(p, dst, (size_t)heapOopSize);
+        const size_t pd = pointer_delta(p, dst_raw, (size_t)heapOopSize);
         // pointer delta is scaled to number of elements (length field in
         // objArrayOop) which we assume is 32 bit.
         assert(pd == (size_t)(int)pd, "length field overflow");
-        bs->write_ref_array((HeapWord*)dst, pd);
+        bs->write_ref_array((HeapWord*)dst_raw, pd);
         return false;
       }
     }
-    bs->write_ref_array((HeapWord*)dst, length);
+    bs->write_ref_array((HeapWord*)dst_raw, length);
   }
   return true;
 }
--- a/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -584,10 +584,8 @@
 
 static void print_module_resolution_error(outputStream* stream) {
   assert(stream != NULL, "invariant");
-  stream->print_cr("%s not found.", JDK_JFR_MODULE_NAME);
+  stream->print_cr("Module %s not found.", JDK_JFR_MODULE_NAME);
   stream->print_cr("Flight Recorder can not be enabled.");
-  stream->print_cr("To use Flight Recorder, you might need to add" \
-    " \"--add-modules %s\" to the VM command-line options.", JDK_JFR_MODULE_NAME);
 }
 
 bool JfrJavaSupport::is_jdk_jfr_module_available() {
--- a/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -44,46 +44,48 @@
   NATIVE_SAMPLE = 2
 };
 
-static bool in_java_sample(JavaThread* thread) {
-  switch (thread->thread_state()) {
-  case _thread_new:
-  case _thread_uninitialized:
-  case _thread_new_trans:
-  case _thread_in_vm_trans:
-  case _thread_blocked_trans:
-  case _thread_in_native_trans:
-  case _thread_blocked:
-  case _thread_in_vm:
-  case _thread_in_native:
-  case _thread_in_Java_trans:
-    break;
-  case _thread_in_Java:
-    return true;
-  default:
-    ShouldNotReachHere();
-    break;
+static bool thread_state_in_java(JavaThread* thread) {
+  assert(thread != NULL, "invariant");
+  switch(thread->thread_state()) {
+    case _thread_new:
+    case _thread_uninitialized:
+    case _thread_new_trans:
+    case _thread_in_vm_trans:
+    case _thread_blocked_trans:
+    case _thread_in_native_trans:
+    case _thread_blocked:
+    case _thread_in_vm:
+    case _thread_in_native:
+    case _thread_in_Java_trans:
+      break;
+    case _thread_in_Java:
+      return true;
+    default:
+      ShouldNotReachHere();
+      break;
   }
   return false;
 }
 
-static bool in_native_sample(JavaThread* thread) {
-  switch (thread->thread_state()) {
-  case _thread_new:
-  case _thread_uninitialized:
-  case _thread_new_trans:
-  case _thread_blocked_trans:
-  case _thread_blocked:
-  case _thread_in_vm:
-  case _thread_in_vm_trans:
-  case _thread_in_Java_trans:
-  case _thread_in_Java:
-  case _thread_in_native_trans:
-    break;
-  case _thread_in_native:
-    return true;
-  default:
-    ShouldNotReachHere();
-    break;
+static bool thread_state_in_native(JavaThread* thread) {
+  assert(thread != NULL, "invariant");
+  switch(thread->thread_state()) {
+    case _thread_new:
+    case _thread_uninitialized:
+    case _thread_new_trans:
+    case _thread_blocked_trans:
+    case _thread_blocked:
+    case _thread_in_vm:
+    case _thread_in_vm_trans:
+    case _thread_in_Java_trans:
+    case _thread_in_Java:
+    case _thread_in_native_trans:
+      break;
+    case _thread_in_native:
+      return true;
+    default:
+      ShouldNotReachHere();
+      break;
   }
   return false;
 }
@@ -94,11 +96,10 @@
   ~JfrThreadSampleClosure() {}
   EventExecutionSample* next_event() { return &_events[_added_java++]; }
   EventNativeMethodSample* next_event_native() { return &_events_native[_added_native++]; }
-  void commit_events();
-  int added() const { return _added_java; }
-  JfrSampleType do_sample_thread(JavaThread* thread, JfrStackFrame* frames, u4 max_frames, bool java_sample, bool native_sample);
-  int java_entries() { return _added_java; }
-  int native_entries() { return _added_native; }
+  void commit_events(JfrSampleType type);
+  bool do_sample_thread(JavaThread* thread, JfrStackFrame* frames, u4 max_frames, JfrSampleType type);
+  uint java_entries() { return _added_java; }
+  uint native_entries() { return _added_native; }
 
  private:
   bool sample_thread_in_java(JavaThread* thread, JfrStackFrame* frames, u4 max_frames);
@@ -106,8 +107,8 @@
   EventExecutionSample* _events;
   EventNativeMethodSample* _events_native;
   Thread* _self;
-  int _added_java;
-  int _added_native;
+  uint _added_java;
+  uint _added_native;
 };
 
 class OSThreadSampler : public os::SuspendedThreadTask {
@@ -172,7 +173,7 @@
 void OSThreadSampler::protected_task(const os::SuspendedThreadTaskContext& context) {
   JavaThread* jth = (JavaThread*)context.thread();
   // Skip sample if we signaled a thread that moved to other state
-  if (!in_java_sample(jth)) {
+  if (!thread_state_in_java(jth)) {
     return;
   }
   JfrGetCallTrace trace(true, jth);
@@ -281,12 +282,21 @@
   return true;
 }
 
-void JfrThreadSampleClosure::commit_events() {
-  for (int i = 0; i < _added_java; ++i) {
-    _events[i].commit();
-  }
-  for (int i = 0; i < _added_native; ++i) {
-    _events_native[i].commit();
+static const uint MAX_NR_OF_JAVA_SAMPLES = 5;
+static const uint MAX_NR_OF_NATIVE_SAMPLES = 1;
+
+void JfrThreadSampleClosure::commit_events(JfrSampleType type) {
+  if (JAVA_SAMPLE == type) {
+    assert(_added_java <= MAX_NR_OF_JAVA_SAMPLES, "invariant");
+    for (uint i = 0; i < _added_java; ++i) {
+      _events[i].commit();
+    }
+  } else {
+    assert(NATIVE_SAMPLE == type, "invariant");
+    assert(_added_native <= MAX_NR_OF_NATIVE_SAMPLES, "invariant");
+    for (uint i = 0; i < _added_native; ++i) {
+      _events_native[i].commit();
+    }
   }
 }
 
@@ -344,23 +354,26 @@
   }
 }
 
-JfrSampleType JfrThreadSampleClosure::do_sample_thread(JavaThread* thread, JfrStackFrame* frames, u4 max_frames, bool java_sample, bool native_sample) {
+bool JfrThreadSampleClosure::do_sample_thread(JavaThread* thread, JfrStackFrame* frames, u4 max_frames, JfrSampleType type) {
   assert(Threads_lock->owned_by_self(), "Holding the thread table lock.");
-  if (thread->is_hidden_from_external_view()) {
-    return NO_SAMPLE;
+  if (thread->is_hidden_from_external_view() || thread->in_deopt_handler()) {
+    return false;
   }
-  if (thread->in_deopt_handler()) {
-    return NO_SAMPLE;
-  }
-  JfrSampleType ret = NO_SAMPLE;
+
+  bool ret = false;
   thread->set_trace_flag();
   if (!UseMembar) {
     os::serialize_thread_states();
   }
-  if (in_java_sample(thread) && java_sample) {
-    ret = sample_thread_in_java(thread, frames, max_frames) ? JAVA_SAMPLE : NO_SAMPLE;
-  } else if (in_native_sample(thread) && native_sample) {
-    ret = sample_thread_in_native(thread, frames, max_frames) ? NATIVE_SAMPLE : NO_SAMPLE;
+  if (JAVA_SAMPLE == type) {
+    if (thread_state_in_java(thread)) {
+      ret = sample_thread_in_java(thread, frames, max_frames);
+    }
+  } else {
+    assert(NATIVE_SAMPLE == type, "invariant");
+    if (thread_state_in_native(thread)) {
+      ret = sample_thread_in_native(thread, frames, max_frames);
+    }
   }
   clear_transition_block(thread);
   return ret;
@@ -396,31 +409,19 @@
 }
 
 JavaThread* JfrThreadSampler::next_thread(ThreadsList* t_list, JavaThread* first_sampled, JavaThread* current) {
+  assert(t_list != NULL, "invariant");
   assert(Threads_lock->owned_by_self(), "Holding the thread table lock.");
-  if (current == NULL) {
+  assert(_cur_index >= -1 && (uint)_cur_index + 1 <= t_list->length(), "invariant");
+  assert((current == NULL && -1 == _cur_index) || (t_list->find_index_of_JavaThread(current) == _cur_index), "invariant");
+  if ((uint)_cur_index + 1 == t_list->length()) {
+    // wrap
     _cur_index = 0;
-    return t_list->thread_at(_cur_index);
-  }
-
-  if (_cur_index == -1 || t_list->thread_at(_cur_index) != current) {
-    // 'current' is not at '_cur_index' so find it:
-    _cur_index = t_list->find_index_of_JavaThread(current);
-    assert(_cur_index != -1, "current JavaThread should be findable.");
+  } else {
+    _cur_index++;
   }
-  _cur_index++;
-
-  JavaThread* next = NULL;
-  // wrap
-  if ((uint)_cur_index >= t_list->length()) {
-    _cur_index = 0;
-  }
-  next = t_list->thread_at(_cur_index);
-
-  // sample wrap
-  if (next == first_sampled) {
-    return NULL;
-  }
-  return next;
+  assert(_cur_index >= 0 && (uint)_cur_index < t_list->length(), "invariant");
+  JavaThread* const next = t_list->thread_at(_cur_index);
+  return next != first_sampled ? next : NULL;
 }
 
 void JfrThreadSampler::start_thread() {
@@ -494,54 +495,50 @@
   delete this;
 }
 
-static const int MAX_NR_OF_SAMPLES = 5;
 
 void JfrThreadSampler::task_stacktrace(JfrSampleType type, JavaThread** last_thread) {
   ResourceMark rm;
-  EventExecutionSample samples[MAX_NR_OF_SAMPLES];
-  EventNativeMethodSample samples_native[MAX_NR_OF_SAMPLES];
+  EventExecutionSample samples[MAX_NR_OF_JAVA_SAMPLES];
+  EventNativeMethodSample samples_native[MAX_NR_OF_NATIVE_SAMPLES];
   JfrThreadSampleClosure sample_task(samples, samples_native);
 
-  int num_samples = 0;
+  const uint sample_limit = JAVA_SAMPLE == type ? MAX_NR_OF_JAVA_SAMPLES : MAX_NR_OF_NATIVE_SAMPLES;
+  uint num_sample_attempts = 0;
+  JavaThread* start = NULL;
+
   {
     elapsedTimer sample_time;
     sample_time.start();
-
     {
       MonitorLockerEx tlock(Threads_lock, Mutex::_allow_vm_block_flag);
       ThreadsListHandle tlh;
-      JavaThread* current = tlh.includes(*last_thread) ? *last_thread : NULL;
-      JavaThread* start = NULL;
+      // Resolve a sample session relative start position index into the thread list array.
+      // In cases where the last sampled thread is NULL or not-NULL but stale, find_index() returns -1.
+      _cur_index = tlh.list()->find_index_of_JavaThread(*last_thread);
+      JavaThread* current = _cur_index != -1 ? *last_thread : NULL;
 
-      while (num_samples < MAX_NR_OF_SAMPLES) {
+      while (num_sample_attempts < sample_limit) {
         current = next_thread(tlh.list(), start, current);
         if (current == NULL) {
           break;
         }
         if (start == NULL) {
-          start = current;  // remember thread where we started sampling
+          start = current;  // remember the thread where we started to attempt sampling
         }
         if (current->is_Compiler_thread()) {
           continue;
         }
-        *last_thread = current;  // remember thread we last sampled
-        JfrSampleType ret = sample_task.do_sample_thread(current, _frames, _max_frames, type == JAVA_SAMPLE, type == NATIVE_SAMPLE);
-        switch (type) {
-        case JAVA_SAMPLE:
-        case NATIVE_SAMPLE:
-          ++num_samples;
-          break;
-        default:
-          break;
-        }
+        sample_task.do_sample_thread(current, _frames, _max_frames, type);
+        num_sample_attempts++;
       }
+      *last_thread = current;  // remember the thread we last attempted to sample
     }
     sample_time.stop();
     log_trace(jfr)("JFR thread sampling done in %3.7f secs with %d java %d native samples",
-      sample_time.seconds(), sample_task.java_entries(), sample_task.native_entries());
+                   sample_time.seconds(), sample_task.java_entries(), sample_task.native_entries());
   }
-  if (num_samples > 0) {
-    sample_task.commit_events();
+  if (num_sample_attempts > 0) {
+    sample_task.commit_events(type);
   }
 }
 
@@ -573,7 +570,7 @@
 }
 
 static void log(size_t interval_java, size_t interval_native) {
-  log_info(jfr)("Updated thread sampler for java: " SIZE_FORMAT"  ms, native " SIZE_FORMAT " ms", interval_java, interval_native);
+  log_info(jfr)("Updated thread sampler for java: " SIZE_FORMAT "  ms, native " SIZE_FORMAT " ms", interval_java, interval_native);
 }
 
 void JfrThreadSampling::start_sampler(size_t interval_java, size_t interval_native) {
@@ -591,13 +588,11 @@
     interval_java = _sampler->get_java_interval();
     interval_native = _sampler->get_native_interval();
   }
-
   if (java_interval) {
     interval_java = period;
   } else {
     interval_native = period;
   }
-
   if (interval_java > 0 || interval_native > 0) {
     if (_sampler == NULL) {
       log_info(jfr)("Creating thread sampler for java:%zu ms, native %zu ms", interval_java, interval_native);
--- a/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -27,7 +27,6 @@
 
 #include "jfr/utilities/jfrAllocation.hpp"
 
-class Monitor;
 class JavaThread;
 class JfrStackFrame;
 class JfrThreadSampler;
--- a/src/hotspot/share/logging/logTag.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/logging/logTag.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -103,6 +103,7 @@
   LOG_TAG(normalize) \
   LOG_TAG(objecttagging) \
   LOG_TAG(obsolete) \
+  LOG_TAG(oom) \
   LOG_TAG(oopmap) \
   LOG_TAG(oopstorage) \
   LOG_TAG(os) \
--- a/src/hotspot/share/memory/metaspace.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/memory/metaspace.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 
 #include "aot/aotLoader.hpp"
+#include "gc/shared/collectedHeap.hpp"
 #include "logging/log.hpp"
 #include "logging/logStream.hpp"
 #include "memory/filemap.hpp"
@@ -37,11 +38,13 @@
 #include "memory/metaspace/virtualSpaceList.hpp"
 #include "memory/metaspaceShared.hpp"
 #include "memory/metaspaceTracer.hpp"
+#include "memory/universe.hpp"
 #include "runtime/init.hpp"
 #include "runtime/orderAccess.inline.hpp"
 #include "services/memTracker.hpp"
 #include "utilities/copy.hpp"
 #include "utilities/debug.hpp"
+#include "utilities/formatBuffer.hpp"
 #include "utilities/globalDefinitions.hpp"
 
 
@@ -1270,7 +1273,7 @@
   tracer()->report_metadata_oom(loader_data, word_size, type, mdtype);
 
   // If result is still null, we are out of memory.
-  Log(gc, metaspace, freelist) log;
+  Log(gc, metaspace, freelist, oom) log;
   if (log.is_info()) {
     log.info("Metaspace (%s) allocation failed for size " SIZE_FORMAT,
              is_class_space_allocation(mdtype) ? "class" : "data", word_size);
--- a/src/hotspot/share/memory/metaspace/chunkManager.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/memory/metaspace/chunkManager.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -40,6 +40,13 @@
 
 namespace metaspace {
 
+ChunkManager::ChunkManager(bool is_class)
+      : _is_class(is_class), _free_chunks_total(0), _free_chunks_count(0) {
+  _free_chunks[SpecializedIndex].set_size(get_size_for_nonhumongous_chunktype(SpecializedIndex, is_class));
+  _free_chunks[SmallIndex].set_size(get_size_for_nonhumongous_chunktype(SmallIndex, is_class));
+  _free_chunks[MediumIndex].set_size(get_size_for_nonhumongous_chunktype(MediumIndex, is_class));
+}
+
 void ChunkManager::remove_chunk(Metachunk* chunk) {
   size_t word_size = chunk->word_size();
   ChunkIndex index = list_index(word_size);
--- a/src/hotspot/share/memory/metaspace/chunkManager.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/memory/metaspace/chunkManager.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -27,7 +27,7 @@
 
 #include "memory/allocation.hpp"
 #include "memory/binaryTreeDictionary.hpp"
-#include "memory/freeList.inline.hpp"
+#include "memory/freeList.hpp"
 #include "memory/metaspace/metachunk.hpp"
 #include "memory/metaspace/metaspaceStatistics.hpp"
 #include "memory/metaspaceChunkFreeListSummary.hpp"
@@ -115,12 +115,7 @@
 
  public:
 
-  ChunkManager(bool is_class)
-      : _is_class(is_class), _free_chunks_total(0), _free_chunks_count(0) {
-    _free_chunks[SpecializedIndex].set_size(get_size_for_nonhumongous_chunktype(SpecializedIndex, is_class));
-    _free_chunks[SmallIndex].set_size(get_size_for_nonhumongous_chunktype(SmallIndex, is_class));
-    _free_chunks[MediumIndex].set_size(get_size_for_nonhumongous_chunktype(MediumIndex, is_class));
-  }
+  ChunkManager(bool is_class);
 
   // Add or delete (return) a chunk to the global freelist.
   Metachunk* chunk_freelist_allocate(size_t word_size);
--- a/src/hotspot/share/oops/access.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/access.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -55,7 +55,7 @@
 // * atomic_cmpxchg_at: Atomically compare-and-swap a new value at an internal pointer address if previous value matched the compared value.
 // * atomic_xchg: Atomically swap a new value at an address if previous value matched the compared value.
 // * atomic_xchg_at: Atomically swap a new value at an internal pointer address if previous value matched the compared value.
-// * arraycopy: Copy data from one heap array to another heap array.
+// * arraycopy: Copy data from one heap array to another heap array. The ArrayAccess class has convenience functions for this.
 // * clone: Clone the contents of an object to a newly allocated object.
 // * resolve: Resolve a stable to-space invariant oop that is guaranteed not to relocate its payload until a subsequent thread transition.
 // * equals: Object equality, e.g. when different copies of the same objects are in use (from-space vs. to-space)
@@ -130,6 +130,29 @@
   static const DecoratorSet atomic_xchg_mo_decorators = MO_SEQ_CST;
   static const DecoratorSet atomic_cmpxchg_mo_decorators = MO_RELAXED | MO_SEQ_CST;
 
+protected:
+  template <typename T>
+  static inline bool oop_arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, const T* src_raw,
+                                   arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                   size_t length) {
+    verify_decorators<ARRAYCOPY_DECORATOR_MASK | IN_HEAP |  IN_HEAP_ARRAY |
+                      AS_DECORATOR_MASK>();
+    return AccessInternal::arraycopy<decorators | INTERNAL_VALUE_IS_OOP>(src_obj, src_offset_in_bytes, src_raw,
+                                                                         dst_obj, dst_offset_in_bytes, dst_raw,
+                                                                         length);
+  }
+
+  template <typename T>
+  static inline void arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, const T* src_raw,
+                               arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                               size_t length) {
+    verify_decorators<ARRAYCOPY_DECORATOR_MASK | IN_HEAP | IN_HEAP_ARRAY |
+                      AS_DECORATOR_MASK>();
+    AccessInternal::arraycopy<decorators>(src_obj, src_offset_in_bytes, src_raw,
+                                          dst_obj, dst_offset_in_bytes, dst_raw,
+                                          length);
+  }
+
 public:
   // Primitive heap accesses
   static inline AccessInternal::LoadAtProxy<decorators> load_at(oop base, ptrdiff_t offset) {
@@ -155,13 +178,6 @@
     return AccessInternal::atomic_xchg_at<decorators>(new_value, base, offset);
   }
 
-  template <typename T>
-  static inline void arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T *dst, size_t length) {
-    verify_decorators<ARRAYCOPY_DECORATOR_MASK | IN_HEAP |
-                      AS_DECORATOR_MASK>();
-    AccessInternal::arraycopy<decorators>(src_obj, dst_obj, src, dst, length);
-  }
-
   // Oop heap accesses
   static inline AccessInternal::OopLoadAtProxy<decorators> oop_load_at(oop base, ptrdiff_t offset) {
     verify_heap_oop_decorators<load_mo_decorators>();
@@ -193,12 +209,6 @@
     return AccessInternal::atomic_xchg_at<decorators | INTERNAL_VALUE_IS_OOP>(new_oop_value, base, offset);
   }
 
-  template <typename T>
-  static inline bool oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T *dst, size_t length) {
-    verify_decorators<ARRAYCOPY_DECORATOR_MASK | IN_HEAP | AS_DECORATOR_MASK>();
-    return AccessInternal::arraycopy<decorators | INTERNAL_VALUE_IS_OOP>(src_obj, dst_obj, src, dst, length);
-  }
-
   // Clone an object from src to dst
   static inline void clone(oop src, oop dst, size_t size) {
     verify_decorators<IN_HEAP>();
@@ -288,6 +298,55 @@
 template <DecoratorSet decorators = INTERNAL_EMPTY>
 class RootAccess: public Access<IN_ROOT | decorators> {};
 
+// Helper for array access.
+template <DecoratorSet decorators = INTERNAL_EMPTY>
+class ArrayAccess: public HeapAccess<IN_HEAP_ARRAY | decorators> {
+  typedef HeapAccess<IN_HEAP_ARRAY | decorators> AccessT;
+public:
+  template <typename T>
+  static inline void arraycopy(arrayOop src_obj, size_t src_offset_in_bytes,
+                               arrayOop dst_obj, size_t dst_offset_in_bytes,
+                               size_t length) {
+    AccessT::arraycopy(src_obj, src_offset_in_bytes, reinterpret_cast<const T*>(NULL),
+                       dst_obj, dst_offset_in_bytes, reinterpret_cast<T*>(NULL),
+                       length);
+  }
+
+  template <typename T>
+  static inline void arraycopy_to_native(arrayOop src_obj, size_t src_offset_in_bytes,
+                                         T* dst,
+                                         size_t length) {
+    AccessT::arraycopy(src_obj, src_offset_in_bytes, reinterpret_cast<const T*>(NULL),
+                       NULL, 0, dst,
+                       length);
+  }
+
+  template <typename T>
+  static inline void arraycopy_from_native(const T* src,
+                                           arrayOop dst_obj, size_t dst_offset_in_bytes,
+                                           size_t length) {
+    AccessT::arraycopy(NULL, 0, src,
+                       dst_obj, dst_offset_in_bytes, reinterpret_cast<T*>(NULL),
+                       length);
+  }
+
+  static inline bool oop_arraycopy(arrayOop src_obj, size_t src_offset_in_bytes,
+                                   arrayOop dst_obj, size_t dst_offset_in_bytes,
+                                   size_t length) {
+    return AccessT::oop_arraycopy(src_obj, src_offset_in_bytes, reinterpret_cast<const HeapWord*>(NULL),
+                                  dst_obj, dst_offset_in_bytes, reinterpret_cast<HeapWord*>(NULL),
+                                  length);
+  }
+
+  template <typename T>
+  static inline bool oop_arraycopy_raw(T* src, T* dst, size_t length) {
+    return AccessT::oop_arraycopy(NULL, 0, src,
+                                  NULL, 0, dst,
+                                  length);
+  }
+
+};
+
 template <DecoratorSet decorators>
 template <DecoratorSet expected_decorators>
 void Access<decorators>::verify_decorators() {
--- a/src/hotspot/share/oops/access.inline.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/access.inline.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -123,17 +123,23 @@
   template <class GCBarrierType, DecoratorSet decorators>
   struct PostRuntimeDispatch<GCBarrierType, BARRIER_ARRAYCOPY, decorators>: public AllStatic {
     template <typename T>
-    static bool access_barrier(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
-      GCBarrierType::arraycopy_in_heap(src_obj, dst_obj, src, dst, length);
+    static bool access_barrier(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                               arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                               size_t length) {
+      GCBarrierType::arraycopy_in_heap(src_obj, src_offset_in_bytes, src_raw,
+                                       dst_obj, dst_offset_in_bytes, dst_raw,
+                                       length);
       return true;
     }
 
     template <typename T>
-    static bool oop_access_barrier(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
+    static bool oop_access_barrier(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                                   arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                   size_t length) {
       typedef typename HeapOopType<decorators>::type OopType;
-      return GCBarrierType::oop_arraycopy_in_heap(src_obj, dst_obj,
-                                                  reinterpret_cast<OopType*>(src),
-                                                  reinterpret_cast<OopType*>(dst), length);
+      return GCBarrierType::oop_arraycopy_in_heap(src_obj, src_offset_in_bytes, reinterpret_cast<OopType*>(src_raw),
+                                                  dst_obj, dst_offset_in_bytes, reinterpret_cast<OopType*>(dst_raw),
+                                                  length);
     }
   };
 
@@ -337,10 +343,14 @@
   }
 
   template <DecoratorSet decorators, typename T>
-  bool RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>::arraycopy_init(arrayOop src_obj, arrayOop dst_obj, T *src, T* dst, size_t length) {
+  bool RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>::arraycopy_init(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                                                                         arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                                                         size_t length) {
     func_t function = BarrierResolver<decorators, func_t, BARRIER_ARRAYCOPY>::resolve_barrier();
     _arraycopy_func = function;
-    return function(src_obj, dst_obj, src, dst, length);
+    return function(src_obj, src_offset_in_bytes, src_raw,
+                    dst_obj, dst_offset_in_bytes, dst_raw,
+                    length);
   }
 
   template <DecoratorSet decorators, typename T>
--- a/src/hotspot/share/oops/accessBackend.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/accessBackend.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -105,11 +105,21 @@
   }
 
   template<>
+  void arraycopy_conjoint<jboolean>(jboolean* src, jboolean* dst, size_t length) {
+    Copy::conjoint_jbytes(reinterpret_cast<jbyte*>(src), reinterpret_cast<jbyte*>(dst), length);
+  }
+
+  template<>
   void arraycopy_conjoint<jbyte>(jbyte* src, jbyte* dst, size_t length) {
     Copy::conjoint_jbytes(src, dst, length);
   }
 
   template<>
+  void arraycopy_conjoint<jchar>(jchar* src, jchar* dst, size_t length) {
+    Copy::conjoint_jshorts_atomic(reinterpret_cast<jshort*>(src), reinterpret_cast<jshort*>(dst), length);
+  }
+
+  template<>
   void arraycopy_conjoint<jshort>(jshort* src, jshort* dst, size_t length) {
     Copy::conjoint_jshorts_atomic(src, dst, length);
   }
@@ -120,11 +130,21 @@
   }
 
   template<>
+  void arraycopy_conjoint<jfloat>(jfloat* src, jfloat* dst, size_t length) {
+    Copy::conjoint_jints_atomic(reinterpret_cast<jint*>(src), reinterpret_cast<jint*>(dst), length);
+  }
+
+  template<>
   void arraycopy_conjoint<jlong>(jlong* src, jlong* dst, size_t length) {
     Copy::conjoint_jlongs_atomic(src, dst, length);
   }
 
   template<>
+  void arraycopy_conjoint<jdouble>(jdouble* src, jdouble* dst, size_t length) {
+    Copy::conjoint_jlongs_atomic(reinterpret_cast<jlong*>(src), reinterpret_cast<jlong*>(dst), length);
+  }
+
+  template<>
   void arraycopy_arrayof_conjoint<jbyte>(jbyte* src, jbyte* dst, size_t length) {
     Copy::arrayof_conjoint_jbytes(reinterpret_cast<HeapWord*>(src),
                                   reinterpret_cast<HeapWord*>(dst),
--- a/src/hotspot/share/oops/accessBackend.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/accessBackend.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -110,7 +110,9 @@
     typedef T (*atomic_cmpxchg_func_t)(T new_value, void* addr, T compare_value);
     typedef T (*atomic_xchg_func_t)(T new_value, void* addr);
 
-    typedef bool (*arraycopy_func_t)(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
+    typedef bool (*arraycopy_func_t)(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                                     arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                     size_t length);
     typedef void (*clone_func_t)(oop src, oop dst, size_t size);
     typedef oop (*resolve_func_t)(oop obj);
     typedef bool (*equals_func_t)(oop o1, oop o2);
@@ -118,7 +120,9 @@
 
   template <DecoratorSet decorators>
   struct AccessFunctionTypes<decorators, void> {
-    typedef bool (*arraycopy_func_t)(arrayOop src_obj, arrayOop dst_obj, void* src, void* dst, size_t length);
+    typedef bool (*arraycopy_func_t)(arrayOop src_obj, size_t src_offset_in_bytes, void* src,
+                                     arrayOop dst_obj, size_t dst_offset_in_bytes, void* dst,
+                                     size_t length);
   };
 
   template <DecoratorSet decorators, typename T, BarrierType barrier> struct AccessFunction {};
@@ -256,7 +260,7 @@
   static inline typename EnableIf<
     HasDecorator<ds, MO_UNORDERED>::value, T>::type
   load_internal(void* addr) {
-    return *reinterpret_cast<const T*>(addr);
+    return *reinterpret_cast<T*>(addr);
   }
 
   template <DecoratorSet ds, typename T>
@@ -353,7 +357,9 @@
   }
 
   template <typename T>
-  static bool arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
+  static bool arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                        arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                        size_t length);
 
   template <typename T>
   static void oop_store(void* addr, T value);
@@ -396,7 +402,9 @@
   }
 
   template <typename T>
-  static bool oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
+  static bool oop_arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                            arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                            size_t length);
 
   static void clone(oop src, oop dst, size_t size);
 
@@ -559,10 +567,16 @@
     typedef typename AccessFunction<decorators, T, BARRIER_ARRAYCOPY>::type func_t;
     static func_t _arraycopy_func;
 
-    static bool arraycopy_init(arrayOop src_obj, arrayOop dst_obj, T *src, T* dst, size_t length);
+    static bool arraycopy_init(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                               arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                               size_t length);
 
-    static inline bool arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T* dst, size_t length) {
-      return _arraycopy_func(src_obj, dst_obj, src, dst, length);
+    static inline bool arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                                 arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                 size_t length) {
+      return _arraycopy_func(src_obj, src_offset_in_bytes, src_raw,
+                             dst_obj, dst_offset_in_bytes, dst_raw,
+                             length);
     }
   };
 
@@ -900,37 +914,55 @@
     template <DecoratorSet decorators, typename T>
     inline static typename EnableIf<
       HasDecorator<decorators, AS_RAW>::value && CanHardwireRaw<decorators>::value, bool>::type
-    arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
+    arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+              arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+              size_t length) {
       typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
       if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) {
-        return Raw::oop_arraycopy(src_obj, dst_obj, src, dst, length);
+        return Raw::oop_arraycopy(src_obj, src_offset_in_bytes, src_raw,
+                                  dst_obj, dst_offset_in_bytes, dst_raw,
+                                  length);
       } else {
-        return Raw::arraycopy(src_obj, dst_obj, src, dst, length);
+        return Raw::arraycopy(src_obj, src_offset_in_bytes, src_raw,
+                              dst_obj, dst_offset_in_bytes, dst_raw,
+                              length);
       }
     }
 
     template <DecoratorSet decorators, typename T>
     inline static typename EnableIf<
       HasDecorator<decorators, AS_RAW>::value && !CanHardwireRaw<decorators>::value, bool>::type
-    arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
+    arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+              arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+              size_t length) {
       if (UseCompressedOops) {
         const DecoratorSet expanded_decorators = decorators | convert_compressed_oops;
-        return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, dst_obj, src, dst, length);
+        return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, src_offset_in_bytes, src_raw,
+                                                                  dst_obj, dst_offset_in_bytes, dst_raw,
+                                                                  length);
       } else {
         const DecoratorSet expanded_decorators = decorators & ~convert_compressed_oops;
-        return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, dst_obj, src, dst, length);
+        return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, src_offset_in_bytes, src_raw,
+                                                                  dst_obj, dst_offset_in_bytes, dst_raw,
+                                                                  length);
       }
     }
 
     template <DecoratorSet decorators, typename T>
     inline static typename EnableIf<
       !HasDecorator<decorators, AS_RAW>::value, bool>::type
-    arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
+    arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+              arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+              size_t length) {
       if (is_hardwired_primitive<decorators>()) {
         const DecoratorSet expanded_decorators = decorators | AS_RAW;
-        return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, dst_obj, src, dst, length);
+        return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, src_offset_in_bytes, src_raw,
+                                                                  dst_obj, dst_offset_in_bytes, dst_raw,
+                                                                  length);
       } else {
-        return RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>::arraycopy(src_obj, dst_obj, src, dst, length);
+        return RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>::arraycopy(src_obj, src_offset_in_bytes, src_raw,
+                                                                            dst_obj, dst_offset_in_bytes, dst_raw,
+                                                                            length);
       }
     }
 
@@ -1092,21 +1124,33 @@
   }
 
   template <DecoratorSet decorators, typename T>
-  inline bool arraycopy_reduce_types(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
-    return PreRuntimeDispatch::arraycopy<decorators>(src_obj, dst_obj, src, dst, length);
+  inline bool arraycopy_reduce_types(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                                     arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                     size_t length) {
+    return PreRuntimeDispatch::arraycopy<decorators>(src_obj, src_offset_in_bytes, src_raw,
+                                                     dst_obj, dst_offset_in_bytes, dst_raw,
+                                                     length);
   }
 
   template <DecoratorSet decorators>
-  inline bool arraycopy_reduce_types(arrayOop src_obj, arrayOop dst_obj, HeapWord* src, HeapWord* dst, size_t length) {
+  inline bool arraycopy_reduce_types(arrayOop src_obj, size_t src_offset_in_bytes, HeapWord* src_raw,
+                                     arrayOop dst_obj, size_t dst_offset_in_bytes, HeapWord* dst_raw,
+                                     size_t length) {
     const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP;
-    return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, dst_obj, src, dst, length);
+    return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, src_offset_in_bytes, src_raw,
+                                                              dst_obj, dst_offset_in_bytes, dst_raw,
+                                                              length);
   }
 
   template <DecoratorSet decorators>
-  inline bool arraycopy_reduce_types(arrayOop src_obj, arrayOop dst_obj, narrowOop* src, narrowOop* dst, size_t length) {
+  inline bool arraycopy_reduce_types(arrayOop src_obj, size_t src_offset_in_bytes, narrowOop* src_raw,
+                                     arrayOop dst_obj, size_t dst_offset_in_bytes, narrowOop* dst_raw,
+                                     size_t length) {
     const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP |
                                              INTERNAL_RT_USE_COMPRESSED_OOPS;
-    return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, dst_obj, src, dst, length);
+    return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, src_offset_in_bytes, src_raw,
+                                                              dst_obj, dst_offset_in_bytes, dst_raw,
+                                                              length);
   }
 
   // Step 1: Set default decorators. This step remembers if a type was volatile
@@ -1239,15 +1283,16 @@
   }
 
   template <DecoratorSet decorators, typename T>
-  inline bool arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
+  inline bool arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, const T* src_raw,
+                        arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                        size_t length) {
     STATIC_ASSERT((HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ||
                    (IsSame<T, void>::value || IsIntegral<T>::value) ||
                     IsFloatingPoint<T>::value)); // arraycopy allows type erased void elements
     typedef typename Decay<T>::type DecayedT;
     const DecoratorSet expanded_decorators = DecoratorFixup<decorators | IN_HEAP_ARRAY | IN_HEAP>::value;
-    return arraycopy_reduce_types<expanded_decorators>(src_obj, dst_obj,
-                                                       const_cast<DecayedT*>(src),
-                                                       const_cast<DecayedT*>(dst),
+    return arraycopy_reduce_types<expanded_decorators>(src_obj, src_offset_in_bytes, const_cast<DecayedT*>(src_raw),
+                                                       dst_obj, dst_offset_in_bytes, const_cast<DecayedT*>(dst_raw),
                                                        length);
   }
 
--- a/src/hotspot/share/oops/accessBackend.inline.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/accessBackend.inline.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -118,8 +118,12 @@
 
 template <DecoratorSet decorators>
 template <typename T>
-inline bool RawAccessBarrier<decorators>::oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
-  return arraycopy(src_obj, dst_obj, src, dst, length);
+inline bool RawAccessBarrier<decorators>::oop_arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                                                        arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                                        size_t length) {
+  return arraycopy(src_obj, src_offset_in_bytes, src_raw,
+                   dst_obj, dst_offset_in_bytes, dst_raw,
+                   length);
 }
 
 template <DecoratorSet decorators>
@@ -247,35 +251,45 @@
   template <DecoratorSet decorators, typename T>
   static inline typename EnableIf<
   HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value>::type
-  arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
+  arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+            arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+            size_t length) {
+
+    src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
+    dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
+
     // We do not check for ARRAYCOPY_ATOMIC for oops, because they are unconditionally always atomic.
     if (HasDecorator<decorators, ARRAYCOPY_ARRAYOF>::value) {
-      AccessInternal::arraycopy_arrayof_conjoint_oops(src, dst, length);
+      AccessInternal::arraycopy_arrayof_conjoint_oops(src_raw, dst_raw, length);
     } else {
       typedef typename HeapOopType<decorators>::type OopType;
-      AccessInternal::arraycopy_conjoint_oops(reinterpret_cast<OopType*>(src),
-                                              reinterpret_cast<OopType*>(dst), length);
+      AccessInternal::arraycopy_conjoint_oops(reinterpret_cast<OopType*>(src_raw),
+                                              reinterpret_cast<OopType*>(dst_raw), length);
     }
   }
 
   template <DecoratorSet decorators, typename T>
   static inline typename EnableIf<
     !HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value>::type
-  arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
+  arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, const T* src_raw, arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw, size_t length) {
+
+    src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
+    dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
+
     if (HasDecorator<decorators, ARRAYCOPY_ARRAYOF>::value) {
-      AccessInternal::arraycopy_arrayof_conjoint(src, dst, length);
+      AccessInternal::arraycopy_arrayof_conjoint(const_cast<T*>(src_raw), dst_raw, length);
     } else if (HasDecorator<decorators, ARRAYCOPY_DISJOINT>::value && sizeof(T) == HeapWordSize) {
       // There is only a disjoint optimization for word granularity copying
       if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) {
-        AccessInternal::arraycopy_disjoint_words_atomic(src, dst, length);
+        AccessInternal::arraycopy_disjoint_words_atomic(const_cast<T*>(src_raw), dst_raw, length);
       } else {
-        AccessInternal::arraycopy_disjoint_words(src, dst, length);
+        AccessInternal::arraycopy_disjoint_words(const_cast<T*>(src_raw), dst_raw, length);
       }
     } else {
       if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) {
-        AccessInternal::arraycopy_conjoint_atomic(src, dst, length);
+        AccessInternal::arraycopy_conjoint_atomic(const_cast<T*>(src_raw), dst_raw, length);
       } else {
-        AccessInternal::arraycopy_conjoint(src, dst, length);
+        AccessInternal::arraycopy_conjoint(const_cast<T*>(src_raw), dst_raw, length);
       }
     }
   }
@@ -283,19 +297,29 @@
   template <DecoratorSet decorators>
   static inline typename EnableIf<
     !HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value>::type
-  arraycopy(arrayOop src_obj, arrayOop dst_obj, void* src, void* dst, size_t length) {
+  arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, const void* src_raw,
+            arrayOop dst_obj, size_t dst_offset_in_bytes, void* dst_raw,
+            size_t length) {
+
+    src_raw = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw);
+    dst_raw = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw);
+
     if (HasDecorator<decorators, ARRAYCOPY_ATOMIC>::value) {
-      AccessInternal::arraycopy_conjoint_atomic(src, dst, length);
+      AccessInternal::arraycopy_conjoint_atomic(const_cast<void*>(src_raw), dst_raw, length);
     } else {
-      AccessInternal::arraycopy_conjoint(src, dst, length);
+      AccessInternal::arraycopy_conjoint(const_cast<void*>(src_raw), dst_raw, length);
     }
   }
 };
 
 template <DecoratorSet decorators>
 template <typename T>
-inline bool RawAccessBarrier<decorators>::arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
-  RawAccessBarrierArrayCopy::arraycopy<decorators>(src_obj, dst_obj, src, dst, length);
+inline bool RawAccessBarrier<decorators>::arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
+                                                    arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
+                                                    size_t length) {
+  RawAccessBarrierArrayCopy::arraycopy<decorators>(src_obj, src_offset_in_bytes, src_raw,
+                                                   dst_obj, dst_offset_in_bytes, dst_raw,
+                                                   length);
   return true;
 }
 
--- a/src/hotspot/share/oops/arrayOop.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/arrayOop.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -88,6 +88,18 @@
   inline void* base(BasicType type) const;
   inline void* base_raw(BasicType type) const; // GC barrier invariant
 
+  template <typename T>
+  static T* obj_offset_to_raw(arrayOop obj, size_t offset_in_bytes, T* raw) {
+    if (obj != NULL) {
+      assert(raw == NULL, "either raw or in-heap");
+      char* base = reinterpret_cast<char*>((void*) obj);
+      raw = reinterpret_cast<T*>(base + offset_in_bytes);
+    } else {
+      assert(raw != NULL, "either raw or in-heap");
+    }
+    return raw;
+  }
+
   // Tells whether index is within bounds.
   bool is_within_bounds(int index) const        { return 0 <= index && index < length(); }
 
--- a/src/hotspot/share/oops/objArrayKlass.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/objArrayKlass.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -218,23 +218,23 @@
 }
 
 // Either oop or narrowOop depending on UseCompressedOops.
-template <class T> void ObjArrayKlass::do_copy(arrayOop s, T* src,
-                               arrayOop d, T* dst, int length, TRAPS) {
+void ObjArrayKlass::do_copy(arrayOop s, size_t src_offset,
+                            arrayOop d, size_t dst_offset, int length, TRAPS) {
   if (oopDesc::equals(s, d)) {
     // since source and destination are equal we do not need conversion checks.
     assert(length > 0, "sanity check");
-    HeapAccess<>::oop_arraycopy(s, d, src, dst, length);
+    ArrayAccess<>::oop_arraycopy(s, src_offset, d, dst_offset, length);
   } else {
     // We have to make sure all elements conform to the destination array
     Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass();
     Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass();
     if (stype == bound || stype->is_subtype_of(bound)) {
       // elements are guaranteed to be subtypes, so no check necessary
-      HeapAccess<ARRAYCOPY_DISJOINT>::oop_arraycopy(s, d, src, dst, length);
+      ArrayAccess<ARRAYCOPY_DISJOINT>::oop_arraycopy(s, src_offset, d, dst_offset, length);
     } else {
       // slow case: need individual subtype checks
       // note: don't use obj_at_put below because it includes a redundant store check
-      if (!HeapAccess<ARRAYCOPY_DISJOINT | ARRAYCOPY_CHECKCAST>::oop_arraycopy(s, d, src, dst, length)) {
+      if (!ArrayAccess<ARRAYCOPY_DISJOINT | ARRAYCOPY_CHECKCAST>::oop_arraycopy(s, src_offset, d, dst_offset, length)) {
         THROW(vmSymbols::java_lang_ArrayStoreException());
       }
     }
@@ -289,13 +289,21 @@
     return;
   }
   if (UseCompressedOops) {
-    narrowOop* const src = objArrayOop(s)->obj_at_addr<narrowOop>(src_pos);
-    narrowOop* const dst = objArrayOop(d)->obj_at_addr<narrowOop>(dst_pos);
-    do_copy<narrowOop>(s, src, d, dst, length, CHECK);
+    size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(src_pos);
+    size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(dst_pos);
+    assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(s, src_offset, NULL) ==
+           objArrayOop(s)->obj_at_addr<narrowOop>(src_pos), "sanity");
+    assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(d, dst_offset, NULL) ==
+           objArrayOop(d)->obj_at_addr<narrowOop>(dst_pos), "sanity");
+    do_copy(s, src_offset, d, dst_offset, length, CHECK);
   } else {
-    oop* const src = objArrayOop(s)->obj_at_addr<oop>(src_pos);
-    oop* const dst = objArrayOop(d)->obj_at_addr<oop>(dst_pos);
-    do_copy<oop> (s, src, d, dst, length, CHECK);
+    size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(src_pos);
+    size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(dst_pos);
+    assert(arrayOopDesc::obj_offset_to_raw<oop>(s, src_offset, NULL) ==
+           objArrayOop(s)->obj_at_addr<oop>(src_pos), "sanity");
+    assert(arrayOopDesc::obj_offset_to_raw<oop>(d, dst_offset, NULL) ==
+           objArrayOop(d)->obj_at_addr<oop>(dst_pos), "sanity");
+    do_copy(s, src_offset, d, dst_offset, length, CHECK);
   }
 }
 
--- a/src/hotspot/share/oops/objArrayKlass.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/objArrayKlass.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -88,8 +88,9 @@
  private:
   // Either oop or narrowOop depending on UseCompressedOops.
   // must be called from within ObjArrayKlass.cpp
-  template <class T> void do_copy(arrayOop s, T* src, arrayOop d,
-                                  T* dst, int length, TRAPS);
+  void do_copy(arrayOop s, size_t src_offset,
+               arrayOop d, size_t dst_offset,
+               int length, TRAPS);
  protected:
   // Returns the ObjArrayKlass for n'th dimension.
   virtual Klass* array_klass_impl(bool or_null, int n, TRAPS);
--- a/src/hotspot/share/oops/typeArrayKlass.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/typeArrayKlass.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -175,10 +175,9 @@
 
   // This is an attempt to make the copy_array fast.
   int l2es = log2_element_size();
-  int ihs = array_header_in_bytes() / wordSize;
-  void* src = (char*) (s->base(element_type())) + ((size_t)src_pos << l2es);
-  void* dst = (char*) (d->base(element_type())) + ((size_t)dst_pos << l2es);
-  HeapAccess<ARRAYCOPY_ATOMIC>::arraycopy(s, d, src, dst, (size_t)length << l2es);
+  size_t src_offset = arrayOopDesc::base_offset_in_bytes(element_type()) + ((size_t)src_pos << l2es);
+  size_t dst_offset = arrayOopDesc::base_offset_in_bytes(element_type()) + ((size_t)dst_pos << l2es);
+  ArrayAccess<ARRAYCOPY_ATOMIC>::arraycopy<void>(s, src_offset, d, dst_offset, (size_t)length << l2es);
 }
 
 // create a klass of array holding typeArrays
--- a/src/hotspot/share/oops/typeArrayOop.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/typeArrayOop.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -32,12 +32,22 @@
 // It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs}
 #include <limits.h>
 
+namespace TypeToBT {
+  template<typename T> BasicType to_basic_type();
+  template<> inline BasicType to_basic_type<jboolean>() { return T_BOOLEAN; }
+  template<> inline BasicType to_basic_type<jbyte>()    { return T_BYTE;    }
+  template<> inline BasicType to_basic_type<jchar>()    { return T_CHAR;    }
+  template<> inline BasicType to_basic_type<jshort>()   { return T_SHORT;   }
+  template<> inline BasicType to_basic_type<jint>()     { return T_INT;     }
+  template<> inline BasicType to_basic_type<jlong>()    { return T_LONG;    }
+  template<> inline BasicType to_basic_type<jfloat>()   { return T_FLOAT;   }
+  template<> inline BasicType to_basic_type<jdouble>()  { return T_DOUBLE;  }
+};
+
 class typeArrayOopDesc : public arrayOopDesc {
 private:
-  template <class T>
-  static ptrdiff_t element_offset(BasicType bt, int index) {
-    return arrayOopDesc::base_offset_in_bytes(bt) + sizeof(T) * index;
-  }
+  template <typename T>
+  static BasicType bt() { return TypeToBT::to_basic_type<T>(); }
 
  protected:
   jchar*    char_base()   const;
@@ -52,6 +62,11 @@
   friend class TypeArrayKlass;
 
  public:
+  template <typename T>
+  static ptrdiff_t element_offset(int index) {
+    return arrayOopDesc::base_offset_in_bytes(bt<T>()) + sizeof(T) * index;
+  }
+
   jbyte* byte_at_addr(int which) const;
   jboolean* bool_at_addr(int which) const;
   jchar* char_at_addr(int which) const;
--- a/src/hotspot/share/oops/typeArrayOop.inline.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/oops/typeArrayOop.inline.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -90,92 +90,92 @@
 }
 
 inline jbyte typeArrayOopDesc::byte_at(int which) const {
-  ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
+  ptrdiff_t offset = element_offset<jbyte>(which);
   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::byte_at_put(int which, jbyte contents) {
-  ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
+  ptrdiff_t offset = element_offset<jbyte>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 }
 
 inline jboolean typeArrayOopDesc::bool_at(int which) const {
-  ptrdiff_t offset = element_offset<jboolean>(T_BOOLEAN, which);
+  ptrdiff_t offset = element_offset<jboolean>(which);
   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::bool_at_put(int which, jboolean contents) {
-  ptrdiff_t offset = element_offset<jboolean>(T_BOOLEAN, which);
+  ptrdiff_t offset = element_offset<jboolean>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, jboolean(contents & 1));
 }
 
 inline jchar typeArrayOopDesc::char_at(int which) const {
-  ptrdiff_t offset = element_offset<jchar>(T_CHAR, which);
+  ptrdiff_t offset = element_offset<jchar>(which);
   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::char_at_put(int which, jchar contents) {
-  ptrdiff_t offset = element_offset<jchar>(T_CHAR, which);
+  ptrdiff_t offset = element_offset<jchar>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 }
 
 inline jint typeArrayOopDesc::int_at(int which) const {
-  ptrdiff_t offset = element_offset<jint>(T_INT, which);
+  ptrdiff_t offset = element_offset<jint>(which);
   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::int_at_put(int which, jint contents) {
-  ptrdiff_t offset = element_offset<jint>(T_INT, which);
+  ptrdiff_t offset = element_offset<jint>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 }
 
 inline jshort typeArrayOopDesc::short_at(int which) const {
-  ptrdiff_t offset = element_offset<jshort>(T_SHORT, which);
+  ptrdiff_t offset = element_offset<jshort>(which);
   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::short_at_put(int which, jshort contents) {
-  ptrdiff_t offset = element_offset<jshort>(T_SHORT, which);
+  ptrdiff_t offset = element_offset<jshort>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 }
 
 inline jushort typeArrayOopDesc::ushort_at(int which) const {
-  ptrdiff_t offset = element_offset<jushort>(T_SHORT, which);
+  ptrdiff_t offset = element_offset<jushort>(which);
   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::ushort_at_put(int which, jushort contents) {
-  ptrdiff_t offset = element_offset<jushort>(T_SHORT, which);
+  ptrdiff_t offset = element_offset<jushort>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 }
 
 inline jlong typeArrayOopDesc::long_at(int which) const {
-  ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
+  ptrdiff_t offset = element_offset<jlong>(which);
   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::long_at_put(int which, jlong contents) {
-  ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
+  ptrdiff_t offset = element_offset<jlong>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 }
 
 inline jfloat typeArrayOopDesc::float_at(int which) const {
-  ptrdiff_t offset = element_offset<jfloat>(T_FLOAT, which);
+  ptrdiff_t offset = element_offset<jfloat>(which);
   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::float_at_put(int which, jfloat contents) {
-  ptrdiff_t offset = element_offset<jfloat>(T_FLOAT, which);
+  ptrdiff_t offset = element_offset<jfloat>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 }
 
 inline jdouble typeArrayOopDesc::double_at(int which) const {
-  ptrdiff_t offset = element_offset<jdouble>(T_DOUBLE, which);
+  ptrdiff_t offset = element_offset<jdouble>(which);
   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::double_at_put(int which, jdouble contents) {
-  ptrdiff_t offset = element_offset<jdouble>(T_DOUBLE, which);
+  ptrdiff_t offset = element_offset<jdouble>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 }
 
 inline jbyte typeArrayOopDesc::byte_at_acquire(int which) const {
-  ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
+  ptrdiff_t offset = element_offset<jbyte>(which);
   return HeapAccess<MO_ACQUIRE | IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::release_byte_at_put(int which, jbyte contents) {
-  ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
+  ptrdiff_t offset = element_offset<jbyte>(which);
   HeapAccess<MO_RELEASE | IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 }
 
@@ -184,20 +184,20 @@
 // casting
 #ifdef _LP64
 inline Symbol* typeArrayOopDesc::symbol_at(int which) const {
-  ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
+  ptrdiff_t offset = element_offset<jlong>(which);
   return (Symbol*)(jlong) HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::symbol_at_put(int which, Symbol* contents) {
-  ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
+  ptrdiff_t offset = element_offset<jlong>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, (jlong)contents);
 }
 #else
 inline Symbol* typeArrayOopDesc::symbol_at(int which) const {
-  ptrdiff_t offset = element_offset<jint>(T_INT, which);
+  ptrdiff_t offset = element_offset<jint>(which);
   return (Symbol*)(jint) HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 }
 inline void typeArrayOopDesc::symbol_at_put(int which, Symbol* contents) {
-  ptrdiff_t offset = element_offset<jint>(T_INT, which);
+  ptrdiff_t offset = element_offset<jint>(which);
   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, (jint)contents);
 }
 #endif // _LP64
--- a/src/hotspot/share/opto/runtime.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/opto/runtime.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -393,9 +393,9 @@
   ResourceMark rm;
   jint len = dims->length();
   assert(len > 0, "Dimensions array should contain data");
-  jint *j_dims = typeArrayOop(dims)->int_at_addr(0);
   jint *c_dims = NEW_RESOURCE_ARRAY(jint, len);
-  Copy::conjoint_jints_atomic(j_dims, c_dims, len);
+  ArrayAccess<>::arraycopy_to_native<>(dims, typeArrayOopDesc::element_offset<jint>(0),
+                                       c_dims, len);
 
   Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD);
--- a/src/hotspot/share/prims/jni.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/prims/jni.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -2466,7 +2466,8 @@
     if (buf != NULL) {
       if (s_len > 0) {
         if (!is_latin1) {
-          memcpy(buf, s_value->char_at_addr(0), sizeof(jchar)*s_len);
+          ArrayAccess<>::arraycopy_to_native(s_value, (size_t) typeArrayOopDesc::element_offset<jchar>(0),
+                                             buf, s_len);
         } else {
           for (int i = 0; i < s_len; i++) {
             buf[i] = ((jchar) s_value->byte_at(i)) & 0xff;
@@ -2722,7 +2723,8 @@
     result = NEW_C_HEAP_ARRAY_RETURN_NULL(ElementType, len, mtInternal); \
     if (result != NULL) {                                                \
       /* copy the array to the c chunk */                                \
-      memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len);      \
+      ArrayAccess<>::arraycopy_to_native(a, typeArrayOopDesc::element_offset<ElementType>(0), \
+                                         result, len);                   \
       if (isCopy) {                                                      \
         *isCopy = JNI_TRUE;                                              \
       }                                                                  \
@@ -2771,7 +2773,7 @@
   int len = a->length(); \
   if (len != 0) {   /* Empty array:  nothing to free or copy. */  \
     if ((mode == 0) || (mode == JNI_COMMIT)) { \
-      memcpy(a->Tag##_at_addr(0), buf, sizeof(ElementType)*len); \
+      ArrayAccess<>::arraycopy_from_native(buf, a, typeArrayOopDesc::element_offset<ElementType>(0), len); \
     } \
     if ((mode == 0) || (mode == JNI_ABORT)) { \
       FreeHeap(buf); \
@@ -2822,10 +2824,7 @@
     THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \
   } else { \
     if (len > 0) { \
-      int sc = TypeArrayKlass::cast(src->klass())->log2_element_size(); \
-      memcpy((u_char*) buf, \
-             (u_char*) src->Tag##_at_addr(start), \
-             len << sc);                          \
+      ArrayAccess<>::arraycopy_to_native(src, typeArrayOopDesc::element_offset<ElementType>(start), buf, len); \
     } \
   } \
 JNI_END
@@ -2872,10 +2871,7 @@
     THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \
   } else { \
     if (len > 0) { \
-      int sc = TypeArrayKlass::cast(dst->klass())->log2_element_size(); \
-      memcpy((u_char*) dst->Tag##_at_addr(start), \
-             (u_char*) buf, \
-             len << sc);    \
+      ArrayAccess<>::arraycopy_from_native(buf, dst, typeArrayOopDesc::element_offset<ElementType>(start), len); \
     } \
   } \
 JNI_END
@@ -3111,7 +3107,8 @@
       typeArrayOop s_value = java_lang_String::value(s);
       bool is_latin1 = java_lang_String::is_latin1(s);
       if (!is_latin1) {
-        memcpy(buf, s_value->char_at_addr(start), sizeof(jchar)*len);
+        ArrayAccess<>::arraycopy_to_native(s_value, typeArrayOopDesc::element_offset<jchar>(start),
+                                           buf, len);
       } else {
         for (int i = 0; i < len; i++) {
           buf[i] = ((jchar) s_value->byte_at(i + start)) & 0xff;
--- a/src/hotspot/share/prims/jvmtiEventController.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/prims/jvmtiEventController.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -508,14 +508,19 @@
 
   julong was_any_env_enabled = state->thread_event_enable()->_event_enabled.get_bits();
   julong any_env_enabled = 0;
+  // JVMTI_EVENT_FRAME_POP can be disabled (in the case FRAME_POP_BIT is not set),
+  // but we need to set interp_only if some JvmtiEnvThreadState has frame pop set
+  // to clear the request
+  bool has_frame_pops = false;
 
   {
-    // This iteration will include JvmtiEnvThreadStates whoses environments
+    // This iteration will include JvmtiEnvThreadStates whose environments
     // have been disposed.  These JvmtiEnvThreadStates must not be filtered
     // as recompute must be called on them to disable their events,
     JvmtiEnvThreadStateIterator it(state);
     for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
       any_env_enabled |= recompute_env_thread_enabled(ets, state);
+      has_frame_pops |= ets->has_frame_pops();
     }
   }
 
@@ -523,23 +528,23 @@
     // mark if event is truly enabled on this thread in any environment
     state->thread_event_enable()->_event_enabled.set_bits(any_env_enabled);
 
-    // compute interp_only mode
-    bool should_be_interp = (any_env_enabled & INTERP_EVENT_BITS) != 0;
-    bool is_now_interp = state->is_interp_only_mode();
-
-    if (should_be_interp != is_now_interp) {
-      if (should_be_interp) {
-        enter_interp_only_mode(state);
-      } else {
-        leave_interp_only_mode(state);
-      }
-    }
-
     // update the JavaThread cached value for thread-specific should_post_on_exceptions value
     bool should_post_on_exceptions = (any_env_enabled & SHOULD_POST_ON_EXCEPTIONS_BITS) != 0;
     state->set_should_post_on_exceptions(should_post_on_exceptions);
   }
 
+  // compute interp_only mode
+  bool should_be_interp = (any_env_enabled & INTERP_EVENT_BITS) != 0 || has_frame_pops;
+  bool is_now_interp = state->is_interp_only_mode();
+
+  if (should_be_interp != is_now_interp) {
+    if (should_be_interp) {
+      enter_interp_only_mode(state);
+    } else {
+      leave_interp_only_mode(state);
+    }
+  }
+
   return any_env_enabled;
 }
 
--- a/src/hotspot/share/prims/jvmtiExport.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/prims/jvmtiExport.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -1576,9 +1576,9 @@
     }
   }
 
-  if (state->is_enabled(JVMTI_EVENT_FRAME_POP)) {
-    JvmtiEnvThreadStateIterator it(state);
-    for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
+  JvmtiEnvThreadStateIterator it(state);
+  for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
+    if (ets->has_frame_pops()) {
       int cur_frame_number = state->cur_stack_depth();
 
       if (ets->is_frame_pop(cur_frame_number)) {
--- a/src/hotspot/share/prims/unsafe.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/prims/unsafe.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -762,8 +762,8 @@
   // caller responsible to free it:
   *temp_alloc = class_bytes;
 
-  jbyte* array_base = typeArrayOop(JNIHandles::resolve_non_null(data))->byte_at_addr(0);
-  Copy::conjoint_jbytes(array_base, class_bytes, length);
+  ArrayAccess<>::arraycopy_to_native(arrayOop(JNIHandles::resolve_non_null(data)), typeArrayOopDesc::element_offset<jbyte>(0),
+                                     reinterpret_cast<jbyte*>(class_bytes), length);
 
   objArrayHandle cp_patches_h;
   if (cp_patches_jh != NULL) {
--- a/src/hotspot/share/runtime/os_perf.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/runtime/os_perf.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -26,7 +26,7 @@
 #define SHARE_VM_RUNTIME_OS_PERF_HPP
 
 #include "utilities/macros.hpp"
-#include "memory/allocation.inline.hpp"
+#include "memory/allocation.hpp"
 #include "utilities/globalDefinitions.hpp"
 
 #define FUNCTIONALITY_NOT_IMPLEMENTED -8
--- a/src/hotspot/share/runtime/sharedRuntime.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -76,9 +76,6 @@
 #ifdef COMPILER1
 #include "c1/c1_Runtime1.hpp"
 #endif
-#if INCLUDE_G1GC
-#include "gc/g1/g1ThreadLocalData.hpp"
-#endif // INCLUDE_G1GC
 
 // Shared stub locations
 RuntimeStub*        SharedRuntime::_wrong_method_blob;
@@ -208,26 +205,6 @@
 }
 #endif // PRODUCT
 
-#if INCLUDE_G1GC
-
-// G1 write-barrier pre: executed before a pointer store.
-JRT_LEAF(void, SharedRuntime::g1_wb_pre(oopDesc* orig, JavaThread *thread))
-  if (orig == NULL) {
-    assert(false, "should be optimized out");
-    return;
-  }
-  assert(oopDesc::is_oop(orig, true /* ignore mark word */), "Error");
-  // store the original value that was in the field reference
-  G1ThreadLocalData::satb_mark_queue(thread).enqueue(orig);
-JRT_END
-
-// G1 write-barrier post: executed after a pointer store.
-JRT_LEAF(void, SharedRuntime::g1_wb_post(void* card_addr, JavaThread* thread))
-  G1ThreadLocalData::dirty_card_queue(thread).enqueue(card_addr);
-JRT_END
-
-#endif // INCLUDE_G1GC
-
 
 JRT_LEAF(jlong, SharedRuntime::lmul(jlong y, jlong x))
   return x * y;
--- a/src/hotspot/share/runtime/sharedRuntime.hpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/runtime/sharedRuntime.hpp	Mon Jun 04 14:59:53 2018 -0700
@@ -182,12 +182,6 @@
   static address raw_exception_handler_for_return_address(JavaThread* thread, address return_address);
   static address exception_handler_for_return_address(JavaThread* thread, address return_address);
 
-#if INCLUDE_G1GC
-  // G1 write barriers
-  static void g1_wb_pre(oopDesc* orig, JavaThread *thread);
-  static void g1_wb_post(void* card_addr, JavaThread* thread);
-#endif // INCLUDE_G1GC
-
   // exception handling and implicit exceptions
   static address compute_compiled_exc_handler(CompiledMethod* nm, address ret_pc, Handle& exception,
                                               bool force_unwind, bool top_frame_only, bool& recursive_exception_occurred);
--- a/src/hotspot/share/runtime/stubRoutines.cpp	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/hotspot/share/runtime/stubRoutines.cpp	Mon Jun 04 14:59:53 2018 -0700
@@ -410,7 +410,7 @@
   SharedRuntime::_oop_array_copy_ctr++;        // Slow-path oop array copy
 #endif // !PRODUCT
   assert(count != 0, "count should be non-zero");
-  HeapAccess<>::oop_arraycopy(NULL, NULL, (HeapWord*)src, (HeapWord*)dest, count);
+  ArrayAccess<>::oop_arraycopy_raw((HeapWord*)src, (HeapWord*)dest, count);
 JRT_END
 
 JRT_LEAF(void, StubRoutines::oop_copy_uninit(oop* src, oop* dest, size_t count))
@@ -418,7 +418,7 @@
   SharedRuntime::_oop_array_copy_ctr++;        // Slow-path oop array copy
 #endif // !PRODUCT
   assert(count != 0, "count should be non-zero");
-  HeapAccess<AS_DEST_NOT_INITIALIZED>::oop_arraycopy(NULL, NULL, (HeapWord*)src, (HeapWord*)dest, count);
+  ArrayAccess<AS_DEST_NOT_INITIALIZED>::oop_arraycopy_raw((HeapWord*)src, (HeapWord*)dest, count);
 JRT_END
 
 JRT_LEAF(void, StubRoutines::arrayof_jbyte_copy(HeapWord* src, HeapWord* dest, size_t count))
@@ -454,7 +454,7 @@
   SharedRuntime::_oop_array_copy_ctr++;        // Slow-path oop array copy
 #endif // !PRODUCT
   assert(count != 0, "count should be non-zero");
-  HeapAccess<ARRAYCOPY_ARRAYOF>::oop_arraycopy(NULL, NULL, src, dest, count);
+  ArrayAccess<ARRAYCOPY_ARRAYOF>::oop_arraycopy_raw(src, dest, count);
 JRT_END
 
 JRT_LEAF(void, StubRoutines::arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count))
@@ -462,7 +462,7 @@
   SharedRuntime::_oop_array_copy_ctr++;        // Slow-path oop array copy
 #endif // !PRODUCT
   assert(count != 0, "count should be non-zero");
-  HeapAccess<ARRAYCOPY_ARRAYOF | AS_DEST_NOT_INITIALIZED>::oop_arraycopy(NULL, NULL, src, dest, count);
+  ArrayAccess<ARRAYCOPY_ARRAYOF | AS_DEST_NOT_INITIALIZED>::oop_arraycopy_raw(src, dest, count);
 JRT_END
 
 address StubRoutines::select_fill_function(BasicType t, bool aligned, const char* &name) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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
@@ -746,7 +746,8 @@
         }
 
         protected Scope finalizeSingleScope(Scope impScope) {
-            if (impScope instanceof FilterImportScope && impScope.owner.kind == Kind.TYP) {
+            if (impScope instanceof FilterImportScope && impScope.owner.kind == Kind.TYP &&
+                ((FilterImportScope) impScope).isStaticallyImported()) {
                 WriteableScope finalized = WriteableScope.create(impScope.owner);
 
                 for (Symbol sym : impScope.getSymbols()) {
@@ -973,6 +974,10 @@
 
         @Override
         public boolean isStaticallyImported(Symbol byName) {
+            return isStaticallyImported();
+        }
+
+        public boolean isStaticallyImported() {
             return imp.staticImport;
         }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Jun 04 14:59:53 2018 -0700
@@ -1257,15 +1257,19 @@
     ClassSymbol accessConstructorTag() {
         ClassSymbol topClass = currentClass.outermostClass();
         ModuleSymbol topModle = topClass.packge().modle;
-        Name flatname = names.fromString("" + topClass.getQualifiedName() +
-                                         target.syntheticNameChar() +
-                                         "1");
-        ClassSymbol ctag = chk.getCompiled(topModle, flatname);
-        if (ctag == null)
-            ctag = makeEmptyClass(STATIC | SYNTHETIC, topClass).sym;
-        // keep a record of all tags, to verify that all are generated as required
-        accessConstrTags = accessConstrTags.prepend(ctag);
-        return ctag;
+        for (int i = 1; ; i++) {
+            Name flatname = names.fromString("" + topClass.getQualifiedName() +
+                                            target.syntheticNameChar() +
+                                            i);
+            ClassSymbol ctag = chk.getCompiled(topModle, flatname);
+            if (ctag == null)
+                ctag = makeEmptyClass(STATIC | SYNTHETIC, topClass).sym;
+            else if (!ctag.isAnonymous())
+                continue;
+            // keep a record of all tags, to verify that all are generated as required
+            accessConstrTags = accessConstrTags.prepend(ctag);
+            return ctag;
+        }
     }
 
     /** Add all required access methods for a private symbol to enclosing class.
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Jun 04 14:59:53 2018 -0700
@@ -1978,7 +1978,7 @@
             ClassSymbol c = finder.loadClass(env.toplevel.modle, name);
             return isAccessible(env, c) ? c : new AccessError(env, null, c);
         } catch (ClassFinder.BadClassFile err) {
-            throw err;
+            return new BadClassFileError(err);
         } catch (CompletionFailure ex) {
             Symbol candidate = recoveryLoadClass.loadClass(env, name);
 
@@ -4499,6 +4499,27 @@
         }
     }
 
+    class BadClassFileError extends InvalidSymbolError {
+
+        private final CompletionFailure ex;
+
+        public BadClassFileError(CompletionFailure ex) {
+            super(HIDDEN, ex.sym, "BadClassFileError");
+            this.name = sym.name;
+            this.ex = ex;
+        }
+
+        @Override
+        JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
+            JCDiagnostic d = diags.create(dkind, log.currentSource(), pos,
+                "cant.access", ex.sym, ex.getDetailValue());
+
+            d.setFlag(DiagnosticFlag.NON_DEFERRABLE);
+            return d;
+        }
+
+    }
+
     /**
      * Helper class for method resolution diagnostic simplification.
      * Certain resolution diagnostic are rewritten as simpler diagnostic
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -223,6 +223,8 @@
             chk.checkImportedPackagesObservable(toplevel);
             toplevel.namedImportScope.finalizeScope();
             toplevel.starImportScope.finalizeScope();
+        } catch (CompletionFailure cf) {
+            chk.completionError(toplevel.pos(), cf);
         } finally {
             log.useSource(prev);
         }
--- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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
@@ -89,13 +89,17 @@
             throw new Error(testCase + " : method is not compiled");
         }
         InstalledCode installedCode = testCase.toInstalledCode();
-        String str = CompilerToVMHelper.disassembleCodeBlob(installedCode);
-        if (str != null) {
-            Asserts.assertGT(str.length(), 0,
+        String str1 = CompilerToVMHelper.disassembleCodeBlob(installedCode);
+        if (str1 != null) {
+            Asserts.assertGT(str1.length(), 0,
                    testCase +  " : returned string has to be non-zero length");
         }
+        // The very first call to the disassembler contains a string specifying the
+        // architecture: [Disassembling for mach='i386:x86-64']
+        // Therefore compare strings 2 and 3.
         String str2 = CompilerToVMHelper.disassembleCodeBlob(installedCode);
-        Asserts.assertEQ(str, str2,
-                testCase + " : 2nd invocation returned different value");
+        String str3 = CompilerToVMHelper.disassembleCodeBlob(installedCode);
+        Asserts.assertEQ(str2, str3,
+                testCase + " : 3nd invocation returned different value from 2nd");
     }
 }
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/limitmods/LimitModsHelper.java	Mon Jun 04 04:08:12 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2015, 2018, 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.
- *
- */
-
-/**
- * Used with -p or --upgrade-module-path to exercise the replacement
- * of classes in modules that are linked into the runtime image.
- */
-
-import java.lang.*;
-import java.lang.reflect.*;
-import sun.hotspot.WhiteBox;
-
-
-public class LimitModsHelper {
-    static final ClassLoader PLATFORM_LOADER = ClassLoader.getPlatformClassLoader();
-    static final ClassLoader SYS_LOADER      = ClassLoader.getSystemClassLoader();
-
-    public static void main(String[] args) throws Exception {
-        assertTrue(args.length == 4);
-        String[] classNames = new String[3];
-        for (int i = 0; i < 3; i++) {
-            classNames[i] = args[i].replace('/', '.');
-        }
-        int excludeModIdx = Integer.parseInt(args[3]);
-
-        ClassLoader expectedLoaders[] = {null, PLATFORM_LOADER, SYS_LOADER};
-
-        WhiteBox wb = WhiteBox.getWhiteBox();
-
-        Class<?> clazz = null;
-        for (int i = 0; i < 3; i++) {
-            try {
-                // Load the class with the default ClassLoader.
-                clazz = Class.forName(classNames[i]);
-            } catch (Exception e) {
-                if (i == excludeModIdx) {
-                    System.out.println(classNames[i] + " not found as expected because the module isn't in the --limit-modules - PASSED");
-                } else {
-                    throw(e);
-                }
-            }
-
-            if (clazz != null && i != excludeModIdx) {
-                // Make sure we got the expected defining ClassLoader
-                testLoader(clazz, expectedLoaders[i]);
-
-                // Make sure the class is not in the shared space
-                // because CDS is disabled with --limit-modules during run time.
-                if (excludeModIdx != -1) {
-                    if (wb.isSharedClass(clazz)) {
-                        throw new RuntimeException(clazz.getName() +
-                            ".class should not be in the shared space. " +
-                             "loader=" + clazz.getClassLoader() + " module=" + clazz.getModule().getName());
-                    }
-                } else {
-                    // class should be in the shared space if --limit-modules
-                    // isn't specified during run time
-                    if (!wb.isSharedClass(clazz)) {
-                        throw new RuntimeException(clazz.getName() +
-                            ".class should be in the shared space. " +
-                             "loader=" + clazz.getClassLoader() + " module=" + clazz.getModule().getName());
-                    }
-                }
-            }
-            clazz = null;
-        }
-    }
-
-    /**
-     * Asserts that given class has the expected defining loader.
-     */
-    static void testLoader(Class<?> clazz, ClassLoader expected) {
-        ClassLoader loader = clazz.getClassLoader();
-        if (loader != expected) {
-            throw new RuntimeException(clazz + " loaded by " + loader + ", expected " + expected);
-        }
-    }
-
-    static void assertTrue(boolean expr) {
-        if (!expr)
-            throw new RuntimeException("assertion failed");
-    }
-}
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/limitmods/LimitModsTests.java	Mon Jun 04 04:08:12 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2015, 2018, 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
- * @requires vm.cds & !vm.graal.enabled
- * @library ../..
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- * @modules jdk.jartool/sun.tools.jar
- *          jdk.internal.jvmstat/sun.jvmstat.monitor
- * @compile LimitModsHelper.java
- * @compile ../../test-classes/java/net/HttpCookie.jasm
- * @compile ../../test-classes/jdk/dynalink/DynamicLinker.jasm
- * @compile ../../test-classes/com/sun/tools/javac/Main.jasm
- * @build sun.hotspot.WhiteBox
- * @run driver ClassFileInstaller sun.hotspot.WhiteBox
- * @run main LimitModsTests
- * @summary AppCDS tests for excluding class in module by using --limit-modules.
- */
-
-/**
- * This is for testing the --limit-modules option with AppCDS.
- * This test assumes the following defining class loader, module, class relations:
- * class loader    module            class
- * -----------------------------------------------------
- * boot            java.base         java/net/HttpCookie
- * platform        jdk.dynalink      jdk/dynalink/DynamicLinker
- * app             jdk.compiler      com/sun/tools/javac/Main
- *
- * This test dumps the above 3 classes into a shared archive.
- * Then it will run the following 4 -limit-modules scenarios:
- * 1. without --limit-modules
- *    All 3 classes should be loaded successfully.
- *    All 3 classes should be loaded by the appropriate class loader.
- *    All 3 classes should be found in the shared archive.
- * 2. --limit-modules java.base,jdk.dynalink
- *    The loading of the com/sun/tools/javac/Main class should fail.
- *    The other 2 classes should be loaded successfully and by the appropriate class loader.
- *    The other 2 classes should be found in the shared archive.
- * 3. --limit-modules java.base,jdk.compiler
- *    The loading of the jdk/nio/dynalink/DynamicLinker class should fail.
- *    The other 2 classes should be loaded successfully and by the appropriate class loader.
- *    The other 2 classes should be found in the shared archive.
- * 4. --limit-modules jdk.dynalink,jdk.compiler
- *    The java.base module can't be excluded.
- *    The results for this case is the same as for case #1.
- */
-
-import java.io.File;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.process.OutputAnalyzer;
-
-
-public class LimitModsTests {
-
-    // the module that is limited
-    private static final String[] LIMIT_MODULES = {"java.base", "jdk.dynalink", "jdk.compiler"};
-
-    // test classes to archive.
-    private static final String BOOT_ARCHIVE_CLASS = "java/net/HttpCookie";
-    private static final String PLATFORM_ARCHIVE_CLASS = "jdk/dynalink/DynamicLinker";
-    private static final String APP_ARCHIVE_CLASS = "com/sun/tools/javac/Main";
-    private static final String[] ARCHIVE_CLASSES = {
-        BOOT_ARCHIVE_CLASS, PLATFORM_ARCHIVE_CLASS, APP_ARCHIVE_CLASS};
-    private String bootClassPath = null;
-    private String whiteBoxJar = null;
-    private String helperJar = null;
-    private String appJar = null;
-    private OutputAnalyzer output = null;
-
-    public static void main(String[] args) throws Exception {
-        LimitModsTests tests = new LimitModsTests();
-        tests.dumpArchive();
-        tests.runTestNoLimitMods();
-        tests.runTestLimitMods();
-    }
-
-    void dumpArchive() throws Exception {
-        JarBuilder.build("limitModsTest", BOOT_ARCHIVE_CLASS, PLATFORM_ARCHIVE_CLASS, APP_ARCHIVE_CLASS);
-        JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
-        JarBuilder.build("limitModsHelper", "LimitModsHelper");
-
-        appJar = TestCommon.getTestJar("limitModsTest.jar");
-        whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar");
-        helperJar = TestCommon.getTestJar("limitModsHelper.jar");
-        bootClassPath = "-Xbootclasspath/a:" + whiteBoxJar;
-        // Dump the test classes into the archive
-        OutputAnalyzer output1  = TestCommon.dump(appJar, TestCommon.list(ARCHIVE_CLASSES), bootClassPath);
-        TestCommon.checkDump(output1);
-        // Make sure all the classes where successfully archived.
-        for (String archiveClass : ARCHIVE_CLASSES) {
-            output1.shouldNotContain("Preload Warning: Cannot find " + archiveClass);
-        }
-    }
-
-    // run the test without --limit-modules
-    public void runTestNoLimitMods() throws Exception {
-        output = TestCommon.exec(
-            appJar + File.pathSeparator + helperJar,
-            "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", bootClassPath,
-            "LimitModsHelper",
-            BOOT_ARCHIVE_CLASS, PLATFORM_ARCHIVE_CLASS, APP_ARCHIVE_CLASS, "-1"); // last 4 args passed to test
-        TestCommon.checkExec(output);
-    }
-
-    // run the test with --limit-modules
-    //
-    // --limit-modules jdk.dynalink,jdk.compiler
-    // It seems we can't exclude the java.base module. For this case,
-    // although the java.base module isn't in --limit-modules, the class
-    // in the java.base module (java.net.HttpCookie) can also be found.
-    //
-    // --limit-modules java.base,jdk.dynalink
-    // --limit-modules java.base,jdk.compiler
-    public void runTestLimitMods() throws Exception {
-        String limitMods = null;
-        for (int excludeModIdx = 0; excludeModIdx < 3; excludeModIdx++) {
-            for (int includeModIdx = 0; includeModIdx < 3; includeModIdx++) {
-                if (includeModIdx != excludeModIdx) {
-                    if (limitMods != null) {
-                        limitMods += ",";
-                        limitMods += LIMIT_MODULES[includeModIdx];
-                    } else {
-                        limitMods = LIMIT_MODULES[includeModIdx];
-                    }
-                }
-            }
-            TestCommon.run(
-                "-cp", appJar + File.pathSeparator + helperJar,
-                "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", bootClassPath,
-                "--limit-modules", limitMods,
-                "LimitModsHelper",
-                BOOT_ARCHIVE_CLASS, PLATFORM_ARCHIVE_CLASS, APP_ARCHIVE_CLASS,
-                Integer.toString(excludeModIdx)) // last 4 args passed to test
-                .assertSilentlyDisabledCDS(0);
-            limitMods = null;
-        }
-    }
-}
--- a/test/hotspot/jtreg/runtime/appcds/test-classes/jdk/dynalink/DynamicLinker.jasm	Mon Jun 04 04:08:12 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2016, 2017, 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/dynalink;
-
-public class DynamicLinker
-    version 51:0
-{
-
-public Method thisClassIsDummy:"()V"
-    stack 0 locals 2
-{
-    return;
-}
-
-} // end class DynamicLinker
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/modules/ClassLoaderNoUnnamedModule.java	Mon Jun 04 14:59:53 2018 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2018, 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.internal.misc.Unsafe;
+
+public class ClassLoaderNoUnnamedModule {
+    static final Unsafe UNSAFE = Unsafe.getUnsafe();
+
+    class TestClass extends ClassLoader {
+        public boolean calledConstructor = false;
+
+        public TestClass() {
+            calledConstructor = true;
+        }
+    }
+
+    static void testConstructorCall() throws Exception {
+        // Use Unsafe allocateInstance to construct an instance of TestClass
+        // which does not invoke its super's, java.lang.ClassLoader, constructor.
+        // An unnamed module for this ClassLoader is not created.
+        TestClass tc = (TestClass)UNSAFE.allocateInstance(TestClass.class);
+        System.out.println("tc = " + tc + "tc's ctor called = " + tc.calledConstructor);
+        Module unnamed_module = tc.getUnnamedModule();
+        if (unnamed_module == null) {
+            System.out.println("The unnamed module for this class loader is null");
+        }
+
+        tc.loadClass(String.class.getName());
+        Class.forName(String.class.getName(), false, tc);
+    }
+
+    public static void main(String args[]) throws Exception {
+        testConstructorCall();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/modules/ClassLoaderNoUnnamedModuleTest.java	Mon Jun 04 14:59:53 2018 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2018, 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 8202758
+ * @summary Ensure that if the JVM encounters a ClassLoader whose unnamedModule field is not set an InternalError results.
+ * @modules java.base/jdk.internal.misc
+ * @library /test/lib
+ * @compile ClassLoaderNoUnnamedModule.java
+ * @run main/othervm ClassLoaderNoUnnamedModuleTest
+ */
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class ClassLoaderNoUnnamedModuleTest {
+    public static void main(String args[]) throws Throwable {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+                               "--add-modules=java.base",
+                               "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
+                               "-XX:-CreateCoredumpOnCrash",
+                               "ClassLoaderNoUnnamedModule");
+        OutputAnalyzer oa = new OutputAnalyzer(pb.start());
+        oa.shouldContain("Internal Error");
+        oa.shouldContain("unnamed module");
+        oa.shouldContain("null or not an instance of java.lang.Module");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/jvmti/NotifyFramePop/NotifyFramePopTest.java	Mon Jun 04 14:59:53 2018 -0700
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2018, 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 Verifies NotifyFramePop request is cleared if JVMTI_EVENT_FRAME_POP is disabled
+ * @compile NotifyFramePopTest.java
+ * @run main/othervm/native -agentlib:NotifyFramePopTest NotifyFramePopTest
+ */
+
+public class NotifyFramePopTest {
+    static {
+        try {
+            System.loadLibrary("NotifyFramePopTest");
+        } catch (UnsatisfiedLinkError ex) {
+            System.err.println("Could not load NotifyFramePopTest library");
+            System.err.println("java.library.path:"
+                + System.getProperty("java.library.path"));
+            throw ex;
+        }
+    }
+
+    public static void main(String args[]) {
+        if (!canGenerateFramePopEvents()) {
+            log("FramePop event is not supported - skipping the test");
+            return;
+        }
+
+        // Sanity testing that FRAME_POP works.
+        test("sanity", true, () -> {
+            setFramePopNotificationMode(true);
+            notifyFramePop(null);
+        });
+
+        // Request notification and then disable FRAME_POP event notification.
+        // This should not prevent the notification for the frame being cleared
+        // when we return from the method.
+        test("requestAndDisable", false, () -> {
+            setFramePopNotificationMode(true);
+            notifyFramePop(null);
+            setFramePopNotificationMode(false);
+        });
+
+        // Ensure there is no pending event
+        test("ensureCleared", false, () -> {
+            setFramePopNotificationMode(true);
+        });
+
+        log("Test PASSED");
+    }
+
+    private native static boolean canGenerateFramePopEvents();
+    private native static void setFramePopNotificationMode(boolean enabled);
+    private native static void notifyFramePop(Thread thread);
+    private native static boolean framePopReceived();
+
+    private static void log(String msg) {
+        System.out.println(msg);
+    }
+
+    private interface Test {
+        void test();
+    }
+
+    private static void test(String name, boolean framePopExpected, Test theTest) {
+        log("test: " + name);
+        theTest.test();
+        boolean actual = framePopReceived();
+        if (framePopExpected != actual) {
+            throw new RuntimeException("unexpected notification:"
+                    + " FramePop expected: " + (framePopExpected ? "yes" : "no")
+                    + ", actually received: " + (actual ? "yes" : "no"));
+        }
+        log("  - OK (" + (actual ? "received" : "NOT received") + ")");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/jvmti/NotifyFramePop/libNotifyFramePopTest.c	Mon Jun 04 14:59:53 2018 -0700
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2018, 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
+
+static jvmtiEnv *jvmti = NULL;
+static jvmtiCapabilities caps;
+static jvmtiEventCallbacks callbacks;
+static jboolean framePopReceived = JNI_FALSE;
+
+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 void reportError(const char *msg, int err) {
+    fprintf(stdout, "%s, error: %d\n", msg, err);
+    fflush(stdout);
+}
+
+
+static void JNICALL
+FramePop(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread,
+         jmethodID method, jboolean wasPoppedByException)
+{
+    jvmtiError err;
+    jclass cls = NULL;
+    char* csig = NULL;
+    char* name = NULL;
+    char* sign = NULL;
+
+    framePopReceived = JNI_TRUE;
+
+    err = (*jvmti_env)->GetMethodDeclaringClass(jvmti_env, method, &cls);
+    if (err != JVMTI_ERROR_NONE) {
+        reportError("FramePop: GetMethodDeclaringClass failed", err);
+    }
+    err = (*jvmti_env)->GetClassSignature(jvmti_env, cls, &csig, NULL);
+    if (err != JVMTI_ERROR_NONE) {
+        reportError("FramePop: GetClassSignature failed", err);
+    }
+    err = (*jvmti_env)->GetMethodName(jvmti_env, method, &name, &sign, NULL);
+    if (err != JVMTI_ERROR_NONE) {
+        reportError("FramePop: GetMethodName failed", err);
+    }
+    fprintf(stdout, "FramePop event from method: %s %s%s\n", csig, name, sign);
+    fflush(stdout);
+
+    (*jvmti_env)->Deallocate(jvmti_env, (unsigned char*)csig);
+    (*jvmti_env)->Deallocate(jvmti_env, (unsigned char*)name);
+    (*jvmti_env)->Deallocate(jvmti_env, (unsigned char*)sign);
+}
+
+static
+jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
+    jint res;
+    jvmtiError err;
+
+    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_9);
+    if (res != JNI_OK || jvmti == NULL) {
+        reportError("GetEnv(JVMTI_VERSION_9) failed", res);
+        return JNI_ERR;
+    }
+    err = (*jvmti)->GetPotentialCapabilities(jvmti, &caps);
+    if (err != JVMTI_ERROR_NONE) {
+        reportError("GetPotentialCapabilities failed", err);
+        return JNI_ERR;
+    }
+    err = (*jvmti)->AddCapabilities(jvmti, &caps);
+    if (err != JVMTI_ERROR_NONE) {
+        reportError("AddCapabilities failed",err);
+        return JNI_ERR;
+    }
+    err = (*jvmti)->GetCapabilities(jvmti, &caps);
+    if (err != JVMTI_ERROR_NONE) {
+        reportError("GetCapabilities failed", err);
+        return JNI_ERR;
+    }
+    if (caps.can_generate_frame_pop_events) {
+        callbacks.FramePop = &FramePop;
+        err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, sizeof(callbacks));
+        if (err != JVMTI_ERROR_NONE) {
+            reportError("SetEventCallbacks failed", err);
+            return JNI_ERR;
+        }
+    }
+    return JNI_OK;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_NotifyFramePopTest_canGenerateFramePopEvents(JNIEnv *env, jclass cls) {
+    return caps.can_generate_frame_pop_events ? JNI_TRUE : JNI_FALSE;
+}
+
+JNIEXPORT void JNICALL
+Java_NotifyFramePopTest_setFramePopNotificationMode(JNIEnv *env, jclass cl, jboolean enable) {
+    jvmtiEventMode mode = enable ? JVMTI_ENABLE : JVMTI_DISABLE;
+    jvmtiError err = (*jvmti)->SetEventNotificationMode(jvmti, mode, JVMTI_EVENT_FRAME_POP, NULL);
+    if (err != JVMTI_ERROR_NONE) {
+        reportError("Failed to set notification mode for FRAME_POP events", err);
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_NotifyFramePopTest_notifyFramePop(JNIEnv *env, jclass cls, jthread thread)
+{
+    jvmtiError err= (*jvmti)->NotifyFramePop(jvmti, thread, 1);
+    if (err != JVMTI_ERROR_NONE) {
+        reportError("NotifyFramePop failed", err);
+    }
+}
+
+JNIEXPORT jboolean JNICALL
+Java_NotifyFramePopTest_framePopReceived(JNIEnv *env, jclass cls) {
+    jboolean result = framePopReceived;
+    framePopReceived = JNI_FALSE;
+    return result;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/invoke/condy/CondyNestedResolution.jcod	Mon Jun 04 14:59:53 2018 -0700
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+/*
+Pseudo Java code:
+
+class CondyNestedResolution {
+    public static Object bsm1arg(MethodHandles$Lookup p1, String p2, Object p3, Object p4) {
+        System.out.println("In bsm1arg");
+        System.out.println(p4);
+        return p4;
+    }
+    public static Object bsm2arg(MethodHandles$Lookup p1, String p2, Object p3, Object p4, Object p5) {
+        System.out.println("In bsm2arg");
+        System.out.println(p4);
+        System.out.println(p5);
+        return p4;
+    }
+    public static Object bsm3arg(MethodHandles$Lookup p1, String p2, Object p3, Object p4, Object p5, Object p6) {
+        System.out.println("In bsm3arg");
+        System.out.println(p4);
+        System.out.println(p5);
+        System.out.println(p6);
+        return p4;
+    }
+    public static Object bsm4arg(MethodHandles$Lookup p1, String p2, Object p3, Object p4, Object p5, Object p6, Object p7) {
+        System.out.println("In bsm4arg");
+        System.out.println(p4);
+        System.out.println(p5);
+        System.out.println(p6);
+        System.out.println(p7);
+        return p4;
+    }
+
+    public static void test_condy() {
+        // The following condy of BSM#8 results in the invocation of bootstrap method bsm4arg with the following
+        // parameters:
+        // bsm4arg(bsm1arg("hello1"),
+        //         bsm1arg("hello2"),
+        //         bsm3arg(bsm1arg("hello4"), bsm2arg(bsm1arg("hello6"), (circular reference to BSM#8)), bsm1arg("hello5")),
+        //         bsm1arg("hello3"));
+        // JVMS 5.4.3.6 Dynamically-Computed Constant and Call Site Resolution
+        // Ensure that calls to bsm1arg("hello5") and bsm1arg("hello3") are never resolved due to the nested condy circularity
+        // which results in a StackOverflowError.
+        //
+        ldc Dynamic BSM#8;
+    }
+    public static void main(String args[]) {
+        CondyNestedResolution.test_condy();
+    }
+}
+
+BootstrapMethods:
+  BSM0=invokestatic CondyNestedResolution.bsm1arg("hello1");
+  BSM1=invokestatic CondyNestedResolution.bsm1arg("hello2");
+  BSM2=invokestatic CondyNestedResolution.bsm1arg("hello4");
+  BSM3=invokestatic CondyNestedResolution.bsm1arg("hello6");
+  BSM4=invokestatic CondyNestedResolution.bsm2arg(BSM#3, BSM#8);
+  BSM5=invokestatic CondyNestedResolution.bsm1arg("hello5");
+  BSM6=invokestatic CondyNestedResolution.bsm3arg(BSM#2, BSM#4, BSM#5);
+  BSM7=invokestatic CondyNestedResolution.bsm1arg("hello3");
+  BSM8=invokestatic CondyNestedResolution.bsm4arg(BSM#0, BSM#1, BSM#6, BSM#7);
+
+Expected output:
+  In bsm1arg
+  hello1
+  In bsm1arg
+  hello2
+  In bsm1arg
+  hello4
+  In bsm1arg
+  hello6
+  Exception in thread "main" java.lang.StackOverflowError
+          at java.base/java.lang.invoke.MethodHandleNatives.copyOutBootstrapArguments(Native Method)
+*/
+
+
+class CondyNestedResolution {
+  0xCAFEBABE;
+  0; // minor version
+  55; // version
+  [85] { // Constant Pool
+    ; // first element is empty
+    String #22; // #1     at 0x0A
+    String #61; // #2     at 0x0D
+    String #11; // #3     at 0x10
+    Dynamic 8s #12; // #4     at 0x13
+    Method #51 #10; // #5     at 0x18
+    Method #13 #39; // #6     at 0x1D
+    Field #50 #81; // #7     at 0x22
+    Method #84 #45; // #8     at 0x27
+    Utf8 "java/io/PrintStream"; // #9     at 0x2C
+    NameAndType #71 #47; // #10     at 0x42
+    Utf8 "In bsm1arg"; // #11     at 0x47
+    NameAndType #18 #17; // #12     at 0x54
+    class #9; // #13     at 0x59
+    Utf8 "SourceFile"; // #14     at 0x5C
+    Utf8 "bsm3arg"; // #15     at 0x69
+    Utf8 "CondyNestedResolution.jasm"; // #16     at 0x73
+    Utf8 "Ljava/lang/String;"; // #17     at 0x90
+    Utf8 "name"; // #18     at 0xA5
+    Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"; // #19     at 0xAC
+    Utf8 "test_condy"; // #20     at 0x0144
+    NameAndType #15 #19; // #21     at 0x0151
+    Utf8 "In bsm2arg"; // #22     at 0x0156
+    Utf8 "Code"; // #23     at 0x0163
+    Utf8 "([Ljava/lang/String;)V"; // #24     at 0x016A
+    Utf8 "bsm4arg"; // #25     at 0x0183
+    Utf8 "out"; // #26     at 0x018D
+    NameAndType #69 #55; // #27     at 0x0193
+    Utf8 "BootstrapMethods"; // #28     at 0x0198
+    MethodHandle 6b #44; // #29     at 0x01AB
+    Method #84 #63; // #30     at 0x01AF
+    Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"; // #31     at 0x01B4
+    Method #84 #27; // #32     at 0x0228
+    MethodHandle 6b #30; // #33     at 0x022D
+    MethodHandle 6b #30; // #34     at 0x0231
+    MethodHandle 6b #30; // #35     at 0x0235
+    MethodHandle 6b #30; // #36     at 0x0239
+    MethodHandle 6b #30; // #37     at 0x023D
+    MethodHandle 6b #30; // #38     at 0x0241
+    NameAndType #40 #41; // #39     at 0x0245
+    Utf8 "println"; // #40     at 0x024A
+    Utf8 "(Ljava/lang/Object;)V"; // #41     at 0x0254
+    Utf8 "java/lang/Object"; // #42     at 0x026C
+    Utf8 "java/lang/System"; // #43     at 0x027F
+    Method #84 #21; // #44     at 0x0292
+    NameAndType #20 #47; // #45     at 0x0297
+    MethodHandle 6b #82; // #46     at 0x029C
+    Utf8 "()V"; // #47     at 0x02A0
+    String #62; // #48     at 0x02A6
+    String #64; // #49     at 0x02A9
+    class #43; // #50     at 0x02AC
+    class #42; // #51     at 0x02AF
+    String #65; // #52     at 0x02B2
+    String #66; // #53     at 0x02B5
+    String #67; // #54     at 0x02B8
+    Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"; // #55     at 0x02BB
+    Utf8 "main"; // #56     at 0x0341
+    String #68; // #57     at 0x0348
+    MethodHandle 6b #32; // #58     at 0x034B
+    Utf8 "bsm1arg"; // #59     at 0x034F
+    NameAndType #25 #83; // #60     at 0x0359
+    Utf8 "In bsm4arg"; // #61     at 0x035E
+    Utf8 "hello6"; // #62     at 0x036B
+    NameAndType #59 #31; // #63     at 0x0374
+    Utf8 "hello5"; // #64     at 0x0379
+    Utf8 "hello4"; // #65     at 0x0382
+    Utf8 "hello3"; // #66     at 0x038B
+    Utf8 "hello2"; // #67     at 0x0394
+    Utf8 "hello1"; // #68     at 0x039D
+    Utf8 "bsm2arg"; // #69     at 0x03A6
+    Utf8 "Ljava/io/PrintStream;"; // #70     at 0x03B0
+    Utf8 "<init>"; // #71     at 0x03C8
+    Utf8 "CondyNestedResolution"; // #72     at 0x03D1
+    Dynamic 7s #12; // #73     at 0x03E9
+    Dynamic 6s #12; // #74     at 0x03EE
+    Dynamic 5s #12; // #75     at 0x03F3
+    Dynamic 4s #12; // #76     at 0x03F8
+    Dynamic 3s #12; // #77     at 0x03FD
+    Dynamic 0s #12; // #78     at 0x0402
+    Dynamic 1s #12; // #79     at 0x0407
+    Dynamic 2s #12; // #80     at 0x040C
+    NameAndType #26 #70; // #81     at 0x0411
+    Method #84 #60; // #82     at 0x0416
+    Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"; // #83     at 0x041B
+    class #72; // #84     at 0x04C5
+  } // Constant Pool
+
+  0x0000; // access [ ]
+  #84;// this_cpx
+  #51;// super_cpx
+
+  [0] { // Interfaces
+  } // Interfaces
+
+  [0] { // fields
+  } // fields
+
+  [7] { // methods
+    { // Member at 0x04D4
+      0x0001; // access
+      #71; // name_cpx
+      #47; // sig_cpx
+      [1] { // Attributes
+        Attr(#23, 17) { // Code at 0x04DC
+          1; // max_stack
+          1; // max_locals
+          Bytes[5]{
+            0x2AB70005B1;
+          }
+          [0] { // Traps
+          } // end Traps
+          [0] { // Attributes
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x04F3
+      0x0009; // access
+      #59; // name_cpx
+      #31; // sig_cpx
+      [1] { // Attributes
+        Attr(#23, 29) { // Code at 0x04FB
+          4; // max_stack
+          4; // max_locals
+          Bytes[17]{
+            0xB200071203B60006;
+            0xB200072DB600062D;
+            0xB0;
+          }
+          [0] { // Traps
+          } // end Traps
+          [0] { // Attributes
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x051E
+      0x0009; // access
+      #69; // name_cpx
+      #55; // sig_cpx
+      [1] { // Attributes
+        Attr(#23, 37) { // Code at 0x0526
+          8; // max_stack
+          8; // max_locals
+          Bytes[25]{
+            0xB200071201B60006;
+            0xB200072DB60006B2;
+            0x00071904B600062D;
+            0xB0;
+          }
+          [0] { // Traps
+          } // end Traps
+          [0] { // Attributes
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x0551
+      0x0009; // access
+      #15; // name_cpx
+      #19; // sig_cpx
+      [1] { // Attributes
+        Attr(#23, 45) { // Code at 0x0559
+          19; // max_stack
+          19; // max_locals
+          Bytes[33]{
+            0xB200071202B60006;
+            0xB200072DB60006B2;
+            0x00071904B60006B2;
+            0x00071905B600062D;
+            0xB0;
+          }
+          [0] { // Traps
+          } // end Traps
+          [0] { // Attributes
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x058C
+      0x0009; // access
+      #25; // name_cpx
+      #83; // sig_cpx
+      [1] { // Attributes
+        Attr(#23, 53) { // Code at 0x0594
+          19; // max_stack
+          19; // max_locals
+          Bytes[41]{
+            0xB200071202B60006;
+            0xB200072DB60006B2;
+            0x00071904B60006B2;
+            0x00071905B60006B2;
+            0x00071906B600062D;
+            0xB0;
+          }
+          [0] { // Traps
+          } // end Traps
+          [0] { // Attributes
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x05CF
+      0x0009; // access
+      #20; // name_cpx
+      #47; // sig_cpx
+      [1] { // Attributes
+        Attr(#23, 15) { // Code at 0x05D7
+          12; // max_stack
+          12; // max_locals
+          Bytes[3]{
+            0x1204B1;
+          }
+          [0] { // Traps
+          } // end Traps
+          [0] { // Attributes
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member at 0x05EC
+      0x0009; // access
+      #56; // name_cpx
+      #24; // sig_cpx
+      [1] { // Attributes
+        Attr(#23, 16) { // Code at 0x05F4
+          2; // max_stack
+          2; // max_locals
+          Bytes[4]{
+            0xB80008B1;
+          }
+          [0] { // Traps
+          } // end Traps
+          [0] { // Attributes
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [2] { // Attributes
+    Attr(#14, 2) { // SourceFile at 0x060C
+      #16;
+    } // end SourceFile
+    ;
+    Attr(#28, 68) { // BootstrapMethods at 0x0614
+      [9] { // bootstrap_methods
+        {  //  bootstrap_method
+          #36; // bootstrap_method_ref
+          [1] { // bootstrap_arguments
+            #57; //  at 0x0622
+          }  //  bootstrap_arguments
+        }  //  bootstrap_method
+        ;
+        {  //  bootstrap_method
+          #37; // bootstrap_method_ref
+          [1] { // bootstrap_arguments
+            #54; //  at 0x0628
+          }  //  bootstrap_arguments
+        }  //  bootstrap_method
+        ;
+        {  //  bootstrap_method
+          #38; // bootstrap_method_ref
+          [1] { // bootstrap_arguments
+            #52; //  at 0x062E
+          }  //  bootstrap_arguments
+        }  //  bootstrap_method
+        ;
+        {  //  bootstrap_method
+          #35; // bootstrap_method_ref
+          [1] { // bootstrap_arguments
+            #48; //  at 0x0634
+          }  //  bootstrap_arguments
+        }  //  bootstrap_method
+        ;
+        {  //  bootstrap_method
+          #58; // bootstrap_method_ref
+          [2] { // bootstrap_arguments
+            #77; //  at 0x063A
+            #4; //  at 0x063C
+          }  //  bootstrap_arguments
+        }  //  bootstrap_method
+        ;
+        {  //  bootstrap_method
+          #34; // bootstrap_method_ref
+          [1] { // bootstrap_arguments
+            #49; //  at 0x0642
+          }  //  bootstrap_arguments
+        }  //  bootstrap_method
+        ;
+        {  //  bootstrap_method
+          #29; // bootstrap_method_ref
+          [3] { // bootstrap_arguments
+            #80; //  at 0x0648
+            #76; //  at 0x064A
+            #75; //  at 0x064C
+          }  //  bootstrap_arguments
+        }  //  bootstrap_method
+        ;
+        {  //  bootstrap_method
+          #33; // bootstrap_method_ref
+          [1] { // bootstrap_arguments
+            #53; //  at 0x0652
+          }  //  bootstrap_arguments
+        }  //  bootstrap_method
+        ;
+        {  //  bootstrap_method
+          #46; // bootstrap_method_ref
+          [4] { // bootstrap_arguments
+            #78; //  at 0x0658
+            #79; //  at 0x065A
+            #74; //  at 0x065C
+            #73; //  at 0x065E
+          }  //  bootstrap_arguments
+        }  //  bootstrap_method
+      }
+    } // end BootstrapMethods
+  } // Attributes
+} // end class CondyNestedResolution
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/invoke/condy/CondyNestedResolutionTest.java	Mon Jun 04 14:59:53 2018 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2018, 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 8203435
+ * @summary Test JVMs 5.4.3.6 with respect to a dynamically-computed constant and circularity.
+ * @modules java.base/jdk.internal.misc
+ * @library /test/lib
+ * @compile CondyNestedResolution.jcod
+ * @run main/othervm CondyNestedResolutionTest
+ */
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.compiler.InMemoryJavaCompiler;
+
+/*
+ * JVMs section 5.4.3.6 Dynamically-Computed Constant and Call Site Resolution
+ *     "Let X be the symbolic reference currently being resolved, and let Y be a static argument of X
+ *      to be resolved as described above. If X and Y are both dynamically-computed constants, and if Y
+ *      is either the same as X or has a static argument that references X through its static arguments,
+ *      directly or indirectly, resolution fails with a StackOverflowError.
+ */
+public class CondyNestedResolutionTest {
+    public static void main(String args[]) throws Throwable {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("CondyNestedResolution");
+        OutputAnalyzer oa = new OutputAnalyzer(pb.start());
+        oa.shouldContain("StackOverflowError");
+        oa.shouldContain("bsm1arg");
+        oa.shouldContain("hello1");
+        oa.shouldContain("hello2");
+        oa.shouldContain("hello4");
+        oa.shouldContain("hello6");
+        oa.shouldNotContain("hello3");
+        oa.shouldNotContain("hello5");
+        oa.shouldNotContain("bsm2arg");
+        oa.shouldNotContain("bsm3arg");
+        oa.shouldNotContain("bsm4arg");
+        oa.shouldHaveExitValue(1);
+    }
+}
--- a/test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java	Mon Jun 04 14:59:53 2018 -0700
@@ -43,9 +43,8 @@
 public class TestJfrJavaBase {
 
     private static void checkOutput(OutputAnalyzer output) {
-        output.shouldContain("jdk.jfr not found.");
+        output.shouldContain("Module jdk.jfr not found.");
         output.shouldContain("Flight Recorder can not be enabled.");
-        output.shouldContain("To use Flight Recorder, you might need to add \"--add-modules jdk.jfr\" to the VM command-line options.");
     }
 
     public static void main(String[] args) throws Exception {
--- a/test/langtools/tools/javac/6330997/T6330997.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/test/langtools/tools/javac/6330997/T6330997.java	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, 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
@@ -44,7 +44,7 @@
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.ClassFinder.BadClassFile;
 import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.util.Names;
 import javax.tools.ToolProvider;
 
 public class T6330997 {
@@ -53,17 +53,17 @@
         increaseMajor("T2.class", 2);
         javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, null, null, null, null, null);
-        JavaCompiler compiler = JavaCompiler.instance(task.getContext());
         Symtab syms = Symtab.instance(task.getContext());
+        Names names = Names.instance(task.getContext());
         task.ensureEntered();
         try {
-            compiler.resolveIdent(syms.unnamedModule, "T1").complete();
+            syms.enterClass(syms.unnamedModule, names.fromString("T1")).complete();
         } catch (Exception e) {
             e.printStackTrace();
             throw new RuntimeException("Failed: unexpected exception while reading class T1");
         }
         try {
-            compiler.resolveIdent(syms.unnamedModule, "T2").complete();
+            syms.enterClass(syms.unnamedModule, names.fromString("T2")).complete();
         } catch (BadClassFile e) {
             System.err.println("Passed: expected completion failure " + e.getClass().getName());
             return;
--- a/test/langtools/tools/javac/T6435291/T6435291.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/test/langtools/tools/javac/T6435291/T6435291.java	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, 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
@@ -38,7 +38,7 @@
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.ClassFinder.BadClassFile;
 import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.util.Names;
 import javax.tools.ToolProvider;
 
 public class T6435291 {
@@ -46,10 +46,10 @@
         javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, null, null, null, null, null);
         Symtab syms = Symtab.instance(task.getContext());
+        Names names = Names.instance(task.getContext());
         task.ensureEntered();
-        JavaCompiler compiler = JavaCompiler.instance(task.getContext());
         try {
-            compiler.resolveIdent(syms.unnamedModule, "T").complete();
+            syms.enterClass(syms.unnamedModule, names.fromString("T")).complete();
         } catch (BadClassFile e) {
             System.err.println("Passed: expected completion failure " + e.getClass().getName());
             return;
--- a/test/langtools/tools/javac/api/6400303/T6400303.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/test/langtools/tools/javac/api/6400303/T6400303.java	Mon Jun 04 14:59:53 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, 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,17 +41,17 @@
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Symbol.CompletionFailure;
 import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.util.Names;
 
 public class T6400303 {
     public static void main(String... args) {
         javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, null, null, null, null, null);
+        Names names = Names.instance(task.getContext());
         Symtab syms = Symtab.instance(task.getContext());
         task.ensureEntered();
-        JavaCompiler compiler = JavaCompiler.instance(task.getContext());
         try {
-            compiler.resolveIdent(syms.unnamedModule, "Test$1").complete();
+            syms.enterClass(syms.unnamedModule, names.fromString("Test$1")).complete();
         } catch (CompletionFailure ex) {
             System.err.println("Got expected completion failure: " + ex.getLocalizedMessage());
             return;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/classfiles/attributes/Synthetic/AccessToPrivateInnerClassConstructorsTest.java	Mon Jun 04 14:59:53 2018 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2018, 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 8189335
+ * @summary Synthetic anonymous class used as access constructor tag conflicting with a top level class.
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.jdeps/com.sun.tools.classfile
+ * @library /tools/lib /tools/javac/lib ../lib
+ * @build toolbox.ToolBox InMemoryFileManager TestResult
+ * @build AccessToPrivateInnerClassConstructorsTest SyntheticTestDriver ExpectedClass ExpectedClasses
+ * @run main SyntheticTestDriver AccessToPrivateInnerClassConstructorsTest 1
+ * @run main AccessToPrivateInnerClassConstructorsTest
+ */
+
+@ExpectedClass(className = "AccessToPrivateInnerClassConstructorsTest",
+        expectedMethods = {"<init>()", "main(java.lang.String[])", "f()", "g()"})
+@ExpectedClass(className = "AccessToPrivateInnerClassConstructorsTest$1",
+        expectedMethods = {"<init>()"})
+@ExpectedClass(className = "AccessToPrivateInnerClassConstructorsTest$A",
+        expectedMethods = {
+                "<init>(AccessToPrivateInnerClassConstructorsTest)",
+                "<init>(AccessToPrivateInnerClassConstructorsTest, " +
+                       "AccessToPrivateInnerClassConstructorsTest$1)"},
+        expectedNumberOfSyntheticFields = 1,
+        expectedNumberOfSyntheticMethods = 2)
+@ExpectedClass(className = "AccessToPrivateInnerClassConstructorsTest$1Local",
+        expectedMethods = {"<init>(AccessToPrivateInnerClassConstructorsTest)"},
+        expectedNumberOfSyntheticFields = 1)
+@ExpectedClass(className = "AccessToPrivateInnerClassConstructorsTest$2Local",
+        expectedMethods = {"<init>(AccessToPrivateInnerClassConstructorsTest)"},
+        expectedNumberOfSyntheticFields = 1)
+public class AccessToPrivateInnerClassConstructorsTest {
+
+    public static void main(String... args) {
+        new AccessToPrivateInnerClassConstructorsTest().f();
+    }
+
+    private class A {
+        private A() { }
+        private A(AccessToPrivateInnerClassConstructorsTest$1 o) { }
+    }
+
+    void f() {
+        new A();
+        new A(null);
+
+        class Local {};
+        new Local();
+    }
+
+    void g() {
+        class Local {};
+        new Local();
+    }
+}
+class AccessToPrivateInnerClassConstructorsTest$1 {}
--- a/test/langtools/tools/javac/classreader/8171132/BadConstantValue.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/test/langtools/tools/javac/classreader/8171132/BadConstantValue.java	Mon Jun 04 14:59:53 2018 -0700
@@ -37,11 +37,8 @@
  * @run main BadConstantValue
  */
 
-import com.sun.tools.classfile.Attribute;
 import com.sun.tools.classfile.ClassFile;
 import com.sun.tools.classfile.ClassWriter;
-import com.sun.tools.classfile.ConstantPool.CONSTANT_Integer_info;
-import com.sun.tools.classfile.ConstantValue_attribute;
 import com.sun.tools.classfile.Field;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.ClassFinder.BadClassFile;
@@ -49,6 +46,7 @@
 import com.sun.tools.javac.jvm.Target;
 import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.Names;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -169,12 +167,11 @@
         JavaCompiler c = ToolProvider.getSystemJavaCompiler();
         JavacTaskImpl task = (JavacTaskImpl) c.getTask(null, null, null,
                 Arrays.asList("-classpath", classesdir.getPath()), null, null);
+        Names names = Names.instance(task.getContext());
         Symtab syms = Symtab.instance(task.getContext());
         task.ensureEntered();
-        BadClassFile badClassFile;
         try {
-            com.sun.tools.javac.main.JavaCompiler.instance(task.getContext())
-                    .resolveIdent(syms.unnamedModule, className).complete();
+            syms.enterClass(syms.unnamedModule, names.fromString(className)).complete();
         } catch (BadClassFile e) {
             return e;
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/importscope/BadClassFileDuringImport.java	Mon Jun 04 14:59:53 2018 -0700
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2018, 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 8198378
+ * @summary Verify that BadClassFile related to imports are handled properly.
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask
+ * @run main BadClassFileDuringImport
+ */
+
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class BadClassFileDuringImport {
+    public static void main(String... args) throws Exception {
+        new BadClassFileDuringImport().run();
+    }
+
+    ToolBox tb = new ToolBox();
+
+    void run() throws Exception {
+        new JavacTask(tb)
+          .outdir(".")
+          .sources("package p; public class A { }",
+                   "package p; public class B { public static class I { } }")
+          .run()
+          .writeAll();
+
+        try (OutputStream out = Files.newOutputStream(Paths.get(".", "p", "A.class"))) {
+            out.write("broken".getBytes("UTF-8"));
+        }
+
+        try (OutputStream out = Files.newOutputStream(Paths.get(".", "p", "B$I.class"))) {
+            out.write("broken".getBytes("UTF-8"));
+        }
+
+        doTest("import p.A;",
+               "",
+               "Test.java:2:9: compiler.err.cant.access: p.A, (compiler.misc.bad.class.file.header: A.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import p.A;",
+               "A a;",
+               "Test.java:2:9: compiler.err.cant.access: p.A, (compiler.misc.bad.class.file.header: A.class, (compiler.misc.illegal.start.of.class.file))",
+               "Test.java:2:33: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, Test, null)",
+               "2 errors");
+        doTest("import p.A;",
+               "void test() { A a; }",
+               "Test.java:2:9: compiler.err.cant.access: p.A, (compiler.misc.bad.class.file.header: A.class, (compiler.misc.illegal.start.of.class.file))",
+               "Test.java:2:47: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, Test, null)",
+               "2 errors");
+        doTest("import p.*;",
+               "",
+               (String[]) null);
+        doTest("import p.*;",
+               "A a;",
+               "Test.java:2:33: compiler.err.cant.access: p.A, (compiler.misc.bad.class.file.header: A.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import p.*;",
+               "void test() { A a; }",
+               "Test.java:2:47: compiler.err.cant.access: p.A, (compiler.misc.bad.class.file.header: A.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+
+        doTest("import p.B.I;",
+               "",
+               "Test.java:2:11: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import p.B.I;",
+               "I i;",
+               "Test.java:2:11: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import p.B.I;",
+               "void test() { I i; }",
+               "Test.java:2:11: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import p.B.*;",
+               "",
+               (String[]) null);
+        doTest("import p.B.*;",
+               "I i;",
+               "Test.java:2:35: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import p.B.*;",
+               "void test() { I i; }",
+               "Test.java:2:49: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+
+        doTest("import static p.B.I;",
+               "",
+               "Test.java:2:1: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import static p.B.I;",
+               "I i;",
+               "Test.java:2:42: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import static p.B.I;",
+               "void test() { I i; }",
+               "Test.java:2:1: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import static p.B.*;",
+               "",
+               "Test.java:2:1: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import static p.B.*;",
+               "I i;",
+               "Test.java:2:42: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+        doTest("import static p.B.*;",
+               "void test() { I i; }",
+               "Test.java:2:1: compiler.err.cant.access: p.B.I, (compiler.misc.bad.class.file.header: B$I.class, (compiler.misc.illegal.start.of.class.file))",
+               "1 error");
+    }
+
+    void doTest(String importText, String useText, String... expectedOutput) {
+        List<String> log = new JavacTask(tb)
+                .classpath(".")
+                .sources("\n" + importText + " public class Test { " + useText + " }")
+                .options("-XDrawDiagnostics")
+                .run(expectedOutput != null ? Task.Expect.FAIL : Task.Expect.SUCCESS)
+                .writeAll()
+                .getOutputLines(Task.OutputKind.DIRECT);
+
+        if (expectedOutput != null && !log.equals(Arrays.asList(expectedOutput))) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+}
--- a/test/lib/jdk/test/lib/jfr/CommonHelper.java	Mon Jun 04 04:08:12 2018 +0000
+++ b/test/lib/jdk/test/lib/jfr/CommonHelper.java	Mon Jun 04 14:59:53 2018 -0700
@@ -106,7 +106,7 @@
 
     public static void waitForSystemCurrentMillisToChange() {
         long t = System.currentTimeMillis();
-        while (t != System.currentTimeMillis()) {
+        while (t == System.currentTimeMillis()) {
             try {
                 Thread.sleep(2);
             } catch (InterruptedException e) {