Merge
authorjwilhelm
Tue, 30 Jan 2018 16:41:40 +0100
changeset 48819 ee513596f3ee
parent 48818 ec4a84ba2aaf (diff)
parent 48680 f944d1b7ab25 (current diff)
child 48820 9a411a9a17f0
Merge
make/devkit/createWindowsDevkit.sh
src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp
src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
src/hotspot/share/oops/cpCache.cpp
src/hotspot/share/oops/klassVtable.cpp
src/hotspot/share/prims/jni.cpp
src/hotspot/share/runtime/arguments.cpp
src/hotspot/share/runtime/vmStructs.cpp
src/java.compiler/share/classes/javax/lang/model/overview.html
src/java.compiler/share/classes/javax/tools/overview.html
src/java.xml/share/classes/com/sun/org/apache/xalan/internal/utils/FactoryImpl.java
src/jdk.jdeps/share/classes/com/sun/tools/javap/overview.html
test/jdk/sun/security/krb5/auto/principalProperty/TestHosts
test/langtools/tools/javac/T8192885/AddGotoAfterForLoopToLNTTest.java
--- a/make/test/JtregNativeHotspot.gmk	Thu Jan 25 15:18:13 2018 -0800
+++ b/make/test/JtregNativeHotspot.gmk	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2015, 2017, 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
@@ -68,6 +68,7 @@
     $(TOPDIR)/test/hotspot/jtreg/compiler/runtime/criticalnatives/lookup \
     $(TOPDIR)/test/hotspot/jtreg/compiler/runtime/criticalnatives/argumentcorruption \
     $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo \
+    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorStackDepthInfo \
     $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetNamedModule \
     $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/IsModifiableModule \
     $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/AddModuleReads \
@@ -101,6 +102,7 @@
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_liboverflow := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libSimpleClassFileLoadHook := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetOwnedMonitorInfoTest := -lc
+    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetOwnedMonitorStackDepthInfoTest := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetNamedModuleTest := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libIsModifiableModuleTest := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleReadsTest := -lc
--- a/src/hotspot/cpu/aarch64/aarch64.ad	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/aarch64/aarch64.ad	Tue Jan 30 16:41:40 2018 +0100
@@ -17725,7 +17725,7 @@
   ins_cost(INSN_COST);
   format %{ "shl    $dst, $src, $shift\t# vector (8B)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 8) {
       __ eor(as_FloatRegister($dst$$reg), __ T8B,
              as_FloatRegister($src$$reg),
@@ -17744,7 +17744,7 @@
   ins_cost(INSN_COST);
   format %{ "shl    $dst, $src, $shift\t# vector (16B)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 8) {
       __ eor(as_FloatRegister($dst$$reg), __ T16B,
              as_FloatRegister($src$$reg),
@@ -17764,9 +17764,8 @@
   ins_cost(INSN_COST);
   format %{ "sshr    $dst, $src, $shift\t# vector (8B)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 8) sh = 7;
-    sh = -sh & 7;
     __ sshr(as_FloatRegister($dst$$reg), __ T8B,
            as_FloatRegister($src$$reg), sh);
   %}
@@ -17779,9 +17778,8 @@
   ins_cost(INSN_COST);
   format %{ "sshr    $dst, $src, $shift\t# vector (16B)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 8) sh = 7;
-    sh = -sh & 7;
     __ sshr(as_FloatRegister($dst$$reg), __ T16B,
            as_FloatRegister($src$$reg), sh);
   %}
@@ -17795,14 +17793,14 @@
   ins_cost(INSN_COST);
   format %{ "ushr    $dst, $src, $shift\t# vector (8B)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 8) {
       __ eor(as_FloatRegister($dst$$reg), __ T8B,
              as_FloatRegister($src$$reg),
              as_FloatRegister($src$$reg));
     } else {
       __ ushr(as_FloatRegister($dst$$reg), __ T8B,
-             as_FloatRegister($src$$reg), -sh & 7);
+             as_FloatRegister($src$$reg), sh);
     }
   %}
   ins_pipe(vshift64_imm);
@@ -17814,14 +17812,14 @@
   ins_cost(INSN_COST);
   format %{ "ushr    $dst, $src, $shift\t# vector (16B)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 8) {
       __ eor(as_FloatRegister($dst$$reg), __ T16B,
              as_FloatRegister($src$$reg),
              as_FloatRegister($src$$reg));
     } else {
       __ ushr(as_FloatRegister($dst$$reg), __ T16B,
-             as_FloatRegister($src$$reg), -sh & 7);
+             as_FloatRegister($src$$reg), sh);
     }
   %}
   ins_pipe(vshift128_imm);
@@ -17890,7 +17888,7 @@
   ins_cost(INSN_COST);
   format %{ "shl    $dst, $src, $shift\t# vector (4H)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 16) {
       __ eor(as_FloatRegister($dst$$reg), __ T8B,
              as_FloatRegister($src$$reg),
@@ -17909,7 +17907,7 @@
   ins_cost(INSN_COST);
   format %{ "shl    $dst, $src, $shift\t# vector (8H)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 16) {
       __ eor(as_FloatRegister($dst$$reg), __ T16B,
              as_FloatRegister($src$$reg),
@@ -17929,9 +17927,8 @@
   ins_cost(INSN_COST);
   format %{ "sshr    $dst, $src, $shift\t# vector (4H)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 16) sh = 15;
-    sh = -sh & 15;
     __ sshr(as_FloatRegister($dst$$reg), __ T4H,
            as_FloatRegister($src$$reg), sh);
   %}
@@ -17944,9 +17941,8 @@
   ins_cost(INSN_COST);
   format %{ "sshr    $dst, $src, $shift\t# vector (8H)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 16) sh = 15;
-    sh = -sh & 15;
     __ sshr(as_FloatRegister($dst$$reg), __ T8H,
            as_FloatRegister($src$$reg), sh);
   %}
@@ -17960,14 +17956,14 @@
   ins_cost(INSN_COST);
   format %{ "ushr    $dst, $src, $shift\t# vector (4H)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 16) {
       __ eor(as_FloatRegister($dst$$reg), __ T8B,
              as_FloatRegister($src$$reg),
              as_FloatRegister($src$$reg));
     } else {
       __ ushr(as_FloatRegister($dst$$reg), __ T4H,
-             as_FloatRegister($src$$reg), -sh & 15);
+             as_FloatRegister($src$$reg), sh);
     }
   %}
   ins_pipe(vshift64_imm);
@@ -17979,14 +17975,14 @@
   ins_cost(INSN_COST);
   format %{ "ushr    $dst, $src, $shift\t# vector (8H)" %}
   ins_encode %{
-    int sh = (int)$shift$$constant & 31;
+    int sh = (int)$shift$$constant;
     if (sh >= 16) {
       __ eor(as_FloatRegister($dst$$reg), __ T16B,
              as_FloatRegister($src$$reg),
              as_FloatRegister($src$$reg));
     } else {
       __ ushr(as_FloatRegister($dst$$reg), __ T8H,
-             as_FloatRegister($src$$reg), -sh & 15);
+             as_FloatRegister($src$$reg), sh);
     }
   %}
   ins_pipe(vshift128_imm);
@@ -18054,7 +18050,7 @@
   ins_encode %{
     __ shl(as_FloatRegister($dst$$reg), __ T2S,
            as_FloatRegister($src$$reg),
-           (int)$shift$$constant & 31);
+           (int)$shift$$constant);
   %}
   ins_pipe(vshift64_imm);
 %}
@@ -18067,7 +18063,7 @@
   ins_encode %{
     __ shl(as_FloatRegister($dst$$reg), __ T4S,
            as_FloatRegister($src$$reg),
-           (int)$shift$$constant & 31);
+           (int)$shift$$constant);
   %}
   ins_pipe(vshift128_imm);
 %}
@@ -18080,7 +18076,7 @@
   ins_encode %{
     __ sshr(as_FloatRegister($dst$$reg), __ T2S,
             as_FloatRegister($src$$reg),
-            -(int)$shift$$constant & 31);
+            (int)$shift$$constant);
   %}
   ins_pipe(vshift64_imm);
 %}
@@ -18093,7 +18089,7 @@
   ins_encode %{
     __ sshr(as_FloatRegister($dst$$reg), __ T4S,
             as_FloatRegister($src$$reg),
-            -(int)$shift$$constant & 31);
+            (int)$shift$$constant);
   %}
   ins_pipe(vshift128_imm);
 %}
@@ -18106,7 +18102,7 @@
   ins_encode %{
     __ ushr(as_FloatRegister($dst$$reg), __ T2S,
             as_FloatRegister($src$$reg),
-            -(int)$shift$$constant & 31);
+            (int)$shift$$constant);
   %}
   ins_pipe(vshift64_imm);
 %}
@@ -18119,7 +18115,7 @@
   ins_encode %{
     __ ushr(as_FloatRegister($dst$$reg), __ T4S,
             as_FloatRegister($src$$reg),
-            -(int)$shift$$constant & 31);
+            (int)$shift$$constant);
   %}
   ins_pipe(vshift128_imm);
 %}
@@ -18159,7 +18155,7 @@
   ins_encode %{
     __ shl(as_FloatRegister($dst$$reg), __ T2D,
            as_FloatRegister($src$$reg),
-           (int)$shift$$constant & 63);
+           (int)$shift$$constant);
   %}
   ins_pipe(vshift128_imm);
 %}
@@ -18172,7 +18168,7 @@
   ins_encode %{
     __ sshr(as_FloatRegister($dst$$reg), __ T2D,
             as_FloatRegister($src$$reg),
-            -(int)$shift$$constant & 63);
+            (int)$shift$$constant);
   %}
   ins_pipe(vshift128_imm);
 %}
@@ -18185,7 +18181,7 @@
   ins_encode %{
     __ ushr(as_FloatRegister($dst$$reg), __ T2D,
             as_FloatRegister($src$$reg),
-            -(int)$shift$$constant & 63);
+            (int)$shift$$constant);
   %}
   ins_pipe(vshift128_imm);
 %}
--- a/src/hotspot/cpu/ppc/assembler_ppc.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/ppc/assembler_ppc.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -518,6 +518,7 @@
     XXMRGHW_OPCODE = (60u << OPCODE_SHIFT |   18u << 3),
     XXMRGLW_OPCODE = (60u << OPCODE_SHIFT |   50u << 3),
     XXSPLTW_OPCODE = (60u << OPCODE_SHIFT |  164u << 2),
+    XXLOR_OPCODE   = (60u << OPCODE_SHIFT |  146u << 3),
     XXLXOR_OPCODE  = (60u << OPCODE_SHIFT |  154u << 3),
     XXLEQV_OPCODE  = (60u << OPCODE_SHIFT |  186u << 3),
 
@@ -2162,6 +2163,7 @@
   inline void mtvsrd(   VectorSRegister d, Register a);
   inline void mtvsrwz(  VectorSRegister d, Register a);
   inline void xxspltw(  VectorSRegister d, VectorSRegister b, int ui2);
+  inline void xxlor(    VectorSRegister d, VectorSRegister a, VectorSRegister b);
   inline void xxlxor(   VectorSRegister d, VectorSRegister a, VectorSRegister b);
   inline void xxleqv(   VectorSRegister d, VectorSRegister a, VectorSRegister b);
 
--- a/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -766,6 +766,7 @@
 inline void Assembler::mtvsrd(  VectorSRegister d, Register a)               { emit_int32( MTVSRD_OPCODE  | vsrt(d)  | ra(a)); }
 inline void Assembler::mtvsrwz( VectorSRegister d, Register a)               { emit_int32( MTVSRWZ_OPCODE | vsrt(d) | ra(a)); }
 inline void Assembler::xxspltw( VectorSRegister d, VectorSRegister b, int ui2)           { emit_int32( XXSPLTW_OPCODE | vsrt(d) | vsrb(b) | xxsplt_uim(uimm(ui2,2))); }
+inline void Assembler::xxlor(   VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XXLOR_OPCODE  | vsrt(d) | vsra(a) | vsrb(b)); }
 inline void Assembler::xxlxor(  VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XXLXOR_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
 inline void Assembler::xxleqv(  VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XXLEQV_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); }
 inline void Assembler::mtvrd(    VectorRegister d, Register a)               { emit_int32( MTVSRD_OPCODE  | vsrt(d->to_vsr()) | ra(a)); }
--- a/src/hotspot/cpu/ppc/ppc.ad	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/ppc/ppc.ad	Tue Jan 30 16:41:40 2018 +0100
@@ -1656,9 +1656,9 @@
 
 // =============================================================================
 
-// Figure out which register class each belongs in: rc_int, rc_float or
+// Figure out which register class each belongs in: rc_int, rc_float, rc_vs or
 // rc_stack.
-enum RC { rc_bad, rc_int, rc_float, rc_stack };
+enum RC { rc_bad, rc_int, rc_float, rc_vs, rc_stack };
 
 static enum RC rc_class(OptoReg::Name reg) {
   // Return the register class for the given register. The given register
@@ -1673,6 +1673,9 @@
   // We have 64 floating-point register halves, starting at index 64.
   if (reg < 64+64) return rc_float;
 
+  // We have 64 vector-scalar registers, starting at index 128.
+  if (reg < 64+64+64) return rc_vs;
+
   // Between float regs & stack are the flags regs.
   assert(OptoReg::is_stack(reg) || reg < 64+64+64, "blow up if spilling flags");
 
@@ -1735,6 +1738,58 @@
   if (src_lo == dst_lo && src_hi == dst_hi)
     return size;            // Self copy, no move.
 
+  if (bottom_type()->isa_vect() != NULL && ideal_reg() == Op_VecX) {
+    // Memory->Memory Spill.
+    if (src_lo_rc == rc_stack && dst_lo_rc == rc_stack) {
+      int src_offset = ra_->reg2offset(src_lo);
+      int dst_offset = ra_->reg2offset(dst_lo);
+      if (cbuf) {
+        MacroAssembler _masm(cbuf);
+        __ ld(R0, src_offset, R1_SP);
+        __ std(R0, dst_offset, R1_SP);
+        __ ld(R0, src_offset+8, R1_SP);
+        __ std(R0, dst_offset+8, R1_SP);
+      }
+      size += 16;
+    }
+    // VectorSRegister->Memory Spill.
+    else if (src_lo_rc == rc_vs && dst_lo_rc == rc_stack) {
+      VectorSRegister Rsrc = as_VectorSRegister(Matcher::_regEncode[src_lo]);
+      int dst_offset = ra_->reg2offset(dst_lo);
+      if (cbuf) {
+        MacroAssembler _masm(cbuf);
+        __ addi(R0, R1_SP, dst_offset);
+        __ stxvd2x(Rsrc, R0);
+      }
+      size += 8;
+    }
+    // Memory->VectorSRegister Spill.
+    else if (src_lo_rc == rc_stack && dst_lo_rc == rc_vs) {
+      VectorSRegister Rdst = as_VectorSRegister(Matcher::_regEncode[dst_lo]);
+      int src_offset = ra_->reg2offset(src_lo);
+      if (cbuf) {
+        MacroAssembler _masm(cbuf);
+        __ addi(R0, R1_SP, src_offset);
+        __ lxvd2x(Rdst, R0);
+      }
+      size += 8;
+    }
+    // VectorSRegister->VectorSRegister.
+    else if (src_lo_rc == rc_vs && dst_lo_rc == rc_vs) {
+      VectorSRegister Rsrc = as_VectorSRegister(Matcher::_regEncode[src_lo]);
+      VectorSRegister Rdst = as_VectorSRegister(Matcher::_regEncode[dst_lo]);
+      if (cbuf) {
+        MacroAssembler _masm(cbuf);
+        __ xxlor(Rdst, Rsrc, Rsrc);
+      }
+      size += 4;
+    }
+    else {
+      ShouldNotReachHere(); // No VSR spill.
+    }
+    return size;
+  }
+
   // --------------------------------------
   // Memory->Memory Spill. Use R0 to hold the value.
   if (src_lo_rc == rc_stack && dst_lo_rc == rc_stack) {
@@ -3524,7 +3579,7 @@
     assert(loadConLNodes._last->bottom_type()->isa_long(), "must be long");
   %}
 
-  enc_class postalloc_expand_load_replF_constant_vsx(vecX dst, immF src, iRegLdst toc) %{
+  enc_class postalloc_expand_load_replF_constant_vsx(vecX dst, immF src, iRegLdst toc, iRegLdst tmp) %{
     // Create new nodes.
 
     // Make an operand with the bit pattern to load as float.
@@ -3533,8 +3588,8 @@
 
     loadConLReplicatedNodesTuple loadConLNodes =
       loadConLReplicatedNodesTuple_create(C, ra_, n_toc, op_repl, op_dst, op_zero,
-                                OptoReg::Name(R20_H_num), OptoReg::Name(R20_num),
-                                OptoReg::Name(VSR11_num), OptoReg::Name(VSR10_num));
+                                ra_->get_reg_second(n_tmp), ra_->get_reg_first(n_tmp),
+                                ra_->get_reg_second(this), ra_->get_reg_first(this));
 
     // Push new nodes.
     if (loadConLNodes._large_hi) { nodes->push(loadConLNodes._large_hi); }
@@ -14013,12 +14068,13 @@
   %}
 %}
 
-instruct repl4F_immF_Ex(vecX dst, immF src) %{
+instruct repl4F_immF_Ex(vecX dst, immF src, iRegLdst tmp) %{
   match(Set dst (ReplicateF src));
   predicate(n->as_Vector()->length() == 4);
+  effect(TEMP tmp);
   ins_cost(10 * DEFAULT_COST);
 
-  postalloc_expand( postalloc_expand_load_replF_constant_vsx(dst, src, constanttablebase) );
+  postalloc_expand( postalloc_expand_load_replF_constant_vsx(dst, src, constanttablebase, tmp) );
 %}
 
 instruct repl4F_immF0(vecX dst, immF_0 zero) %{
--- a/src/hotspot/cpu/ppc/vm_version_ppc.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/ppc/vm_version_ppc.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -109,8 +109,7 @@
 
   if (PowerArchitecturePPC64 >= 8) {
     if (FLAG_IS_DEFAULT(SuperwordUseVSX)) {
-      // TODO: Switch on when it works stable. Currently, MachSpillCopyNode::implementation code is missing.
-      //FLAG_SET_ERGO(bool, SuperwordUseVSX, true);
+      FLAG_SET_ERGO(bool, SuperwordUseVSX, true);
     }
   } else {
     if (SuperwordUseVSX) {
--- a/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -991,8 +991,8 @@
   int offset = -1;
 
   switch (c->type()) {
+    case T_FLOAT: type = T_INT; // Float constants are stored by int store instructions.
     case T_INT:
-    case T_FLOAT:
     case T_ADDRESS: {
       LIR_Opr tmp = FrameMap::O7_opr;
       int value = c->as_jint_bits();
@@ -1202,6 +1202,7 @@
       __ stw(tmp, to.base(), to.disp());
       break;
     }
+    case T_ADDRESS:
     case T_OBJECT: {
       Register tmp = O7;
       Address from = frame_map()->address_for_slot(src->single_stack_ix());
@@ -1355,7 +1356,6 @@
   }
 }
 
-
 void LIR_Assembler::reg2mem(LIR_Opr from_reg, LIR_Opr dest, BasicType type,
                             LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack,
                             bool wide, bool unaligned) {
@@ -2265,10 +2265,10 @@
          op->obj()->as_register()   == O0 &&
          op->klass()->as_register() == G5, "must be");
   if (op->init_check()) {
+    add_debug_info_for_null_check_here(op->stub()->info());
     __ ldub(op->klass()->as_register(),
           in_bytes(InstanceKlass::init_state_offset()),
           op->tmp1()->as_register());
-    add_debug_info_for_null_check_here(op->stub()->info());
     __ cmp(op->tmp1()->as_register(), InstanceKlass::fully_initialized);
     __ br(Assembler::notEqual, false, Assembler::pn, *op->stub()->entry());
     __ delayed()->nop();
--- a/src/hotspot/cpu/sparc/c1_globals_sparc.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/sparc/c1_globals_sparc.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -32,32 +32,32 @@
 // (see c1_globals.hpp)
 
 #ifndef TIERED
-define_pd_global(bool, BackgroundCompilation,        true );
-define_pd_global(bool, CICompileOSR,                 true );
-define_pd_global(bool, InlineIntrinsics,             true );
-define_pd_global(bool, PreferInterpreterNativeStubs, false);
-define_pd_global(bool, ProfileTraps,                 false);
-define_pd_global(bool, UseOnStackReplacement,        true );
-define_pd_global(bool, TieredCompilation,            false);
-define_pd_global(intx, CompileThreshold,             1000 ); // Design center runs on 1.3.1
+define_pd_global(bool,  BackgroundCompilation,        true );
+define_pd_global(bool,  CICompileOSR,                 true );
+define_pd_global(bool,  InlineIntrinsics,             true );
+define_pd_global(bool,  PreferInterpreterNativeStubs, false);
+define_pd_global(bool,  ProfileTraps,                 false);
+define_pd_global(bool,  UseOnStackReplacement,        true );
+define_pd_global(bool,  TieredCompilation,            false);
+define_pd_global(intx,  CompileThreshold,             1000 ); // Design center runs on 1.3.1
 
-define_pd_global(intx, OnStackReplacePercentage,     1400 );
-define_pd_global(bool, UseTLAB,                      true );
-define_pd_global(bool, ProfileInterpreter,           false);
-define_pd_global(intx, FreqInlineSize,               325  );
-define_pd_global(bool, ResizeTLAB,                   true );
-define_pd_global(intx, ReservedCodeCacheSize,        32*M );
-define_pd_global(intx, NonProfiledCodeHeapSize,      13*M );
-define_pd_global(intx, ProfiledCodeHeapSize,         14*M );
-define_pd_global(intx, NonNMethodCodeHeapSize,       5*M  );
-define_pd_global(intx, CodeCacheExpansionSize,       32*K );
-define_pd_global(uintx, CodeCacheMinBlockLength,     1);
-define_pd_global(uintx, CodeCacheMinimumUseSpace,    400*K);
-define_pd_global(size_t, MetaspaceSize,              12*M );
-define_pd_global(bool, NeverActAsServerClassMachine, true );
-define_pd_global(size_t, NewSizeThreadIncrease,      16*K );
-define_pd_global(uint64_t, MaxRAM,                   1ULL*G);
-define_pd_global(intx, InitialCodeCacheSize,         160*K);
+define_pd_global(intx,  OnStackReplacePercentage,     1400 );
+define_pd_global(bool,  UseTLAB,                      true );
+define_pd_global(bool,  ProfileInterpreter,           false);
+define_pd_global(intx,  FreqInlineSize,               325  );
+define_pd_global(bool,  ResizeTLAB,                   true );
+define_pd_global(uintx, ReservedCodeCacheSize,        32*M );
+define_pd_global(uintx, NonProfiledCodeHeapSize,      13*M );
+define_pd_global(uintx, ProfiledCodeHeapSize,         14*M );
+define_pd_global(uintx, NonNMethodCodeHeapSize,       5*M  );
+define_pd_global(uintx, CodeCacheExpansionSize,       32*K );
+define_pd_global(uintx, CodeCacheMinBlockLength,      1);
+define_pd_global(uintx, CodeCacheMinimumUseSpace,     400*K);
+define_pd_global(size_t, MetaspaceSize,               12*M );
+define_pd_global(bool,  NeverActAsServerClassMachine, true );
+define_pd_global(size_t, NewSizeThreadIncrease,       16*K );
+define_pd_global(uint64_t, MaxRAM,                    1ULL*G);
+define_pd_global(uintx, InitialCodeCacheSize,         160*K);
 #endif // !TIERED
 
 define_pd_global(bool, UseTypeProfile,               false);
--- a/src/hotspot/cpu/sparc/c2_globals_sparc.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/sparc/c2_globals_sparc.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -71,12 +71,12 @@
 // sequence of instructions to load a 64 bit pointer.
 //
 // InitialCodeCacheSize derived from specjbb2000 run.
-define_pd_global(intx, InitialCodeCacheSize,         2048*K); // Integral multiple of CodeCacheExpansionSize
-define_pd_global(intx, ReservedCodeCacheSize,        48*M);
-define_pd_global(intx, NonProfiledCodeHeapSize,      21*M);
-define_pd_global(intx, ProfiledCodeHeapSize,         22*M);
-define_pd_global(intx, NonNMethodCodeHeapSize,       5*M );
-define_pd_global(intx, CodeCacheExpansionSize,       64*K);
+define_pd_global(uintx, InitialCodeCacheSize,        2048*K); // Integral multiple of CodeCacheExpansionSize
+define_pd_global(uintx, ReservedCodeCacheSize,       48*M);
+define_pd_global(uintx, NonProfiledCodeHeapSize,     21*M);
+define_pd_global(uintx, ProfiledCodeHeapSize,        22*M);
+define_pd_global(uintx, NonNMethodCodeHeapSize,      5*M );
+define_pd_global(uintx, CodeCacheExpansionSize,      64*K);
 
 // Ergonomics related flags
 define_pd_global(uint64_t,MaxRAM,                    128ULL*G);
--- a/src/hotspot/cpu/sparc/compiledIC_sparc.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/sparc/compiledIC_sparc.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, 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
@@ -107,8 +107,8 @@
 
 #ifdef ASSERT
   // read the value once
-  intptr_t data = method_holder->data();
-  address destination = jump->jump_destination();
+  volatile intptr_t data = method_holder->data();
+  volatile address destination = jump->jump_destination();
   assert(data == 0 || data == (intptr_t)callee(),
          "a) MT-unsafe modification of inline cache");
   assert(destination == (address)-1 || destination == entry,
--- a/src/hotspot/cpu/sparc/stubGenerator_sparc.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/sparc/stubGenerator_sparc.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -837,6 +837,20 @@
       case BarrierSet::G1SATBCTLogging:
         // With G1, don't generate the call if we statically know that the target in uninitialized
         if (!dest_uninitialized) {
+          Register tmp = O5;
+          assert_different_registers(addr, count, tmp);
+          Label filtered;
+          // Is marking active?
+          if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
+            __ ld(G2, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), tmp);
+          } else {
+            guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1,
+                      "Assumption");
+            __ ldsb(G2, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), tmp);
+          }
+          // Is marking active?
+          __ cmp_and_br_short(tmp, G0, Assembler::equal, Assembler::pt, filtered);
+
           __ save_frame(0);
           // Save the necessary global regs... will be used after.
           if (addr->is_global()) {
@@ -856,6 +870,9 @@
             __ mov(L1, count);
           }
           __ restore();
+
+          __ bind(filtered);
+          DEBUG_ONLY(__ set(0xDEADC0DE, tmp);) // we have killed tmp
         }
         break;
       case BarrierSet::CardTableForRS:
--- a/src/hotspot/cpu/x86/assembler_x86.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/assembler_x86.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1510,11 +1510,11 @@
 }
 
 void Assembler::call_literal(address entry, RelocationHolder const& rspec) {
-  assert(entry != NULL, "call most probably wrong");
   InstructionMark im(this);
   emit_int8((unsigned char)0xE8);
   intptr_t disp = entry - (pc() + sizeof(int32_t));
-  assert(is_simm32(disp), "must be 32bit offset (call2)");
+  // Entry is NULL in case of a scratch emit.
+  assert(entry == NULL || is_simm32(disp), "disp=" INTPTR_FORMAT " must be 32bit offset (call2)", disp);
   // Technically, should use call32_operand, but this format is
   // implied by the fact that we're emitting a call instruction.
 
--- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -1543,10 +1543,10 @@
 
 void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
   if (op->init_check()) {
+    add_debug_info_for_null_check_here(op->stub()->info());
     __ cmpb(Address(op->klass()->as_register(),
                     InstanceKlass::init_state_offset()),
                     InstanceKlass::fully_initialized);
-    add_debug_info_for_null_check_here(op->stub()->info());
     __ jcc(Assembler::notEqual, *op->stub()->entry());
   }
   __ allocate_object(op->obj()->as_register(),
@@ -2580,7 +2580,9 @@
     move_regs(lreg, rax);
 
     int idivl_offset = __ corrected_idivl(rreg);
-    add_debug_info_for_div0(idivl_offset, info);
+    if (ImplicitDiv0Checks) {
+      add_debug_info_for_div0(idivl_offset, info);
+    }
     if (code == lir_irem) {
       move_regs(rdx, dreg); // result is in rdx
     } else {
--- a/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -572,6 +572,8 @@
     if (!ImplicitDiv0Checks) {
       __ cmp(lir_cond_equal, right.result(), LIR_OprFact::intConst(0));
       __ branch(lir_cond_equal, T_INT, new DivByZeroStub(info));
+      // Idiv/irem cannot trap (passing info would generate an assertion).
+      info = NULL;
     }
     LIR_Opr tmp = FrameMap::rdx_opr; // idiv and irem use rdx in their implementation
     if (x->op() == Bytecodes::_irem) {
--- a/src/hotspot/cpu/x86/c1_globals_x86.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/c1_globals_x86.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -45,15 +45,15 @@
 define_pd_global(intx,   OnStackReplacePercentage,     933  );
 define_pd_global(intx,   FreqInlineSize,               325  );
 define_pd_global(size_t, NewSizeThreadIncrease,        4*K  );
-define_pd_global(intx, InitialCodeCacheSize,           160*K);
-define_pd_global(intx, ReservedCodeCacheSize,          32*M );
-define_pd_global(intx, NonProfiledCodeHeapSize,        13*M );
-define_pd_global(intx, ProfiledCodeHeapSize,           14*M );
-define_pd_global(intx, NonNMethodCodeHeapSize,         5*M  );
+define_pd_global(uintx,  InitialCodeCacheSize,         160*K);
+define_pd_global(uintx,  ReservedCodeCacheSize,        32*M );
+define_pd_global(uintx,  NonProfiledCodeHeapSize,      13*M );
+define_pd_global(uintx,  ProfiledCodeHeapSize,         14*M );
+define_pd_global(uintx,  NonNMethodCodeHeapSize,       5*M  );
 define_pd_global(bool,   ProfileInterpreter,           false);
-define_pd_global(intx, CodeCacheExpansionSize,         32*K );
-define_pd_global(uintx, CodeCacheMinBlockLength,       1    );
-define_pd_global(uintx, CodeCacheMinimumUseSpace,      400*K);
+define_pd_global(uintx,  CodeCacheExpansionSize,       32*K );
+define_pd_global(uintx,  CodeCacheMinBlockLength,      1    );
+define_pd_global(uintx,  CodeCacheMinimumUseSpace,     400*K);
 define_pd_global(size_t, MetaspaceSize,                12*M );
 define_pd_global(bool,   NeverActAsServerClassMachine, true );
 define_pd_global(uint64_t, MaxRAM,                    1ULL*G);
--- a/src/hotspot/cpu/x86/c2_globals_x86.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/c2_globals_x86.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -48,26 +48,26 @@
 define_pd_global(intx, MinJumpTableSize,             10);
 define_pd_global(intx, LoopPercentProfileLimit,      30);
 #ifdef AMD64
-define_pd_global(intx, INTPRESSURE,                  13);
-define_pd_global(intx, FLOATPRESSURE,                14);
-define_pd_global(intx, InteriorEntryAlignment,       16);
-define_pd_global(size_t, NewSizeThreadIncrease,      ScaleForWordSize(4*K));
-define_pd_global(intx, LoopUnrollLimit,              60);
+define_pd_global(intx,  INTPRESSURE,                 13);
+define_pd_global(intx,  FLOATPRESSURE,               14);
+define_pd_global(intx,  InteriorEntryAlignment,      16);
+define_pd_global(size_t, NewSizeThreadIncrease,     ScaleForWordSize(4*K));
+define_pd_global(intx,  LoopUnrollLimit,             60);
 // InitialCodeCacheSize derived from specjbb2000 run.
-define_pd_global(intx, InitialCodeCacheSize,         2496*K); // Integral multiple of CodeCacheExpansionSize
-define_pd_global(intx, CodeCacheExpansionSize,       64*K);
+define_pd_global(uintx, InitialCodeCacheSize,        2496*K); // Integral multiple of CodeCacheExpansionSize
+define_pd_global(uintx, CodeCacheExpansionSize,      64*K);
 
 // Ergonomics related flags
 define_pd_global(uint64_t, MaxRAM,                   128ULL*G);
 #else
-define_pd_global(intx, INTPRESSURE,                  6);
-define_pd_global(intx, FLOATPRESSURE,                6);
-define_pd_global(intx, InteriorEntryAlignment,       4);
+define_pd_global(intx,  INTPRESSURE,                 6);
+define_pd_global(intx,  FLOATPRESSURE,               6);
+define_pd_global(intx,  InteriorEntryAlignment,      4);
 define_pd_global(size_t, NewSizeThreadIncrease,      4*K);
-define_pd_global(intx, LoopUnrollLimit,              50);     // Design center runs on 1.3.1
+define_pd_global(intx,  LoopUnrollLimit,             50);     // Design center runs on 1.3.1
 // InitialCodeCacheSize derived from specjbb2000 run.
-define_pd_global(intx, InitialCodeCacheSize,         2304*K); // Integral multiple of CodeCacheExpansionSize
-define_pd_global(intx, CodeCacheExpansionSize,       32*K);
+define_pd_global(uintx, InitialCodeCacheSize,        2304*K); // Integral multiple of CodeCacheExpansionSize
+define_pd_global(uintx, CodeCacheExpansionSize,      32*K);
 
 // Ergonomics related flags
 define_pd_global(uint64_t, MaxRAM,                   4ULL*G);
@@ -84,10 +84,10 @@
 define_pd_global(bool, SuperWordLoopUnrollAnalysis,  true);
 define_pd_global(bool, IdealizeClearArrayNode,       true);
 
-define_pd_global(intx, ReservedCodeCacheSize,        48*M);
-define_pd_global(intx, NonProfiledCodeHeapSize,      21*M);
-define_pd_global(intx, ProfiledCodeHeapSize,         22*M);
-define_pd_global(intx, NonNMethodCodeHeapSize,       5*M );
+define_pd_global(uintx, ReservedCodeCacheSize,       48*M);
+define_pd_global(uintx, NonProfiledCodeHeapSize,     21*M);
+define_pd_global(uintx, ProfiledCodeHeapSize,        22*M);
+define_pd_global(uintx, NonNMethodCodeHeapSize,      5*M );
 define_pd_global(uintx, CodeCacheMinBlockLength,     4);
 define_pd_global(uintx, CodeCacheMinimumUseSpace,    400*K);
 
--- a/src/hotspot/cpu/x86/compiledIC_x86.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/compiledIC_x86.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, 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
@@ -160,8 +160,8 @@
 
 #ifdef ASSERT
   // read the value once
-  intptr_t data = method_holder->data();
-  address destination = jump->jump_destination();
+  volatile intptr_t data = method_holder->data();
+  volatile address destination = jump->jump_destination();
   assert(data == 0 || data == (intptr_t)callee(),
          "a) MT-unsafe modification of inline cache");
   assert(destination == (address)-1 || destination == entry,
--- a/src/hotspot/cpu/x86/methodHandles_x86.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/methodHandles_x86.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -589,7 +589,7 @@
 
 void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {
   if (!TraceMethodHandles)  return;
-  BLOCK_COMMENT("trace_method_handle {");
+  BLOCK_COMMENT(err_msg("trace_method_handle %s {", adaptername));
   __ enter();
   __ andptr(rsp, -16); // align stack if needed for FPU state
   __ pusha();
--- a/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -145,7 +145,7 @@
   // We assume caller has already has return address slot on the stack
   // We push epb twice in this sequence because we want the real rbp,
   // to be under the return like a normal enter and we want to use pusha
-  // We push by hand instead of pusing push
+  // We push by hand instead of using push.
   __ enter();
   __ pusha();
   __ pushf();
--- a/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, 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
@@ -679,10 +679,28 @@
       case BarrierSet::G1SATBCTLogging:
         // With G1, don't generate the call if we statically know that the target in uninitialized
         if (!uninitialized_target) {
+          Register thread = rax;
+          Label filtered;
+          __ push(thread);
+          __ get_thread(thread);
+          Address in_progress(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
+                                               SATBMarkQueue::byte_offset_of_active()));
+          // Is marking active?
+          if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
+            __ cmpl(in_progress, 0);
+          } else {
+            assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
+            __ cmpb(in_progress, 0);
+          }
+          __ pop(thread);
+          __ jcc(Assembler::equal, filtered);
+
            __ pusha();                      // push registers
            __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre),
                            start, count);
            __ popa();
+
+           __ bind(filtered);
          }
         break;
       case BarrierSet::CardTableForRS:
--- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -1201,6 +1201,18 @@
       case BarrierSet::G1SATBCTLogging:
         // With G1, don't generate the call if we statically know that the target in uninitialized
         if (!dest_uninitialized) {
+          Label filtered;
+          Address in_progress(r15_thread, in_bytes(JavaThread::satb_mark_queue_offset() +
+                                                   SATBMarkQueue::byte_offset_of_active()));
+          // Is marking active?
+          if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
+            __ cmpl(in_progress, 0);
+          } else {
+            assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
+            __ cmpb(in_progress, 0);
+          }
+          __ jcc(Assembler::equal, filtered);
+
            __ pusha();                      // push registers
            if (count == c_rarg0) {
              if (addr == c_rarg1) {
@@ -1216,6 +1228,8 @@
            }
            __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre), 2);
            __ popa();
+
+           __ bind(filtered);
         }
          break;
       case BarrierSet::CardTableForRS:
--- a/src/hotspot/cpu/x86/x86_32.ad	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/cpu/x86/x86_32.ad	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -27,7 +27,7 @@
 //----------REGISTER DEFINITION BLOCK------------------------------------------
 // This information is used by the matcher and the register allocator to
 // describe individual registers and classes of registers within the target
-// archtecture.
+// architecture.
 
 register %{
 //----------Architecture Description Register Definitions----------------------
--- a/src/hotspot/os/aix/os_aix.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/os/aix/os_aix.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -4244,48 +4244,6 @@
   return -1;
 }
 
-// is_headless_jre()
-//
-// Test for the existence of xawt/libmawt.so or libawt_xawt.so
-// in order to report if we are running in a headless jre.
-//
-// Since JDK8 xawt/libmawt.so is moved into the same directory
-// as libawt.so, and renamed libawt_xawt.so
-bool os::is_headless_jre() {
-  struct stat statbuf;
-  char buf[MAXPATHLEN];
-  char libmawtpath[MAXPATHLEN];
-  const char *xawtstr = "/xawt/libmawt.so";
-  const char *new_xawtstr = "/libawt_xawt.so";
-
-  char *p;
-
-  // Get path to libjvm.so
-  os::jvm_path(buf, sizeof(buf));
-
-  // Get rid of libjvm.so
-  p = strrchr(buf, '/');
-  if (p == NULL) return false;
-  else *p = '\0';
-
-  // Get rid of client or server
-  p = strrchr(buf, '/');
-  if (p == NULL) return false;
-  else *p = '\0';
-
-  // check xawt/libmawt.so
-  strcpy(libmawtpath, buf);
-  strcat(libmawtpath, xawtstr);
-  if (::stat(libmawtpath, &statbuf) == 0) return false;
-
-  // check libawt_xawt.so
-  strcpy(libmawtpath, buf);
-  strcat(libmawtpath, new_xawtstr);
-  if (::stat(libmawtpath, &statbuf) == 0) return false;
-
-  return true;
-}
-
 // Get the default path to the core file
 // Returns the length of the string
 int os::get_core_path(char* buffer, size_t bufferSize) {
--- a/src/hotspot/os/bsd/os_bsd.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/os/bsd/os_bsd.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -3894,59 +3894,6 @@
   }
 }
 
-// is_headless_jre()
-//
-// Test for the existence of xawt/libmawt.so or libawt_xawt.so
-// in order to report if we are running in a headless jre
-//
-// Since JDK8 xawt/libmawt.so was moved into the same directory
-// as libawt.so, and renamed libawt_xawt.so
-//
-bool os::is_headless_jre() {
-#ifdef __APPLE__
-  // We no longer build headless-only on Mac OS X
-  return false;
-#else
-  struct stat statbuf;
-  char buf[MAXPATHLEN];
-  char libmawtpath[MAXPATHLEN];
-  const char *xawtstr  = "/xawt/libmawt" JNI_LIB_SUFFIX;
-  const char *new_xawtstr = "/libawt_xawt" JNI_LIB_SUFFIX;
-  char *p;
-
-  // Get path to libjvm.so
-  os::jvm_path(buf, sizeof(buf));
-
-  // Get rid of libjvm.so
-  p = strrchr(buf, '/');
-  if (p == NULL) {
-    return false;
-  } else {
-    *p = '\0';
-  }
-
-  // Get rid of client or server
-  p = strrchr(buf, '/');
-  if (p == NULL) {
-    return false;
-  } else {
-    *p = '\0';
-  }
-
-  // check xawt/libmawt.so
-  strcpy(libmawtpath, buf);
-  strcat(libmawtpath, xawtstr);
-  if (::stat(libmawtpath, &statbuf) == 0) return false;
-
-  // check libawt_xawt.so
-  strcpy(libmawtpath, buf);
-  strcat(libmawtpath, new_xawtstr);
-  if (::stat(libmawtpath, &statbuf) == 0) return false;
-
-  return true;
-#endif
-}
-
 // Get the default path to the core file
 // Returns the length of the string
 int os::get_core_path(char* buffer, size_t bufferSize) {
--- a/src/hotspot/os/linux/os_linux.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/os/linux/os_linux.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -5690,54 +5690,6 @@
   }
 }
 
-// is_headless_jre()
-//
-// Test for the existence of xawt/libmawt.so or libawt_xawt.so
-// in order to report if we are running in a headless jre
-//
-// Since JDK8 xawt/libmawt.so was moved into the same directory
-// as libawt.so, and renamed libawt_xawt.so
-//
-bool os::is_headless_jre() {
-  struct stat statbuf;
-  char buf[MAXPATHLEN];
-  char libmawtpath[MAXPATHLEN];
-  const char *xawtstr  = "/xawt/libmawt.so";
-  const char *new_xawtstr = "/libawt_xawt.so";
-  char *p;
-
-  // Get path to libjvm.so
-  os::jvm_path(buf, sizeof(buf));
-
-  // Get rid of libjvm.so
-  p = strrchr(buf, '/');
-  if (p == NULL) {
-    return false;
-  } else {
-    *p = '\0';
-  }
-
-  // Get rid of client or server
-  p = strrchr(buf, '/');
-  if (p == NULL) {
-    return false;
-  } else {
-    *p = '\0';
-  }
-
-  // check xawt/libmawt.so
-  strcpy(libmawtpath, buf);
-  strcat(libmawtpath, xawtstr);
-  if (::stat(libmawtpath, &statbuf) == 0) return false;
-
-  // check libawt_xawt.so
-  strcpy(libmawtpath, buf);
-  strcat(libmawtpath, new_xawtstr);
-  if (::stat(libmawtpath, &statbuf) == 0) return false;
-
-  return true;
-}
-
 // Get the default path to the core file
 // Returns the length of the string
 int os::get_core_path(char* buffer, size_t bufferSize) {
--- a/src/hotspot/os/linux/perfMemory_linux.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/os/linux/perfMemory_linux.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -147,13 +147,26 @@
 // which is always a local file system and is sometimes a RAM based file
 // system.
 
+
 // return the user specific temporary directory name.
 //
+// If containerized process, get dirname of
+// /proc/{vmid}/root/tmp/{PERFDATA_NAME_user}
+// otherwise /tmp/{PERFDATA_NAME_user}
+//
 // the caller is expected to free the allocated memory.
 //
-static char* get_user_tmp_dir(const char* user) {
+#define TMP_BUFFER_LEN (4+22)
+static char* get_user_tmp_dir(const char* user, int vmid, int nspid) {
+  char buffer[TMP_BUFFER_LEN];
+  char* tmpdir = (char *)os::get_temp_directory();
+  assert(strlen(tmpdir) == 4, "No longer using /tmp - update buffer size");
 
-  const char* tmpdir = os::get_temp_directory();
+  if (nspid != -1) {
+    jio_snprintf(buffer, TMP_BUFFER_LEN, "/proc/%d/root%s", vmid, tmpdir);
+    tmpdir = buffer;
+  }
+
   const char* perfdir = PERFDATA_NAME;
   size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 3;
   char* dirname = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
@@ -502,7 +515,10 @@
 //
 // the caller is expected to free the allocated memory.
 //
-static char* get_user_name_slow(int vmid, TRAPS) {
+// If nspid != -1, look in /proc/{vmid}/root/tmp for directories
+// containing nspid, otherwise just look for vmid in /tmp
+//
+static char* get_user_name_slow(int vmid, int nspid, TRAPS) {
 
   // short circuit the directory search if the process doesn't even exist.
   if (kill(vmid, 0) == OS_ERR) {
@@ -518,8 +534,19 @@
   // directory search
   char* oldest_user = NULL;
   time_t oldest_ctime = 0;
+  char buffer[TMP_BUFFER_LEN];
+  int searchpid;
+  char* tmpdirname = (char *)os::get_temp_directory();
+  assert(strlen(tmpdirname) == 4, "No longer using /tmp - update buffer size");
 
-  const char* tmpdirname = os::get_temp_directory();
+  if (nspid == -1) {
+    searchpid = vmid;
+  }
+  else {
+    jio_snprintf(buffer, MAXPATHLEN, "/proc/%d/root%s", vmid, tmpdirname);
+    tmpdirname = buffer;
+    searchpid = nspid;
+  }
 
   // open the temp directory
   DIR* tmpdirp = os::opendir(tmpdirname);
@@ -530,7 +557,7 @@
   }
 
   // for each entry in the directory that matches the pattern hsperfdata_*,
-  // open the directory and check if the file for the given vmid exists.
+  // open the directory and check if the file for the given vmid or nspid exists.
   // The file with the expected name and the latest creation date is used
   // to determine the user name for the process id.
   //
@@ -575,7 +602,7 @@
     errno = 0;
     while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) {
 
-      if (filename_to_pid(udentry->d_name) == vmid) {
+      if (filename_to_pid(udentry->d_name) == searchpid) {
         struct stat statbuf;
         int result;
 
@@ -626,10 +653,51 @@
   return(oldest_user);
 }
 
+// Determine if the vmid is the parent pid
+// for a child in a PID namespace.
+// return the namespace pid if so, otherwise -1
+static int get_namespace_pid(int vmid) {
+  char fname[24];
+  int retpid = -1;
+
+  snprintf(fname, sizeof(fname), "/proc/%d/status", vmid);
+  FILE *fp = fopen(fname, "r");
+
+  if (fp) {
+    int pid, nspid;
+    int ret;
+    while (!feof(fp)) {
+      ret = fscanf(fp, "NSpid: %d %d", &pid, &nspid);
+      if (ret == 1) {
+        break;
+      }
+      if (ret == 2) {
+        retpid = nspid;
+        break;
+      }
+      for (;;) {
+        int ch = fgetc(fp);
+        if (ch == EOF || ch == (int)'\n') break;
+      }
+    }
+    fclose(fp);
+  }
+  return retpid;
+}
+
 // return the name of the user that owns the JVM indicated by the given vmid.
 //
-static char* get_user_name(int vmid, TRAPS) {
-  return get_user_name_slow(vmid, THREAD);
+static char* get_user_name(int vmid, int *nspid, TRAPS) {
+  char *result = get_user_name_slow(vmid, *nspid, THREAD);
+
+  // If we are examining a container process without PID namespaces enabled
+  // we need to use /proc/{pid}/root/tmp to find hsperfdata files.
+  if (result == NULL) {
+    result = get_user_name_slow(vmid, vmid, THREAD);
+    // Enable nspid logic going forward
+    if (result != NULL) *nspid = vmid;
+  }
+  return result;
 }
 
 // return the file name of the backing store file for the named
@@ -637,13 +705,15 @@
 //
 // the caller is expected to free the allocated memory.
 //
-static char* get_sharedmem_filename(const char* dirname, int vmid) {
+static char* get_sharedmem_filename(const char* dirname, int vmid, int nspid) {
+
+  int pid = (nspid == -1) ? vmid : nspid;
 
   // add 2 for the file separator and a null terminator.
   size_t nbytes = strlen(dirname) + UINT_CHARS + 2;
 
   char* name = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
-  snprintf(name, nbytes, "%s/%d", dirname, vmid);
+  snprintf(name, nbytes, "%s/%d", dirname, pid);
 
   return name;
 }
@@ -940,8 +1010,8 @@
   if (user_name == NULL)
     return NULL;
 
-  char* dirname = get_user_tmp_dir(user_name);
-  char* filename = get_sharedmem_filename(dirname, vmid);
+  char* dirname = get_user_tmp_dir(user_name, vmid, -1);
+  char* filename = get_sharedmem_filename(dirname, vmid, -1);
 
   // get the short filename
   char* short_filename = strrchr(filename, '/');
@@ -1088,8 +1158,11 @@
               "Illegal access mode");
   }
 
+  // determine if vmid is for a containerized process
+  int nspid = get_namespace_pid(vmid);
+
   if (user == NULL || strlen(user) == 0) {
-    luser = get_user_name(vmid, CHECK);
+    luser = get_user_name(vmid, &nspid, CHECK);
   }
   else {
     luser = user;
@@ -1100,7 +1173,7 @@
               "Could not map vmid to user Name");
   }
 
-  char* dirname = get_user_tmp_dir(luser);
+  char* dirname = get_user_tmp_dir(luser, vmid, nspid);
 
   // since we don't follow symbolic links when creating the backing
   // store file, we don't follow them when attaching either.
@@ -1114,7 +1187,7 @@
               "Process not found");
   }
 
-  char* filename = get_sharedmem_filename(dirname, vmid);
+  char* filename = get_sharedmem_filename(dirname, vmid, nspid);
 
   // copy heap memory to resource memory. the open_sharedmem_file
   // method below need to use the filename, but could throw an
--- a/src/hotspot/os/posix/vmError_posix.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/os/posix/vmError_posix.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -23,7 +23,7 @@
  */
 
 #include "precompiled.hpp"
-#include "memory/filemap.hpp"
+#include "memory/metaspaceShared.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/os.hpp"
 #include "runtime/thread.hpp"
@@ -153,8 +153,7 @@
     if (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) {
       const void* const fault_addr = si->si_addr;
       if (fault_addr != NULL) {
-        FileMapInfo* const mapinfo = FileMapInfo::current_info();
-        if (mapinfo->is_in_shared_space(fault_addr)) {
+        if (MetaspaceShared::is_in_shared_metaspace(fault_addr)) {
           st->print("Error accessing class data sharing archive. "
             "Mapped file inaccessible during execution, possible disk/network problem.");
         }
--- a/src/hotspot/os/solaris/os_solaris.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/os/solaris/os_solaris.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -5366,54 +5366,6 @@
   }
 }
 
-// is_headless_jre()
-//
-// Test for the existence of xawt/libmawt.so or libawt_xawt.so
-// in order to report if we are running in a headless jre
-//
-// Since JDK8 xawt/libmawt.so was moved into the same directory
-// as libawt.so, and renamed libawt_xawt.so
-//
-bool os::is_headless_jre() {
-  struct stat statbuf;
-  char buf[MAXPATHLEN];
-  char libmawtpath[MAXPATHLEN];
-  const char *xawtstr  = "/xawt/libmawt.so";
-  const char *new_xawtstr = "/libawt_xawt.so";
-  char *p;
-
-  // Get path to libjvm.so
-  os::jvm_path(buf, sizeof(buf));
-
-  // Get rid of libjvm.so
-  p = strrchr(buf, '/');
-  if (p == NULL) {
-    return false;
-  } else {
-    *p = '\0';
-  }
-
-  // Get rid of client or server
-  p = strrchr(buf, '/');
-  if (p == NULL) {
-    return false;
-  } else {
-    *p = '\0';
-  }
-
-  // check xawt/libmawt.so
-  strcpy(libmawtpath, buf);
-  strcat(libmawtpath, xawtstr);
-  if (::stat(libmawtpath, &statbuf) == 0) return false;
-
-  // check libawt_xawt.so
-  strcpy(libmawtpath, buf);
-  strcat(libmawtpath, new_xawtstr);
-  if (::stat(libmawtpath, &statbuf) == 0) return false;
-
-  return true;
-}
-
 size_t os::write(int fd, const void *buf, unsigned int nBytes) {
   size_t res;
   RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
--- a/src/hotspot/os/windows/os_windows.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/os/windows/os_windows.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -5262,9 +5262,6 @@
   return EXCEPTION_CONTINUE_SEARCH;
 }
 
-// We don't build a headless jre for Windows
-bool os::is_headless_jre() { return false; }
-
 static jint initSock() {
   WSADATA wsadata;
 
--- a/src/hotspot/os/windows/vmError_windows.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/os/windows/vmError_windows.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -23,7 +23,7 @@
  */
 
 #include "precompiled.hpp"
-#include "memory/filemap.hpp"
+#include "memory/metaspaceShared.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/os.hpp"
 #include "runtime/thread.hpp"
@@ -58,8 +58,7 @@
         er->NumberParameters >= 2) {
       const void* const fault_addr = (const void*) er->ExceptionInformation[1];
       if (fault_addr != NULL) {
-        FileMapInfo* const mapinfo = FileMapInfo::current_info();
-        if (mapinfo->is_in_shared_space(fault_addr)) {
+        if (MetaspaceShared::is_in_shared_metaspace(fault_addr)) {
           st->print("Error accessing class data sharing archive. "
             "Mapped file inaccessible during execution, possible disk/network problem.");
         }
--- a/src/hotspot/share/classfile/classLoaderData.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/classfile/classLoaderData.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
  /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -1292,7 +1292,7 @@
       // Remove entries in the dictionary of live class loader that have
       // initiated loading classes in a dead class loader.
       if (data->dictionary() != NULL) {
-        data->dictionary()->do_unloading();
+        data->dictionary()->do_unloading(is_alive_closure);
       }
       // Walk a ModuleEntry's reads, and a PackageEntry's exports
       // lists to determine if there are modules on those lists that are now
--- a/src/hotspot/share/classfile/dictionary.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/classfile/dictionary.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -167,7 +167,7 @@
     for (ProtectionDomainEntry* current = pd_set_acquire();
                                 current != NULL;
                                 current = current->next()) {
-      if (current->protection_domain() == protection_domain) {
+      if (current->object_no_keepalive() == protection_domain) {
         in_pd_set = true;
         break;
       }
@@ -187,7 +187,7 @@
   for (ProtectionDomainEntry* current = pd_set_acquire();
                               current != NULL;
                               current = current->next()) {
-    if (current->protection_domain() == protection_domain) return true;
+    if (current->object_no_keepalive() == protection_domain) return true;
   }
   return false;
 }
@@ -212,8 +212,44 @@
   }
 }
 
+// During class loading we may have cached a protection domain that has
+// since been unreferenced, so this entry should be cleared.
+void Dictionary::clean_cached_protection_domains(BoolObjectClosure* is_alive, DictionaryEntry* probe) {
+  assert_locked_or_safepoint(SystemDictionary_lock);
 
-void Dictionary::do_unloading() {
+  ProtectionDomainEntry* current = probe->pd_set();
+  ProtectionDomainEntry* prev = NULL;
+  while (current != NULL) {
+    if (!is_alive->do_object_b(current->object_no_keepalive())) {
+      LogTarget(Debug, protectiondomain) lt;
+      if (lt.is_enabled()) {
+        ResourceMark rm;
+        // Print out trace information
+        LogStream ls(lt);
+        ls.print_cr("PD in set is not alive:");
+        ls.print("class loader: "); loader_data()->class_loader()->print_value_on(&ls);
+        ls.print(" protection domain: "); current->object_no_keepalive()->print_value_on(&ls);
+        ls.print(" loading: "); probe->instance_klass()->print_value_on(&ls);
+        ls.cr();
+      }
+      if (probe->pd_set() == current) {
+        probe->set_pd_set(current->next());
+      } else {
+        assert(prev != NULL, "should be set by alive entry");
+        prev->set_next(current->next());
+      }
+      ProtectionDomainEntry* to_delete = current;
+      current = current->next();
+      delete to_delete;
+    } else {
+      prev = current;
+      current = current->next();
+    }
+  }
+}
+
+
+void Dictionary::do_unloading(BoolObjectClosure* is_alive) {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 
   // The NULL class loader doesn't initiate loading classes from other class loaders
@@ -239,6 +275,8 @@
         free_entry(probe);
         continue;
       }
+      // Clean pd_set
+      clean_cached_protection_domains(is_alive, probe);
       p = probe->next_addr();
     }
   }
@@ -412,6 +450,10 @@
 
   entry->add_protection_domain(this, protection_domain);
 
+#ifdef ASSERT
+  assert(loader_data() != ClassLoaderData::the_null_class_loader_data(), "doesn't make sense");
+#endif
+
   assert(entry->contains_protection_domain(protection_domain()),
          "now protection domain should be present");
 }
--- a/src/hotspot/share/classfile/dictionary.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/classfile/dictionary.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -53,6 +53,8 @@
 
   DictionaryEntry* get_entry(int index, unsigned int hash, Symbol* name);
 
+  void clean_cached_protection_domains(BoolObjectClosure* is_alive, DictionaryEntry* probe);
+
 protected:
   static size_t entry_size();
 public:
@@ -84,7 +86,7 @@
   void remove_classes_in_error_state();
 
   // Unload classes whose defining loaders are unloaded
-  void do_unloading();
+  void do_unloading(BoolObjectClosure* is_alive);
 
   // Protection domains
   InstanceKlass* find(unsigned int hash, Symbol* name, Handle protection_domain);
@@ -189,7 +191,7 @@
     for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint
                                 current != NULL;
                                 current = current->_next) {
-      current->_pd_cache->protection_domain()->verify();
+      current->_pd_cache->object_no_keepalive()->verify();
     }
   }
 
--- a/src/hotspot/share/classfile/javaClasses.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/classfile/javaClasses.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1702,7 +1702,7 @@
       method = mhandle();
     }
 
-    _methods->short_at_put(_index, method->orig_method_idnum());
+    _methods->ushort_at_put(_index, method->orig_method_idnum());
     _bcis->int_at_put(_index, Backtrace::merge_bci_and_version(bci, method->constants()->version()));
 
     // Note:this doesn't leak symbols because the mirror in the backtrace keeps the
@@ -1756,7 +1756,7 @@
 
   BacktraceElement next(Thread* thread) {
     BacktraceElement e (Handle(thread, _mirrors->obj_at(_index)),
-                        _methods->short_at(_index),
+                        _methods->ushort_at(_index),
                         Backtrace::version_at(_bcis->int_at(_index)),
                         Backtrace::bci_at(_bcis->int_at(_index)),
                         _names->symbol_at(_index));
--- a/src/hotspot/share/classfile/protectionDomainCache.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/classfile/protectionDomainCache.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -52,14 +52,14 @@
     ProtectionDomainCacheEntry** p = bucket_addr(i);
     ProtectionDomainCacheEntry* entry = bucket(i);
     while (entry != NULL) {
-      if (is_alive->do_object_b(entry->literal())) {
+      if (is_alive->do_object_b(entry->object_no_keepalive())) {
         p = entry->next_addr();
       } else {
         LogTarget(Debug, protectiondomain) lt;
         if (lt.is_enabled()) {
           LogStream ls(lt);
           ls.print("protection domain unlinked: ");
-          entry->literal()->print_value_on(&ls);
+          entry->object_no_keepalive()->print_value_on(&ls);
           ls.cr();
         }
         *p = entry->next();
@@ -87,7 +87,7 @@
     for (ProtectionDomainCacheEntry* probe = bucket(index);
                                      probe != NULL;
                                      probe = probe->next()) {
-      st->print_cr("%4d: protection_domain: " PTR_FORMAT, index, p2i(probe->literal()));
+      st->print_cr("%4d: protection_domain: " PTR_FORMAT, index, p2i(probe->object_no_keepalive()));
     }
   }
 }
@@ -96,8 +96,27 @@
   verify_table<ProtectionDomainCacheEntry>("Protection Domain Table");
 }
 
+oop ProtectionDomainCacheEntry::object() {
+  return RootAccess<ON_PHANTOM_OOP_REF>::oop_load(literal_addr());
+}
+
+oop ProtectionDomainEntry::object() {
+  return _pd_cache->object();
+}
+
+// The object_no_keepalive() call peeks at the phantomly reachable oop without
+// keeping it alive. This is okay to do in the VM thread state if it is not
+// leaked out to become strongly reachable.
+oop ProtectionDomainCacheEntry::object_no_keepalive() {
+  return RootAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(literal_addr());
+}
+
+oop ProtectionDomainEntry::object_no_keepalive() {
+  return _pd_cache->object_no_keepalive();
+}
+
 void ProtectionDomainCacheEntry::verify() {
-  guarantee(oopDesc::is_oop(literal()), "must be an oop");
+  guarantee(oopDesc::is_oop(object_no_keepalive()), "must be an oop");
 }
 
 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::get(Handle protection_domain) {
@@ -113,7 +132,7 @@
 
 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::find_entry(int index, Handle protection_domain) {
   for (ProtectionDomainCacheEntry* e = bucket(index); e != NULL; e = e->next()) {
-    if (e->protection_domain() == protection_domain()) {
+    if (e->object_no_keepalive() == protection_domain()) {
       return e;
     }
   }
--- a/src/hotspot/share/classfile/protectionDomainCache.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/classfile/protectionDomainCache.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -37,7 +37,8 @@
 class ProtectionDomainCacheEntry : public HashtableEntry<oop, mtClass> {
   friend class VMStructs;
  public:
-  oop protection_domain() { return literal(); }
+  oop object();
+  oop object_no_keepalive();
 
   ProtectionDomainCacheEntry* next() {
     return (ProtectionDomainCacheEntry*)HashtableEntry<oop, mtClass>::next();
@@ -112,6 +113,8 @@
   }
 
   ProtectionDomainEntry* next() { return _next; }
-  oop protection_domain() { return _pd_cache->protection_domain(); }
+  void set_next(ProtectionDomainEntry* entry) { _next = entry; }
+  oop object();
+  oop object_no_keepalive();
 };
 #endif // SHARE_VM_CLASSFILE_PROTECTIONDOMAINCACHE_HPP
--- a/src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -54,7 +54,7 @@
   // pre-marking object graph.
   static void enqueue(oop pre_val);
 
-  static void enqueue_if_weak(DecoratorSet decorators, oop value);
+  static void enqueue_if_weak_or_archive(DecoratorSet decorators, oop value);
 
   template <class T> void write_ref_array_pre_work(T* dst, int count);
   virtual void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized);
--- a/src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/gc/g1/g1SATBCardTableModRefBS.inline.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -60,12 +60,17 @@
   _byte_map[card_index] = val;
 }
 
-inline void G1SATBCardTableModRefBS::enqueue_if_weak(DecoratorSet decorators, oop value) {
+inline void G1SATBCardTableModRefBS::enqueue_if_weak_or_archive(DecoratorSet decorators, oop value) {
   assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
+  // Archive roots need to be enqueued since they add subgraphs to the
+  // Java heap that were not there at the snapshot when marking started.
+  // Weak and phantom references also need enqueueing for similar reasons.
+  const bool in_archive_root   = (decorators & IN_ARCHIVE_ROOT) != 0;
   const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;
   const bool peek              = (decorators & AS_NO_KEEPALIVE) != 0;
+  const bool needs_enqueue     = in_archive_root || (!peek && !on_strong_oop_ref);
 
-  if (!peek && !on_strong_oop_ref && value != NULL) {
+  if (needs_enqueue && value != NULL) {
     enqueue(value);
   }
 }
@@ -75,7 +80,7 @@
 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
 oop_load_not_in_heap(T* addr) {
   oop value = ModRef::oop_load_not_in_heap(addr);
-  enqueue_if_weak(decorators, value);
+  enqueue_if_weak_or_archive(decorators, value);
   return value;
 }
 
@@ -84,7 +89,7 @@
 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
 oop_load_in_heap(T* addr) {
   oop value = ModRef::oop_load_in_heap(addr);
-  enqueue_if_weak(decorators, value);
+  enqueue_if_weak_or_archive(decorators, value);
   return value;
 }
 
@@ -92,7 +97,7 @@
 inline oop G1SATBCardTableLoggingModRefBS::AccessBarrier<decorators, BarrierSetT>::
 oop_load_in_heap_at(oop base, ptrdiff_t offset) {
   oop value = ModRef::oop_load_in_heap_at(base, offset);
-  enqueue_if_weak(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);
+  enqueue_if_weak_or_archive(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);
   return value;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/oopStorage.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,709 @@
+/*
+ * 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/shared/oopStorage.inline.hpp"
+#include "gc/shared/oopStorageParState.inline.hpp"
+#include "logging/log.hpp"
+#include "memory/allocation.inline.hpp"
+#include "runtime/atomic.hpp"
+#include "runtime/handles.inline.hpp"
+#include "runtime/mutex.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/orderAccess.inline.hpp"
+#include "runtime/safepoint.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "utilities/align.hpp"
+#include "utilities/count_trailing_zeros.hpp"
+#include "utilities/debug.hpp"
+#include "utilities/globalDefinitions.hpp"
+#include "utilities/macros.hpp"
+#include "utilities/ostream.hpp"
+
+OopStorage::BlockEntry::BlockEntry() : _prev(NULL), _next(NULL) {}
+
+OopStorage::BlockEntry::~BlockEntry() {
+  assert(_prev == NULL, "deleting attached block");
+  assert(_next == NULL, "deleting attached block");
+}
+
+OopStorage::BlockList::BlockList(const BlockEntry& (*get_entry)(const Block& block)) :
+  _head(NULL), _tail(NULL), _get_entry(get_entry)
+{}
+
+OopStorage::BlockList::~BlockList() {
+  // ~OopStorage() empties its lists before destroying them.
+  assert(_head == NULL, "deleting non-empty block list");
+  assert(_tail == NULL, "deleting non-empty block list");
+}
+
+void OopStorage::BlockList::push_front(const Block& block) {
+  const Block* old = _head;
+  if (old == NULL) {
+    assert(_tail == NULL, "invariant");
+    _head = _tail = &block;
+  } else {
+    _get_entry(block)._next = old;
+    _get_entry(*old)._prev = &block;
+    _head = &block;
+  }
+}
+
+void OopStorage::BlockList::push_back(const Block& block) {
+  const Block* old = _tail;
+  if (old == NULL) {
+    assert(_head == NULL, "invariant");
+    _head = _tail = &block;
+  } else {
+    _get_entry(*old)._next = &block;
+    _get_entry(block)._prev = old;
+    _tail = &block;
+  }
+}
+
+void OopStorage::BlockList::unlink(const Block& block) {
+  const BlockEntry& block_entry = _get_entry(block);
+  const Block* prev_blk = block_entry._prev;
+  const Block* next_blk = block_entry._next;
+  block_entry._prev = NULL;
+  block_entry._next = NULL;
+  if ((prev_blk == NULL) && (next_blk == NULL)) {
+    assert(_head == &block, "invariant");
+    assert(_tail == &block, "invariant");
+    _head = _tail = NULL;
+  } else if (prev_blk == NULL) {
+    assert(_head == &block, "invariant");
+    _get_entry(*next_blk)._prev = NULL;
+    _head = next_blk;
+  } else if (next_blk == NULL) {
+    assert(_tail == &block, "invariant");
+    _get_entry(*prev_blk)._next = NULL;
+    _tail = prev_blk;
+  } else {
+    _get_entry(*next_blk)._prev = prev_blk;
+    _get_entry(*prev_blk)._next = next_blk;
+  }
+}
+
+// Blocks start with an array of BitsPerWord oop entries.  That array
+// is divided into conceptual BytesPerWord sections of BitsPerWord
+// entries.  Blocks are allocated aligned on section boundaries, for
+// the convenience of mapping from an entry to the containing block;
+// see block_for_ptr().  Aligning on section boundary rather than on
+// the full _data wastes a lot less space, but makes for a bit more
+// work in block_for_ptr().
+
+const unsigned section_size = BitsPerByte;
+const unsigned section_count = BytesPerWord;
+const unsigned block_alignment = sizeof(oop) * section_size;
+
+// VS2013 warns (C4351) that elements of _data will be *correctly* default
+// initialized, unlike earlier versions that *incorrectly* did not do so.
+#ifdef _WINDOWS
+#pragma warning(push)
+#pragma warning(disable: 4351)
+#endif // _WINDOWS
+OopStorage::Block::Block(const OopStorage* owner, void* memory) :
+  _data(),
+  _allocated_bitmask(0),
+  _owner(owner),
+  _memory(memory),
+  _active_entry(),
+  _allocate_entry()
+{
+  STATIC_ASSERT(_data_pos == 0);
+  STATIC_ASSERT(section_size * section_count == ARRAY_SIZE(_data));
+  assert(offset_of(Block, _data) == _data_pos, "invariant");
+  assert(owner != NULL, "NULL owner");
+  assert(is_aligned(this, block_alignment), "misaligned block");
+}
+#ifdef _WINDOWS
+#pragma warning(pop)
+#endif
+
+OopStorage::Block::~Block() {
+  // Clear fields used by block_for_ptr and entry validation, which
+  // might help catch bugs.  Volatile to prevent dead-store elimination.
+  const_cast<uintx volatile&>(_allocated_bitmask) = 0;
+  const_cast<OopStorage* volatile&>(_owner) = NULL;
+}
+
+const OopStorage::BlockEntry& OopStorage::Block::get_active_entry(const Block& block) {
+  return block._active_entry;
+}
+
+const OopStorage::BlockEntry& OopStorage::Block::get_allocate_entry(const Block& block) {
+  return block._allocate_entry;
+}
+
+size_t OopStorage::Block::allocation_size() {
+  // _data must be first member, so aligning Block aligns _data.
+  STATIC_ASSERT(_data_pos == 0);
+  return sizeof(Block) + block_alignment - sizeof(void*);
+}
+
+size_t OopStorage::Block::allocation_alignment_shift() {
+  return exact_log2(block_alignment);
+}
+
+inline bool is_full_bitmask(uintx bitmask) { return ~bitmask == 0; }
+inline bool is_empty_bitmask(uintx bitmask) { return bitmask == 0; }
+
+bool OopStorage::Block::is_full() const {
+  return is_full_bitmask(allocated_bitmask());
+}
+
+bool OopStorage::Block::is_empty() const {
+  return is_empty_bitmask(allocated_bitmask());
+}
+
+uintx OopStorage::Block::bitmask_for_entry(const oop* ptr) const {
+  return bitmask_for_index(get_index(ptr));
+}
+
+uintx OopStorage::Block::cmpxchg_allocated_bitmask(uintx new_value, uintx compare_value) {
+  return Atomic::cmpxchg(new_value, &_allocated_bitmask, compare_value);
+}
+
+bool OopStorage::Block::contains(const oop* ptr) const {
+  const oop* base = get_pointer(0);
+  return (base <= ptr) && (ptr < (base + ARRAY_SIZE(_data)));
+}
+
+unsigned OopStorage::Block::get_index(const oop* ptr) const {
+  assert(contains(ptr), PTR_FORMAT " not in block " PTR_FORMAT, p2i(ptr), p2i(this));
+  return static_cast<unsigned>(ptr - get_pointer(0));
+}
+
+oop* OopStorage::Block::allocate() {
+  // Use CAS loop because release may change bitmask outside of lock.
+  uintx allocated = allocated_bitmask();
+  while (true) {
+    assert(!is_full_bitmask(allocated), "attempt to allocate from full block");
+    unsigned index = count_trailing_zeros(~allocated);
+    uintx new_value = allocated | bitmask_for_index(index);
+    uintx fetched = cmpxchg_allocated_bitmask(new_value, allocated);
+    if (fetched == allocated) {
+      return get_pointer(index); // CAS succeeded; return entry for index.
+    }
+    allocated = fetched;       // CAS failed; retry with latest value.
+  }
+}
+
+OopStorage::Block* OopStorage::Block::new_block(const OopStorage* owner) {
+  // _data must be first member: aligning block => aligning _data.
+  STATIC_ASSERT(_data_pos == 0);
+  size_t size_needed = allocation_size();
+  void* memory = NEW_C_HEAP_ARRAY_RETURN_NULL(char, size_needed, mtGC);
+  if (memory == NULL) {
+    return NULL;
+  }
+  void* block_mem = align_up(memory, block_alignment);
+  assert(sizeof(Block) + pointer_delta(block_mem, memory, 1) <= size_needed,
+         "allocated insufficient space for aligned block");
+  return ::new (block_mem) Block(owner, memory);
+}
+
+void OopStorage::Block::delete_block(const Block& block) {
+  void* memory = block._memory;
+  block.Block::~Block();
+  FREE_C_HEAP_ARRAY(char, memory);
+}
+
+// This can return a false positive if ptr is not contained by some
+// block.  For some uses, it is a precondition that ptr is valid,
+// e.g. contained in some block in owner's _active_list.  Other uses
+// require additional validation of the result.
+OopStorage::Block*
+OopStorage::Block::block_for_ptr(const OopStorage* owner, const oop* ptr) {
+  assert(CanUseSafeFetchN(), "precondition");
+  STATIC_ASSERT(_data_pos == 0);
+  // Const-ness of ptr is not related to const-ness of containing block.
+  // Blocks are allocated section-aligned, so get the containing section.
+  oop* section_start = align_down(const_cast<oop*>(ptr), block_alignment);
+  // Start with a guess that the containing section is the last section,
+  // so the block starts section_count-1 sections earlier.
+  oop* section = section_start - (section_size * (section_count - 1));
+  // Walk up through the potential block start positions, looking for
+  // the owner in the expected location.  If we're below the actual block
+  // start position, the value at the owner position will be some oop
+  // (possibly NULL), which can never match the owner.
+  intptr_t owner_addr = reinterpret_cast<intptr_t>(owner);
+  for (unsigned i = 0; i < section_count; ++i, section += section_size) {
+    Block* candidate = reinterpret_cast<Block*>(section);
+    intptr_t* candidate_owner_addr
+      = reinterpret_cast<intptr_t*>(&candidate->_owner);
+    if (SafeFetchN(candidate_owner_addr, 0) == owner_addr) {
+      return candidate;
+    }
+  }
+  return NULL;
+}
+
+bool OopStorage::is_valid_block_locked_or_safepoint(const Block* check_block) const {
+  assert_locked_or_safepoint(_allocate_mutex);
+  // For now, simple linear search.  Do something more clever if this
+  // is a performance bottleneck, particularly for allocation_status.
+  for (const Block* block = _active_list.chead();
+       block != NULL;
+       block = _active_list.next(*block)) {
+    if (check_block == block) {
+      return true;
+    }
+  }
+  return false;
+}
+
+#ifdef ASSERT
+void OopStorage::assert_at_safepoint() {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
+}
+#endif // ASSERT
+
+//////////////////////////////////////////////////////////////////////////////
+// Allocation
+//
+// Allocation involves the _allocate_list, which contains a subset of the
+// blocks owned by a storage object.  This is a doubly-linked list, linked
+// through dedicated fields in the blocks.  Full blocks are removed from this
+// list, though they are still present in the _active_list.  Empty blocks are
+// kept at the end of the _allocate_list, to make it easy for empty block
+// deletion to find them.
+//
+// allocate(), release(), and delete_empty_blocks_concurrent() all lock the
+// _allocate_mutex while performing any list modifications.
+//
+// allocate() and release() update a block's _allocated_bitmask using CAS
+// loops.  This prevents loss of updates even though release() may perform
+// some updates without any locking.
+//
+// allocate() obtains the entry from the first block in the _allocate_list,
+// and updates that block's _allocated_bitmask to indicate the entry is in
+// use.  If this makes the block full (all entries in use), the block is
+// removed from the _allocate_list so it won't be considered by future
+// allocations until some entries in it are relased.
+//
+// release() looks up the block for the entry without locking.  Once the block
+// has been determined, its _allocated_bitmask needs to be updated, and its
+// position in the _allocate_list may need to be updated.  There are two
+// cases:
+//
+// (a) If the block is neither full nor would become empty with the release of
+// the entry, only its _allocated_bitmask needs to be updated.  But if the CAS
+// update fails, the applicable case may change for the retry.
+//
+// (b) Otherwise, the _allocate_list will also need to be modified.  This
+// requires locking the _allocate_mutex, and then attempting to CAS the
+// _allocated_bitmask.  If the CAS fails, the applicable case may change for
+// the retry.  If the CAS succeeds, then update the _allocate_list according
+// to the the state changes.  If the block changed from full to not full, then
+// it needs to be added to the _allocate_list, for use in future allocations.
+// If the block changed from not empty to empty, then it is moved to the end
+// of the _allocate_list, for ease of empty block deletion processing.
+
+oop* OopStorage::allocate() {
+  MutexLockerEx ml(_allocate_mutex, Mutex::_no_safepoint_check_flag);
+  Block* block = _allocate_list.head();
+  if (block == NULL) {
+    // No available blocks; make a new one, and add to storage.
+    {
+      MutexUnlockerEx mul(_allocate_mutex, Mutex::_no_safepoint_check_flag);
+      block = Block::new_block(this);
+    }
+    if (block != NULL) {
+      // Add new block to storage.
+      log_info(oopstorage, blocks)("%s: new block " PTR_FORMAT, name(), p2i(block));
+
+      // Add to end of _allocate_list.  The mutex release allowed
+      // other threads to add blocks to the _allocate_list.  We prefer
+      // to allocate from non-empty blocks, to allow empty blocks to
+      // be deleted.
+      _allocate_list.push_back(*block);
+      ++_empty_block_count;
+      // Add to front of _active_list, and then record as the head
+      // block, for concurrent iteration protocol.
+      _active_list.push_front(*block);
+      ++_block_count;
+      // Ensure all setup of block is complete before making it visible.
+      OrderAccess::release_store(&_active_head, block);
+    } else {
+      log_info(oopstorage, blocks)("%s: failed new block allocation", name());
+    }
+    block = _allocate_list.head();
+    if (block == NULL) {
+      // Failed to make new block, and no other thread made a block
+      // available while the mutex was released, so return failure.
+      return NULL;
+    }
+  }
+  // Allocate from first block.
+  assert(block != NULL, "invariant");
+  assert(!block->is_full(), "invariant");
+  if (block->is_empty()) {
+    // Transitioning from empty to not empty.
+    log_debug(oopstorage, blocks)("%s: block not empty " PTR_FORMAT, name(), p2i(block));
+    --_empty_block_count;
+  }
+  oop* result = block->allocate();
+  assert(result != NULL, "allocation failed");
+  assert(!block->is_empty(), "postcondition");
+  Atomic::inc(&_allocation_count); // release updates outside lock.
+  if (block->is_full()) {
+    // Transitioning from not full to full.
+    // Remove full blocks from consideration by future allocates.
+    log_debug(oopstorage, blocks)("%s: block full " PTR_FORMAT, name(), p2i(block));
+    _allocate_list.unlink(*block);
+  }
+  log_info(oopstorage, ref)("%s: allocated " PTR_FORMAT, name(), p2i(result));
+  return result;
+}
+
+OopStorage::Block* OopStorage::find_block_or_null(const oop* ptr) const {
+  assert(ptr != NULL, "precondition");
+  return Block::block_for_ptr(this, ptr);
+}
+
+void OopStorage::release_from_block(Block& block, uintx releasing) {
+  assert(releasing != 0, "invariant");
+  uintx allocated = block.allocated_bitmask();
+  while (true) {
+    assert(releasing == (allocated & releasing), "invariant");
+    uintx new_value = allocated ^ releasing;
+    // CAS new_value into block's allocated bitmask, retrying with
+    // updated allocated bitmask until the CAS succeeds.
+    uintx fetched;
+    if (!is_full_bitmask(allocated) && !is_empty_bitmask(new_value)) {
+      fetched = block.cmpxchg_allocated_bitmask(new_value, allocated);
+      if (fetched == allocated) return;
+    } else {
+      // Need special handling if transitioning from full to not full,
+      // or from not empty to empty.  For those cases, must hold the
+      // _allocation_mutex when updating the allocated bitmask, to
+      // ensure the associated list manipulations will be consistent
+      // with the allocation bitmask that is visible to other threads
+      // in allocate() or deleting empty blocks.
+      MutexLockerEx ml(_allocate_mutex, Mutex::_no_safepoint_check_flag);
+      fetched = block.cmpxchg_allocated_bitmask(new_value, allocated);
+      if (fetched == allocated) {
+        // CAS succeeded; handle special cases, which might no longer apply.
+        if (is_full_bitmask(allocated)) {
+          // Transitioning from full to not-full; add to _allocate_list.
+          log_debug(oopstorage, blocks)("%s: block not full " PTR_FORMAT, name(), p2i(&block));
+          _allocate_list.push_front(block);
+          assert(!block.is_full(), "invariant"); // Still not full.
+        }
+        if (is_empty_bitmask(new_value)) {
+          // Transitioning from not-empty to empty; move to end of
+          // _allocate_list, to make it a deletion candidate.
+          log_debug(oopstorage, blocks)("%s: block empty " PTR_FORMAT, name(), p2i(&block));
+          _allocate_list.unlink(block);
+          _allocate_list.push_back(block);
+          ++_empty_block_count;
+          assert(block.is_empty(), "invariant"); // Still empty.
+        }
+        return;                 // Successful CAS and transitions handled.
+      }
+    }
+    // CAS failed; retry with latest value.
+    allocated = fetched;
+  }
+}
+
+#ifdef ASSERT
+void OopStorage::check_release(const Block* block, const oop* ptr) const {
+  switch (allocation_status_validating_block(block, ptr)) {
+  case INVALID_ENTRY:
+    fatal("Releasing invalid entry: " PTR_FORMAT, p2i(ptr));
+    break;
+
+  case UNALLOCATED_ENTRY:
+    fatal("Releasing unallocated entry: " PTR_FORMAT, p2i(ptr));
+    break;
+
+  case ALLOCATED_ENTRY:
+    assert(block->contains(ptr), "invariant");
+    break;
+
+  default:
+    ShouldNotReachHere();
+  }
+}
+#endif // ASSERT
+
+inline void check_release_entry(const oop* entry) {
+  assert(entry != NULL, "Releasing NULL");
+  assert(*entry == NULL, "Releasing uncleared entry: " PTR_FORMAT, p2i(entry));
+}
+
+void OopStorage::release(const oop* ptr) {
+  check_release_entry(ptr);
+  Block* block = find_block_or_null(ptr);
+  check_release(block, ptr);
+  log_info(oopstorage, ref)("%s: released " PTR_FORMAT, name(), p2i(ptr));
+  release_from_block(*block, block->bitmask_for_entry(ptr));
+  Atomic::dec(&_allocation_count);
+}
+
+void OopStorage::release(const oop* const* ptrs, size_t size) {
+  size_t i = 0;
+  while (i < size) {
+    check_release_entry(ptrs[i]);
+    Block* block = find_block_or_null(ptrs[i]);
+    check_release(block, ptrs[i]);
+    log_info(oopstorage, ref)("%s: released " PTR_FORMAT, name(), p2i(ptrs[i]));
+    size_t count = 0;
+    uintx releasing = 0;
+    for ( ; i < size; ++i) {
+      const oop* entry = ptrs[i];
+      // If entry not in block, finish block and resume outer loop with entry.
+      if (!block->contains(entry)) break;
+      check_release_entry(entry);
+      // Add entry to releasing bitmap.
+      log_info(oopstorage, ref)("%s: released " PTR_FORMAT, name(), p2i(entry));
+      uintx entry_bitmask = block->bitmask_for_entry(entry);
+      assert((releasing & entry_bitmask) == 0,
+             "Duplicate entry: " PTR_FORMAT, p2i(entry));
+      releasing |= entry_bitmask;
+      ++count;
+    }
+    // Release the contiguous entries that are in block.
+    release_from_block(*block, releasing);
+    Atomic::sub(count, &_allocation_count);
+  }
+}
+
+const char* dup_name(const char* name) {
+  char* dup = NEW_C_HEAP_ARRAY(char, strlen(name) + 1, mtGC);
+  strcpy(dup, name);
+  return dup;
+}
+
+OopStorage::OopStorage(const char* name,
+                       Mutex* allocate_mutex,
+                       Mutex* active_mutex) :
+  _name(dup_name(name)),
+  _active_list(&Block::get_active_entry),
+  _allocate_list(&Block::get_allocate_entry),
+  _active_head(NULL),
+  _allocate_mutex(allocate_mutex),
+  _active_mutex(active_mutex),
+  _allocation_count(0),
+  _block_count(0),
+  _empty_block_count(0),
+  _concurrent_iteration_active(false)
+{
+  assert(_active_mutex->rank() < _allocate_mutex->rank(),
+         "%s: active_mutex must have lower rank than allocate_mutex", _name);
+  assert(_active_mutex->_safepoint_check_required != Mutex::_safepoint_check_always,
+         "%s: active mutex requires safepoint check", _name);
+  assert(_allocate_mutex->_safepoint_check_required != Mutex::_safepoint_check_always,
+         "%s: allocate mutex requires safepoint check", _name);
+}
+
+void OopStorage::delete_empty_block(const Block& block) {
+  assert(block.is_empty(), "discarding non-empty block");
+  log_info(oopstorage, blocks)("%s: delete empty block " PTR_FORMAT, name(), p2i(&block));
+  Block::delete_block(block);
+}
+
+OopStorage::~OopStorage() {
+  Block* block;
+  while ((block = _allocate_list.head()) != NULL) {
+    _allocate_list.unlink(*block);
+  }
+  while ((block = _active_list.head()) != NULL) {
+    _active_list.unlink(*block);
+    Block::delete_block(*block);
+  }
+  FREE_C_HEAP_ARRAY(char, _name);
+}
+
+void OopStorage::delete_empty_blocks_safepoint(size_t retain) {
+  assert_at_safepoint();
+  // Don't interfere with a concurrent iteration.
+  if (_concurrent_iteration_active) return;
+  // Compute the number of blocks to remove, to minimize volatile accesses.
+  size_t empty_blocks = _empty_block_count;
+  if (retain < empty_blocks) {
+    size_t remove_count = empty_blocks - retain;
+    // Update volatile counters once.
+    _block_count -= remove_count;
+    _empty_block_count -= remove_count;
+    do {
+      const Block* block = _allocate_list.ctail();
+      assert(block != NULL, "invariant");
+      assert(block->is_empty(), "invariant");
+      // Remove block from lists, and delete it.
+      _active_list.unlink(*block);
+      _allocate_list.unlink(*block);
+      delete_empty_block(*block);
+    } while (--remove_count > 0);
+    // Update _active_head, in case current value was in deleted set.
+    _active_head = _active_list.head();
+  }
+}
+
+void OopStorage::delete_empty_blocks_concurrent(size_t retain) {
+  MutexLockerEx ml(_allocate_mutex, Mutex::_no_safepoint_check_flag);
+  // Other threads could be adding to the empty block count while we
+  // release the mutex across the block deletions.  Set an upper bound
+  // on how many blocks we'll try to release, so other threads can't
+  // cause an unbounded stay in this function.
+  if (_empty_block_count <= retain) return;
+  size_t limit = _empty_block_count - retain;
+  for (size_t i = 0; (i < limit) && (retain < _empty_block_count); ++i) {
+    const Block* block = _allocate_list.ctail();
+    assert(block != NULL, "invariant");
+    assert(block->is_empty(), "invariant");
+    {
+      MutexLockerEx aml(_active_mutex, Mutex::_no_safepoint_check_flag);
+      // Don't interfere with a concurrent iteration.
+      if (_concurrent_iteration_active) return;
+      // Remove block from _active_list, updating head if needed.
+      _active_list.unlink(*block);
+      --_block_count;
+      if (block == _active_head) {
+        _active_head = _active_list.head();
+      }
+    }
+    // Remove block from _allocate_list and delete it.
+    _allocate_list.unlink(*block);
+    --_empty_block_count;
+    // Release mutex while deleting block.
+    MutexUnlockerEx ul(_allocate_mutex, Mutex::_no_safepoint_check_flag);
+    delete_empty_block(*block);
+  }
+}
+
+OopStorage::EntryStatus
+OopStorage::allocation_status_validating_block(const Block* block,
+                                               const oop* ptr) const {
+  MutexLockerEx ml(_allocate_mutex, Mutex::_no_safepoint_check_flag);
+  if ((block == NULL) || !is_valid_block_locked_or_safepoint(block)) {
+    return INVALID_ENTRY;
+  } else if ((block->allocated_bitmask() & block->bitmask_for_entry(ptr)) != 0) {
+    return ALLOCATED_ENTRY;
+  } else {
+    return UNALLOCATED_ENTRY;
+  }
+}
+
+OopStorage::EntryStatus OopStorage::allocation_status(const oop* ptr) const {
+  return allocation_status_validating_block(find_block_or_null(ptr), ptr);
+}
+
+size_t OopStorage::allocation_count() const {
+  return _allocation_count;
+}
+
+size_t OopStorage::block_count() const {
+  return _block_count;
+}
+
+size_t OopStorage::empty_block_count() const {
+  return _empty_block_count;
+}
+
+size_t OopStorage::total_memory_usage() const {
+  size_t total_size = sizeof(OopStorage);
+  total_size += strlen(name()) + 1;
+  total_size += block_count() * Block::allocation_size();
+  return total_size;
+}
+
+// Parallel iteration support
+#if INCLUDE_ALL_GCS
+
+static char* not_started_marker_dummy = NULL;
+static void* const not_started_marker = &not_started_marker_dummy;
+
+OopStorage::BasicParState::BasicParState(OopStorage* storage, bool concurrent) :
+  _storage(storage),
+  _next_block(not_started_marker),
+  _concurrent(concurrent)
+{
+  update_iteration_state(true);
+}
+
+OopStorage::BasicParState::~BasicParState() {
+  update_iteration_state(false);
+}
+
+void OopStorage::BasicParState::update_iteration_state(bool value) {
+  if (_concurrent) {
+    MutexLockerEx ml(_storage->_active_mutex, Mutex::_no_safepoint_check_flag);
+    assert(_storage->_concurrent_iteration_active != value, "precondition");
+    _storage->_concurrent_iteration_active = value;
+  }
+}
+
+void OopStorage::BasicParState::ensure_iteration_started() {
+  if (!_concurrent) assert_at_safepoint();
+  assert(!_concurrent || _storage->_concurrent_iteration_active, "invariant");
+  // Ensure _next_block is not the not_started_marker, setting it to
+  // the _active_head to start the iteration if necessary.
+  if (OrderAccess::load_acquire(&_next_block) == not_started_marker) {
+    Atomic::cmpxchg(_storage->_active_head, &_next_block, not_started_marker);
+  }
+  assert(_next_block != not_started_marker, "postcondition");
+}
+
+OopStorage::Block* OopStorage::BasicParState::claim_next_block() {
+  assert(_next_block != not_started_marker, "Iteration not started");
+  void* next = _next_block;
+  while (next != NULL) {
+    void* new_next = _storage->_active_list.next(*static_cast<Block*>(next));
+    void* fetched = Atomic::cmpxchg(new_next, &_next_block, next);
+    if (fetched == next) break; // Claimed.
+    next = fetched;
+  }
+  return static_cast<Block*>(next);
+}
+
+#endif // INCLUDE_ALL_GCS
+
+const char* OopStorage::name() const { return _name; }
+
+#ifndef PRODUCT
+
+void OopStorage::print_on(outputStream* st) const {
+  size_t allocations = _allocation_count;
+  size_t blocks = _block_count;
+  size_t empties = _empty_block_count;
+  // Comparison is being careful about racy accesses.
+  size_t used = (blocks < empties) ? 0 : (blocks - empties);
+
+  double data_size = section_size * section_count;
+  double alloc_percentage = percent_of((double)allocations, used * data_size);
+
+  st->print("%s: " SIZE_FORMAT " entries in " SIZE_FORMAT " blocks (%.F%%), "
+            SIZE_FORMAT " empties, " SIZE_FORMAT " bytes",
+            name(), allocations, used, alloc_percentage,
+            empties, total_memory_usage());
+  if (_concurrent_iteration_active) {
+    st->print(", concurrent iteration active");
+  }
+}
+
+#endif // !PRODUCT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/oopStorage.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,279 @@
+/*
+ * 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_SHARED_OOPSTORAGE_HPP
+#define SHARE_GC_SHARED_OOPSTORAGE_HPP
+
+#include "memory/allocation.hpp"
+#include "oops/oop.hpp"
+#include "utilities/globalDefinitions.hpp"
+#include "utilities/macros.hpp"
+
+class Mutex;
+class outputStream;
+
+// OopStorage supports management of off-heap references to objects allocated
+// in the Java heap.  An OopStorage object provides a set of Java object
+// references (oop values), which clients refer to via oop* handles to the
+// associated OopStorage entries.  Clients allocate entries to create a
+// (possibly weak) reference to a Java object, use that reference, and release
+// the reference when no longer needed.
+//
+// The garbage collector must know about all OopStorage objects and their
+// reference strength.  OopStorage provides the garbage collector with support
+// for iteration over all the allocated entries.
+//
+// There are several categories of interaction with an OopStorage object.
+//
+// (1) allocation and release of entries, by the mutator or the VM.
+// (2) iteration by the garbage collector, possibly concurrent with mutator.
+// (3) iteration by other, non-GC, tools (only at safepoints).
+// (4) cleanup of unused internal storage, possibly concurrent with mutator.
+//
+// A goal of OopStorage is to make these interactions thread-safe, while
+// minimizing potential lock contention issues within and between these
+// categories.  In particular, support for concurrent iteration by the garbage
+// collector, under certain restrictions, is required.  Further, it must not
+// block nor be blocked by other operations for long periods.
+//
+// Internally, OopStorage is a set of Block objects, from which entries are
+// allocated and released.  A block contains an oop[] and a bitmask indicating
+// which entries are in use (have been allocated and not yet released).  New
+// blocks are constructed and added to the storage object when an entry
+// allocation request is made and there are no blocks with unused entries.
+// Blocks may be removed and deleted when empty.
+//
+// There are two important (and somewhat intertwined) protocols governing
+// concurrent access to a storage object.  These are the Concurrent Iteration
+// Protocol and the Allocation Protocol.  See the ParState class for a
+// discussion of concurrent iteration and the management of thread
+// interactions for this protocol.  Similarly, see the allocate() function for
+// a discussion of allocation.
+
+class OopStorage : public CHeapObj<mtGC> {
+public:
+  OopStorage(const char* name, Mutex* allocate_mutex, Mutex* active_mutex);
+  ~OopStorage();
+
+  // These count and usage accessors are racy unless at a safepoint.
+
+  // The number of allocated and not yet released entries.
+  size_t allocation_count() const;
+
+  // The number of blocks of entries.  Useful for sizing parallel iteration.
+  size_t block_count() const;
+
+  // The number of blocks with no allocated entries.  Useful for sizing
+  // parallel iteration and scheduling block deletion.
+  size_t empty_block_count() const;
+
+  // Total number of blocks * memory allocation per block, plus
+  // bookkeeping overhead, including this storage object.
+  size_t total_memory_usage() const;
+
+  enum EntryStatus {
+    INVALID_ENTRY,
+    UNALLOCATED_ENTRY,
+    ALLOCATED_ENTRY
+  };
+
+  // Locks _allocate_mutex.
+  // precondition: ptr != NULL.
+  EntryStatus allocation_status(const oop* ptr) const;
+
+  // Allocates and returns a new entry.  Returns NULL if memory allocation
+  // failed.  Locks _allocate_mutex.
+  // postcondition: *result == NULL.
+  oop* allocate();
+
+  // Deallocates ptr, after setting its value to NULL. Locks _allocate_mutex.
+  // precondition: ptr is a valid allocated entry.
+  // precondition: *ptr == NULL.
+  void release(const oop* ptr);
+
+  // Releases all the ptrs.  Possibly faster than individual calls to
+  // release(oop*).  Best if ptrs is sorted by address.  Locks
+  // _allocate_mutex.
+  // precondition: All elements of ptrs are valid allocated entries.
+  // precondition: *ptrs[i] == NULL, for i in [0,size).
+  void release(const oop* const* ptrs, size_t size);
+
+  // Applies f to each allocated entry's location.  f must be a function or
+  // function object.  Assume p is either a const oop* or an oop*, depending
+  // on whether the associated storage is const or non-const, respectively.
+  // Then f(p) must be a valid expression.  The result of invoking f(p) must
+  // be implicitly convertible to bool.  Iteration terminates and returns
+  // false if any invocation of f returns false.  Otherwise, the result of
+  // iteration is true.
+  // precondition: at safepoint.
+  template<typename F> inline bool iterate_safepoint(F f);
+  template<typename F> inline bool iterate_safepoint(F f) const;
+
+  // oops_do and weak_oops_do are wrappers around iterate_safepoint, providing
+  // an adaptation layer allowing the use of existing is-alive closures and
+  // OopClosures.  Assume p is either const oop* or oop*, depending on whether
+  // the associated storage is const or non-const, respectively.  Then
+  //
+  // - closure->do_oop(p) must be a valid expression whose value is ignored.
+  //
+  // - is_alive->do_object_b(*p) must be a valid expression whose value is
+  // convertible to bool.
+  //
+  // For weak_oops_do, if *p == NULL then neither is_alive nor closure will be
+  // invoked for p.  If is_alive->do_object_b(*p) is false, then closure will
+  // not be invoked on p, and *p will be set to NULL.
+
+  template<typename Closure> inline void oops_do(Closure* closure);
+  template<typename Closure> inline void oops_do(Closure* closure) const;
+  template<typename Closure> inline void weak_oops_do(Closure* closure);
+
+  template<typename IsAliveClosure, typename Closure>
+  inline void weak_oops_do(IsAliveClosure* is_alive, Closure* closure);
+
+#if INCLUDE_ALL_GCS
+  // Parallel iteration is for the exclusive use of the GC.
+  // Other clients must use serial iteration.
+  template<bool concurrent, bool is_const> class ParState;
+#endif // INCLUDE_ALL_GCS
+
+  // Block cleanup functions are for the exclusive use of the GC.
+  // Both stop deleting if there is an in-progress concurrent iteration.
+  // Concurrent deletion locks both the allocate_mutex and the active_mutex.
+  void delete_empty_blocks_safepoint(size_t retain = 1);
+  void delete_empty_blocks_concurrent(size_t retain = 1);
+
+  // Debugging and logging support.
+  const char* name() const;
+  void print_on(outputStream* st) const PRODUCT_RETURN;
+
+  // Provides access to storage internals, for unit testing.
+  // Declare, but not define, the public class OopStorage::TestAccess.
+  // That class is defined as part of the unit-test. It "exports" the needed
+  // private types by providing public typedefs for them.
+  class TestAccess;
+
+  // xlC on AIX can't compile test_oopStorage.cpp with following private
+  // classes. C++03 introduced access for nested classes with DR45, but xlC
+  // version 12 rejects it.
+NOT_AIX( private: )
+  class Block;                  // Forward decl; defined in .inline.hpp file.
+  class BlockList;              // Forward decl for BlockEntry friend decl.
+
+  class BlockEntry VALUE_OBJ_CLASS_SPEC {
+    friend class BlockList;
+
+    // Members are mutable, and we deal exclusively with pointers to
+    // const, to make const blocks easier to use; a block being const
+    // doesn't prevent modifying its list state.
+    mutable const Block* _prev;
+    mutable const Block* _next;
+
+    // Noncopyable.
+    BlockEntry(const BlockEntry&);
+    BlockEntry& operator=(const BlockEntry&);
+
+  public:
+    BlockEntry();
+    ~BlockEntry();
+  };
+
+  class BlockList VALUE_OBJ_CLASS_SPEC {
+    const Block* _head;
+    const Block* _tail;
+    const BlockEntry& (*_get_entry)(const Block& block);
+
+    // Noncopyable.
+    BlockList(const BlockList&);
+    BlockList& operator=(const BlockList&);
+
+  public:
+    BlockList(const BlockEntry& (*get_entry)(const Block& block));
+    ~BlockList();
+
+    Block* head();
+    const Block* chead() const;
+    const Block* ctail() const;
+
+    Block* prev(Block& block);
+    Block* next(Block& block);
+
+    const Block* prev(const Block& block) const;
+    const Block* next(const Block& block) const;
+
+    void push_front(const Block& block);
+    void push_back(const Block& block);
+    void unlink(const Block& block);
+  };
+
+private:
+  const char* _name;
+  BlockList _active_list;
+  BlockList _allocate_list;
+  Block* volatile _active_head;
+
+  Mutex* _allocate_mutex;
+  Mutex* _active_mutex;
+
+  // Counts are volatile for racy unlocked accesses.
+  volatile size_t _allocation_count;
+  volatile size_t _block_count;
+  volatile size_t _empty_block_count;
+  // mutable because this gets set even for const iteration.
+  mutable bool _concurrent_iteration_active;
+
+  Block* find_block_or_null(const oop* ptr) const;
+  bool is_valid_block_locked_or_safepoint(const Block* block) const;
+  EntryStatus allocation_status_validating_block(const Block* block, const oop* ptr) const;
+  void check_release(const Block* block, const oop* ptr) const NOT_DEBUG_RETURN;
+  void release_from_block(Block& block, uintx release_bitmask);
+  void delete_empty_block(const Block& block);
+
+  static void assert_at_safepoint() NOT_DEBUG_RETURN;
+
+  template<typename F, typename Storage>
+  static bool iterate_impl(F f, Storage* storage);
+
+#if INCLUDE_ALL_GCS
+  // Implementation support for parallel iteration
+  class BasicParState;
+#endif // INCLUDE_ALL_GCS
+
+  // Wrapper for OopClosure-style function, so it can be used with
+  // iterate.  Assume p is of type oop*.  Then cl->do_oop(p) must be a
+  // valid expression whose value may be ignored.
+  template<typename Closure> class OopFn;
+  template<typename Closure> static OopFn<Closure> oop_fn(Closure* cl);
+
+  // Wrapper for BoolObjectClosure + iteration handler pair, so they
+  // can be used with iterate.
+  template<typename IsAlive, typename F> class IfAliveFn;
+  template<typename IsAlive, typename F>
+  static IfAliveFn<IsAlive, F> if_alive_fn(IsAlive* is_alive, F f);
+
+  // Wrapper for iteration handler, automatically skipping NULL entries.
+  template<typename F> class SkipNullFn;
+  template<typename F> static SkipNullFn<F> skip_null_fn(F f);
+};
+
+#endif // include guard
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/oopStorage.inline.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,289 @@
+/*
+ * 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_SHARED_OOPSTORAGE_INLINE_HPP
+#define SHARE_GC_SHARED_OOPSTORAGE_INLINE_HPP
+
+#include "gc/shared/oopStorage.hpp"
+#include "memory/allocation.hpp"
+#include "metaprogramming/conditional.hpp"
+#include "metaprogramming/isConst.hpp"
+#include "oops/oop.hpp"
+#include "utilities/count_trailing_zeros.hpp"
+#include "utilities/debug.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+class OopStorage::Block /* No base class, to avoid messing up alignment. */ {
+  // _data must be the first non-static data member, for alignment.
+  oop _data[BitsPerWord];
+  static const unsigned _data_pos = 0; // Position of _data.
+
+  volatile uintx _allocated_bitmask; // One bit per _data element.
+  const OopStorage* _owner;
+  void* _memory;              // Unaligned storage containing block.
+  BlockEntry _active_entry;
+  BlockEntry _allocate_entry;
+
+  Block(const OopStorage* owner, void* memory);
+  ~Block();
+
+  void check_index(unsigned index) const;
+  unsigned get_index(const oop* ptr) const;
+
+  template<typename F, typename BlockPtr>
+  static bool iterate_impl(F f, BlockPtr b);
+
+  // Noncopyable.
+  Block(const Block&);
+  Block& operator=(const Block&);
+
+public:
+  static const BlockEntry& get_active_entry(const Block& block);
+  static const BlockEntry& get_allocate_entry(const Block& block);
+
+  static size_t allocation_size();
+  static size_t allocation_alignment_shift();
+
+  oop* get_pointer(unsigned index);
+  const oop* get_pointer(unsigned index) const;
+
+  uintx bitmask_for_index(unsigned index) const;
+  uintx bitmask_for_entry(const oop* ptr) const;
+
+  // Allocation bitmask accessors are racy.
+  bool is_full() const;
+  bool is_empty() const;
+  uintx allocated_bitmask() const;
+  uintx cmpxchg_allocated_bitmask(uintx new_value, uintx compare_value);
+
+  bool contains(const oop* ptr) const;
+
+  // Returns NULL if ptr is not in a block or not allocated in that block.
+  static Block* block_for_ptr(const OopStorage* owner, const oop* ptr);
+
+  oop* allocate();
+  static Block* new_block(const OopStorage* owner);
+  static void delete_block(const Block& block);
+
+  template<typename F> bool iterate(F f);
+  template<typename F> bool iterate(F f) const;
+}; // class Block
+
+inline OopStorage::Block* OopStorage::BlockList::head() {
+  return const_cast<Block*>(_head);
+}
+
+inline const OopStorage::Block* OopStorage::BlockList::chead() const {
+  return _head;
+}
+
+inline const OopStorage::Block* OopStorage::BlockList::ctail() const {
+  return _tail;
+}
+
+inline OopStorage::Block* OopStorage::BlockList::prev(Block& block) {
+  return const_cast<Block*>(_get_entry(block)._prev);
+}
+
+inline OopStorage::Block* OopStorage::BlockList::next(Block& block) {
+  return const_cast<Block*>(_get_entry(block)._next);
+}
+
+inline const OopStorage::Block* OopStorage::BlockList::prev(const Block& block) const {
+  return _get_entry(block)._prev;
+}
+
+inline const OopStorage::Block* OopStorage::BlockList::next(const Block& block) const {
+  return _get_entry(block)._next;
+}
+
+template<typename Closure>
+class OopStorage::OopFn VALUE_OBJ_CLASS_SPEC {
+public:
+  explicit OopFn(Closure* cl) : _cl(cl) {}
+
+  template<typename OopPtr>     // [const] oop*
+  bool operator()(OopPtr ptr) const {
+    _cl->do_oop(ptr);
+    return true;
+  }
+
+private:
+  Closure* _cl;
+};
+
+template<typename Closure>
+inline OopStorage::OopFn<Closure> OopStorage::oop_fn(Closure* cl) {
+  return OopFn<Closure>(cl);
+}
+
+template<typename IsAlive, typename F>
+class OopStorage::IfAliveFn VALUE_OBJ_CLASS_SPEC {
+public:
+  IfAliveFn(IsAlive* is_alive, F f) : _is_alive(is_alive), _f(f) {}
+
+  bool operator()(oop* ptr) const {
+    bool result = true;
+    oop v = *ptr;
+    if (v != NULL) {
+      if (_is_alive->do_object_b(v)) {
+        result = _f(ptr);
+      } else {
+        *ptr = NULL;            // Clear dead value.
+      }
+    }
+    return result;
+  }
+
+private:
+  IsAlive* _is_alive;
+  F _f;
+};
+
+template<typename IsAlive, typename F>
+inline OopStorage::IfAliveFn<IsAlive, F> OopStorage::if_alive_fn(IsAlive* is_alive, F f) {
+  return IfAliveFn<IsAlive, F>(is_alive, f);
+}
+
+template<typename F>
+class OopStorage::SkipNullFn VALUE_OBJ_CLASS_SPEC {
+public:
+  SkipNullFn(F f) : _f(f) {}
+
+  template<typename OopPtr>     // [const] oop*
+  bool operator()(OopPtr ptr) const {
+    return (*ptr != NULL) ? _f(ptr) : true;
+  }
+
+private:
+  F _f;
+};
+
+template<typename F>
+inline OopStorage::SkipNullFn<F> OopStorage::skip_null_fn(F f) {
+  return SkipNullFn<F>(f);
+}
+
+// Inline Block accesses for use in iteration inner loop.
+
+inline void OopStorage::Block::check_index(unsigned index) const {
+  assert(index < ARRAY_SIZE(_data), "Index out of bounds: %u", index);
+}
+
+inline oop* OopStorage::Block::get_pointer(unsigned index) {
+  check_index(index);
+  return &_data[index];
+}
+
+inline const oop* OopStorage::Block::get_pointer(unsigned index) const {
+  check_index(index);
+  return &_data[index];
+}
+
+inline uintx OopStorage::Block::allocated_bitmask() const {
+  return _allocated_bitmask;
+}
+
+inline uintx OopStorage::Block::bitmask_for_index(unsigned index) const {
+  check_index(index);
+  return uintx(1) << index;
+}
+
+// Provide const or non-const iteration, depending on whether BlockPtr
+// is const Block* or Block*, respectively.
+template<typename F, typename BlockPtr> // BlockPtr := [const] Block*
+inline bool OopStorage::Block::iterate_impl(F f, BlockPtr block) {
+  uintx bitmask = block->allocated_bitmask();
+  while (bitmask != 0) {
+    unsigned index = count_trailing_zeros(bitmask);
+    bitmask ^= block->bitmask_for_index(index);
+    if (!f(block->get_pointer(index))) {
+      return false;
+    }
+  }
+  return true;
+}
+
+template<typename F>
+inline bool OopStorage::Block::iterate(F f) {
+  return iterate_impl(f, this);
+}
+
+template<typename F>
+inline bool OopStorage::Block::iterate(F f) const {
+  return iterate_impl(f, this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Support for serial iteration, always at a safepoint.
+
+// Provide const or non-const iteration, depending on whether Storage is
+// const OopStorage* or OopStorage*, respectively.
+template<typename F, typename Storage> // Storage := [const] OopStorage
+inline bool OopStorage::iterate_impl(F f, Storage* storage) {
+  assert_at_safepoint();
+  // Propagate const/non-const iteration to the block layer, by using
+  // const or non-const blocks as corresponding to Storage.
+  typedef typename Conditional<IsConst<Storage>::value, const Block*, Block*>::type BlockPtr;
+  for (BlockPtr block = storage->_active_head;
+       block != NULL;
+       block = storage->_active_list.next(*block)) {
+    if (!block->iterate(f)) {
+      return false;
+    }
+  }
+  return true;
+}
+
+template<typename F>
+inline bool OopStorage::iterate_safepoint(F f) {
+  return iterate_impl(f, this);
+}
+
+template<typename F>
+inline bool OopStorage::iterate_safepoint(F f) const {
+  return iterate_impl(f, this);
+}
+
+template<typename Closure>
+inline void OopStorage::oops_do(Closure* cl) {
+  iterate_safepoint(oop_fn(cl));
+}
+
+template<typename Closure>
+inline void OopStorage::oops_do(Closure* cl) const {
+  iterate_safepoint(oop_fn(cl));
+}
+
+template<typename Closure>
+inline void OopStorage::weak_oops_do(Closure* cl) {
+  iterate_safepoint(skip_null_fn(oop_fn(cl)));
+}
+
+template<typename IsAliveClosure, typename Closure>
+inline void OopStorage::weak_oops_do(IsAliveClosure* is_alive, Closure* cl) {
+  iterate_safepoint(if_alive_fn(is_alive, oop_fn(cl)));
+}
+
+#endif // include guard
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/oopStorageParState.inline.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,239 @@
+/*
+ * 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_SHARED_OOPSTORAGEPARSTATE_INLINE_HPP
+#define SHARE_GC_SHARED_OOPSTORAGEPARSTATE_INLINE_HPP
+
+#include "gc/shared/oopStorage.inline.hpp"
+#include "memory/allocation.hpp"
+#include "metaprogramming/conditional.hpp"
+#include "utilities/macros.hpp"
+
+#if INCLUDE_ALL_GCS
+
+//////////////////////////////////////////////////////////////////////////////
+// Support for parallel and optionally concurrent state iteration.
+//
+// Parallel iteration is for the exclusive use of the GC.  Other iteration
+// clients must use serial iteration.
+//
+// Concurrent Iteration
+//
+// Iteration involves the _active_list, which contains all of the blocks owned
+// by a storage object.  This is a doubly-linked list, linked through
+// dedicated fields in the blocks.
+//
+// At most one concurrent ParState can exist at a time for a given storage
+// object.
+//
+// A concurrent ParState sets the associated storage's
+// _concurrent_iteration_active flag true when the state is constructed, and
+// sets it false when the state is destroyed.  These assignments are made with
+// _active_mutex locked.  Meanwhile, empty block deletion is not done while
+// _concurrent_iteration_active is true.  The flag check and the dependent
+// removal of a block from the _active_list is performed with _active_mutex
+// locked.  This prevents concurrent iteration and empty block deletion from
+// interfering with with each other.
+//
+// Both allocate() and delete_empty_blocks_concurrent() lock the
+// _allocate_mutex while performing their respective list manipulations,
+// preventing them from interfering with each other.
+//
+// When allocate() creates a new block, it is added to the front of the
+// _active_list.  Then _active_head is set to the new block.  When concurrent
+// iteration is started (by a parallel worker thread calling the state's
+// iterate() function), the current _active_head is used as the initial block
+// for the iteration, with iteration proceeding down the list headed by that
+// block.
+//
+// As a result, the list over which concurrent iteration operates is stable.
+// However, once the iteration is started, later allocations may add blocks to
+// the front of the list that won't be examined by the iteration.  And while
+// the list is stable, concurrent allocate() and release() operations may
+// change the set of allocated entries in a block at any time during the
+// iteration.
+//
+// As a result, a concurrent iteration handler must accept that some
+// allocations and releases that occur after the iteration started will not be
+// seen by the iteration.  Further, some may overlap examination by the
+// iteration.  To help with this, allocate() and release() have an invariant
+// that an entry's value must be NULL when it is not in use.
+//
+// An in-progress delete_empty_blocks_concurrent() operation can contend with
+// the start of a concurrent iteration over the _active_mutex.  Since both are
+// under GC control, that potential contention can be eliminated by never
+// scheduling both operations to run at the same time.
+//
+// ParState<concurrent, is_const>
+//   concurrent must be true if iteration is concurrent with the
+//   mutator, false if iteration is at a safepoint.
+//
+//   is_const must be true if the iteration is over a constant storage
+//   object, false if the iteration may modify the storage object.
+//
+// ParState([const] OopStorage* storage)
+//   Construct an object for managing an iteration over storage.  For a
+//   concurrent ParState, empty block deletion for the associated storage
+//   is inhibited for the life of the ParState.  There can be no more
+//   than one live concurrent ParState at a time for a given storage object.
+//
+// template<typename F> void iterate(F f)
+//   Repeatedly claims a block from the associated storage that has
+//   not been processed by this iteration (possibly by other threads),
+//   and applies f to each entry in the claimed block. Assume p is of
+//   type const oop* or oop*, according to is_const. Then f(p) must be
+//   a valid expression whose value is ignored.  Concurrent uses must
+//   be prepared for an entry's value to change at any time, due to
+//   mutator activity.
+//
+// template<typename Closure> void oops_do(Closure* cl)
+//   Wrapper around iterate, providing an adaptation layer allowing
+//   the use of OopClosures and similar objects for iteration.  Assume
+//   p is of type const oop* or oop*, according to is_const.  Then
+//   cl->do_oop(p) must be a valid expression whose value is ignored.
+//   Concurrent uses must be prepared for the entry's value to change
+//   at any time, due to mutator activity.
+//
+// Optional operations, provided only if !concurrent && !is_const.
+// These are not provided when is_const, because the storage object
+// may be modified by the iteration infrastructure, even if the
+// provided closure doesn't modify the storage object.  These are not
+// provided when concurrent because any pre-filtering behavior by the
+// iteration infrastructure is inappropriate for concurrent iteration;
+// modifications of the storage by the mutator could result in the
+// pre-filtering being applied (successfully or not) to objects that
+// are unrelated to what the closure finds in the entry.
+//
+// template<typename Closure> void weak_oops_do(Closure* cl)
+// template<typename IsAliveClosure, typename Closure>
+// void weak_oops_do(IsAliveClosure* is_alive, Closure* cl)
+//   Wrappers around iterate, providing an adaptation layer allowing
+//   the use of is-alive closures and OopClosures for iteration.
+//   Assume p is of type oop*.  Then
+//
+//   - cl->do_oop(p) must be a valid expression whose value is ignored.
+//
+//   - is_alive->do_object_b(*p) must be a valid expression whose value
+//   is convertible to bool.
+//
+//   If *p == NULL then neither is_alive nor cl will be invoked for p.
+//   If is_alive->do_object_b(*p) is false, then cl will not be
+//   invoked on p.
+
+class OopStorage::BasicParState VALUE_OBJ_CLASS_SPEC {
+  OopStorage* _storage;
+  void* volatile _next_block;
+  bool _concurrent;
+
+  // Noncopyable.
+  BasicParState(const BasicParState&);
+  BasicParState& operator=(const BasicParState&);
+
+  void update_iteration_state(bool value);
+  void ensure_iteration_started();
+  Block* claim_next_block();
+
+  // Wrapper for iteration handler; ignore handler result and return true.
+  template<typename F> class AlwaysTrueFn;
+
+public:
+  BasicParState(OopStorage* storage, bool concurrent);
+  ~BasicParState();
+
+  template<bool is_const, typename F> void iterate(F f) {
+    // Wrap f in ATF so we can use Block::iterate.
+    AlwaysTrueFn<F> atf_f(f);
+    ensure_iteration_started();
+    typename Conditional<is_const, const Block*, Block*>::type block;
+    while ((block = claim_next_block()) != NULL) {
+      block->iterate(atf_f);
+    }
+  }
+};
+
+template<typename F>
+class OopStorage::BasicParState::AlwaysTrueFn VALUE_OBJ_CLASS_SPEC {
+  F _f;
+
+public:
+  AlwaysTrueFn(F f) : _f(f) {}
+
+  template<typename OopPtr>     // [const] oop*
+  bool operator()(OopPtr ptr) const { _f(ptr); return true; }
+};
+
+template<bool concurrent, bool is_const>
+class OopStorage::ParState VALUE_OBJ_CLASS_SPEC {
+  BasicParState _basic_state;
+
+public:
+  ParState(const OopStorage* storage) :
+    // For simplicity, always recorded as non-const.
+    _basic_state(const_cast<OopStorage*>(storage), concurrent)
+  {}
+
+  template<typename F>
+  void iterate(F f) {
+    _basic_state.template iterate<is_const>(f);
+  }
+
+  template<typename Closure>
+  void oops_do(Closure* cl) {
+    this->iterate(oop_fn(cl));
+  }
+};
+
+template<>
+class OopStorage::ParState<false, false> VALUE_OBJ_CLASS_SPEC {
+  BasicParState _basic_state;
+
+public:
+  ParState(OopStorage* storage) :
+    _basic_state(storage, false)
+  {}
+
+  template<typename F>
+  void iterate(F f) {
+    _basic_state.template iterate<false>(f);
+  }
+
+  template<typename Closure>
+  void oops_do(Closure* cl) {
+    this->iterate(oop_fn(cl));
+  }
+
+  template<typename Closure>
+  void weak_oops_do(Closure* cl) {
+    this->iterate(skip_null_fn(oop_fn(cl)));
+  }
+
+  template<typename IsAliveClosure, typename Closure>
+  void weak_oops_do(IsAliveClosure* is_alive, Closure* cl) {
+    this->iterate(if_alive_fn(is_alive, oop_fn(cl)));
+  }
+};
+
+#endif // INCLUDE_ALL_GCS
+
+#endif // include guard
--- a/src/hotspot/share/interpreter/rewriter.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/interpreter/rewriter.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -28,7 +28,6 @@
 #include "interpreter/interpreter.hpp"
 #include "interpreter/rewriter.hpp"
 #include "memory/metadataFactory.hpp"
-#include "memory/metaspaceShared.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/generateOopMap.hpp"
 #include "prims/methodHandles.hpp"
@@ -556,7 +555,7 @@
 
 void Rewriter::rewrite(InstanceKlass* klass, TRAPS) {
   if (!DumpSharedSpaces) {
-    assert(!MetaspaceShared::is_in_shared_space(klass), "archive methods must not be rewritten at run time");
+    assert(!klass->is_shared(), "archive methods must not be rewritten at run time");
   }
   ResourceMark rm(THREAD);
   Rewriter     rw(klass, klass->constants(), klass->methods(), CHECK);
--- a/src/hotspot/share/logging/logTag.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/logging/logTag.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, 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
@@ -101,6 +101,7 @@
   LOG_TAG(objecttagging) \
   LOG_TAG(obsolete) \
   LOG_TAG(oopmap) \
+  LOG_TAG(oopstorage) \
   LOG_TAG(os) \
   LOG_TAG(pagesize) \
   LOG_TAG(patch) \
--- a/src/hotspot/share/memory/allocation.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/memory/allocation.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -37,6 +37,9 @@
 #include "services/memTracker.hpp"
 #include "utilities/ostream.hpp"
 
+void* MetaspaceObj::_shared_metaspace_base = NULL;
+void* MetaspaceObj::_shared_metaspace_top  = NULL;
+
 void* StackObj::operator new(size_t size)     throw() { ShouldNotCallThis(); return 0; }
 void  StackObj::operator delete(void* p)              { ShouldNotCallThis(); }
 void* StackObj::operator new [](size_t size)  throw() { ShouldNotCallThis(); return 0; }
@@ -54,10 +57,6 @@
   return Metaspace::allocate(loader_data, word_size, type, THREAD);
 }
 
-bool MetaspaceObj::is_shared() const {
-  return MetaspaceShared::is_in_shared_space(this);
-}
-
 bool MetaspaceObj::is_metaspace_object() const {
   return Metaspace::contains((void*)this);
 }
--- a/src/hotspot/share/memory/allocation.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/memory/allocation.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -227,9 +227,23 @@
 class MetaspaceClosure;
 
 class MetaspaceObj {
+  friend class MetaspaceShared;
+  // When CDS is enabled, all shared metaspace objects are mapped
+  // into a single contiguous memory block, so we can use these
+  // two pointers to quickly determine if something is in the
+  // shared metaspace.
+  //
+  // When CDS is not enabled, both pointers are set to NULL.
+  static void* _shared_metaspace_base; // (inclusive) low address
+  static void* _shared_metaspace_top;  // (exclusive) high address
+
  public:
   bool is_metaspace_object() const;
-  bool is_shared() const;
+  bool is_shared() const {
+    // If no shared metaspace regions are mapped, _shared_metaspace_{base,top} will
+    // both be NULL and all values of p will be rejected quickly.
+    return (((void*)this) < _shared_metaspace_top && ((void*)this) >= _shared_metaspace_base);
+  }
   void print_address_on(outputStream* st) const;  // nonvirtual address printing
 
 #define METASPACE_OBJ_TYPES_DO(f) \
--- a/src/hotspot/share/memory/filemap.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/memory/filemap.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -659,7 +659,7 @@
 static const char* shared_region_name[] = { "MiscData", "ReadWrite", "ReadOnly", "MiscCode", "OptionalData",
                                             "String1", "String2", "OpenArchive1", "OpenArchive2" };
 
-char* FileMapInfo::map_region(int i) {
+char* FileMapInfo::map_region(int i, char** top_ret) {
   assert(!MetaspaceShared::is_heap_region(i), "sanity");
   struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
   size_t used = si->_used;
@@ -686,6 +686,12 @@
   MemTracker::record_virtual_memory_type((address)base, mtClassShared);
 #endif
 
+
+  if (!verify_region_checksum(i)) {
+    return NULL;
+  }
+
+  *top_ret = base + size;
   return base;
 }
 
@@ -1040,27 +1046,6 @@
   return status;
 }
 
-// The following method is provided to see whether a given pointer
-// falls in the mapped shared metadata space.
-// Param:
-// p, The given pointer
-// Return:
-// True if the p is within the mapped shared space, otherwise, false.
-bool FileMapInfo::is_in_shared_space(const void* p) {
-  for (int i = 0; i < MetaspaceShared::num_non_heap_spaces; i++) {
-    char *base;
-    if (_header->_space[i]._used == 0) {
-      continue;
-    }
-    base = _header->region_addr(i);
-    if (p >= base && p < base + _header->_space[i]._used) {
-      return true;
-    }
-  }
-
-  return false;
-}
-
 // Check if a given address is within one of the shared regions
 bool FileMapInfo::is_in_shared_region(const void* p, int idx) {
   assert(idx == MetaspaceShared::ro ||
--- a/src/hotspot/share/memory/filemap.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/memory/filemap.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -248,7 +248,7 @@
                                     int first_region_id, int max_num_regions);
   void  write_bytes(const void* buffer, int count);
   void  write_bytes_aligned(const void* buffer, int count);
-  char* map_region(int i);
+  char* map_region(int i, char** top_ret);
   void  map_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
   void  fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
   void  unmap_region(int i);
@@ -265,8 +265,6 @@
   static void fail_stop(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
   static void fail_continue(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
 
-  // Return true if given address is in the mapped shared space.
-  bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);
   bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false);
   void print_shared_spaces() NOT_CDS_RETURN;
 
--- a/src/hotspot/share/memory/metaspace.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/memory/metaspace.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -4070,7 +4070,7 @@
 }
 
 bool Metaspace::contains(const void* ptr) {
-  if (UseSharedSpaces && MetaspaceShared::is_in_shared_space(ptr)) {
+  if (MetaspaceShared::is_in_shared_metaspace(ptr)) {
     return true;
   }
   return contains_non_shared(ptr);
--- a/src/hotspot/share/memory/metaspaceShared.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/memory/metaspaceShared.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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,7 @@
 }
 
 bool MetaspaceShared::is_valid_shared_method(const Method* m) {
-  assert(is_in_shared_space(m), "must be");
+  assert(is_in_shared_metaspace(m), "must be");
   return CppVtableCloner<Method>::is_valid_shared_object(m);
 }
 
@@ -1819,11 +1819,6 @@
   bool reading() const { return true; }
 };
 
-// Return true if given address is in the mapped shared space.
-bool MetaspaceShared::is_in_shared_space(const void* p) {
-  return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_space(p);
-}
-
 // Return true if given address is in the misc data region
 bool MetaspaceShared::is_in_shared_region(const void* p, int idx) {
   return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_region(p, idx);
@@ -1857,35 +1852,46 @@
 
   assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces");
 
-  char* _ro_base = NULL;
-  char* _rw_base = NULL;
-  char* _mc_base = NULL;
-  char* _md_base = NULL;
-  char* _od_base = NULL;
+  char* ro_base = NULL; char* ro_top;
+  char* rw_base = NULL; char* rw_top;
+  char* mc_base = NULL; char* mc_top;
+  char* md_base = NULL; char* md_top;
+  char* od_base = NULL; char* od_top;
 
   // Map each shared region
-  if ((_mc_base = mapinfo->map_region(mc)) != NULL &&
-      mapinfo->verify_region_checksum(mc) &&
-      (_rw_base = mapinfo->map_region(rw)) != NULL &&
-      mapinfo->verify_region_checksum(rw) &&
-      (_ro_base = mapinfo->map_region(ro)) != NULL &&
-      mapinfo->verify_region_checksum(ro) &&
-      (_md_base = mapinfo->map_region(md)) != NULL &&
-      mapinfo->verify_region_checksum(md) &&
-      (_od_base = mapinfo->map_region(od)) != NULL &&
-      mapinfo->verify_region_checksum(od) &&
+  if ((mc_base = mapinfo->map_region(mc, &mc_top)) != NULL &&
+      (rw_base = mapinfo->map_region(rw, &rw_top)) != NULL &&
+      (ro_base = mapinfo->map_region(ro, &ro_top)) != NULL &&
+      (md_base = mapinfo->map_region(md, &md_top)) != NULL &&
+      (od_base = mapinfo->map_region(od, &od_top)) != NULL &&
       (image_alignment == (size_t)os::vm_allocation_granularity()) &&
       mapinfo->validate_classpath_entry_table()) {
-    // Success (no need to do anything)
+    // Success -- set up MetaspaceObj::_shared_metaspace_{base,top} for
+    // fast checking in MetaspaceShared::is_in_shared_metaspace() and
+    // MetaspaceObj::is_shared().
+    //
+    // We require that mc->rw->ro->md->od to be laid out consecutively, with no
+    // gaps between them. That way, we can ensure that the OS won't be able to
+    // allocate any new memory spaces inside _shared_metaspace_{base,top}, which
+    // would mess up the simple comparision in MetaspaceShared::is_in_shared_metaspace().
+    assert(mc_base < ro_base && mc_base < rw_base && mc_base < md_base && mc_base < od_base, "must be");
+    assert(od_top  > ro_top  && od_top  > rw_top  && od_top  > md_top  && od_top  > mc_top , "must be");
+    assert(mc_top == rw_base, "must be");
+    assert(rw_top == ro_base, "must be");
+    assert(ro_top == md_base, "must be");
+    assert(md_top == od_base, "must be");
+
+    MetaspaceObj::_shared_metaspace_base = (void*)mc_base;
+    MetaspaceObj::_shared_metaspace_top  = (void*)od_top;
     return true;
   } else {
     // If there was a failure in mapping any of the spaces, unmap the ones
     // that succeeded
-    if (_ro_base != NULL) mapinfo->unmap_region(ro);
-    if (_rw_base != NULL) mapinfo->unmap_region(rw);
-    if (_mc_base != NULL) mapinfo->unmap_region(mc);
-    if (_md_base != NULL) mapinfo->unmap_region(md);
-    if (_od_base != NULL) mapinfo->unmap_region(od);
+    if (ro_base != NULL) mapinfo->unmap_region(ro);
+    if (rw_base != NULL) mapinfo->unmap_region(rw);
+    if (mc_base != NULL) mapinfo->unmap_region(mc);
+    if (md_base != NULL) mapinfo->unmap_region(md);
+    if (od_base != NULL) mapinfo->unmap_region(od);
 #ifndef _WINDOWS
     // Release the entire mapped region
     shared_rs.release();
--- a/src/hotspot/share/memory/metaspaceShared.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/memory/metaspaceShared.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -164,8 +164,13 @@
   static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false);
   static void initialize_shared_spaces() NOT_CDS_RETURN;
 
-  // Return true if given address is in the mapped shared space.
-  static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);
+  // Return true if given address is in the shared metaspace regions (i.e., excluding any
+  // mapped shared heap regions.)
+  static bool is_in_shared_metaspace(const void* p) {
+    // If no shared metaspace regions are mapped, MetaspceObj::_shared_metaspace_{base,top} will
+    // both be NULL and all values of p will be rejected quickly.
+    return (p < MetaspaceObj::_shared_metaspace_top && p >= MetaspaceObj::_shared_metaspace_base);
+  }
 
   // Return true if given address is in the shared region corresponding to the idx
   static bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false);
--- a/src/hotspot/share/oops/access.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/oops/access.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -200,12 +200,14 @@
 const DecoratorSet IN_HEAP_ARRAY      = UCONST64(1) << 19;
 const DecoratorSet IN_ROOT            = UCONST64(1) << 20;
 const DecoratorSet IN_CONCURRENT_ROOT = UCONST64(1) << 21;
+const DecoratorSet IN_ARCHIVE_ROOT    = UCONST64(1) << 22;
 const DecoratorSet IN_DECORATOR_MASK  = IN_HEAP | IN_HEAP_ARRAY |
-                                        IN_ROOT | IN_CONCURRENT_ROOT;
+                                        IN_ROOT | IN_CONCURRENT_ROOT |
+                                        IN_ARCHIVE_ROOT;
 
 // == Value Decorators ==
 // * OOP_NOT_NULL: This property can make certain barriers faster such as compressing oops.
-const DecoratorSet OOP_NOT_NULL       = UCONST64(1) << 22;
+const DecoratorSet OOP_NOT_NULL       = UCONST64(1) << 23;
 const DecoratorSet OOP_DECORATOR_MASK = OOP_NOT_NULL;
 
 // == Arraycopy Decorators ==
--- a/src/hotspot/share/oops/access.inline.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/oops/access.inline.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -788,7 +788,9 @@
       ((IN_HEAP_ARRAY & barrier_strength_default) != 0 ? IN_HEAP : INTERNAL_EMPTY);
     static const DecoratorSet conc_root_is_root = heap_array_is_in_heap |
       ((IN_CONCURRENT_ROOT & heap_array_is_in_heap) != 0 ? IN_ROOT : INTERNAL_EMPTY);
-    static const DecoratorSet value = conc_root_is_root | BT_BUILDTIME_DECORATORS;
+    static const DecoratorSet archive_root_is_root = conc_root_is_root |
+      ((IN_ARCHIVE_ROOT & conc_root_is_root) != 0 ? IN_ROOT : INTERNAL_EMPTY);
+    static const DecoratorSet value = archive_root_is_root | BT_BUILDTIME_DECORATORS;
   };
 
   // Step 2: Reduce types.
@@ -1082,7 +1084,8 @@
     (location_decorators ^ IN_ROOT) == 0 ||
     (location_decorators ^ IN_HEAP) == 0 ||
     (location_decorators ^ (IN_HEAP | IN_HEAP_ARRAY)) == 0 ||
-    (location_decorators ^ (IN_ROOT | IN_CONCURRENT_ROOT)) == 0
+    (location_decorators ^ (IN_ROOT | IN_CONCURRENT_ROOT)) == 0 ||
+    (location_decorators ^ (IN_ROOT | IN_ARCHIVE_ROOT)) == 0
   ));
 }
 
--- a/src/hotspot/share/oops/constantPool.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/oops/constantPool.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -49,9 +49,6 @@
 #include "runtime/signature.hpp"
 #include "runtime/vframe.hpp"
 #include "utilities/copy.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc/g1/g1SATBCardTableModRefBS.hpp"
-#endif // INCLUDE_ALL_GCS
 
 ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, TRAPS) {
   Array<u1>* tags = MetadataFactory::new_array<u1>(loader_data, length, 0, CHECK_NULL);
@@ -333,13 +330,8 @@
     if (MetaspaceShared::open_archive_heap_region_mapped() &&
         _cache->archived_references() != NULL) {
       oop archived = _cache->archived_references();
-      // Make sure GC knows the cached object is now live. This is necessary after
-      // initial GC marking and during concurrent marking as strong roots are only
-      // scanned during initial marking (at the start of the GC marking).
-      assert(UseG1GC, "Requires G1 GC");
-      G1SATBCardTableModRefBS::enqueue(archived);
       // Create handle for the archived resolved reference array object
-      Handle refs_handle(THREAD, (oop)archived);
+      Handle refs_handle(THREAD, archived);
       set_resolved_references(loader_data->add_handle(refs_handle));
     } else
 #endif
--- a/src/hotspot/share/oops/cpCache.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/oops/cpCache.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -33,6 +33,7 @@
 #include "memory/metaspaceClosure.hpp"
 #include "memory/resourceArea.hpp"
 #include "memory/universe.inline.hpp"
+#include "oops/access.inline.hpp"
 #include "oops/cpCache.hpp"
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
@@ -741,13 +742,16 @@
 
 #if INCLUDE_CDS_JAVA_HEAP
 oop ConstantPoolCache::archived_references() {
-  assert(UseSharedSpaces, "UseSharedSpaces expected.");
-  return oopDesc::decode_heap_oop(_archived_references);
+  // Loading an archive root forces the oop to become strongly reachable.
+  // For example, if it is loaded during concurrent marking in a SATB
+  // collector, it will be enqueued to the SATB queue, effectively
+  // shading the previously white object gray.
+  return RootAccess<IN_ARCHIVE_ROOT>::oop_load(&_archived_references);
 }
 
 void ConstantPoolCache::set_archived_references(oop o) {
   assert(DumpSharedSpaces, "called only during runtime");
-  _archived_references = oopDesc::encode_heap_oop(o);
+  RootAccess<IN_ARCHIVE_ROOT>::oop_store(&_archived_references, o);
 }
 #endif
 
--- a/src/hotspot/share/oops/instanceKlass.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/oops/instanceKlass.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -2229,7 +2229,7 @@
   }
 
   // deallocate the cached class file
-  if (_cached_class_file != NULL && !MetaspaceShared::is_in_shared_space(_cached_class_file)) {
+  if (_cached_class_file != NULL && !MetaspaceShared::is_in_shared_metaspace(_cached_class_file)) {
     os::free(_cached_class_file);
     _cached_class_file = NULL;
   }
@@ -3732,7 +3732,7 @@
 
 #if INCLUDE_JVMTI
 JvmtiCachedClassFileData* InstanceKlass::get_cached_class_file() {
-  if (MetaspaceShared::is_in_shared_space(_cached_class_file)) {
+  if (MetaspaceShared::is_in_shared_metaspace(_cached_class_file)) {
     // Ignore the archived class stream data
     return NULL;
   } else {
@@ -3754,7 +3754,7 @@
     return _cached_class_file;
   } else {
     assert(this->is_shared(), "class should be shared");
-    if (MetaspaceShared::is_in_shared_space(_cached_class_file)) {
+    if (MetaspaceShared::is_in_shared_metaspace(_cached_class_file)) {
       return _cached_class_file;
     } else {
       return NULL;
--- a/src/hotspot/share/oops/klassVtable.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/oops/klassVtable.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -1040,7 +1040,7 @@
   if (m == NULL) return;
 
 #ifdef ASSERT
-  if (MetaspaceShared::is_in_shared_space((void*)&_method) &&
+  if (MetaspaceShared::is_in_shared_metaspace((void*)&_method) &&
      !MetaspaceShared::remapped_readwrite()) {
     // At runtime initialize_itable is rerun as part of link_class_impl()
     // for a shared class loaded by the non-boot loader.
--- a/src/hotspot/share/oops/method.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/oops/method.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -2180,7 +2180,7 @@
   } else if ((intptr_t(this) & (wordSize-1)) != 0) {
     // Quick sanity check on pointer.
     return false;
-  } else if (MetaspaceShared::is_in_shared_space(this)) {
+  } else if (is_shared()) {
     return MetaspaceShared::is_valid_shared_method(this);
   } else if (Metaspace::contains_non_shared(this)) {
     return has_method_vptr((const void*)this);
--- a/src/hotspot/share/opto/mathexactnode.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/opto/mathexactnode.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -117,23 +117,33 @@
   return SubHelper<OverflowSubLNode>::will_overflow(v1, v2);
 }
 
-bool OverflowMulLNode::will_overflow(jlong val1, jlong val2) const {
-    jlong result = val1 * val2;
-    jlong ax = (val1 < 0 ? -val1 : val1);
-    jlong ay = (val2 < 0 ? -val2 : val2);
+bool OverflowMulLNode::is_overflow(jlong val1, jlong val2) {
+    // x * { 0, 1 } will never overflow. Even for x = min_jlong
+    if (val1 == 0 || val2 == 0 || val1 == 1 || val2 == 1) {
+      return false;
+    }
 
-    bool overflow = false;
-    if ((ax | ay) & CONST64(0xFFFFFFFF00000000)) {
-      // potential overflow if any bit in upper 32 bits are set
-      if ((val1 == min_jlong && val2 == -1) || (val2 == min_jlong && val1 == -1)) {
-        // -1 * Long.MIN_VALUE will overflow
-        overflow = true;
-      } else if (val2 != 0 && (result / val2 != val1)) {
-        overflow = true;
-      }
+    // x * min_jlong for x not in { 0, 1 } overflows
+    // even -1 as -1 * min_jlong is an overflow
+    if (val1 == min_jlong || val2 == min_jlong) {
+      return true;
     }
 
-    return overflow;
+    // if (x * y) / y == x there is no overflow
+    //
+    // the multiplication here is done as unsigned to avoid undefined behaviour which
+    // can be used by the compiler to assume that the check further down (result / val2 != val1)
+    // is always false and breaks the overflow check
+    julong v1 = (julong) val1;
+    julong v2 = (julong) val2;
+    julong tmp = v1 * v2;
+    jlong result = (jlong) tmp;
+
+    if (result / val2 != val1) {
+      return true;
+    }
+
+    return false;
 }
 
 bool OverflowAddINode::can_overflow(const Type* t1, const Type* t2) const {
--- a/src/hotspot/share/opto/mathexactnode.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/opto/mathexactnode.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -129,8 +129,10 @@
   OverflowMulLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {}
   virtual int Opcode() const;
 
-  virtual bool will_overflow(jlong v1, jlong v2) const;
+  virtual bool will_overflow(jlong v1, jlong v2) const { return is_overflow(v1, v2); }
   virtual bool can_overflow(const Type* t1, const Type* t2) const;
+
+  static bool is_overflow(jlong v1, jlong v2);
 };
 
 #endif
--- a/src/hotspot/share/prims/jni.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/prims/jni.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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.
  * Copyright (c) 2012 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -862,16 +862,10 @@
 
   HOTSPOT_JNI_GETOBJECTREFTYPE_ENTRY(env, obj);
 
-  jobjectRefType ret;
-  if (JNIHandles::is_local_handle(thread, obj) ||
-      JNIHandles::is_frame_handle(thread, obj))
-    ret = JNILocalRefType;
-  else if (JNIHandles::is_global_handle(obj))
-    ret = JNIGlobalRefType;
-  else if (JNIHandles::is_weak_global_handle(obj))
-    ret = JNIWeakGlobalRefType;
-  else
-    ret = JNIInvalidRefType;
+  jobjectRefType ret = JNIInvalidRefType;
+  if (obj != NULL) {
+    ret = JNIHandles::handle_type(thread, obj);
+  }
 
   HOTSPOT_JNI_GETOBJECTREFTYPE_RETURN((void *) ret);
   return ret;
--- a/src/hotspot/share/prims/jniCheck.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/prims/jniCheck.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -435,10 +435,7 @@
 }
 
 oop jniCheck::validate_handle(JavaThread* thr, jobject obj) {
-  if (JNIHandles::is_frame_handle(thr, obj) ||
-      JNIHandles::is_local_handle(thr, obj) ||
-      JNIHandles::is_global_handle(obj) ||
-      JNIHandles::is_weak_global_handle(obj)) {
+  if ((obj != NULL) && (JNIHandles::handle_type(thr, obj) != JNIInvalidRefType)) {
     ASSERT_OOPS_ALLOWED;
     return JNIHandles::resolve_external_guard(obj);
   }
--- a/src/hotspot/share/prims/jvmti.xml	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/prims/jvmti.xml	Tue Jan 30 16:41:40 2018 +0100
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <?xml-stylesheet type="text/xsl" href="jvmti.xsl"?>
 <!--
- Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2002, 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
@@ -333,6 +333,8 @@
 
    <!ELEMENT p EMPTY>
 
+   <!ELEMENT blockquote ANY>
+
    <!ELEMENT dl  (dt|dd)+>
 
    <!ELEMENT dd  ANY>
@@ -344,10 +346,10 @@
    <!ELEMENT tr  (td|th)*>
 
    <!ELEMENT td  ANY>
-   <!ATTLIST td align (left|right|center) "center">
+   <!ATTLIST td class CDATA #IMPLIED>
 
    <!ELEMENT th  ANY>
-   <!ATTLIST th align (left|right|center) "center">
+   <!ATTLIST th class CDATA #IMPLIED>
 
    <!ELEMENT ul  (li)+>
    <!ATTLIST ul type (disc|circle|square) "disc">
@@ -3527,15 +3529,15 @@
             returned in the order: q, r.
             An instance of class <code>C1</code> will have the
             following field indices:
-            <dl><dd><table>
+            <blockquote><table>
               <tr>
-                <td>
+                <td class="centered">
                   a
                 </td>
-                <td>
+                <td class="centered">
                   2
                 </td>
-                <td align="left">
+                <td>
                   The count of the fields in the interfaces
                   implemented by <code>C1</code> is two (<i>n</i>=2):
                   <code>p</code> of <code>I0</code>
@@ -3543,30 +3545,30 @@
                 </td>
               </tr>
               <tr>
-                <td>
+                <td class="centered">
                   b
                 </td>
+                <td class="centered">
+                  3
+                </td>
                 <td>
-                  3
-                </td>
-                <td align="left">
                   the subsequent index.
                 </td>
               </tr>
-            </table></dd></dl>
+            </table></blockquote>
             The class <code>C1</code> will have the same field indices.
             <p/>
             An instance of class <code>C2</code> will have the
             following field indices:
-            <dl><dd><table>
+            <blockquote><table>
               <tr>
-                <td>
+                <td class="centered">
                   a
                 </td>
-                <td>
+                <td class="centered">
                   3
                 </td>
-                <td align="left">
+                <td>
                   The count of the fields in the interfaces
                   implemented by <code>C2</code> is three (<i>n</i>=3):
                   <code>p</code> of <code>I0</code>,
@@ -3576,39 +3578,39 @@
                 </td>
               </tr>
               <tr>
-                <td>
+                <td class="centered">
                   b
                 </td>
+                <td class="centered">
+                  4
+                </td>
                 <td>
-                  4
-                </td>
-                <td align="left">
                   the subsequent index to "a".
                 </td>
               </tr>
               <tr>
-                <td>
+                <td class="centered">
                   q
                 </td>
+                <td class="centered">
+                  5
+                </td>
                 <td>
-                  5
-                </td>
-                <td align="left">
                   the subsequent index to "b".
                 </td>
               </tr>
               <tr>
-                <td>
+                <td class="centered">
                   r
                 </td>
+                <td class="centered">
+                  6
+                </td>
                 <td>
-                  6
-                </td>
-                <td align="left">
                   the subsequent index to "q".
                 </td>
               </tr>
-            </table></dd></dl>
+            </table></blockquote>
             The class <code>C2</code> will have the same field indices.
             Note that a field may have a different index depending on the
             object that is viewing it -- for example field "a" above.
@@ -3617,21 +3619,21 @@
             <p/>
             The interface <code>I1</code> will have the
             following field indices:
-            <dl><dd><table>
+            <blockquote><table>
               <tr>
-                <td>
+                <td class="centered">
                   x
                 </td>
-                <td>
+                <td class="centered">
                   1
                 </td>
-                <td align="left">
+                <td>
                   The count of the fields in the superinterfaces
                   of <code>I1</code> is one (<i>n</i>=1):
                   <code>p</code> of <code>I0</code>.
                 </td>
               </tr>
-            </table></dd></dl>
+            </table></blockquote>
 	  </description>
 	</field>
       </typedef>
@@ -4486,61 +4488,61 @@
             </th>
           </tr>
           <tr>
-            <th align="left">
+            <th class="leftAligned">
               the
               <datalink id="jvmtiHeapVisitControl">Heap Visit Control Flags</datalink>
               returned by <functionlink id="jvmtiHeapReferenceCallback"/>
             </th>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>, since visits are controlled
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>, since visits are controlled
             </td>
           </tr>
           <tr>
-            <th align="left">
+            <th class="leftAligned">
               <fieldlink id="array_primitive_value_callback" struct="jvmtiHeapCallbacks"/>
               in <paramlink id="callbacks"/> set
             </th>
-            <td>
+            <td class="centered">
               No
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
-            <td>
+            <td class="centered">
               No
             </td>
           </tr>
           <tr>
-            <th align="left">
+            <th class="leftAligned">
               <paramlink id="heap_filter"/>
             </th>
-            <td>
+            <td class="centered">
               No
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
           </tr>
           <tr>
-            <th align="left">
+            <th class="leftAligned">
               <paramlink id="klass"/>
             </th>
-            <td>
+            <td class="centered">
               No
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
           </tr>
@@ -4678,61 +4680,61 @@
             </th>
           </tr>
           <tr>
-            <th align="left">
+            <th class="leftAligned">
               the
               <datalink id="jvmtiHeapVisitControl">Heap Visit Control Flags</datalink>
               returned by <functionlink id="jvmtiHeapIterationCallback"/>
             </th>
-            <td>
+            <td class="centered">
               No<br/>(unless they abort the iteration)
             </td>
-            <td>
+            <td class="centered">
               No<br/>(unless they abort the iteration)
             </td>
-            <td>
+            <td class="centered">
               No<br/>(unless they abort the iteration)
             </td>
           </tr>
           <tr>
-            <th align="left">
+            <th class="leftAligned">
               <fieldlink id="array_primitive_value_callback" struct="jvmtiHeapCallbacks"/>
               in <paramlink id="callbacks"/> set
             </th>
-            <td>
+            <td class="centered">
               No
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
-            <td>
+            <td class="centered">
               No
             </td>
           </tr>
           <tr>
-            <th align="left">
+            <th class="leftAligned">
               <paramlink id="heap_filter"/>
             </th>
-            <td>
+            <td class="centered">
               No
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
           </tr>
           <tr>
-            <th align="left">
+            <th class="leftAligned">
               <paramlink id="klass"/>
             </th>
-            <td>
+            <td class="centered">
               No
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
-            <td>
+            <td class="centered">
               <b>Yes</b>
             </td>
           </tr>
--- a/src/hotspot/share/prims/jvmti.xsl	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/prims/jvmti.xsl	Tue Jan 30 16:41:40 2018 +0100
@@ -1,6 +1,6 @@
 <?xml version="1.0"?> 
 <!--
- Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2002, 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
@@ -28,31 +28,40 @@
 <xsl:import href="jvmtiLib.xsl"/>
 
 <xsl:output method="html" indent="yes" 
-  doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" 
-  doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>
+  doctype-system="about:legacy-compat"/>
 
 <xsl:param name="development"></xsl:param>
 
 <xsl:template match="specification">
-  <html>
+  <html lang="en">
   <head>
         <title>
           <xsl:value-of select="@label"/>
           <xsl:text> </xsl:text>
           <xsl:call-template name="showversion"/>
         </title>
-        <style type="text/css">
-          td.tableHeader {font-size: larger}
+        <style>
+          .centered { text-align: center; }
+          .leftAligned { text-align: left; }
+          .rightAligned { text-align: right; }
+          .bgLight { background-color: #EEEEFF; }
+          .bgDark { background-color: #CCCCFF}
+          th { background-color: #EEEEFF; }
+          td.tableHeader {font-size: larger; text-align:center; }
+          div.sep { height: 10px; }
+          div.callbackCtnr { margin: 0 5%; }
+          hr { border-width:0; color:gray; background-color:gray; }
+          hr.thick { height:3px; }
+          hr.thin { height:1px; }
+          table.bordered { border: 1px solid gray; border-spacing: 0; border-collapse: separate; }
+          table.bordered td, table.bordered th { padding: 3px; border: 1px solid black; }
+          table.wide { width: 100%; }
         </style>
   </head>
   <body>
-    <table border="0" width="100%">
-      <tr>
-        <td align="center">
-          <xsl:apply-templates select="title"/>
-        </td>
-      </tr>
-    </table>
+    <div class="centered">
+      <xsl:apply-templates select="title"/>
+    </div>
     <ul>
       <li>
         <a href="#SpecificationIntro"><b>Introduction</b></a>
@@ -158,9 +167,9 @@
       </li>
     </ul>
     <!-- end table of contents, begin body -->
-    <p/>
-    <hr noshade="noshade" size="3"/>
-    <p/>
+    <div class="sep"/>
+    <hr class="thick"/>
+    <div class="sep"/>
     <p id="SpecificationIntro"/>
       <xsl:apply-templates select="intro"/>
     <p id="FunctionSection"/>
@@ -172,8 +181,8 @@
     <p id="EventSection"/>
       <xsl:apply-templates select="eventsection"/>
     <p id="ConstantIndex"/>
-      <p/>
-      <hr noshade="noshade" size="3"/>
+      <div class="sep"/>
+      <hr class="thick"/>
       <h2>
         Constant Index
       </h2>
@@ -184,8 +193,8 @@
       </blockquote>
     <xsl:if test="$development = 'Show'">
       <p id="SpecificationIssues"/>
-      <p/>
-      <hr noshade="noshade" size="3"/>
+      <div class="sep"/>
+      <hr class="thick"/>
       <h2>
         <xsl:value-of select="issuessection/@label"/>
       </h2>
@@ -209,8 +218,8 @@
 </xsl:template>
 
 <xsl:template match="functionsection">
-  <p/>
-  <hr noshade="noshade" size="3"/>
+  <div class="sep"/>
+  <hr class="thick"/>
   <h2>
     <xsl:value-of select="@label"/>
   </h2>
@@ -255,8 +264,8 @@
       <xsl:value-of select="@id"/>
     </xsl:attribute>
   </p>
-  <hr noshade="noshade" size="3"/>
-  <h2 align="center"><xsl:value-of select="@label"/></h2>
+  <hr class="thick"/>
+  <h2 class="centered"><xsl:value-of select="@label"/></h2>
   <xsl:value-of select="@label"/> functions:
   <ul>
     <xsl:apply-templates select="function[count(@hide)=0]" mode="index"/>
@@ -307,12 +316,12 @@
     </ul>    
   </xsl:if>
   <xsl:apply-templates select="intro|typedef|uniontypedef|capabilitiestypedef"/>
-  <p/>
+  <div class="sep"/>
   <xsl:apply-templates select="function[count(@hide)=0]|callback" mode="body"/>
 </xsl:template>
 
 <xsl:template match="function" mode="body">
-  <hr noshade="noshade" width="100%" size="1">
+  <hr class="thin">
     <xsl:attribute name="id">
       <xsl:value-of select="@id"/>
     </xsl:attribute>
@@ -336,8 +345,8 @@
 </xsl:template>
 
 <xsl:template match="function" mode="generalinfo">
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
-    <tr bgcolor="#EEEEFF">
+  <table class="bordered wide">
+     <tr class="bgLight">
       <td >
         <a href="#jvmtiPhase">Phase</a>
       </td>
@@ -369,8 +378,8 @@
 </xsl:template>
 
 <xsl:template match="event" mode="generalinfo">
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
-    <tr bgcolor="#EEEEFF">
+  <table class="bordered wide">
+    <tr class="bgLight">
       <td >
         <a href="#jvmtiPhase">Phase</a>
       </td>
@@ -500,13 +509,13 @@
 
 
 <xsl:template match="callback" mode="body">
-  <hr noshade="noshade" width="100%" size="1">
+  <hr class="thin">
     <xsl:attribute name="id">
       <xsl:value-of select="@id"/>
     </xsl:attribute>
   </hr>
   <xsl:apply-templates select="synopsis" mode="body"/>
-  <table cellpadding="0" cellspacing="0" border="0" width="90%" align="center"><tr><td>
+  <div class="callbackCtnr">
   <blockquote>
     <pre>
       <xsl:text>typedef </xsl:text>
@@ -528,7 +537,7 @@
   </blockquote>
   <xsl:apply-templates select="description"/>
   <xsl:apply-templates select="parameters" mode="body"/>
-</td></tr></table>
+  </div>
 </xsl:template>
 
 <xsl:template match="synopsis" mode="body">
@@ -536,8 +545,8 @@
 </xsl:template>
 
 <xsl:template match="eventsection">
-  <p/>
-  <hr noshade="noshade" size="3"/>
+  <div class="sep"/>
+  <hr class="thick"/>
   <h2>
     <xsl:value-of select="@label"/>
   </h2>
@@ -557,8 +566,8 @@
 </xsl:text>
   </pre>
   </blockquote>
-  <p/>
-  <hr noshade="noshade" width="100%" size="1"/>
+  <div class="sep"/>
+  <hr class="thin"/>
   <h3 id="EventIndex">Event Index</h3>
   <ul>
     <xsl:apply-templates select="event" mode="index">
@@ -585,9 +594,9 @@
       <xsl:value-of select="@id"/>
     </xsl:attribute>
   </p>
-  <hr noshade="noshade" size="3"/>
+  <hr class="thick"/>
   <h2><xsl:value-of select="@label"/></h2>
-  <p/>
+  <div class="sep"/>
   <blockquote>
     <xsl:apply-templates select="typedef" mode="code"/>
     <pre>
@@ -660,13 +669,13 @@
 </xsl:template>
 
 <xsl:template match="typedef|uniontypedef" mode="justbody">
-    <table border="1" cellpadding="3" cellspacing="0" width="100%">
-      <tr bgcolor="#CCCCFF">
-        <td colspan="3" align="center" class="tableHeader">
+    <table class="bordered wide">
+      <tr class="bgDark">
+        <td colspan="3" class="tableHeader">
           <code><xsl:value-of select="@id"/></code> - <xsl:value-of select="@label"/>
         </td>
       </tr>
-      <tr bgcolor="#EEEEFF">
+      <tr class="bgLight">
         <td>
           Field
         </td>
@@ -691,18 +700,18 @@
 </xsl:template>
 
 <xsl:template match="capabilitiestypedef" mode="justbody">
-    <table border="1" cellpadding="3" cellspacing="0" width="100%">
-      <tr bgcolor="#CCCCFF">
-        <td colspan="3" align="center" class="tableHeader">
+    <table class="bordered wide">
+      <tr class="bgDark">
+        <td colspan="3" class="tableHeader">
           <code><xsl:value-of select="@id"/></code> - <xsl:value-of select="@label"/>
         </td>
       </tr>
-      <tr bgcolor="#EEEEFF">
+      <tr class="bgLight">
         <td colspan="3">
           All types are <code>unsigned int : 1</code>
         </td>
       </tr>
-      <tr bgcolor="#EEEEFF">
+      <tr class="bgLight">
         <td>
           Field
         </td>
@@ -772,11 +781,9 @@
       </code>
     </td>
     <td>
-      <a>
-        <xsl:attribute name="name">
-          <xsl:value-of select="../@id"/>.<xsl:value-of select="@id"/>
-        </xsl:attribute>
-      </a>
+      <xsl:attribute name="id">
+        <xsl:value-of select="../@id"/>.<xsl:value-of select="@id"/>
+      </xsl:attribute>
       <xsl:apply-templates select="description" mode="brief"/>
     </td>
     <td>
@@ -806,14 +813,12 @@
 
 <xsl:template match="constants">
   <blockquote>
-  <a>
-    <xsl:attribute name="name">
-      <xsl:value-of select="@id"/>
-    </xsl:attribute>
-  </a>
-    <table border="1" cellpadding="3" cellspacing="0">
-      <tr bgcolor="#CCCCFF">
-        <td colspan="3" align="center" class="tableHeader">
+    <table class="bordered">
+      <xsl:attribute name="id">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+      <tr class="bgDark">
+        <td colspan="3" class="tableHeader">
             <xsl:value-of select="@label"/>
             <xsl:if test="@kind='enum'">
               <xsl:text> (</xsl:text>
@@ -824,7 +829,7 @@
             </xsl:if>
         </td>
       </tr>
-      <tr bgcolor="#EEEEFF">
+      <tr class="bgLight">
         <td>
           Constant
         </td>
@@ -861,7 +866,7 @@
         <xsl:value-of select="@id"/>
       </code>
     </td>
-    <td align="right">
+    <td class="rightAligned">
       <xsl:value-of select="@num"/>
     </td>
     <td>
@@ -876,13 +881,13 @@
       <xsl:value-of select="@id"/>
     </xsl:attribute>
   </p>
-    <table border="1" cellpadding="3" cellspacing="0" width="100%">
-      <tr bgcolor="#CCCCFF">
-        <td colspan="2" align="center" class="tableHeader">
+    <table class="bordered wide">
+      <tr class="bgDark">
+        <td colspan="2" class="tableHeader">
           <xsl:value-of select="@label"/>
         </td>
       </tr>
-      <tr bgcolor="#EEEEFF">
+      <tr class="bgLight">
         <td>
           Type
         </td>
@@ -949,7 +954,7 @@
 
 <xsl:template match="description">
   <xsl:apply-templates/>
-  <p/>
+  <div class="sep"/>
 </xsl:template>
 
 <xsl:template match="description" mode="brief">
@@ -1064,14 +1069,14 @@
 </xsl:template>
 
 <xsl:template match="parameters" mode="body">
-  <p/>
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
-    <tr bgcolor="#CCCCFF">
-      <td colspan="3" align="center" class="tableHeader">
+  <div class="sep"/>
+  <table class="bordered wide">
+    <tr class="bgDark">
+      <td colspan="3" class="tableHeader">
         Parameters
       </td>
     </tr>
-    <tr bgcolor="#EEEEFF">
+    <tr class="bgLight">
       <td>
         Name
       </td>
@@ -1111,17 +1116,28 @@
 </xsl:template>
 
 <xsl:template match="capabilities">
-  <p/>
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
-    <tr bgcolor="#CCCCFF">
-      <td colspan="2" align="center" class="tableHeader">
+  <div class="sep"/>
+  <!--
+  W3C Validator reports error if all cells has colspan==2.
+  The workaround is to detect the case and set colspan = 1 for all cells
+  which fills the entire row.
+  -->
+  <xsl:variable name="fullRowColspan">
+    <xsl:choose>
+      <xsl:when test="count(required)!=0 or count(capability)!=0">2</xsl:when>
+      <xsl:otherwise>1</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <table class="bordered wide">
+    <tr class="bgDark">
+      <td colspan="{$fullRowColspan}" class="tableHeader">
         Capabilities
       </td>
     </tr>
     <xsl:choose>
       <xsl:when test="count(required)=0">
         <tr>
-          <td colspan="2">
+          <td colspan="{$fullRowColspan}">
             <b>Required Functionality</b>
           </td>
         </tr>
@@ -1152,7 +1168,7 @@
             </xsl:choose>
           </td>
         </tr>
-        <tr bgcolor="#EEEEFF">
+        <tr class="bgLight">
           <td >
             Capability
           </td>
@@ -1164,13 +1180,13 @@
       </xsl:otherwise>
     </xsl:choose>
     <xsl:if test="count(capability)!=0">
-      <tr bgcolor="#CCCCFF">
-        <td colspan="2" align="center">
+      <tr class="bgDark">
+        <td colspan="{$fullRowColspan}" class="centered">
           Optional Features
         </td>
       </tr>
       <xsl:if test="count(required)=0">
-        <tr bgcolor="#EEEEFF">
+        <tr class="bgLight">
           <td >
             Capability
           </td>
@@ -1185,10 +1201,10 @@
 </xsl:template>
 
 <xsl:template match="eventcapabilities">
-  <p/>
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
-    <tr bgcolor="#CCCCFF">
-      <td colspan="2" align="center" class="tableHeader">
+  <div class="sep"/>
+  <table class="bordered wide">
+    <tr class="bgDark">
+      <td colspan="2" class="tableHeader">
         Capabilities
       </td>
     </tr>
@@ -1197,12 +1213,12 @@
         <b>Required Functionality</b>
       </td>
     </tr>
-    <tr bgcolor="#CCCCFF">
-      <td colspan="2" align="center">
+    <tr class="bgDark">
+      <td colspan="2" class="centered">
         Event Enabling Capabilities
       </td>
     </tr>
-    <tr bgcolor="#EEEEFF">
+    <tr class="bgLight">
       <td >
         Capability
       </td>
@@ -1275,10 +1291,21 @@
     <xsl:apply-templates select="errors/error" mode="haserrors"/>
     <xsl:apply-templates select="parameters/param" mode="haserrors"/>
   </xsl:variable>
-  <p/>
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
-    <tr bgcolor="#CCCCFF">
-      <td colspan="2" align="center" class="tableHeader">
+  <div class="sep"/>
+  <!--
+  W3C Validator reports error if all cells has colspan==2.
+  The workaround is to detect the case and set colspan = 1 for all cells
+  which fills the entire row.
+  -->
+  <xsl:variable name="fullRowColspan">
+    <xsl:choose>
+      <xsl:when test="contains($haserrors,'yes')">2</xsl:when>
+      <xsl:otherwise>1</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <table class="bordered wide">
+    <tr class="bgDark">
+      <td colspan="{$fullRowColspan}" class="tableHeader">
         Errors
       </td>
     </tr>
@@ -1291,7 +1318,7 @@
             or one of the following errors
           </td>
         </tr>
-        <tr bgcolor="#EEEEFF">
+        <tr class="bgLight">
           <td>
             Error
           </td>
@@ -1305,7 +1332,7 @@
       </xsl:when>
       <xsl:otherwise>
         <tr>
-          <td colspan="2">
+          <td colspan="{$fullRowColspan}">
             This function returns a 
             <a href="#universal-error">universal error</a>
           </td>
@@ -1673,36 +1700,35 @@
 </xsl:template>
 
 <xsl:template match="errorsection">
-  <p/>
-  <hr noshade="noshade" size="3"/>
+  <div class="sep"/>
+  <hr class="thick"/>
   <h2>
     Errors
   </h2>
-  <p/>
+  <div class="sep"/>
   <xsl:apply-templates select="intro"/>
-  <p/>
+  <div class="sep"/>
   <xsl:apply-templates select="errorcategory"/>
-  <p/>
+  <div class="sep"/>
 </xsl:template>
 
 <xsl:template match="datasection">
-  <p/>
-  <hr noshade="noshade" size="3"/>
+  <div class="sep"/>
+  <hr class="thick"/>
   <h2>
     Data Types
   </h2>
-  <p/>
+  <div class="sep"/>
   <xsl:apply-templates select="intro"/>
   <xsl:apply-templates select="basetypes"/>
-  <p/>
-  <a name="StructureTypeDefinitions"></a>
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
-    <tr bgcolor="#CCCCFF">
-      <td colspan="2" align="center" class="tableHeader">
+  <div class="sep"/>
+  <table id="StructureTypeDefinitions" class="bordered wide">
+    <tr class="bgDark">
+      <td colspan="2" class="tableHeader">
         Structure Type Definitions
       </td>
     </tr>
-    <tr bgcolor="#EEEEFF">
+    <tr class="bgLight">
       <td>
         Type
       </td>
@@ -1714,15 +1740,14 @@
       <xsl:sort select="@id"/>
     </xsl:apply-templates>
   </table>
-  <p/>
-  <a name="FunctionTypeDefinitions"></a>
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
-    <tr bgcolor="#CCCCFF">
-      <td colspan="2" align="center" class="tableHeader">
+  <div class="sep"/>
+  <table id="FunctionTypeDefinitions" class="bordered wide">
+    <tr class="bgDark">
+      <td colspan="2" class="tableHeader">
         Function Type Definitions
       </td>
     </tr>
-    <tr bgcolor="#EEEEFF">
+    <tr class="bgLight">
       <td>
         Type
       </td>
@@ -1734,15 +1759,14 @@
       <xsl:sort select="@id"/>
     </xsl:apply-templates>
   </table>
-  <p/>
-  <a name="EnumerationDefinitions"></a>
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
-    <tr bgcolor="#CCCCFF">
-      <td colspan="2" align="center" class="tableHeader">
+  <div class="sep"/>
+  <table id="EnumerationDefinitions" class="bordered wide">
+    <tr class="bgDark">
+      <td colspan="2" class="tableHeader">
         Enumeration Definitions
       </td>
     </tr>
-    <tr bgcolor="#EEEEFF">
+    <tr class="bgLight">
       <td>
         Type
       </td>
@@ -1754,15 +1778,14 @@
       <xsl:sort select="@id"/>
     </xsl:apply-templates>
   </table>
-  <p/>
-  <a name="FunctionTable"></a>
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
-    <tr bgcolor="#CCCCFF">
-      <td colspan="3" align="center" class="tableHeader">
+  <div class="sep"/>
+  <table id="FunctionTable" class="bordered wide">
+    <tr class="bgDark">
+      <td colspan="3" class="tableHeader">
         Function Table Layout
       </td>
     </tr>
-    <tr bgcolor="#EEEEFF">
+    <tr class="bgLight">
       <td>
         Position
       </td>
@@ -1778,7 +1801,7 @@
       <xsl:with-param name="index" select="1"/>
     </xsl:call-template>
   </table>
-  <p/>
+  <div class="sep"/>
 </xsl:template>
 
 
@@ -1787,7 +1810,7 @@
   <xsl:param name="index"/>
   <xsl:variable name="thisFunction" select="$funcs[@num=$index]"/>
   <tr>
-    <td align="right">
+    <td class="rightAligned">
       <xsl:number value="$index" format="  1"/>
     </td>
     <xsl:choose>
@@ -1852,11 +1875,11 @@
     <xsl:value-of select="@label"/>
   </h3>
   <xsl:apply-templates select="intro"/>
-  <p/>
+  <div class="sep"/>
   <dl>
     <xsl:apply-templates select="errorid"/>
   </dl>
-  <p/>
+  <div class="sep"/>
 </xsl:template>
 
 <xsl:template match="errorid">
@@ -1870,20 +1893,21 @@
   </dt>
   <dd>
     <xsl:apply-templates/>
-    <p/>
+    <div class="sep"/>
   </dd>
 </xsl:template>
 
 <xsl:template match="changehistory">
-    <p/><hr noshade="noshade" size="3"/>
+    <div class="sep"/>
+    <hr class="thick"/>
     <h2>Change History</h2>
     Last update: <xsl:value-of select="@update"/><br/>
     Version: <xsl:call-template name="showversion"/>
-    <p/>
+    <div class="sep"/>
     <xsl:apply-templates select="intro"/>
-    <p/>
-    <table border="1" cellpadding="3" cellspacing="0" width="100%">
-      <tr bgcolor="#EEEEFF">
+    <div class="sep"/>
+    <table class="bordered wide">
+      <tr class="bgLight">
         <td>
           <b>Version</b><br/>
           <b>Date</b>
@@ -1980,7 +2004,7 @@
 
 
 <xsl:template match="table">
-  <table border="1" cellpadding="3" cellspacing="0" width="100%">
+  <table class="bordered wide">
     <xsl:apply-templates/>
   </table>
 </xsl:template>
@@ -1993,18 +2017,22 @@
 
 <xsl:template match="td">
   <td>
-    <xsl:attribute name="align">
-      <xsl:value-of select="@align"/>
-    </xsl:attribute>
+    <xsl:if test="@class">
+      <xsl:attribute name="class">
+        <xsl:value-of select="@class"/>
+      </xsl:attribute>
+    </xsl:if>
     <xsl:apply-templates/>
   </td>
 </xsl:template>
 
 <xsl:template match="th">
-  <th bgcolor="#EEEEFF">
-    <xsl:attribute name="align">
-      <xsl:value-of select="@align"/>
-    </xsl:attribute>
+  <th>
+    <xsl:if test="@class">
+      <xsl:attribute name="class">
+        <xsl:value-of select="@class"/>
+      </xsl:attribute>
+    </xsl:if>
     <xsl:apply-templates/>
   </th>
 </xsl:template>
@@ -2027,10 +2055,14 @@
   </dd>
 </xsl:template>
 
+<xsl:template match="blockquote">
+  <blockquote>
+    <xsl:apply-templates/>
+  </blockquote>
+</xsl:template>
+
 <xsl:template match="p">
-  <p>
-    <xsl:apply-templates/>
-  </p>
+  <div class="sep"/>
 </xsl:template>
 
 <xsl:template match="br">
@@ -2041,7 +2073,7 @@
 
 <xsl:template match="ul">
   <ul>
-    <xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
+    <xsl:attribute name="style">list-style-type:<xsl:value-of select="@type"/></xsl:attribute>
     <xsl:apply-templates/>
   </ul>
 </xsl:template>
--- a/src/hotspot/share/prims/jvmtiLib.xsl	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/prims/jvmtiLib.xsl	Tue Jan 30 16:41:40 2018 +0100
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
 
- Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2002, 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
@@ -184,12 +184,12 @@
 </xsl:template>
 
 <xsl:template match="ptrtype" mode="funcdescription">
-  <p/>
+  <div class="sep"/>
   <xsl:apply-templates select="nullok" mode="funcdescription"/>
 </xsl:template>
 
 <xsl:template match="inptr" mode="funcdescription">
-  <p/>
+  <div class="sep"/>
   <xsl:variable name="child" select="child::*[position()=1]"/>
   <xsl:text>Agent passes in a pointer</xsl:text>
   <xsl:if test="name($child)!='void'">
@@ -203,7 +203,7 @@
 </xsl:template>
 
 <xsl:template match="inbuf" mode="funcdescription">
-  <p/>
+  <div class="sep"/>
   <xsl:variable name="child" select="child::*[position()=1]"/>
   <xsl:text>Agent passes in </xsl:text>
   <xsl:choose>
@@ -228,7 +228,7 @@
 </xsl:template>
 
 <xsl:template match="outptr" mode="funcdescription">
-  <p/>
+  <div class="sep"/>
   <xsl:text>Agent passes a pointer to a </xsl:text>
   <code>
     <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 
@@ -244,7 +244,7 @@
 </xsl:template>
 
 <xsl:template match="allocbuf" mode="funcdescription">
-  <p/>
+  <div class="sep"/>
   <xsl:text>Agent passes a pointer to a </xsl:text>
   <code>
     <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 
@@ -284,7 +284,7 @@
 </xsl:template>
 
 <xsl:template match="allocallocbuf" mode="funcdescription">
-  <p/>
+  <div class="sep"/>
   <xsl:text>Agent passes a pointer to a </xsl:text>
   <code>
     <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 
@@ -328,7 +328,7 @@
 </xsl:template>
 
 <xsl:template match="outbuf" mode="funcdescription">
-  <p/>
+  <div class="sep"/>
   <xsl:text>Agent passes an array </xsl:text>
   <xsl:if test="count(@incount)=1 and @incount!=''">
     <xsl:text>large enough to hold </xsl:text>
@@ -358,7 +358,7 @@
 </xsl:template>
 
 <xsl:template match="agentbuf" mode="funcdescription">
-  <p/>
+  <div class="sep"/>
   <xsl:apply-templates select="nullok" mode="funcdescription"/>
   <xsl:apply-templates select="child::*[position()=1]" mode="returndescription">
     <xsl:with-param name="plural" select="'plural'"/>
--- a/src/hotspot/share/prims/jvmtiTagMap.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/prims/jvmtiTagMap.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -2582,9 +2582,9 @@
       return;
     }
 
-    // ignore null or deleted handles
     oop o = *obj_p;
-    if (o == NULL || o == JNIHandles::deleted_handle()) {
+    // ignore null
+    if (o == NULL) {
       return;
     }
 
@@ -2641,9 +2641,9 @@
       return;
     }
 
-    // ignore null or deleted handles
     oop o = *obj_p;
-    if (o == NULL || o == JNIHandles::deleted_handle()) {
+    // ignore null
+    if (o == NULL) {
       return;
     }
 
--- a/src/hotspot/share/prims/whitebox.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/prims/whitebox.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -1702,7 +1702,7 @@
 WB_END
 
 WB_ENTRY(jboolean, WB_IsSharedClass(JNIEnv* env, jobject wb, jclass clazz))
-  return (jboolean)MetaspaceShared::is_in_shared_space(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
+  return (jboolean)MetaspaceShared::is_in_shared_metaspace(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
 WB_END
 
 WB_ENTRY(jboolean, WB_AreSharedStringsIgnored(JNIEnv* env))
--- a/src/hotspot/share/runtime/arguments.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/arguments.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -513,7 +513,6 @@
   { "SafepointSpinBeforeYield",     JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
   { "DeferThrSuspendLoopCount",     JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
   { "DeferPollingPageLoopCount",    JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
-  { "UseCGroupMemoryLimitForHeap",  JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::jdk(11) },
   { "IgnoreUnverifiableClassesDuringDump", JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
   { "CheckEndorsedAndExtDirs",      JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 
@@ -1860,32 +1859,6 @@
     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
                             : (julong)MaxRAM;
 
-  // Experimental support for CGroup memory limits
-  if (UseCGroupMemoryLimitForHeap) {
-    // This is a rough indicator that a CGroup limit may be in force
-    // for this process
-    const char* lim_file = "/sys/fs/cgroup/memory/memory.limit_in_bytes";
-    FILE *fp = fopen(lim_file, "r");
-    if (fp != NULL) {
-      julong cgroup_max = 0;
-      int ret = fscanf(fp, JULONG_FORMAT, &cgroup_max);
-      if (ret == 1 && cgroup_max > 0) {
-        // If unlimited, cgroup_max will be a very large, but unspecified
-        // value, so use initial phys_mem as a limit
-        log_info(gc, heap)("Setting phys_mem to the min of cgroup limit ("
-                           JULONG_FORMAT "MB) and initial phys_mem ("
-                           JULONG_FORMAT "MB)", cgroup_max/M, phys_mem/M);
-        phys_mem = MIN2(cgroup_max, phys_mem);
-      } else {
-        warning("Unable to read/parse cgroup memory limit from %s: %s",
-                lim_file, errno != 0 ? strerror(errno) : "unknown error");
-      }
-      fclose(fp);
-    } else {
-      warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
-    }
-  }
-
   // Convert deprecated flags
   if (FLAG_IS_DEFAULT(MaxRAMPercentage) &&
       !FLAG_IS_DEFAULT(MaxRAMFraction))
@@ -3489,27 +3462,6 @@
   }
 #endif
 
-  // If we are running in a headless jre, force java.awt.headless property
-  // to be true unless the property has already been set.
-  // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
-  if (os::is_headless_jre()) {
-    const char* headless = Arguments::get_property("java.awt.headless");
-    if (headless == NULL) {
-      const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
-      if (headless_env == NULL) {
-        if (!add_property("java.awt.headless=true")) {
-          return JNI_ENOMEM;
-        }
-      } else {
-        char buffer[256];
-        jio_snprintf(buffer, sizeof(buffer), "java.awt.headless=%s", headless_env);
-        if (!add_property(buffer)) {
-          return JNI_ENOMEM;
-        }
-      }
-    }
-  }
-
   if (!check_vm_args_consistency()) {
     return JNI_ERR;
   }
--- a/src/hotspot/share/runtime/arguments.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/arguments.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -373,13 +373,7 @@
 
   // Tiered
   static void set_tiered_flags();
-  // CMS/ParNew garbage collectors
-  static void set_parnew_gc_flags();
-  static void set_cms_and_parnew_gc_flags();
-  // UseParallel[Old]GC
-  static void set_parallel_gc_flags();
-  // Garbage-First (UseG1GC)
-  static void set_g1_gc_flags();
+
   // GC ergonomics
   static void set_conservative_max_heap_alignment();
   static void set_use_compressed_oops();
--- a/src/hotspot/share/runtime/globals.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/globals.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -78,21 +78,21 @@
 
 define_pd_global(intx, CompileThreshold,             0);
 
-define_pd_global(intx, OnStackReplacePercentage,     0);
-define_pd_global(bool, ResizeTLAB,                   false);
-define_pd_global(intx, FreqInlineSize,               0);
+define_pd_global(intx,   OnStackReplacePercentage,   0);
+define_pd_global(bool,   ResizeTLAB,                 false);
+define_pd_global(intx,   FreqInlineSize,             0);
 define_pd_global(size_t, NewSizeThreadIncrease,      4*K);
-define_pd_global(intx, InlineClassNatives,           true);
-define_pd_global(intx, InlineUnsafeOps,              true);
-define_pd_global(intx, InitialCodeCacheSize,         160*K);
-define_pd_global(intx, ReservedCodeCacheSize,        32*M);
-define_pd_global(intx, NonProfiledCodeHeapSize,      0);
-define_pd_global(intx, ProfiledCodeHeapSize,         0);
-define_pd_global(intx, NonNMethodCodeHeapSize,       32*M);
+define_pd_global(bool,   InlineClassNatives,         true);
+define_pd_global(bool,   InlineUnsafeOps,            true);
+define_pd_global(uintx,  InitialCodeCacheSize,       160*K);
+define_pd_global(uintx,  ReservedCodeCacheSize,      32*M);
+define_pd_global(uintx,  NonProfiledCodeHeapSize,    0);
+define_pd_global(uintx,  ProfiledCodeHeapSize,       0);
+define_pd_global(uintx,  NonNMethodCodeHeapSize,     32*M);
 
-define_pd_global(intx, CodeCacheExpansionSize,       32*K);
-define_pd_global(intx, CodeCacheMinBlockLength,      1);
-define_pd_global(intx, CodeCacheMinimumUseSpace,     200*K);
+define_pd_global(uintx,  CodeCacheExpansionSize,     32*K);
+define_pd_global(uintx,  CodeCacheMinBlockLength,    1);
+define_pd_global(uintx,  CodeCacheMinimumUseSpace,   200*K);
 define_pd_global(size_t, MetaspaceSize,              ScaleForWordSize(4*M));
 define_pd_global(bool, NeverActAsServerClassMachine, true);
 define_pd_global(uint64_t,MaxRAM,                    1ULL*G);
@@ -2042,11 +2042,6 @@
           "MaxRAM * MaxRAMPercentage / 100")                                \
           range(0, max_uintx)                                               \
                                                                             \
-  experimental(bool, UseCGroupMemoryLimitForHeap, false,                    \
-          "Use CGroup memory limit as physical memory limit for heap "      \
-          "sizing"                                                          \
-          "Deprecated, replaced by container support")                      \
-                                                                            \
   product(uintx, MaxRAMFraction, 4,                                         \
           "Maximum fraction (1/n) of real memory used for maximum heap "    \
           "size. "                                                          \
--- a/src/hotspot/share/runtime/jniHandles.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/jniHandles.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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 "classfile/systemDictionary.hpp"
+#include "gc/shared/oopStorage.inline.hpp"
 #include "logging/log.hpp"
 #include "memory/iterator.hpp"
 #include "oops/oop.inline.hpp"
@@ -32,13 +32,13 @@
 #include "runtime/thread.inline.hpp"
 #include "trace/traceMacros.hpp"
 #include "utilities/align.hpp"
+#include "utilities/debug.hpp"
 #if INCLUDE_ALL_GCS
 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
 #endif
 
-JNIHandleBlock* JNIHandles::_global_handles       = NULL;
-JNIHandleBlock* JNIHandles::_weak_global_handles  = NULL;
-oop             JNIHandles::_deleted_handle       = NULL;
+OopStorage* JNIHandles::_global_handles = NULL;
+OopStorage* JNIHandles::_weak_global_handles = NULL;
 
 
 jobject JNIHandles::make_local(oop obj) {
@@ -46,7 +46,7 @@
     return NULL;                // ignore null handles
   } else {
     Thread* thread = Thread::current();
-    assert(Universe::heap()->is_in_reserved(obj), "sanity check");
+    assert(oopDesc::is_oop(obj), "not an oop");
     assert(!current_thread_in_native(), "must not be in native");
     return thread->active_handles()->allocate_handle(obj);
   }
@@ -59,7 +59,7 @@
   if (obj == NULL) {
     return NULL;                // ignore null handles
   } else {
-    assert(Universe::heap()->is_in_reserved(obj), "sanity check");
+    assert(oopDesc::is_oop(obj), "not an oop");
     assert(thread->is_Java_thread(), "not a Java thread");
     assert(!current_thread_in_native(), "must not be in native");
     return thread->active_handles()->allocate_handle(obj);
@@ -72,22 +72,39 @@
     return NULL;                // ignore null handles
   } else {
     JavaThread* thread = JavaThread::thread_from_jni_environment(env);
-    assert(Universe::heap()->is_in_reserved(obj), "sanity check");
+    assert(oopDesc::is_oop(obj), "not an oop");
     assert(!current_thread_in_native(), "must not be in native");
     return thread->active_handles()->allocate_handle(obj);
   }
 }
 
 
-jobject JNIHandles::make_global(Handle obj) {
+static void report_handle_allocation_failure(AllocFailType alloc_failmode,
+                                             const char* handle_kind) {
+  if (alloc_failmode == AllocFailStrategy::EXIT_OOM) {
+    // Fake size value, since we don't know the min allocation size here.
+    vm_exit_out_of_memory(sizeof(oop), OOM_MALLOC_ERROR,
+                          "Cannot create %s JNI handle", handle_kind);
+  } else {
+    assert(alloc_failmode == AllocFailStrategy::RETURN_NULL, "invariant");
+  }
+}
+
+jobject JNIHandles::make_global(Handle obj, AllocFailType alloc_failmode) {
   assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC");
   assert(!current_thread_in_native(), "must not be in native");
   jobject res = NULL;
   if (!obj.is_null()) {
     // ignore null handles
-    MutexLocker ml(JNIGlobalHandle_lock);
-    assert(Universe::heap()->is_in_reserved(obj()), "sanity check");
-    res = _global_handles->allocate_handle(obj());
+    assert(oopDesc::is_oop(obj()), "not an oop");
+    oop* ptr = _global_handles->allocate();
+    // Return NULL on allocation failure.
+    if (ptr != NULL) {
+      *ptr = obj();
+      res = reinterpret_cast<jobject>(ptr);
+    } else {
+      report_handle_allocation_failure(alloc_failmode, "global");
+    }
   } else {
     CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
   }
@@ -96,32 +113,32 @@
 }
 
 
-jobject JNIHandles::make_weak_global(Handle obj) {
+jobject JNIHandles::make_weak_global(Handle obj, AllocFailType alloc_failmode) {
   assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC");
   assert(!current_thread_in_native(), "must not be in native");
   jobject res = NULL;
   if (!obj.is_null()) {
     // ignore null handles
-    {
-      MutexLocker ml(JNIGlobalHandle_lock);
-      assert(Universe::heap()->is_in_reserved(obj()), "sanity check");
-      res = _weak_global_handles->allocate_handle(obj());
+    assert(oopDesc::is_oop(obj()), "not an oop");
+    oop* ptr = _weak_global_handles->allocate();
+    // Return NULL on allocation failure.
+    if (ptr != NULL) {
+      *ptr = obj();
+      char* tptr = reinterpret_cast<char*>(ptr) + weak_tag_value;
+      res = reinterpret_cast<jobject>(tptr);
+    } else {
+      report_handle_allocation_failure(alloc_failmode, "weak global");
     }
-    // Add weak tag.
-    assert(is_aligned(res, weak_tag_alignment), "invariant");
-    char* tptr = reinterpret_cast<char*>(res) + weak_tag_value;
-    res = reinterpret_cast<jobject>(tptr);
   } else {
     CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
   }
   return res;
 }
 
-template<bool external_guard>
 oop JNIHandles::resolve_jweak(jweak handle) {
+  assert(handle != NULL, "precondition");
   assert(is_jweak(handle), "precondition");
   oop result = jweak_ref(handle);
-  result = guard_value<external_guard>(result);
 #if INCLUDE_ALL_GCS
   if (result != NULL && UseG1GC) {
     G1SATBCardTableModRefBS::enqueue(result);
@@ -130,31 +147,31 @@
   return result;
 }
 
-template oop JNIHandles::resolve_jweak<true>(jweak);
-template oop JNIHandles::resolve_jweak<false>(jweak);
-
 bool JNIHandles::is_global_weak_cleared(jweak handle) {
+  assert(handle != NULL, "precondition");
   assert(is_jweak(handle), "not a weak handle");
-  return guard_value<false>(jweak_ref(handle)) == NULL;
+  return jweak_ref(handle) == NULL;
 }
 
 void JNIHandles::destroy_global(jobject handle) {
   if (handle != NULL) {
-    assert(is_global_handle(handle), "Invalid delete of global JNI handle");
-    jobject_ref(handle) = deleted_handle();
+    assert(!is_jweak(handle), "wrong method for detroying jweak");
+    jobject_ref(handle) = NULL;
+    _global_handles->release(&jobject_ref(handle));
   }
 }
 
 
 void JNIHandles::destroy_weak_global(jobject handle) {
   if (handle != NULL) {
-    jweak_ref(handle) = deleted_handle();
+    assert(is_jweak(handle), "JNI handle not jweak");
+    jweak_ref(handle) = NULL;
+    _weak_global_handles->release(&jweak_ref(handle));
   }
 }
 
 
 void JNIHandles::oops_do(OopClosure* f) {
-  f->do_oop(&_deleted_handle);
   _global_handles->oops_do(f);
 }
 
@@ -165,23 +182,60 @@
 
 
 void JNIHandles::weak_oops_do(OopClosure* f) {
-  AlwaysTrueClosure always_true;
-  weak_oops_do(&always_true, f);
+  _weak_global_handles->weak_oops_do(f);
 }
 
 
 void JNIHandles::initialize() {
-  _global_handles      = JNIHandleBlock::allocate_block();
-  _weak_global_handles = JNIHandleBlock::allocate_block();
-  EXCEPTION_MARK;
-  // We will never reach the CATCH below since Exceptions::_throw will cause
-  // the VM to exit if an exception is thrown during initialization
-  Klass* k      = SystemDictionary::Object_klass();
-  _deleted_handle = InstanceKlass::cast(k)->allocate_instance(CATCH);
+  _global_handles = new OopStorage("JNI Global",
+                                   JNIGlobalAlloc_lock,
+                                   JNIGlobalActive_lock);
+  _weak_global_handles = new OopStorage("JNI Weak",
+                                        JNIWeakAlloc_lock,
+                                        JNIWeakActive_lock);
+}
+
+
+inline bool is_storage_handle(const OopStorage* storage, const oop* ptr) {
+  return storage->allocation_status(ptr) == OopStorage::ALLOCATED_ENTRY;
+}
+
+
+jobjectRefType JNIHandles::handle_type(Thread* thread, jobject handle) {
+  assert(handle != NULL, "precondition");
+  jobjectRefType result = JNIInvalidRefType;
+  if (is_jweak(handle)) {
+    if (is_storage_handle(_weak_global_handles, &jweak_ref(handle))) {
+      result = JNIWeakGlobalRefType;
+    }
+  } else {
+    switch (_global_handles->allocation_status(&jobject_ref(handle))) {
+    case OopStorage::ALLOCATED_ENTRY:
+      result = JNIGlobalRefType;
+      break;
+
+    case OopStorage::UNALLOCATED_ENTRY:
+      break;                    // Invalid global handle
+
+    case OopStorage::INVALID_ENTRY:
+      // Not in global storage.  Might be a local handle.
+      if (is_local_handle(thread, handle) ||
+          (thread->is_Java_thread() &&
+           is_frame_handle((JavaThread*)thread, handle))) {
+        result = JNILocalRefType;
+      }
+      break;
+
+    default:
+      ShouldNotReachHere();
+    }
+  }
+  return result;
 }
 
 
 bool JNIHandles::is_local_handle(Thread* thread, jobject handle) {
+  assert(handle != NULL, "precondition");
   JNIHandleBlock* block = thread->active_handles();
 
   // Look back past possible native calls to jni_PushLocalFrame.
@@ -199,47 +253,36 @@
 // We easily can't isolate any particular stack frame the handle might
 // come from, so we'll check the whole stack.
 
-bool JNIHandles::is_frame_handle(JavaThread* thr, jobject obj) {
+bool JNIHandles::is_frame_handle(JavaThread* thr, jobject handle) {
+  assert(handle != NULL, "precondition");
   // If there is no java frame, then this must be top level code, such
   // as the java command executable, in which case, this type of handle
   // is not permitted.
   return (thr->has_last_Java_frame() &&
-         (void*)obj < (void*)thr->stack_base() &&
-         (void*)obj >= (void*)thr->last_Java_sp());
+         (void*)handle < (void*)thr->stack_base() &&
+         (void*)handle >= (void*)thr->last_Java_sp());
 }
 
 
 bool JNIHandles::is_global_handle(jobject handle) {
-  return _global_handles->chain_contains(handle);
+  assert(handle != NULL, "precondition");
+  return !is_jweak(handle) && is_storage_handle(_global_handles, &jobject_ref(handle));
 }
 
 
 bool JNIHandles::is_weak_global_handle(jobject handle) {
-  return _weak_global_handles->chain_contains(handle);
-}
-
-long JNIHandles::global_handle_memory_usage() {
-  return _global_handles->memory_usage();
-}
-
-long JNIHandles::weak_global_handle_memory_usage() {
-  return _weak_global_handles->memory_usage();
+  assert(handle != NULL, "precondition");
+  return is_jweak(handle) && is_storage_handle(_weak_global_handles, &jweak_ref(handle));
 }
 
+size_t JNIHandles::global_handle_memory_usage() {
+  return _global_handles->total_memory_usage();
+}
 
-class CountHandleClosure: public OopClosure {
-private:
-  int _count;
-public:
-  CountHandleClosure(): _count(0) {}
-  virtual void do_oop(oop* ooph) {
-    if (*ooph != JNIHandles::deleted_handle()) {
-      _count++;
-    }
-  }
-  virtual void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
-  int count() { return _count; }
-};
+size_t JNIHandles::weak_global_handle_memory_usage() {
+  return _weak_global_handles->total_memory_usage();
+}
+
 
 // We assume this is called at a safepoint: no lock is needed.
 void JNIHandles::print_on(outputStream* st) {
@@ -247,16 +290,14 @@
   assert(_global_handles != NULL && _weak_global_handles != NULL,
          "JNIHandles not initialized");
 
-  CountHandleClosure global_handle_count;
-  oops_do(&global_handle_count);
-  weak_oops_do(&global_handle_count);
-
-  st->print_cr("JNI global references: %d", global_handle_count.count());
+  st->print_cr("JNI global refs: " SIZE_FORMAT ", weak refs: " SIZE_FORMAT,
+               _global_handles->allocation_count(),
+               _weak_global_handles->allocation_count());
   st->cr();
   st->flush();
 }
 
-class VerifyHandleClosure: public OopClosure {
+class VerifyJNIHandles: public OopClosure {
 public:
   virtual void do_oop(oop* root) {
     (*root)->verify();
@@ -265,7 +306,7 @@
 };
 
 void JNIHandles::verify() {
-  VerifyHandleClosure verify_handle;
+  VerifyJNIHandles verify_handle;
 
   oops_do(&verify_handle);
   weak_oops_do(&verify_handle);
@@ -419,34 +460,6 @@
 }
 
 
-void JNIHandleBlock::weak_oops_do(BoolObjectClosure* is_alive,
-                                  OopClosure* f) {
-  for (JNIHandleBlock* current = this; current != NULL; current = current->_next) {
-    assert(current->pop_frame_link() == NULL,
-      "blocks holding weak global JNI handles should not have pop frame link set");
-    for (int index = 0; index < current->_top; index++) {
-      oop* root = &(current->_handles)[index];
-      oop value = *root;
-      // traverse heap pointers only, not deleted handles or free list pointers
-      if (value != NULL && Universe::heap()->is_in_reserved(value)) {
-        if (is_alive->do_object_b(value)) {
-          // The weakly referenced object is alive, update pointer
-          f->do_oop(root);
-        } else {
-          // The weakly referenced object is not alive, clear the reference by storing NULL
-          log_develop_trace(gc, ref)("Clearing JNI weak reference (" INTPTR_FORMAT ")", p2i(root));
-          *root = NULL;
-        }
-      }
-    }
-    // the next handle block is valid only if current block is full
-    if (current->_top < block_size_in_oops) {
-      break;
-    }
-  }
-}
-
-
 jobject JNIHandleBlock::allocate_handle(oop obj) {
   assert(Universe::heap()->is_in_reserved(obj), "sanity check");
   if (_top == 0) {
@@ -514,15 +527,6 @@
   return allocate_handle(obj);  // retry
 }
 
-void JNIHandleBlock::release_handle(jobject h) {
-  if (h != NULL) {
-    assert(chain_contains(h), "does not contain the JNI handle");
-    // Mark the handle as deleted, allocate will reuse it
-    *((oop*)h) = JNIHandles::deleted_handle();
-  }
-}
-
-
 void JNIHandleBlock::rebuild_free_list() {
   assert(_allocate_before_rebuild == 0 && _free_list == NULL, "just checking");
   int free = 0;
@@ -530,7 +534,7 @@
   for (JNIHandleBlock* current = this; current != NULL; current = current->_next) {
     for (int index = 0; index < current->_top; index++) {
       oop* handle = &(current->_handles)[index];
-      if (*handle ==  JNIHandles::deleted_handle()) {
+      if (*handle == NULL) {
         // this handle was cleared out by a delete call, reuse it
         *handle = (oop) _free_list;
         _free_list = handle;
@@ -568,30 +572,45 @@
 }
 
 
-int JNIHandleBlock::length() const {
-  int result = 1;
+size_t JNIHandleBlock::length() const {
+  size_t result = 1;
   for (JNIHandleBlock* current = _next; current != NULL; current = current->_next) {
     result++;
   }
   return result;
 }
 
+class CountJNIHandleClosure: public OopClosure {
+private:
+  int _count;
+public:
+  CountJNIHandleClosure(): _count(0) {}
+  virtual void do_oop(oop* ooph) { _count++; }
+  virtual void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
+  int count() { return _count; }
+};
+
 const size_t JNIHandleBlock::get_number_of_live_handles() {
-  CountHandleClosure counter;
+  CountJNIHandleClosure counter;
   oops_do(&counter);
   return counter.count();
 }
 
 // This method is not thread-safe, i.e., must be called while holding a lock on the
 // structure.
-long JNIHandleBlock::memory_usage() const {
+size_t JNIHandleBlock::memory_usage() const {
   return length() * sizeof(JNIHandleBlock);
 }
 
 
 #ifndef PRODUCT
 
+bool JNIHandles::is_local_handle(jobject handle) {
+  return JNIHandleBlock::any_contains(handle);
+}
+
 bool JNIHandleBlock::any_contains(jobject handle) {
+  assert(handle != NULL, "precondition");
   for (JNIHandleBlock* current = _block_list; current != NULL; current = current->_block_list_link) {
     if (current->contains(handle)) {
       return true;
--- a/src/hotspot/share/runtime/jniHandles.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/jniHandles.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -29,6 +29,7 @@
 #include "runtime/handles.hpp"
 
 class JNIHandleBlock;
+class OopStorage;
 
 
 // Interface for creating and resolving local/global JNI handles
@@ -36,17 +37,15 @@
 class JNIHandles : AllStatic {
   friend class VMStructs;
  private:
-  static JNIHandleBlock* _global_handles;             // First global handle block
-  static JNIHandleBlock* _weak_global_handles;        // First weak global handle block
-  static oop _deleted_handle;                         // Sentinel marking deleted handles
+  static OopStorage* _global_handles;
+  static OopStorage* _weak_global_handles;
 
   inline static bool is_jweak(jobject handle);
   inline static oop& jobject_ref(jobject handle); // NOT jweak!
   inline static oop& jweak_ref(jobject handle);
 
-  template<bool external_guard> inline static oop guard_value(oop value);
   template<bool external_guard> inline static oop resolve_impl(jobject handle);
-  template<bool external_guard> static oop resolve_jweak(jweak handle);
+  static oop resolve_jweak(jweak handle);
 
   // This method is not inlined in order to avoid circular includes between
   // this header file and thread.hpp.
@@ -80,19 +79,14 @@
   inline static void destroy_local(jobject handle);
 
   // Global handles
-  static jobject make_global(Handle  obj);
+  static jobject make_global(Handle  obj, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
   static void destroy_global(jobject handle);
 
   // Weak global handles
-  static jobject make_weak_global(Handle obj);
+  static jobject make_weak_global(Handle obj, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
   static void destroy_weak_global(jobject handle);
   static bool is_global_weak_cleared(jweak handle); // Test jweak without resolution
 
-  // Sentinel marking deleted handles in block. Note that we cannot store NULL as
-  // the sentinel, since clearing weak global JNI refs are done by storing NULL in
-  // the handle. The handle may not be reused before destroy_weak_global is called.
-  static oop deleted_handle()   { return _deleted_handle; }
-
   // Initialization
   static void initialize();
 
@@ -100,12 +94,21 @@
   static void print_on(outputStream* st);
   static void print()           { print_on(tty); }
   static void verify();
+  // The category predicates all require handle != NULL.
   static bool is_local_handle(Thread* thread, jobject handle);
-  static bool is_frame_handle(JavaThread* thr, jobject obj);
+  static bool is_frame_handle(JavaThread* thread, jobject handle);
   static bool is_global_handle(jobject handle);
   static bool is_weak_global_handle(jobject handle);
-  static long global_handle_memory_usage();
-  static long weak_global_handle_memory_usage();
+  static size_t global_handle_memory_usage();
+  static size_t weak_global_handle_memory_usage();
+
+#ifndef PRODUCT
+  // Is handle from any local block of any thread?
+  static bool is_local_handle(jobject handle);
+#endif
+
+  // precondition: handle != NULL.
+  static jobjectRefType handle_type(Thread* thread, jobject handle);
 
   // Garbage collection support(global handles only, local handles are traversed from thread)
   // Traversal of regular global handles
@@ -164,9 +167,6 @@
   // Handle allocation
   jobject allocate_handle(oop obj);
 
-  // Release Handle
-  void release_handle(jobject);
-
   // Block allocation and block free list management
   static JNIHandleBlock* allocate_block(Thread* thread = NULL);
   static void release_block(JNIHandleBlock* block, Thread* thread = NULL);
@@ -179,10 +179,8 @@
   static int top_offset_in_bytes()                { return offset_of(JNIHandleBlock, _top); }
 
   // Garbage collection support
-  // Traversal of regular handles
+  // Traversal of handles
   void oops_do(OopClosure* f);
-  // Traversal of weak handles. Unreachable oops are cleared.
-  void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f);
 
   // Checked JNI support
   void set_planned_capacity(size_t planned_capacity) { _planned_capacity = planned_capacity; }
@@ -192,8 +190,8 @@
   // Debugging
   bool chain_contains(jobject handle) const;    // Does this block or following blocks contain handle
   bool contains(jobject handle) const;          // Does this block contain handle
-  int length() const;                           // Length of chain starting with this block
-  long memory_usage() const;
+  size_t length() const;                        // Length of chain starting with this block
+  size_t memory_usage() const;
   #ifndef PRODUCT
   static bool any_contains(jobject handle);     // Does any block currently in use contain handle
   static void print_statistics();
@@ -218,33 +216,18 @@
 }
 
 // external_guard is true if called from resolve_external_guard.
-// Treat deleted (and possibly zapped) as NULL for external_guard,
-// else as (asserted) error.
-template<bool external_guard>
-inline oop JNIHandles::guard_value(oop value) {
-  if (!external_guard) {
-    assert(value != deleted_handle(), "Used a deleted global handle");
-  } else if (value == deleted_handle()) {
-    value = NULL;
-  }
-  return value;
-}
-
-// external_guard is true if called from resolve_external_guard.
 template<bool external_guard>
 inline oop JNIHandles::resolve_impl(jobject handle) {
   assert(handle != NULL, "precondition");
   assert(!current_thread_in_native(), "must not be in native");
   oop result;
   if (is_jweak(handle)) {       // Unlikely
-    result = resolve_jweak<external_guard>(handle);
+    result = resolve_jweak(handle);
   } else {
     result = jobject_ref(handle);
     // Construction of jobjects canonicalize a null value into a null
     // jobject, so for non-jweak the pointee should never be null.
-    assert(external_guard || result != NULL,
-           "Invalid value read from jni handle");
-    result = guard_value<external_guard>(result);
+    assert(external_guard || result != NULL, "Invalid JNI handle");
   }
   return result;
 }
@@ -278,7 +261,8 @@
 
 inline void JNIHandles::destroy_local(jobject handle) {
   if (handle != NULL) {
-    jobject_ref(handle) = deleted_handle();
+    assert(!is_jweak(handle), "Invalid JNI local handle");
+    jobject_ref(handle) = NULL;
   }
 }
 
--- a/src/hotspot/share/runtime/mutexLocker.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/mutexLocker.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -43,7 +43,10 @@
 Mutex*   CompiledIC_lock              = NULL;
 Mutex*   InlineCacheBuffer_lock       = NULL;
 Mutex*   VMStatistic_lock             = NULL;
-Mutex*   JNIGlobalHandle_lock         = NULL;
+Mutex*   JNIGlobalAlloc_lock          = NULL;
+Mutex*   JNIGlobalActive_lock         = NULL;
+Mutex*   JNIWeakAlloc_lock            = NULL;
+Mutex*   JNIWeakActive_lock           = NULL;
 Mutex*   JNIHandleBlockFreeList_lock  = NULL;
 Mutex*   ResolvedMethodTable_lock     = NULL;
 Mutex*   JmethodIdCreation_lock       = NULL;
@@ -245,7 +248,15 @@
   def(Terminator_lock              , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);
   def(VtableStubs_lock             , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_always);
   def(Notify_lock                  , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_always);
-  def(JNIGlobalHandle_lock         , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_always);     // locks JNIHandleBlockFreeList_lock
+  // OopStorage-based JNI may lock the alloc_locks while releasing a handle,
+  // while previous JNI didn't need a lock for handle release.  This runs afoul
+  // of some places which hold other locks while releasing a handle, including
+  // the Patching_lock, which is of "special" rank.  As a temporary workaround,
+  // lower the JNI oopstorage lock ranks to make them super-special.
+  def(JNIGlobalAlloc_lock          , PaddedMutex  , special-1,   true,  Monitor::_safepoint_check_never);
+  def(JNIGlobalActive_lock         , PaddedMutex  , special-2,   true,  Monitor::_safepoint_check_never);
+  def(JNIWeakAlloc_lock            , PaddedMutex  , special-1,   true,  Monitor::_safepoint_check_never);
+  def(JNIWeakActive_lock           , PaddedMutex  , special-2,   true,  Monitor::_safepoint_check_never);
   def(JNICritical_lock             , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_always);     // used for JNI critical regions
   def(AdapterHandlerLibrary_lock   , PaddedMutex  , nonleaf,     true,  Monitor::_safepoint_check_always);
 
--- a/src/hotspot/share/runtime/mutexLocker.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/mutexLocker.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -36,7 +36,10 @@
 extern Mutex*   CompiledIC_lock;                 // a lock used to guard compiled IC patching and access
 extern Mutex*   InlineCacheBuffer_lock;          // a lock used to guard the InlineCacheBuffer
 extern Mutex*   VMStatistic_lock;                // a lock used to guard statistics count increment
-extern Mutex*   JNIGlobalHandle_lock;            // a lock on creating JNI global handles
+extern Mutex*   JNIGlobalAlloc_lock;             // JNI global storage allocate list lock
+extern Mutex*   JNIGlobalActive_lock;            // JNI global storage active list lock
+extern Mutex*   JNIWeakAlloc_lock;               // JNI weak storage allocate list lock
+extern Mutex*   JNIWeakActive_lock;              // JNI weak storage active list lock
 extern Mutex*   JNIHandleBlockFreeList_lock;     // a lock on the JNI handle block free list
 extern Mutex*   ResolvedMethodTable_lock;        // a lock on the ResolvedMethodTable updates
 extern Mutex*   JmethodIdCreation_lock;          // a lock on creating JNI method identifiers
--- a/src/hotspot/share/runtime/os.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/os.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -987,6 +987,11 @@
 // The verbose parameter is only set by the debug code in one case
 void os::print_location(outputStream* st, intptr_t x, bool verbose) {
   address addr = (address)x;
+  // Handle NULL first, so later checks don't need to protect against it.
+  if (addr == NULL) {
+    st->print_cr("0x0 is NULL");
+    return;
+  }
   CodeBlob* b = CodeCache::find_blob_unsafe(addr);
   if (b != NULL) {
     if (b->is_buffer_blob()) {
@@ -1087,7 +1092,7 @@
   }
 #ifndef PRODUCT
   // we don't keep the block list in product mode
-  if (JNIHandleBlock::any_contains((jobject) addr)) {
+  if (JNIHandles::is_local_handle((jobject) addr)) {
     st->print_cr(INTPTR_FORMAT " is a local jni handle", p2i(addr));
     return;
   }
--- a/src/hotspot/share/runtime/os.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/os.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -717,9 +717,6 @@
   // Fills in path to jvm.dll/libjvm.so (used by the Disassembler)
   static void     jvm_path(char *buf, jint buflen);
 
-  // Returns true if we are running in a headless jre.
-  static bool     is_headless_jre();
-
   // JNI names
   static void     print_jni_name_prefix_on(outputStream* st, int args_size);
   static void     print_jni_name_suffix_on(outputStream* st, int args_size);
--- a/src/hotspot/share/runtime/vmStructs.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/vmStructs.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -55,6 +55,7 @@
 #include "gc/shared/genCollectedHeap.hpp"
 #include "gc/shared/generation.hpp"
 #include "gc/shared/generationSpec.hpp"
+#include "gc/shared/oopStorage.hpp"
 #include "gc/shared/space.hpp"
 #include "interpreter/bytecodeInterpreter.hpp"
 #include "interpreter/bytecodes.hpp"
@@ -948,10 +949,8 @@
   /*********************************/                                                                                                \
   /* JNIHandles and JNIHandleBlock */                                                                                                \
   /*********************************/                                                                                                \
-     static_field(JNIHandles,                  _global_handles,                               JNIHandleBlock*)                       \
-     static_field(JNIHandles,                  _weak_global_handles,                          JNIHandleBlock*)                       \
-     static_field(JNIHandles,                  _deleted_handle,                               oop)                                   \
-                                                                                                                                     \
+  static_field(JNIHandles,                     _global_handles,                               OopStorage*)                           \
+  static_field(JNIHandles,                     _weak_global_handles,                          OopStorage*)                           \
   unchecked_nonstatic_field(JNIHandleBlock,    _handles,       JNIHandleBlock::block_size_in_oops * sizeof(Oop)) /* Note: no type */ \
   nonstatic_field(JNIHandleBlock,              _top,                                          int)                                   \
   nonstatic_field(JNIHandleBlock,              _next,                                         JNIHandleBlock*)                       \
@@ -1677,6 +1676,12 @@
   declare_toplevel_type(JNIHandleBlock)                                   \
   declare_toplevel_type(jobject)                                          \
                                                                           \
+  /**************/                                                        \
+  /* OopStorage */                                                        \
+  /**************/                                                        \
+                                                                          \
+  declare_toplevel_type(OopStorage)                                       \
+                                                                          \
   /**********************/                                                \
   /* Runtime1 (C1 only) */                                                \
   /**********************/                                                \
--- a/src/hotspot/share/runtime/vm_operations.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/runtime/vm_operations.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -115,6 +115,7 @@
   template(ICBufferFull)                          \
   template(ScavengeMonitors)                      \
   template(PrintMetadata)                         \
+  template(GTestExecuteAtSafepoint)               \
 
 class VM_Operation: public CHeapObj<mtInternal> {
  public:
@@ -286,6 +287,17 @@
   bool is_cheap_allocated() const                { return true; }
 };
 
+// Base class for invoking parts of a gtest in a safepoint.
+// Derived classes provide the doit method.
+// Typically also need to transition the gtest thread from native to VM.
+class VM_GTestExecuteAtSafepoint: public VM_Operation {
+ public:
+  VMOp_Type type() const                         { return VMOp_GTestExecuteAtSafepoint; }
+
+ protected:
+  VM_GTestExecuteAtSafepoint() {}
+};
+
 class VM_Deoptimize: public VM_Operation {
  public:
   VM_Deoptimize() {}
--- a/src/hotspot/share/services/heapDumper.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/services/heapDumper.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -1317,9 +1317,9 @@
 
 
 void JNILocalsDumper::do_oop(oop* obj_p) {
-  // ignore null or deleted handles
+  // ignore null handles
   oop o = *obj_p;
-  if (o != NULL && o != JNIHandles::deleted_handle()) {
+  if (o != NULL) {
     writer()->write_u1(HPROF_GC_ROOT_JNI_LOCAL);
     writer()->write_objectID(o);
     writer()->write_u4(_thread_serial_num);
@@ -1347,7 +1347,7 @@
   oop o = *obj_p;
 
   // ignore these
-  if (o == NULL || o == JNIHandles::deleted_handle()) return;
+  if (o == NULL) return;
 
   // we ignore global ref to symbols and other internal objects
   if (o->is_instance() || o->is_objArray() || o->is_typeArray()) {
@@ -1422,9 +1422,6 @@
 };
 
 void HeapObjectDumper::do_object(oop o) {
-  // hide the sentinel for deleted handles
-  if (o == JNIHandles::deleted_handle()) return;
-
   // skip classes as these emitted as HPROF_GC_CLASS_DUMP records
   if (o->klass() == SystemDictionary::Class_klass()) {
     if (!java_lang_Class::is_primitive(o)) {
--- a/src/hotspot/share/services/serviceUtil.hpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/services/serviceUtil.hpp	Tue Jan 30 16:41:40 2018 +0100
@@ -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.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,11 +39,6 @@
   // Return true if oop represents an object that is "visible"
   // to the java world.
   static inline bool visible_oop(oop o) {
-    // the sentinel for deleted handles isn't visible
-    if (o == JNIHandles::deleted_handle()) {
-      return false;
-    }
-
     // instance
     if (o->is_instance()) {
       // instance objects are visible
--- a/src/hotspot/share/utilities/hashtable.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/hotspot/share/utilities/hashtable.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
 #include "classfile/protectionDomainCache.hpp"
 #include "classfile/stringTable.hpp"
 #include "memory/allocation.inline.hpp"
-#include "memory/filemap.hpp"
+#include "memory/metaspaceShared.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/safepoint.hpp"
@@ -161,8 +161,7 @@
   if (NULL != _buckets) {
     // Don't delete the buckets in the shared space.  They aren't
     // allocated by os::malloc
-    if (!UseSharedSpaces ||
-        !FileMapInfo::current_info()->is_in_shared_space(_buckets)) {
+    if (!MetaspaceShared::is_in_shared_metaspace(_buckets)) {
        FREE_C_HEAP_ARRAY(HashtableBucket, _buckets);
     }
     _buckets = NULL;
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Linker.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Linker.java	Tue Jan 30 16:41:40 2018 +0100
@@ -44,6 +44,14 @@
         return libraryFileName;
     }
 
+    private static String getString(InputStream stream) {
+        BufferedReader br = new BufferedReader(new InputStreamReader(stream));
+        Stream<String> lines = br.lines();
+        StringBuilder sb = new StringBuilder();
+        lines.iterator().forEachRemaining(e -> sb.append(e));
+        return sb.toString();
+    }
+
     Linker(Main main) throws Exception {
         this.options = main.options;
         String name = options.outputName;
@@ -106,12 +114,7 @@
             Process p = Runtime.getRuntime().exec(linkerCheck);
             final int exitCode = p.waitFor();
             if (exitCode != 0) {
-                InputStream stderr = p.getErrorStream();
-                BufferedReader br = new BufferedReader(new InputStreamReader(stderr));
-                Stream<String> lines = br.lines();
-                StringBuilder sb = new StringBuilder();
-                lines.iterator().forEachRemaining(e -> sb.append(e));
-                throw new InternalError(sb.toString());
+                throw new InternalError(getString(p.getErrorStream()));
             }
         }
     }
@@ -120,15 +123,11 @@
         Process p = Runtime.getRuntime().exec(linkerCmd);
         final int exitCode = p.waitFor();
         if (exitCode != 0) {
-            InputStream stderr = p.getErrorStream();
-            if (stderr.read() == -1) {
-                stderr = p.getInputStream();
+            String errorMessage = getString(p.getErrorStream());
+            if (errorMessage.isEmpty()) {
+                errorMessage = getString(p.getInputStream());
             }
-            BufferedReader br = new BufferedReader(new InputStreamReader(stderr));
-            Stream<String> lines = br.lines();
-            StringBuilder sb = new StringBuilder();
-            lines.iterator().forEachRemaining(e -> sb.append(e));
-            throw new InternalError(sb.toString());
+            throw new InternalError(errorMessage);
         }
         File objFile = new File(objectFileName);
         if (objFile.exists()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/OopStorage.java	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ *
+ */
+
+package sun.jvm.hotspot.gc.shared;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+public class OopStorage extends VMObject {
+
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) {
+    Type type = db.lookupType("OopStorage");
+  }
+
+  public OopStorage(Address addr) {
+    super(addr);
+  }
+
+  public boolean findOop(Address handle) {
+    // TODO: walk OopStorage to find the Oop
+    return false;
+  }
+
+  public void oopsDo(AddressVisitor visitor) {
+    // TODO: Visit handles in OopStorage
+  }
+}
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JNIHandleBlock.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JNIHandleBlock.java	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -103,7 +103,7 @@
 
   /** Debugging routine only. Returns non-null JNIHandleBlock
       containing the JNI handle or null if this handle block and its
-      successors did not contain it (or if the handle was deleted). */
+      successors did not contain it. */
   public JNIHandleBlock blockContainingHandle(Address jniHandle) {
     JNIHandleBlock cur = this;
     while (cur != null) {
@@ -144,8 +144,8 @@
 
     Address oopAddr = addr.addOffsetTo(handlesField.getOffset() + x * VM.getVM().getOopSize());
     OopHandle handle = oopAddr.getOopHandleAt(0);
-    if (VM.getVM().getUniverse().isInReserved(handle) && !VM.getVM().getJNIHandles().isDeletedHandle(handle)) {
-      /* the oop handle is valid only if it is not freed (i.e. reserved in heap) and is not a deleted oop */
+    if (VM.getVM().getUniverse().isInReserved(handle)) {
+      /* the oop handle is valid only if it is not freed (i.e. reserved in heap) */
       return oopAddr;
     } else {
       return null;
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JNIHandles.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JNIHandles.java	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -27,11 +27,11 @@
 import java.util.*;
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.gc.shared.OopStorage;
 
 public class JNIHandles {
   private static AddressField      globalHandlesField;
   private static AddressField      weakGlobalHandlesField;
-  private static OopField          deletedHandleField;
 
   static {
     VM.registerVMInitializedObserver(new Observer() {
@@ -46,35 +46,26 @@
 
     globalHandlesField = type.getAddressField("_global_handles");
     weakGlobalHandlesField = type.getAddressField("_weak_global_handles");
-    deletedHandleField = type.getOopField("_deleted_handle");
 
   }
 
   public JNIHandles() {
   }
 
-  public JNIHandleBlock globalHandles() {
+  public OopStorage globalHandles() {
     Address handleAddr  = globalHandlesField.getValue();
     if (handleAddr == null) {
       return null;
     }
-    return new JNIHandleBlock(handleAddr);
+    return new OopStorage(handleAddr);
   }
 
-  public JNIHandleBlock weakGlobalHandles() {
+  public OopStorage weakGlobalHandles() {
     Address handleAddr  = weakGlobalHandlesField.getValue();
     if (handleAddr == null) {
       return null;
     }
-    return new JNIHandleBlock(handleAddr);
-  }
-
-  public OopHandle deletedHandle() {
-    return deletedHandleField.getValue();
-  }
-
-  public boolean isDeletedHandle(OopHandle handle) {
-    return (handle != null && handle.equals(deletedHandle()));
+    return new OopStorage(handleAddr);
   }
 
 }
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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,6 +26,7 @@
 
 import java.io.*;
 import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.gc.shared.OopStorage;
 import sun.jvm.hotspot.memory.*;
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.runtime.*;
@@ -147,7 +148,7 @@
 
     protected void writeGlobalJNIHandles() throws IOException {
         JNIHandles handles = VM.getVM().getJNIHandles();
-        JNIHandleBlock blk = handles.globalHandles();
+        OopStorage blk = handles.globalHandles();
         if (blk != null) {
             try {
                 blk.oopsDo(new AddressVisitor() {
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -108,41 +108,36 @@
 
     // Check JNIHandles; both local and global
     JNIHandles handles = VM.getVM().getJNIHandles();
-    JNIHandleBlock handleBlock = handles.globalHandles();
-    if (handleBlock != null) {
-      handleBlock = handleBlock.blockContainingHandle(a);
+
+    // --- looking in oopstorage should model OopStorage::allocation_status?
+    // --- that is, if in a block but not allocated, then not valid.
+
+    // Look in global handles
+    OopStorage storage = handles.globalHandles();
+    if ((storage != null) && storage.findOop(a)) {
+      loc.inStrongGlobalJNIHandles = true;
+      return loc;
     }
-    if (handleBlock != null) {
-      loc.inStrongGlobalJNIHandleBlock = true;
-      loc.handleBlock = handleBlock;
+    // Look in weak global handles
+    storage = handles.weakGlobalHandles();
+    if ((storage != null) && storage.findOop(a)) {
+      loc.inWeakGlobalJNIHandles = true;
       return loc;
-    } else {
-      handleBlock = handles.weakGlobalHandles();
+    }
+    // Look in thread-local handles
+    for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) {
+      JNIHandleBlock handleBlock = t.activeHandles();
       if (handleBlock != null) {
         handleBlock = handleBlock.blockContainingHandle(a);
         if (handleBlock != null) {
-          loc.inWeakGlobalJNIHandleBlock = true;
+          loc.inLocalJNIHandleBlock = true;
           loc.handleBlock = handleBlock;
+          loc.handleThread = t;
           return loc;
-        } else {
-          // Look in thread-local handles
-          for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) {
-            handleBlock = t.activeHandles();
-            if (handleBlock != null) {
-              handleBlock = handleBlock.blockContainingHandle(a);
-              if (handleBlock != null) {
-                loc.inLocalJNIHandleBlock = true;
-                loc.handleBlock = handleBlock;
-                loc.handleThread = t;
-                return loc;
-              }
-            }
-          }
         }
       }
     }
 
-
     // Fall through; have to return it anyway.
     return loc;
   }
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerLocation.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerLocation.java	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -69,8 +69,9 @@
   boolean inBlobOops;
   boolean inBlobUnknownLocation;
 
-  boolean inStrongGlobalJNIHandleBlock;
-  boolean inWeakGlobalJNIHandleBlock;
+  boolean inStrongGlobalJNIHandles;
+  boolean inWeakGlobalJNIHandles;
+
   boolean inLocalJNIHandleBlock;
   JNIHandleBlock handleBlock;
   sun.jvm.hotspot.runtime.Thread handleThread;
@@ -149,32 +150,33 @@
     return inBlobUnknownLocation;
   }
 
-  public boolean isInStrongGlobalJNIHandleBlock() {
-    return inStrongGlobalJNIHandleBlock;
+  public boolean isInStrongGlobalJNIHandles() {
+    return inStrongGlobalJNIHandles;
   }
 
-  public boolean isInWeakGlobalJNIHandleBlock() {
-    return inWeakGlobalJNIHandleBlock;
+  public boolean isInWeakGlobalJNIHandles() {
+    return inWeakGlobalJNIHandles;
   }
 
   public boolean isInLocalJNIHandleBlock() {
     return inLocalJNIHandleBlock;
   }
 
-  /** Only valid if isInStrongGlobalJNIHandleBlock,
-      isInWeakGlobalJNIHandleBlock, or isInLocalJNIHandleBlock is true */
+  /** Only valid if isInLocalJNIHandleBlock is true */
   public JNIHandleBlock getJNIHandleBlock() {
+    assert isInLocalJNIHandleBlock();
     return handleBlock;
   }
 
   /** Only valid if isInLocalJNIHandleBlock is true */
   public sun.jvm.hotspot.runtime.Thread getJNIHandleThread() {
+    assert isInLocalJNIHandleBlock();
     return handleThread;
   }
 
   public boolean isUnknown() {
     return (!(isInHeap() || isInInterpreter() || isInCodeCache() ||
-              isInStrongGlobalJNIHandleBlock() || isInWeakGlobalJNIHandleBlock() || isInLocalJNIHandleBlock()));
+              isInStrongGlobalJNIHandles() || isInWeakGlobalJNIHandles() || isInLocalJNIHandleBlock()));
   }
 
   public String toString() {
@@ -236,25 +238,18 @@
       b.printOn(tty);
 
       // FIXME: add more detail
-    } else if (isInStrongGlobalJNIHandleBlock() ||
-               isInWeakGlobalJNIHandleBlock() ||
-               isInLocalJNIHandleBlock()) {
-      tty.print("In ");
-      if (isInStrongGlobalJNIHandleBlock()) {
-        tty.print("strong global");
-      } else if (isInWeakGlobalJNIHandleBlock()) {
-        tty.print("weak global");
+    } else if (isInStrongGlobalJNIHandles()) {
+      tty.print("In JNI strong global");
+    } else if (isInWeakGlobalJNIHandles()) {
+      tty.print("In JNI weak global");
+    } else if (isInLocalJNIHandleBlock()) {
+      tty.print("In thread-local");
+      tty.print(" JNI handle block (" + handleBlock.top() + " handle slots present)");
+      if (handleThread.isJavaThread()) {
+        tty.print(" for JavaThread ");
+        ((JavaThread) handleThread).printThreadIDOn(tty);
       } else {
-        tty.print("thread-local");
-      }
-      tty.print(" JNI handle block (" + handleBlock.top() + " handle slots present)");
-      if (isInLocalJNIHandleBlock()) {
-        if (handleThread.isJavaThread()) {
-          tty.print(" for JavaThread ");
-          ((JavaThread) handleThread).printThreadIDOn(tty);
-        } else {
-          tty.print("for a non-Java Thread");
-        }
+        tty.print(" for a non-Java Thread");
       }
     } else {
       // This must be last
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ReversePtrsAnalysis.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ReversePtrsAnalysis.java	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -108,10 +108,10 @@
 
     // Do global JNI handles
     JNIHandles handles = VM.getVM().getJNIHandles();
-    doJNIHandleBlock(handles.globalHandles(),
-                     new RootVisitor("Global JNI handle root"));
-    doJNIHandleBlock(handles.weakGlobalHandles(),
-                     new RootVisitor("Weak global JNI handle root"));
+    doOopStorage(handles.globalHandles(),
+                 new RootVisitor("Global JNI handle root"));
+    doOopStorage(handles.weakGlobalHandles(),
+                 new RootVisitor("Weak global JNI handle root"));
 
     // Do Java-level static fields
     ClassLoaderDataGraph cldg = VM.getVM().getClassLoaderDataGraph();
@@ -306,4 +306,9 @@
   private void doJNIHandleBlock(JNIHandleBlock handles, AddressVisitor oopVisitor) {
     handles.oopsDo(oopVisitor);
   }
+
+  // Traverse jobjects in global JNIHandles
+  private void doOopStorage(OopStorage oopSet, AddressVisitor oopVisitor) {
+    oopSet.oopsDo(oopVisitor);
+  }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.jvmstat/linux/classes/sun/jvmstat/PlatformSupportImpl.java	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,227 @@
+/*
+ * 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 sun.jvmstat;
+
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.Files;
+import java.nio.charset.*;
+
+/*
+ * Linux specific implementation of the PlatformSupport routines
+ * providing process ID and temp directory support for host and
+ * cgroup container processes.
+ */
+public class PlatformSupportImpl extends PlatformSupport {
+    private static final String containerTmpPath = "/root" + getTemporaryDirectory();
+    private static final String pidPatternStr = "^[0-9]+$";
+
+    /*
+     * Return the temporary directories that the VM uses for the attach
+     * and perf data files.  This function returns the traditional
+     * /tmp directory in addition to paths within the /proc file system
+     * allowing access to container tmp directories such as /proc/{pid}/root/tmp.
+     *
+     * It is important that this directory is well-known and the
+     * same for all VM instances. It cannot be affected by configuration
+     * variables such as java.io.tmpdir.
+     *
+     * Implementation Details:
+     *
+     * Java processes that run in docker containers are typically running
+     * under cgroups with separate pid namespaces which means that pids
+     * within the container are different that the pid which is visible
+     * from the host.  The container pids typically start with 1 and
+     * increase.  The java process running in the container will use these
+     * pids when creating the hsperfdata files.  In order to locate java
+     * processes that are running in containers, we take advantage of
+     * the Linux proc file system which maps the containers tmp directory
+     * to the hosts under /proc/{hostpid}/root/tmp.  We use the /proc status
+     * file /proc/{hostpid}/status to determine the containers pid and
+     * then access the hsperfdata file.  The status file contains an
+     * entry "NSPid:" which shows the mapping from the hostpid to the
+     * containers pid.
+     *
+     * Example:
+     *
+     * NSPid: 24345 11
+     *
+     * In this example process 24345 is visible from the host,
+     * is running under the PID namespace and has a container specific
+     * pid of 11.
+     *
+     * The search for Java processes is done by first looking in the
+     * traditional /tmp for host process hsperfdata files and then
+     * the search will container in every /proc/{pid}/root/tmp directory.
+     * There are of course added complications to this search that
+     * need to be taken into account.
+     *
+     * 1. duplication of tmp directories
+     *
+     * /proc/{hostpid}/root/tmp directories exist for many processes
+     * that are running on a Linux kernel that has cgroups enabled even
+     * if they are not running in a container.  To avoid this duplication,
+     * we compare the inode of the /proc tmp directories to /tmp and
+     * skip these duplicated directories.
+     *
+     * 2. Containerized processes without PID namespaces being enabled.
+     *
+     * If a container is running a Java process without namespaces being
+     * enabled, an hsperfdata file will only be located at
+     * /proc/{hostpid}/root/tmp/{hostpid}.  This is handled by
+     * checking the last component in the path for both the hostpid
+     * and potential namespacepids (if one exists).
+     */
+    public List<String> getTemporaryDirectories(int pid) {
+        FilenameFilter pidFilter;
+        Matcher pidMatcher;
+        Pattern pidPattern = Pattern.compile(pidPatternStr);
+        long tmpInode = 0;
+
+        File procdir = new File("/proc");
+
+        if (pid != 0) {
+            pidPattern = Pattern.compile(Integer.toString(pid));
+        }
+        else {
+            pidPattern = Pattern.compile(pidPatternStr);
+        }
+        pidMatcher = pidPattern.matcher("");
+
+        // Add the default temporary directory first
+        List<String> v = new ArrayList<>();
+        v.add(getTemporaryDirectory());
+
+        try {
+            File f = new File(getTemporaryDirectory());
+            tmpInode = (Long)Files.getAttribute(f.toPath(), "unix:ino");
+        }
+        catch (IOException e) {}
+
+        pidFilter = new FilenameFilter() {
+            public boolean accept(File dir, String name) {
+                if (!dir.isDirectory())
+                    return false;
+                pidMatcher.reset(name);
+                return pidMatcher.matches();
+            }
+        };
+
+        File[] dirs = procdir.listFiles(pidFilter);
+
+        // Add all unique /proc/{pid}/root/tmp dirs that are not mapped to /tmp
+        for (File dir : dirs) {
+            String containerTmpDir = dir.getAbsolutePath() + containerTmpPath;
+            File containerFile = new File(containerTmpDir);
+
+            try {
+                long procInode = (Long)Files.getAttribute(containerFile.toPath(), "unix:ino");
+                if (containerFile.exists() && containerFile.isDirectory() &&
+                    containerFile.canRead() && procInode != tmpInode) {
+                    v.add(containerTmpDir);
+                }
+            }
+            catch (IOException e) {}
+        }
+
+        return v;
+    }
+
+
+    /*
+     * Extract either the host PID or the NameSpace PID
+     * from a file path.
+     *
+     * File path should be in 1 of these 2 forms:
+     *
+     * /proc/{pid}/root/tmp/hsperfdata_{user}/{nspid}
+     *              or
+     * /tmp/hsperfdata_{user}/{pid}
+     *
+     * In either case we want to return {pid} and NOT {nspid}
+     *
+     * This function filters out host pids which do not have
+     * associated hsperfdata files.  This is due to the fact that
+     * getTemporaryDirectories will return /proc/{pid}/root/tmp
+     * paths for all container processes whether they are java
+     * processes or not causing duplicate matches.
+     */
+    public int getLocalVmId(File file) throws NumberFormatException {
+        String p = file.getAbsolutePath();
+        String s[] = p.split("\\/");
+
+        // Determine if this file is from a container
+        if (s.length == 7 && s[1].equals("proc")) {
+            int hostpid = Integer.parseInt(s[2]);
+            int nspid = Integer.parseInt(s[6]);
+            if (nspid == hostpid || nspid == getNamespaceVmId(hostpid)) {
+                return hostpid;
+            }
+            else {
+                return -1;
+            }
+        }
+        else {
+            return Integer.parseInt(file.getName());
+        }
+    }
+
+
+    /*
+     * Return the inner most namespaced PID if there is one,
+     * otherwise return the original PID.
+     */
+    public int getNamespaceVmId(int pid) {
+        // Assuming a real procfs sits beneath, reading this doesn't block
+        // nor will it consume a lot of memory.
+        Path statusPath = Paths.get("/proc", Integer.toString(pid), "status");
+        if (Files.notExists(statusPath)) {
+            return pid; // Likely a bad pid, but this is properly handled later.
+        }
+
+        try {
+            for (String line : Files.readAllLines(statusPath, StandardCharsets.UTF_8)) {
+                String[] parts = line.split(":");
+                if (parts.length == 2 && parts[0].trim().equals("NSpid")) {
+                    parts = parts[1].trim().split("\\s+");
+                    // The last entry represents the PID the JVM "thinks" it is.
+                    // Even in non-namespaced pids these entries should be
+                    // valid. You could refer to it as the inner most pid.
+                    int ns_pid = Integer.parseInt(parts[parts.length - 1]);
+                    return ns_pid;
+                }
+            }
+            // Old kernels may not have NSpid field (i.e. 3.10).
+            // Fallback to original pid in the event we cannot deduce.
+            return pid;
+        } catch (NumberFormatException | IOException x) {
+            return pid;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/PlatformSupport.java	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,113 @@
+/*
+ * 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 sun.jvmstat;
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.util.List;
+import jdk.internal.vm.VMSupport;
+
+/*
+ * Support routines handling temp directory locating
+ * and process ID extraction.
+ */
+public class PlatformSupport {
+    private static final String tmpDirName;
+    static {
+        /*
+         * For this to work, the target VM and this code need to use
+         * the same directory. Instead of guessing which directory the
+         * VM is using, we will ask.
+         */
+        String tmpdir = VMSupport.getVMTemporaryDirectory();
+
+        /*
+         * Assure that the string returned has a trailing File.separator
+         * character. This check was added because the Linux implementation
+         * changed such that the java.io.tmpdir string no longer terminates
+         * with a File.separator character.
+         */
+        if (tmpdir.lastIndexOf(File.separator) != (tmpdir.length()-1)) {
+            tmpdir = tmpdir + File.separator;
+        }
+        tmpDirName = tmpdir;
+    }
+
+    public static PlatformSupport getInstance() {
+        try {
+            Class<?> c = Class.forName("sun.jvmstat.PlatformSupportImpl");
+            @SuppressWarnings("unchecked")
+            Constructor<PlatformSupport> cntr = (Constructor<PlatformSupport>) c.getConstructor();
+            return cntr.newInstance();
+        } catch (ClassNotFoundException e) {
+            return new PlatformSupport();
+        } catch (ReflectiveOperationException e) {
+            throw new InternalError(e);
+        }
+    }
+
+    // package-private
+    PlatformSupport() {}
+
+    /*
+     * Return the OS specific temporary directory
+     */
+    public static String getTemporaryDirectory() {
+        return tmpDirName;
+    }
+
+    /*
+     * Return a list of the temporary directories that the VM uses
+     * for the attach and perf data files.  This function returns
+     * the traditional temp directory in addition to any paths
+     * accessible by the host which map to temp directories used
+     * by containers. The container functionality is only currently
+     * supported on Linux platforms.
+     *
+     * It is important that this directory is well-known and the
+     * same for all VM instances. It cannot be affected by configuration
+     * variables such as java.io.tmpdir.
+     */
+    public List<String> getTemporaryDirectories(int vmid) {
+        // Add the default temporary directory only
+        return List.of(tmpDirName);
+    }
+
+    /*
+     * Extract the host PID from a file path.
+     */
+    public int getLocalVmId(File file) throws NumberFormatException {
+        return Integer.parseInt(file.getName());
+    }
+
+
+    /*
+     * Return the inner most namespaced PID if there is one,
+     * otherwise return the original PID.
+     */
+    public int getNamespaceVmId(int pid) {
+        return pid;
+    }
+}
--- a/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalVmManager.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalVmManager.java	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -45,7 +45,7 @@
  */
 public class LocalVmManager {
     private String userName;                 // user name for monitored jvm
-    private File tmpdir;
+    private List<String> tmpdirs;
     private Pattern userPattern;
     private Matcher userMatcher;
     private FilenameFilter userFilter;
@@ -77,8 +77,9 @@
     public LocalVmManager(String user) {
         this.userName = user;
 
+
         if (userName == null) {
-            tmpdir = new File(PerfDataFile.getTempDirectory());
+            tmpdirs = PerfDataFile.getTempDirectories(null, 0);
             userPattern = Pattern.compile(PerfDataFile.userDirNamePattern);
             userMatcher = userPattern.matcher("");
 
@@ -89,7 +90,7 @@
                 }
             };
         } else {
-            tmpdir = new File(PerfDataFile.getTempDirectory(userName));
+            tmpdirs = PerfDataFile.getTempDirectories(userName, 0);
         }
 
         filePattern = Pattern.compile(PerfDataFile.fileNamePattern);
@@ -134,65 +135,72 @@
          */
         Set<Integer> jvmSet = new HashSet<Integer>();
 
-        if (! tmpdir.isDirectory()) {
-            return jvmSet;
-        }
+        for (String dir : tmpdirs) {
+            File tmpdir = new File(dir);
+            if (! tmpdir.isDirectory()) {
+                continue;
+            }
+
+            if (userName == null) {
+                /*
+                 * get a list of all of the user temporary directories and
+                 * iterate over the list to find any files within those directories.
+                 */
+                File[] dirs = tmpdir.listFiles(userFilter);
+                for (int i = 0 ; i < dirs.length; i ++) {
+                    if (!dirs[i].isDirectory()) {
+                        continue;
+                    }
 
-        if (userName == null) {
-            /*
-             * get a list of all of the user temporary directories and
-             * iterate over the list to find any files within those directories.
-             */
-            File[] dirs = tmpdir.listFiles(userFilter);
+                    // get a list of files from the directory
+                    File[] files = dirs[i].listFiles(fileFilter);
+                    if (files != null) {
+                        for (int j = 0; j < files.length; j++) {
+                            if (files[j].isFile() && files[j].canRead()) {
+                                int vmid = PerfDataFile.getLocalVmId(files[j]);
+                                if (vmid != -1) {
+                                  jvmSet.add(vmid);
+                                }
+                            }
+                        }
+                    }
+                }
+            } else {
+                /*
+                 * Check if the user directory can be accessed. Any of these
+                 * conditions may have asynchronously changed between subsequent
+                 * calls to this method.
+                 */
 
-            for (int i = 0 ; i < dirs.length; i ++) {
-                if (!dirs[i].isDirectory()) {
-                    continue;
-                }
-
-                // get a list of files from the directory
-                File[] files = dirs[i].listFiles(fileFilter);
+                // get the list of files from the specified user directory
+                File[] files = tmpdir.listFiles(fileFilter);
 
                 if (files != null) {
                     for (int j = 0; j < files.length; j++) {
                         if (files[j].isFile() && files[j].canRead()) {
-                            jvmSet.add(
-                                    PerfDataFile.getLocalVmId(files[j]));
+                            int vmid = PerfDataFile.getLocalVmId(files[j]);
+                            if (vmid != -1) {
+                              jvmSet.add(vmid);
+                            }
                         }
                     }
                 }
             }
-        } else {
-            /*
-             * Check if the user directory can be accessed. Any of these
-             * conditions may have asynchronously changed between subsequent
-             * calls to this method.
-             */
 
-            // get the list of files from the specified user directory
-            File[] files = tmpdir.listFiles(fileFilter);
-
+            // look for any 1.4.1 files
+            File[] files = tmpdir.listFiles(tmpFileFilter);
             if (files != null) {
                 for (int j = 0; j < files.length; j++) {
                     if (files[j].isFile() && files[j].canRead()) {
-                        jvmSet.add(
-                                PerfDataFile.getLocalVmId(files[j]));
+                        int vmid = PerfDataFile.getLocalVmId(files[j]);
+                        if (vmid != -1) {
+                          jvmSet.add(vmid);
+                        }
                     }
                 }
             }
+
         }
-
-        // look for any 1.4.1 files
-        File[] files = tmpdir.listFiles(tmpFileFilter);
-        if (files != null) {
-            for (int j = 0; j < files.length; j++) {
-                if (files[j].isFile() && files[j].canRead()) {
-                    jvmSet.add(
-                            PerfDataFile.getLocalVmId(files[j]));
-                }
-            }
-        }
-
         return jvmSet;
     }
 }
--- a/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java	Tue Jan 30 16:41:40 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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,8 +26,11 @@
 package sun.jvmstat.perfdata.monitor.protocol.local;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
 import java.io.FilenameFilter;
-import jdk.internal.vm.VMSupport;
+import sun.jvmstat.PlatformSupport;
 
 /**
  * Class to provide translations from the local Vm Identifier
@@ -46,11 +49,6 @@
     private PerfDataFile() { };
 
     /**
-     * The name of the of the system dependent temporary directory
-     */
-    public static final String tmpDirName;
-
-    /**
      * The file name prefix for PerfData shared memory files.
      * <p>
      * This prefix must be kept in sync with the prefix used by the JVM.
@@ -81,6 +79,12 @@
 
 
     /**
+     * Platform Specific methods for looking up temporary directories
+     * and process IDs.
+     */
+    private static final PlatformSupport platSupport = PlatformSupport.getInstance();
+
+    /**
      * Get a File object for the instrumentation backing store file
      * for the JVM identified by the given local Vm Identifier.
      * <p>
@@ -94,7 +98,7 @@
      * @return File - a File object to the backing store file for the named
      *                shared memory region of the target JVM.
      * @see java.io.File
-     * @see #getTempDirectory()
+     * @see #getTempDirectories()
      */
     public static File getFile(int lvmid) {
         if (lvmid == 0) {
@@ -107,56 +111,65 @@
             return null;
         }
 
-        /*
-         * iterate over all files in all directories in tmpDirName that
-         * match the file name patterns.
-         */
-        File tmpDir = new File(tmpDirName);
-        String[] files = tmpDir.list(new FilenameFilter() {
-            public boolean accept(File dir, String name) {
-                if (!name.startsWith(dirNamePrefix)) {
-                    return false;
-                }
-                File candidate = new File(dir, name);
-                return ((candidate.isDirectory() || candidate.isFile())
-                        && candidate.canRead());
-            }
-        });
-
-        long newestTime = 0;
+        List<String> tmpDirs = getTempDirectories(null, lvmid);
         File newest = null;
 
-        for (int i = 0; i < files.length; i++) {
-            File f = new File(tmpDirName + files[i]);
-            File candidate = null;
+        for (String dir : tmpDirs) {
+            /*
+             * iterate over all files in all directories in this tmpDir that
+             * match the file name patterns.
+             */
+            File tmpDir = new File(dir);
+            String[] files = tmpDir.list(new FilenameFilter() {
+                public boolean accept(File dir, String name) {
+                    if (!name.startsWith(dirNamePrefix)) {
+                        return false;
+                    }
+                    File candidate = new File(dir, name);
+                    return ((candidate.isDirectory() || candidate.isFile())
+                            && candidate.canRead());
+                }
+            });
 
-            if (f.exists() && f.isDirectory()) {
-                /*
-                 * found a directory matching the name patterns. This
-                 * is a 1.4.2 hsperfdata_<user> directory. Check for
-                 * file named <lvmid> in that directory
-                 */
-                String name = Integer.toString(lvmid);
-                candidate = new File(f.getName(), name);
+            long newestTime = 0;
+
+            for (String file : files) {
+                File f = new File(dir + file);
+                File candidate = null;
 
-            } else if (f.exists() && f.isFile()) {
-                /*
-                 * found a file matching the name patterns. This
-                 * is a 1.4.1 hsperfdata_<lvmid> file.
-                 */
-                candidate = f;
+                if (f.exists() && f.isDirectory()) {
+                    /*
+                     * found a directory matching the name patterns. This
+                     * is a 1.4.2 hsperfdata_<user> directory. Check for
+                     * file named <lvmid> in that directory
+                     */
+                    String name = f.getAbsolutePath() + File.separator + lvmid;
+                    candidate = new File(name);
+                    // Try NameSpace Id if Host Id doesn't exist.
+                    if (!candidate.exists()) {
+                        name = f.getAbsolutePath() + File.separator +
+                               platSupport.getNamespaceVmId(lvmid);
+                        candidate = new File(name);
+                    }
+                } else if (f.exists() && f.isFile()) {
+                    /*
+                     * found a file matching the name patterns. This
+                     * is a 1.4.1 hsperfdata_<lvmid> file.
+                     */
+                    candidate = f;
 
-            } else {
-                // unexpected - let conditional below filter this one out
-                candidate = f;
-            }
+                } else {
+                    // unexpected - let conditional below filter this one out
+                    candidate = f;
+                }
 
-            if (candidate.exists() && candidate.isFile()
-                    && candidate.canRead()) {
-                long modTime = candidate.lastModified();
-                if (modTime >= newestTime) {
-                    newestTime = modTime;
-                    newest = candidate;
+                if (candidate.exists() && candidate.isFile()
+                        && candidate.canRead()) {
+                    long modTime = candidate.lastModified();
+                    if (modTime >= newestTime) {
+                        newestTime = modTime;
+                        newest = candidate;
+                    }
                 }
             }
         }
@@ -177,7 +190,7 @@
      * @return File - a File object to the backing store file for the named
      *                shared memory region of the target JVM.
      * @see java.io.File
-     * @see #getTempDirectory()
+     * @see #getTempDirectories()
      */
     public static File getFile(String user, int lvmid) {
         if (lvmid == 0) {
@@ -191,11 +204,22 @@
         }
 
         // first try for 1.4.2 and later JVMs
-        String basename = getTempDirectory(user) + Integer.toString(lvmid);
-        File f = new File(basename);
+        List<String> tmpDirs = getTempDirectories(user, lvmid);
+        String basename;
+        File f;
 
-        if (f.exists() && f.isFile() && f.canRead()) {
-            return f;
+        for (String dir : tmpDirs) {
+            basename = dir + lvmid;
+            f = new File(basename);
+            if (f.exists() && f.isFile() && f.canRead()) {
+                return f;
+            }
+            // Try NameSpace Id if Host Id doesn't exist.
+            basename = dir + platSupport.getNamespaceVmId(lvmid);
+            f = new File(basename);
+            if (f.exists() && f.isFile() && f.canRead()) {
+                return f;
+            }
         }
 
         // No hit on 1.4.2 JVMs, try 1.4.1 files
@@ -236,7 +260,7 @@
     public static int getLocalVmId(File file) {
         try {
             // try 1.4.2 and later format first
-            return Integer.parseInt(file.getName());
+            return(platSupport.getLocalVmId(file));
         } catch (NumberFormatException e) { }
 
         // now try the 1.4.1 format
@@ -267,7 +291,7 @@
      * @return String - the name of the temporary directory.
      */
     public static String getTempDirectory() {
-        return tmpDirName;
+        return PlatformSupport.getTemporaryDirectory();
     }
 
     /**
@@ -283,26 +307,28 @@
      * @return String - the name of the temporary directory.
      */
     public static String getTempDirectory(String user) {
-        return tmpDirName + dirNamePrefix + user + File.separator;
+        return getTempDirectory() + dirNamePrefix + user + File.separator;
     }
 
-    static {
-        /*
-         * For this to work, the target VM and this code need to use
-         * the same directory. Instead of guessing which directory the
-         * VM is using, we will ask.
-         */
-        String tmpdir = VMSupport.getVMTemporaryDirectory();
+    /**
+     * Return the names of the temporary directories being searched for
+     * HotSpot PerfData backing store files.
+     * <p>
+     * This method returns the traditional host temp directory but also
+     * includes a list of temp directories used by containers.
+     *
+     * @return List<String> - A List of temporary directories to search.
+     */
+    public static List<String> getTempDirectories(String userName, int vmid) {
+        List<String> list = platSupport.getTemporaryDirectories(vmid);
+        if (userName == null) {
+            return list;
+        }
 
-        /*
-         * Assure that the string returned has a trailing File.separator
-         * character. This check was added because the Linux implementation
-         * changed such that the java.io.tmpdir string no longer terminates
-         * with a File.separator character.
-         */
-        if (tmpdir.lastIndexOf(File.separator) != (tmpdir.length()-1)) {
-            tmpdir = tmpdir + File.separator;
-        }
-        tmpDirName = tmpdir;
+        List<String> nameList = list.stream()
+            .map(name -> name + dirNamePrefix + userName + File.separator)
+            .collect(Collectors.toList());
+
+        return nameList;
     }
 }
--- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/LocationImpl.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/LocationImpl.java	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -79,8 +79,7 @@
         return method().hashCode() + (int)codeIndex();
     }
 
-    public int compareTo(Location object) {
-        LocationImpl other = (LocationImpl)object;
+    public int compareTo(Location other) {
         int rc = method().compareTo(other.method());
         if (rc == 0) {
             long diff = codeIndex() - other.codeIndex();
--- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/MirrorImpl.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/MirrorImpl.java	Tue Jan 30 16:41:40 2018 +0100
@@ -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
@@ -26,7 +26,6 @@
 package com.sun.tools.jdi;
 
 import java.util.Collection;
-import java.util.Iterator;
 
 import com.sun.jdi.Mirror;
 import com.sun.jdi.VMMismatchException;
@@ -87,12 +86,8 @@
      * Throw VMMismatchException on wrong VM.
      */
     void validateMirrors(Collection<? extends Mirror> mirrors) {
-        Iterator<? extends Mirror> iter = mirrors.iterator();
-        while (iter.hasNext()) {
-            MirrorImpl mirror = (MirrorImpl)iter.next();
-            if (!vm.equals(mirror.vm)) {
-                throw new VMMismatchException(mirror.toString());
-            }
+        for (Mirror mirror : mirrors) {
+            validateMirror(mirror);
         }
     }
 
@@ -101,12 +96,8 @@
      * Throw VMMismatchException on wrong VM.
      */
     void validateMirrorsOrNulls(Collection<? extends Mirror> mirrors) {
-        Iterator<? extends Mirror> iter = mirrors.iterator();
-        while (iter.hasNext()) {
-            MirrorImpl mirror = (MirrorImpl)iter.next();
-            if ((mirror != null) && !vm.equals(mirror.vm)) {
-                throw new VMMismatchException(mirror.toString());
-            }
+        for (Mirror mirror : mirrors) {
+            validateMirrorOrNull(mirror);
         }
     }
 }
--- a/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java	Tue Jan 30 16:41:40 2018 +0100
@@ -723,9 +723,6 @@
      */
     String type(String id) {
         String result = types.get(id);
-        if (result == null) {
-            reportInternalError(id);
-        }
         String remapped = type2printableMap.get(result);
         if (remapped != null) {
             return remapped;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/gtest/gc/shared/test_oopStorage.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,1385 @@
+/*
+ * 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/shared/oopStorage.inline.hpp"
+#include "gc/shared/oopStorageParState.inline.hpp"
+#include "gc/shared/workgroup.hpp"
+#include "memory/allocation.inline.hpp"
+#include "memory/resourceArea.hpp"
+#include "metaprogramming/conditional.hpp"
+#include "metaprogramming/enableIf.hpp"
+#include "runtime/handles.inline.hpp"
+#include "runtime/interfaceSupport.hpp"
+#include "runtime/mutex.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/thread.hpp"
+#include "runtime/vm_operations.hpp"
+#include "runtime/vmThread.hpp"
+#include "utilities/align.hpp"
+#include "utilities/ostream.hpp"
+#include "utilities/quickSort.hpp"
+#include "unittest.hpp"
+
+// --- FIXME: Disable some tests on 32bit Windows, because SafeFetch
+//     (which is used by allocation_status) doesn't currently provide
+//     protection in the context where gtests are run; see JDK-8185734.
+#ifdef _WIN32
+#define DISABLE_GARBAGE_ALLOCATION_STATUS_TESTS
+#endif
+
+// Access storage internals.
+class OopStorage::TestAccess : public AllStatic {
+public:
+  typedef OopStorage::Block Block;
+  typedef OopStorage::BlockList BlockList;
+
+  static BlockList& active_list(OopStorage& storage) {
+    return storage._active_list;
+  }
+
+  static BlockList& allocate_list(OopStorage& storage) {
+    return storage._allocate_list;
+  }
+
+  static const BlockList& allocate_list(const OopStorage& storage) {
+    return storage._allocate_list;
+  }
+
+  static Mutex* allocate_mutex(const OopStorage& storage) {
+    return storage._allocate_mutex;
+  }
+
+  static bool block_is_empty(const Block& block) {
+    return block.is_empty();
+  }
+
+  static bool block_is_full(const Block& block) {
+    return block.is_full();
+  }
+
+  static unsigned block_allocation_count(const Block& block) {
+    uintx bitmask = block.allocated_bitmask();
+    unsigned count = 0;
+    for ( ; bitmask != 0; bitmask >>= 1) {
+      if ((bitmask & 1) != 0) {
+        ++count;
+      }
+    }
+    return count;
+  }
+
+  static size_t memory_per_block() {
+    return Block::allocation_size();
+  }
+};
+
+typedef OopStorage::TestAccess TestAccess;
+// --- FIXME: Should be just Block, but that collides with opto Block
+//     when building with precompiled headers.  There really should be
+//     an opto namespace.
+typedef TestAccess::Block OopBlock;
+// --- FIXME: Similarly, this typedef collides with opto BlockList.
+// typedef TestAccess::BlockList BlockList;
+
+// Using EXPECT_EQ can't use NULL directly. Otherwise AIX build breaks.
+const OopBlock* const NULL_BLOCK = NULL;
+
+static size_t list_length(const TestAccess::BlockList& list) {
+  size_t result = 0;
+  for (const OopBlock* block = list.chead();
+       block != NULL;
+       block = list.next(*block)) {
+    ++result;
+  }
+  return result;
+}
+
+static void clear_list(TestAccess::BlockList& list) {
+  OopBlock* next;
+  for (OopBlock* block = list.head(); block != NULL; block = next) {
+    next = list.next(*block);
+    list.unlink(*block);
+  }
+}
+
+static bool is_list_empty(const TestAccess::BlockList& list) {
+  return list.chead() == NULL;
+}
+
+static void release_entry(OopStorage& storage, oop* entry) {
+  *entry = NULL;
+  storage.release(entry);
+}
+
+class OopStorageTest : public ::testing::Test {
+public:
+  OopStorageTest();
+  ~OopStorageTest();
+
+  Mutex _allocate_mutex;
+  Mutex _active_mutex;
+  OopStorage _storage;
+
+  static const int _active_rank = Mutex::leaf - 1;
+  static const int _allocate_rank = Mutex::leaf;
+
+  class CountingIterateClosure;
+  template<bool is_const> class VM_CountAtSafepoint;
+};
+
+OopStorageTest::OopStorageTest() :
+  _allocate_mutex(_allocate_rank,
+                  "test_OopStorage_allocate",
+                  false,
+                  Mutex::_safepoint_check_never),
+  _active_mutex(_active_rank,
+                "test_OopStorage_active",
+                false,
+                Mutex::_safepoint_check_never),
+  _storage("Test Storage", &_allocate_mutex, &_active_mutex)
+{ }
+
+OopStorageTest::~OopStorageTest() {
+  clear_list(TestAccess::allocate_list(_storage));
+  clear_list(TestAccess::active_list(_storage));
+}
+
+class OopStorageTestWithAllocation : public OopStorageTest {
+public:
+  OopStorageTestWithAllocation();
+
+  static const size_t _max_entries = 1000;
+  oop* _entries[_max_entries];
+
+  class VM_DeleteBlocksAtSafepoint;
+};
+
+OopStorageTestWithAllocation::OopStorageTestWithAllocation() {
+  for (size_t i = 0; i < _max_entries; ++i) {
+    _entries[i] = _storage.allocate();
+    EXPECT_TRUE(_entries[i] != NULL);
+    EXPECT_EQ(i + 1, _storage.allocation_count());
+  }
+};
+
+const size_t OopStorageTestWithAllocation::_max_entries;
+
+class OopStorageTestWithAllocation::VM_DeleteBlocksAtSafepoint
+  : public VM_GTestExecuteAtSafepoint {
+public:
+  VM_DeleteBlocksAtSafepoint(OopStorage* storage, size_t retain) :
+    _storage(storage), _retain(retain)
+  {}
+
+  void doit() {
+    _storage->delete_empty_blocks_safepoint(_retain);
+  }
+
+private:
+  OopStorage* _storage;
+  size_t _retain;
+};
+
+static bool is_allocate_list_sorted(const OopStorage& storage) {
+  // The allocate_list isn't strictly sorted.  Rather, all empty
+  // blocks are segregated to the end of the list.  And the number of
+  // empty blocks should match empty_block_count().
+  size_t expected_empty = storage.empty_block_count();
+  const TestAccess::BlockList& list = TestAccess::allocate_list(storage);
+  const OopBlock* block = list.ctail();
+  for (size_t i = 0; i < expected_empty; ++i, block = list.prev(*block)) {
+    if ((block == NULL) || !block->is_empty()) {
+      return false;
+    }
+  }
+  for ( ; block != NULL; block = list.prev(*block)) {
+    if (block->is_empty()) {
+      return false;
+    }
+  }
+  return true;
+}
+
+static size_t total_allocation_count(const TestAccess::BlockList& list) {
+  size_t total_count = 0;
+  for (const OopBlock* block = list.chead();
+       block != NULL;
+       block = list.next(*block)) {
+    total_count += TestAccess::block_allocation_count(*block);
+  }
+  return total_count;
+}
+
+TEST_VM_F(OopStorageTest, allocate_one) {
+  EXPECT_TRUE(is_list_empty(TestAccess::active_list(_storage)));
+  EXPECT_TRUE(is_list_empty(TestAccess::allocate_list(_storage)));
+
+  oop* ptr = _storage.allocate();
+  EXPECT_TRUE(ptr != NULL);
+  EXPECT_EQ(1u, _storage.allocation_count());
+
+  EXPECT_EQ(1u, list_length(TestAccess::active_list(_storage)));
+  EXPECT_EQ(1u, _storage.block_count());
+  EXPECT_EQ(1u, list_length(TestAccess::allocate_list(_storage)));
+
+  EXPECT_EQ(0u, _storage.empty_block_count());
+
+  const OopBlock* block = TestAccess::allocate_list(_storage).chead();
+  EXPECT_NE(block, (OopBlock*)NULL);
+  EXPECT_EQ(block, (TestAccess::active_list(_storage).chead()));
+  EXPECT_FALSE(TestAccess::block_is_empty(*block));
+  EXPECT_FALSE(TestAccess::block_is_full(*block));
+  EXPECT_EQ(1u, TestAccess::block_allocation_count(*block));
+
+  release_entry(_storage, ptr);
+  EXPECT_EQ(0u, _storage.allocation_count());
+
+  EXPECT_EQ(1u, list_length(TestAccess::active_list(_storage)));
+  EXPECT_EQ(1u, _storage.block_count());
+  EXPECT_EQ(1u, list_length(TestAccess::allocate_list(_storage)));
+
+  EXPECT_EQ(1u, _storage.empty_block_count());
+
+  const OopBlock* new_block = TestAccess::allocate_list(_storage).chead();
+  EXPECT_EQ(block, new_block);
+  EXPECT_EQ(block, (TestAccess::active_list(_storage).chead()));
+  EXPECT_TRUE(TestAccess::block_is_empty(*block));
+  EXPECT_FALSE(TestAccess::block_is_full(*block));
+  EXPECT_EQ(0u, TestAccess::block_allocation_count(*block));
+}
+
+TEST_VM_F(OopStorageTest, allocation_count) {
+  static const size_t max_entries = 1000;
+  oop* entries[max_entries];
+
+  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
+  TestAccess::BlockList& allocate_list = TestAccess::allocate_list(_storage);
+
+  EXPECT_TRUE(is_list_empty(active_list));
+  EXPECT_EQ(0u, _storage.block_count());
+  EXPECT_TRUE(is_list_empty(allocate_list));
+
+  size_t allocated = 0;
+  for ( ; allocated < max_entries; ++allocated) {
+    EXPECT_EQ(allocated, _storage.allocation_count());
+    if (!is_list_empty(active_list)) {
+      EXPECT_EQ(1u, list_length(active_list));
+      EXPECT_EQ(1u, _storage.block_count());
+      const OopBlock& block = *active_list.chead();
+      EXPECT_EQ(allocated, TestAccess::block_allocation_count(block));
+      if (TestAccess::block_is_full(block)) {
+        break;
+      } else {
+        EXPECT_FALSE(is_list_empty(allocate_list));
+        EXPECT_EQ(&block, allocate_list.chead());
+      }
+    }
+    entries[allocated] = _storage.allocate();
+  }
+
+  EXPECT_EQ(allocated, _storage.allocation_count());
+  EXPECT_EQ(1u, list_length(active_list));
+  EXPECT_EQ(1u, _storage.block_count());
+  EXPECT_TRUE(is_list_empty(allocate_list));
+  const OopBlock& block = *active_list.chead();
+  EXPECT_TRUE(TestAccess::block_is_full(block));
+  EXPECT_EQ(allocated, TestAccess::block_allocation_count(block));
+
+  for (size_t i = 0; i < allocated; ++i) {
+    release_entry(_storage, entries[i]);
+    size_t remaining = allocated - (i + 1);
+    EXPECT_EQ(remaining, TestAccess::block_allocation_count(block));
+    EXPECT_EQ(remaining, _storage.allocation_count());
+    EXPECT_FALSE(is_list_empty(allocate_list));
+  }
+}
+
+TEST_VM_F(OopStorageTest, allocate_many) {
+  static const size_t max_entries = 1000;
+  oop* entries[max_entries];
+
+  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
+  TestAccess::BlockList& allocate_list = TestAccess::allocate_list(_storage);
+
+  EXPECT_EQ(0u, _storage.empty_block_count());
+
+  entries[0] = _storage.allocate();
+  ASSERT_TRUE(entries[0] != NULL);
+  EXPECT_EQ(1u, list_length(active_list));
+  EXPECT_EQ(1u, _storage.block_count());
+  EXPECT_EQ(1u, list_length(allocate_list));
+  EXPECT_EQ(0u, _storage.empty_block_count());
+
+  const OopBlock* block = active_list.chead();
+  EXPECT_EQ(1u, TestAccess::block_allocation_count(*block));
+  EXPECT_EQ(block, allocate_list.chead());
+
+  for (size_t i = 1; i < max_entries; ++i) {
+    entries[i] = _storage.allocate();
+    EXPECT_EQ(i + 1, _storage.allocation_count());
+    ASSERT_TRUE(entries[i] != NULL);
+    EXPECT_EQ(0u, _storage.empty_block_count());
+
+    if (block == NULL) {
+      ASSERT_FALSE(is_list_empty(allocate_list));
+      EXPECT_EQ(1u, list_length(allocate_list));
+      block = allocate_list.chead();
+      EXPECT_EQ(1u, TestAccess::block_allocation_count(*block));
+      EXPECT_EQ(block, active_list.chead());
+    } else if (TestAccess::block_is_full(*block)) {
+      EXPECT_TRUE(is_list_empty(allocate_list));
+      block = NULL;
+    } else {
+      EXPECT_FALSE(is_list_empty(allocate_list));
+      EXPECT_EQ(block, allocate_list.chead());
+      EXPECT_EQ(block, active_list.chead());
+    }
+  }
+
+  if (block != NULL) {
+    EXPECT_NE(0u, TestAccess::block_allocation_count(*block));
+    EXPECT_FALSE(is_list_empty(allocate_list));
+    EXPECT_EQ(block, allocate_list.chead());
+    EXPECT_EQ(block, active_list.chead());
+  }
+
+  size_t active_count = list_length(active_list);
+
+  for (size_t i = 0; i < max_entries; ++i) {
+    release_entry(_storage, entries[i]);
+    EXPECT_TRUE(is_allocate_list_sorted(_storage));
+    EXPECT_EQ(max_entries - (i + 1), total_allocation_count(active_list));
+  }
+
+  EXPECT_EQ(list_length(active_list), list_length(allocate_list));
+  EXPECT_EQ(list_length(active_list), _storage.block_count());
+  EXPECT_EQ(list_length(active_list), _storage.empty_block_count());
+  for (const OopBlock* block = allocate_list.chead();
+       block != NULL;
+       block = allocate_list.next(*block)) {
+    EXPECT_TRUE(TestAccess::block_is_empty(*block));
+  }
+}
+
+TEST_VM_F(OopStorageTestWithAllocation, random_release) {
+  static const size_t step = 11;
+  ASSERT_NE(0u, _max_entries % step); // max_entries and step are mutually prime
+
+  EXPECT_EQ(0u, _storage.empty_block_count());
+
+  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
+  TestAccess::BlockList& allocate_list = TestAccess::allocate_list(_storage);
+
+  EXPECT_EQ(_max_entries, total_allocation_count(active_list));
+  EXPECT_GE(1u, list_length(allocate_list));
+
+  // Release all entries in "random" order.
+  size_t released = 0;
+  for (size_t i = 0; released < _max_entries; i = (i + step) % _max_entries) {
+    if (_entries[i] != NULL) {
+      release_entry(_storage, _entries[i]);
+      _entries[i] = NULL;
+      ++released;
+      EXPECT_EQ(_max_entries - released, total_allocation_count(active_list));
+      EXPECT_TRUE(is_allocate_list_sorted(_storage));
+    }
+  }
+
+  EXPECT_EQ(list_length(active_list), list_length(allocate_list));
+  EXPECT_EQ(list_length(active_list), _storage.block_count());
+  EXPECT_EQ(0u, total_allocation_count(active_list));
+  EXPECT_EQ(list_length(allocate_list), _storage.empty_block_count());
+}
+
+TEST_VM_F(OopStorageTestWithAllocation, random_allocate_release) {
+  static const size_t release_step = 11;
+  static const size_t allocate_step = 5;
+  ASSERT_NE(0u, _max_entries % release_step); // max_entries and step are mutually prime
+
+  EXPECT_EQ(0u, _storage.empty_block_count());
+
+  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
+  TestAccess::BlockList& allocate_list = TestAccess::allocate_list(_storage);
+
+  EXPECT_EQ(_max_entries, total_allocation_count(active_list));
+  EXPECT_GE(1u, list_length(allocate_list));
+
+  // Release all entries in "random" order, "randomly" interspersed
+  // with additional allocations.
+  size_t released = 0;
+  size_t total_released = 0;
+  for (size_t i = 0; released < _max_entries; i = (i + release_step) % _max_entries) {
+    if (_entries[i] != NULL) {
+      release_entry(_storage, _entries[i]);
+      _entries[i] = NULL;
+      ++released;
+      ++total_released;
+      EXPECT_EQ(_max_entries - released, total_allocation_count(active_list));
+      EXPECT_TRUE(is_allocate_list_sorted(_storage));
+      if (total_released % allocate_step == 0) {
+        _entries[i] = _storage.allocate();
+        --released;
+        EXPECT_EQ(_max_entries - released, total_allocation_count(active_list));
+        EXPECT_TRUE(is_allocate_list_sorted(_storage));
+      }
+    }
+  }
+
+  EXPECT_EQ(list_length(active_list), list_length(allocate_list));
+  EXPECT_EQ(list_length(active_list), _storage.block_count());
+  EXPECT_EQ(0u, total_allocation_count(active_list));
+  EXPECT_EQ(list_length(allocate_list), _storage.empty_block_count());
+}
+
+template<bool sorted>
+class OopStorageTestBlockRelease : public OopStorageTestWithAllocation {
+public:
+  void SetUp() {
+    size_t nrelease = _max_entries / 2;
+    oop** to_release = NEW_C_HEAP_ARRAY(oop*, nrelease, mtInternal);
+
+    for (size_t i = 0; i < nrelease; ++i) {
+      to_release[i] = _entries[2 * i];
+      *to_release[i] = NULL;
+    }
+    if (sorted) {
+      QuickSort::sort(to_release, nrelease, PointerCompare(), false);
+    }
+
+    _storage.release(to_release, nrelease);
+    EXPECT_EQ(_max_entries - nrelease, _storage.allocation_count());
+
+    for (size_t i = 0; i < nrelease; ++i) {
+      release_entry(_storage, _entries[2 * i + 1]);
+      EXPECT_EQ(_max_entries - nrelease - (i + 1), _storage.allocation_count());
+    }
+
+    EXPECT_EQ(_storage.block_count(), _storage.empty_block_count());
+
+    FREE_C_HEAP_ARRAY(oop*, to_release);
+  }
+
+  struct PointerCompare {
+    int operator()(const void* p, const void* q) const {
+      return (p < q) ? -1 : int(p != q);
+    }
+  };
+};
+
+typedef OopStorageTestBlockRelease<true> OopStorageTestBlockReleaseSorted;
+typedef OopStorageTestBlockRelease<false> OopStorageTestBlockReleaseUnsorted;
+
+TEST_VM_F(OopStorageTestBlockReleaseSorted, block_release) {}
+TEST_VM_F(OopStorageTestBlockReleaseUnsorted, block_release) {}
+
+#ifndef DISABLE_GARBAGE_ALLOCATION_STATUS_TESTS
+TEST_VM_F(OopStorageTest, invalid_pointer) {
+  {
+    char* mem = NEW_C_HEAP_ARRAY(char, 1000, mtInternal);
+    oop* ptr = reinterpret_cast<oop*>(align_down(mem + 250, sizeof(oop)));
+    // Predicate returns false for some malloc'ed block.
+    EXPECT_EQ(OopStorage::INVALID_ENTRY, _storage.allocation_status(ptr));
+    FREE_C_HEAP_ARRAY(char, mem);
+  }
+
+  {
+    oop obj;
+    oop* ptr = &obj;
+    // Predicate returns false for some "random" location.
+    EXPECT_EQ(OopStorage::INVALID_ENTRY, _storage.allocation_status(ptr));
+  }
+}
+#endif // DISABLE_GARBAGE_ALLOCATION_STATUS_TESTS
+
+class OopStorageTest::CountingIterateClosure VALUE_OBJ_CLASS_SPEC {
+public:
+  size_t _const_count;
+  size_t _const_non_null;
+  size_t _non_const_count;
+  size_t _non_const_non_null;
+
+  void do_oop(const oop* ptr) {
+    ++_const_count;
+    if (*ptr != NULL) {
+      ++_const_non_null;
+    }
+  }
+
+  void do_oop(oop* ptr) {
+    ++_non_const_count;
+    if (*ptr != NULL) {
+      ++_non_const_non_null;
+    }
+  }
+
+  CountingIterateClosure() :
+    _const_count(0),
+    _const_non_null(0),
+    _non_const_count(0),
+    _non_const_non_null(0)
+  {}
+};
+
+template<bool is_const>
+class OopStorageTest::VM_CountAtSafepoint : public VM_GTestExecuteAtSafepoint {
+public:
+  typedef typename Conditional<is_const,
+                               const OopStorage,
+                               OopStorage>::type Storage;
+
+  VM_CountAtSafepoint(Storage* storage, CountingIterateClosure* cl) :
+    _storage(storage), _cl(cl)
+  {}
+
+  void doit() { _storage->oops_do(_cl); }
+
+private:
+  Storage* _storage;
+  CountingIterateClosure* _cl;
+};
+
+TEST_VM_F(OopStorageTest, simple_iterate) {
+  // Dummy oop value.
+  intptr_t dummy_oop_value = 0xbadbeaf;
+  oop dummy_oop = reinterpret_cast<oopDesc*>(&dummy_oop_value);
+
+  const size_t max_entries = 1000;
+  oop* entries[max_entries];
+
+  size_t allocated = 0;
+  size_t entries_with_values = 0;
+  for (size_t i = 0; i < max_entries; i += 10) {
+    for ( ; allocated < i; ++allocated) {
+      entries[allocated] = _storage.allocate();
+      ASSERT_TRUE(entries[allocated] != NULL);
+      if ((allocated % 3) != 0) {
+        *entries[allocated] = dummy_oop;
+        ++entries_with_values;
+      }
+    }
+
+    {
+      CountingIterateClosure cl;
+      VM_CountAtSafepoint<false> op(&_storage, &cl);
+      {
+        ThreadInVMfromNative invm(JavaThread::current());
+        VMThread::execute(&op);
+      }
+      EXPECT_EQ(allocated, cl._non_const_count);
+      EXPECT_EQ(entries_with_values, cl._non_const_non_null);
+      EXPECT_EQ(0u, cl._const_count);
+      EXPECT_EQ(0u, cl._const_non_null);
+    }
+
+    {
+      CountingIterateClosure cl;
+      VM_CountAtSafepoint<true> op(&_storage, &cl);
+      {
+        ThreadInVMfromNative invm(JavaThread::current());
+        VMThread::execute(&op);
+      }
+      EXPECT_EQ(allocated, cl._const_count);
+      EXPECT_EQ(entries_with_values, cl._const_non_null);
+      EXPECT_EQ(0u, cl._non_const_count);
+      EXPECT_EQ(0u, cl._non_const_non_null);
+    }
+  }
+
+  while (allocated > 0) {
+    release_entry(_storage, entries[--allocated]);
+  }
+}
+
+class OopStorageTestIteration : public OopStorageTestWithAllocation {
+public:
+  static const size_t _max_workers = 2;
+  unsigned char _states[_max_workers][_max_entries];
+
+  static const unsigned char mark_released  = 1u << 0;
+  static const unsigned char mark_invalid   = 1u << 1;
+  static const unsigned char mark_const     = 1u << 2;
+  static const unsigned char mark_non_const = 1u << 3;
+
+  virtual void SetUp() {
+    OopStorageTestWithAllocation::SetUp();
+
+    memset(_states, 0, sizeof(_states));
+
+    size_t initial_release = 0;
+    for ( ; _storage.empty_block_count() < 2; ++initial_release) {
+      ASSERT_GT(_max_entries, initial_release);
+      release_entry(_storage, _entries[initial_release]);
+      _states[0][initial_release] = mark_released;
+    }
+
+    for (size_t i = initial_release; i < _max_entries; i += 3) {
+      release_entry(_storage, _entries[i]);
+      _states[0][i] = mark_released;
+    }
+  }
+
+  class VerifyState;
+  class VerifyFn;
+  template<bool is_const> class VM_Verify;
+
+  class VerifyClosure;
+  class VM_VerifyUsingOopsDo;
+};
+
+const unsigned char OopStorageTestIteration::mark_released;
+const unsigned char OopStorageTestIteration::mark_invalid;
+const unsigned char OopStorageTestIteration::mark_const;
+const unsigned char OopStorageTestIteration::mark_non_const;
+
+class OopStorageTestIteration::VerifyState VALUE_OBJ_CLASS_SPEC {
+public:
+  unsigned char _expected_mark;
+  const oop* const* _entries;
+  unsigned char (&_states)[_max_workers][_max_entries];
+
+  VerifyState(unsigned char expected_mark,
+              const oop* const* entries,
+              unsigned char (&states)[_max_workers][_max_entries]) :
+    _expected_mark(expected_mark),
+    _entries(entries),
+    _states(states)
+  { }
+
+  bool update(const oop* ptr, uint worker_id, unsigned char mark) const {
+    size_t index = 0;
+    bool found = find_entry(ptr, &index);
+    EXPECT_TRUE(found);
+    EXPECT_GT(_max_entries, index);
+    EXPECT_GT(_max_workers, worker_id);
+    if (!found) {
+      return false;
+    } else if (index >= _max_entries) {
+      return false;
+    } else if (worker_id >= _max_workers) {
+      return false;
+    } else {
+      EXPECT_EQ(0, _states[worker_id][index]);
+      if (_states[worker_id][index] != 0) {
+        _states[worker_id][index] |= mark_invalid;
+        return false;
+      } else {
+        _states[worker_id][index] |= mark;
+        return true;
+      }
+    }
+  }
+
+  void check() const {
+    for (size_t i = 0; i < _max_entries; ++i) {
+      unsigned char mark = 0;
+      for (size_t w = 0; w < _max_workers; ++w) {
+        if (mark == 0) {
+          mark = _states[w][i];
+        } else {
+          EXPECT_EQ(0u, _states[w][i]);
+        }
+      }
+      if (mark == 0) {
+        EXPECT_NE(0u, mark);
+      } else if ((mark & mark_released) != 0) {
+        EXPECT_EQ(mark_released, mark);
+      } else {
+        EXPECT_EQ(_expected_mark, mark);
+      }
+    }
+  }
+
+private:
+  bool find_entry(const oop* ptr, size_t* index) const {
+    for (size_t i = 0; i < _max_entries; ++i) {
+      if (ptr == _entries[i]) {
+        *index = i;
+        return true;
+      }
+    }
+    return false;
+  }
+};
+
+class OopStorageTestIteration::VerifyFn VALUE_OBJ_CLASS_SPEC {
+public:
+  VerifyFn(VerifyState* state, uint worker_id = 0) :
+    _state(state),
+    _worker_id(worker_id)
+  {}
+
+  bool operator()(      oop* ptr) const {
+    return _state->update(ptr, _worker_id, mark_non_const);
+  }
+
+  bool operator()(const oop* ptr) const {
+    return _state->update(ptr, _worker_id, mark_const);
+  }
+
+private:
+  VerifyState* _state;
+  uint _worker_id;
+};
+
+class OopStorageTestIteration::VerifyClosure VALUE_OBJ_CLASS_SPEC {
+public:
+  VerifyClosure(VerifyState* state, uint worker_id = 0) :
+    _state(state),
+    _worker_id(worker_id)
+  {}
+
+  void do_oop(oop* ptr) {
+    _state->update(ptr, _worker_id, mark_non_const);
+  }
+
+  void do_oop(const oop* ptr) {
+    _state->update(ptr, _worker_id, mark_const);
+  }
+
+private:
+  VerifyState* _state;
+  uint _worker_id;
+};
+
+const size_t OopStorageTestIteration::_max_workers;
+
+template<bool is_const>
+class OopStorageTestIteration::VM_Verify : public VM_GTestExecuteAtSafepoint {
+public:
+  typedef typename Conditional<is_const,
+                               const OopStorage,
+                               OopStorage>::type Storage;
+
+  VM_Verify(Storage* storage, VerifyState* vstate) :
+    _storage(storage), _vstate(vstate), _result(false)
+  {}
+
+  void doit() {
+    VerifyFn verifier(_vstate);
+    _result = _storage->iterate_safepoint(verifier);
+  }
+
+  bool result() const { return _result; }
+
+private:
+  Storage* _storage;
+  VerifyState* _vstate;
+  bool _result;
+};
+
+class OopStorageTestIteration::VM_VerifyUsingOopsDo : public VM_GTestExecuteAtSafepoint {
+public:
+  VM_VerifyUsingOopsDo(OopStorage* storage, VerifyState* vstate) :
+    _storage(storage), _vstate(vstate)
+  {}
+
+  void doit() {
+    VerifyClosure verifier(_vstate);
+    _storage->oops_do(&verifier);
+  }
+
+private:
+  OopStorage* _storage;
+  VerifyState* _vstate;
+};
+
+TEST_VM_F(OopStorageTestIteration, iterate_safepoint) {
+  VerifyState vstate(mark_non_const, _entries, _states);
+  VM_Verify<false> op(&_storage, &vstate);
+  {
+    ThreadInVMfromNative invm(JavaThread::current());
+    VMThread::execute(&op);
+  }
+  EXPECT_TRUE(op.result());
+  vstate.check();
+}
+
+TEST_VM_F(OopStorageTestIteration, const_iterate_safepoint) {
+  VerifyState vstate(mark_const, _entries, _states);
+  VM_Verify<true> op(&_storage, &vstate);
+  {
+    ThreadInVMfromNative invm(JavaThread::current());
+    VMThread::execute(&op);
+  }
+  EXPECT_TRUE(op.result());
+  vstate.check();
+}
+
+TEST_VM_F(OopStorageTestIteration, oops_do) {
+  VerifyState vstate(mark_non_const, _entries, _states);
+  VM_VerifyUsingOopsDo op(&_storage, &vstate);
+  {
+    ThreadInVMfromNative invm(JavaThread::current());
+    VMThread::execute(&op);
+  }
+  vstate.check();
+}
+
+// Parallel iteration not available unless INCLUDE_ALL_GCS
+#if INCLUDE_ALL_GCS
+
+class OopStorageTestParIteration : public OopStorageTestIteration {
+public:
+  WorkGang* workers();
+
+  class VM_ParStateVerify;
+
+  template<bool concurrent, bool is_const> class Task;
+  template<bool concurrent, bool is_const> class TaskUsingOopsDo;
+
+private:
+  static WorkGang* _workers;
+};
+
+WorkGang* OopStorageTestParIteration::_workers = NULL;
+
+WorkGang* OopStorageTestParIteration::workers() {
+  if (_workers == NULL) {
+    _workers = new WorkGang("OopStorageTestParIteration workers",
+                            _max_workers,
+                            false,
+                            false);
+    _workers->initialize_workers();
+    _workers->update_active_workers(_max_workers);
+  }
+  return _workers;
+}
+
+template<bool concurrent, bool is_const>
+class OopStorageTestParIteration::Task : public AbstractGangTask {
+  typedef OopStorage::ParState<concurrent, is_const> StateType;
+
+  typedef typename Conditional<is_const,
+                               const OopStorage,
+                               OopStorage>::type Storage;
+
+public:
+  Task(const char* name, Storage* storage, VerifyState* vstate) :
+    AbstractGangTask(name, GCId::undefined()),
+    _state(storage),
+    _vstate(vstate)
+  {}
+
+  virtual void work(uint worker_id) {
+    VerifyFn verifier(_vstate, worker_id);
+    _state.iterate(verifier);
+  }
+
+private:
+  StateType _state;
+  VerifyState* _vstate;
+};
+
+template<bool concurrent, bool is_const>
+class OopStorageTestParIteration::TaskUsingOopsDo : public AbstractGangTask {
+public:
+  TaskUsingOopsDo(const char* name, OopStorage* storage, VerifyState* vstate) :
+    AbstractGangTask(name, GCId::undefined()),
+    _state(storage),
+    _vstate(vstate)
+  {}
+
+  virtual void work(uint worker_id) {
+    VerifyClosure verifier(_vstate, worker_id);
+    _state.oops_do(&verifier);
+  }
+
+private:
+  OopStorage::ParState<concurrent, is_const> _state;
+  VerifyState* _vstate;
+};
+
+class OopStorageTestParIteration::VM_ParStateVerify : public VM_GTestExecuteAtSafepoint {
+public:
+  VM_ParStateVerify(WorkGang* workers, AbstractGangTask* task) :
+    _workers(workers), _task(task)
+  {}
+
+  void doit() {
+    _workers->run_task(_task);
+  }
+
+private:
+  WorkGang* _workers;
+  AbstractGangTask* _task;
+};
+
+TEST_VM_F(OopStorageTestParIteration, par_state_safepoint_iterate) {
+  VerifyState vstate(mark_non_const, _entries, _states);
+  Task<false, false> task("test", &_storage, &vstate);
+  VM_ParStateVerify op(workers(), &task);
+  {
+    ThreadInVMfromNative invm(JavaThread::current());
+    VMThread::execute(&op);
+  }
+  vstate.check();
+}
+
+TEST_VM_F(OopStorageTestParIteration, par_state_safepoint_const_iterate) {
+  VerifyState vstate(mark_const, _entries, _states);
+  Task<false, true> task("test", &_storage, &vstate);
+  VM_ParStateVerify op(workers(), &task);
+  {
+    ThreadInVMfromNative invm(JavaThread::current());
+    VMThread::execute(&op);
+  }
+  vstate.check();
+}
+
+TEST_VM_F(OopStorageTestParIteration, par_state_safepoint_oops_do) {
+  VerifyState vstate(mark_non_const, _entries, _states);
+  TaskUsingOopsDo<false, false> task("test", &_storage, &vstate);
+  VM_ParStateVerify op(workers(), &task);
+  {
+    ThreadInVMfromNative invm(JavaThread::current());
+    VMThread::execute(&op);
+  }
+  vstate.check();
+}
+
+TEST_VM_F(OopStorageTestParIteration, par_state_safepoint_const_oops_do) {
+  VerifyState vstate(mark_const, _entries, _states);
+  TaskUsingOopsDo<false, true> task("test", &_storage, &vstate);
+  VM_ParStateVerify op(workers(), &task);
+  {
+    ThreadInVMfromNative invm(JavaThread::current());
+    VMThread::execute(&op);
+  }
+  vstate.check();
+}
+
+TEST_VM_F(OopStorageTestParIteration, par_state_concurrent_iterate) {
+  VerifyState vstate(mark_non_const, _entries, _states);
+  Task<true, false> task("test", &_storage, &vstate);
+  workers()->run_task(&task);
+  vstate.check();
+}
+
+TEST_VM_F(OopStorageTestParIteration, par_state_concurrent_const_iterate) {
+  VerifyState vstate(mark_const, _entries, _states);
+  Task<true, true> task("test", &_storage, &vstate);
+  workers()->run_task(&task);
+  vstate.check();
+}
+
+TEST_VM_F(OopStorageTestParIteration, par_state_concurrent_oops_do) {
+  VerifyState vstate(mark_non_const, _entries, _states);
+  TaskUsingOopsDo<true, false> task("test", &_storage, &vstate);
+  workers()->run_task(&task);
+  vstate.check();
+}
+
+TEST_VM_F(OopStorageTestParIteration, par_state_concurrent_const_oops_do) {
+  VerifyState vstate(mark_const, _entries, _states);
+  TaskUsingOopsDo<true, true> task("test", &_storage, &vstate);
+  workers()->run_task(&task);
+  vstate.check();
+}
+
+#endif // INCLUDE_ALL_GCS
+
+TEST_VM_F(OopStorageTestWithAllocation, delete_empty_blocks_safepoint) {
+  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
+
+  size_t initial_active_size = list_length(active_list);
+  EXPECT_EQ(initial_active_size, _storage.block_count());
+  ASSERT_LE(3u, initial_active_size); // Need at least 3 blocks for test
+
+  for (size_t i = 0; _storage.empty_block_count() < 3; ++i) {
+    ASSERT_GT(_max_entries, i);
+    release_entry(_storage, _entries[i]);
+  }
+
+  EXPECT_EQ(initial_active_size, list_length(active_list));
+  EXPECT_EQ(initial_active_size, _storage.block_count());
+  EXPECT_EQ(3u, _storage.empty_block_count());
+
+  {
+    ThreadInVMfromNative invm(JavaThread::current());
+    VM_DeleteBlocksAtSafepoint op(&_storage, 2);
+    VMThread::execute(&op);
+  }
+  EXPECT_EQ(2u, _storage.empty_block_count());
+  EXPECT_EQ(initial_active_size - 1, list_length(active_list));
+  EXPECT_EQ(initial_active_size - 1, _storage.block_count());
+
+  {
+    ThreadInVMfromNative invm(JavaThread::current());
+    VM_DeleteBlocksAtSafepoint op(&_storage, 0);
+    VMThread::execute(&op);
+  }
+  EXPECT_EQ(0u, _storage.empty_block_count());
+  EXPECT_EQ(initial_active_size - 3, list_length(active_list));
+  EXPECT_EQ(initial_active_size - 3, _storage.block_count());
+}
+
+TEST_VM_F(OopStorageTestWithAllocation, delete_empty_blocks_concurrent) {
+  TestAccess::BlockList& active_list = TestAccess::active_list(_storage);
+
+  size_t initial_active_size = list_length(active_list);
+  EXPECT_EQ(initial_active_size, _storage.block_count());
+  ASSERT_LE(3u, initial_active_size); // Need at least 3 blocks for test
+
+  for (size_t i = 0; _storage.empty_block_count() < 3; ++i) {
+    ASSERT_GT(_max_entries, i);
+    release_entry(_storage, _entries[i]);
+  }
+
+  EXPECT_EQ(initial_active_size, list_length(active_list));
+  EXPECT_EQ(initial_active_size, _storage.block_count());
+  EXPECT_EQ(3u, _storage.empty_block_count());
+
+  _storage.delete_empty_blocks_concurrent(2);
+  EXPECT_EQ(2u, _storage.empty_block_count());
+  EXPECT_EQ(initial_active_size - 1, list_length(active_list));
+  EXPECT_EQ(initial_active_size - 1, _storage.block_count());
+
+  _storage.delete_empty_blocks_concurrent(0);
+  EXPECT_EQ(0u, _storage.empty_block_count());
+  EXPECT_EQ(initial_active_size - 3, list_length(active_list));
+  EXPECT_EQ(initial_active_size - 3, _storage.block_count());
+}
+
+TEST_VM_F(OopStorageTestWithAllocation, allocation_status) {
+  oop* retained = _entries[200];
+  oop* released = _entries[300];
+  oop* garbage = reinterpret_cast<oop*>(1024 * 1024);
+  release_entry(_storage, released);
+
+  EXPECT_EQ(OopStorage::ALLOCATED_ENTRY, _storage.allocation_status(retained));
+  EXPECT_EQ(OopStorage::UNALLOCATED_ENTRY, _storage.allocation_status(released));
+#ifndef DISABLE_GARBAGE_ALLOCATION_STATUS_TESTS
+  EXPECT_EQ(OopStorage::INVALID_ENTRY, _storage.allocation_status(garbage));
+#endif
+
+  for (size_t i = 0; i < _max_entries; ++i) {
+    if ((_entries[i] != retained) && (_entries[i] != released)) {
+      release_entry(_storage, _entries[i]);
+    }
+  }
+
+  {
+    ThreadInVMfromNative invm(JavaThread::current());
+    VM_DeleteBlocksAtSafepoint op(&_storage, 0);
+    VMThread::execute(&op);
+  }
+  EXPECT_EQ(OopStorage::ALLOCATED_ENTRY, _storage.allocation_status(retained));
+#ifndef DISABLE_GARBAGE_ALLOCATION_STATUS_TESTS
+  EXPECT_EQ(OopStorage::INVALID_ENTRY, _storage.allocation_status(released));
+  EXPECT_EQ(OopStorage::INVALID_ENTRY, _storage.allocation_status(garbage));
+#endif // DISABLE_GARBAGE_ALLOCATION_STATUS_TESTS
+}
+
+TEST_VM_F(OopStorageTest, usage_info) {
+  size_t goal_blocks = 5;
+  oop* entries[1000];
+  size_t allocated = 0;
+
+  EXPECT_EQ(0u, _storage.block_count());
+  // There is non-block overhead, so always some usage.
+  EXPECT_LT(0u, _storage.total_memory_usage());
+
+  while (_storage.block_count() < goal_blocks) {
+    size_t this_count = _storage.block_count();
+    while (_storage.block_count() == this_count) {
+      ASSERT_GT(ARRAY_SIZE(entries), allocated);
+      entries[allocated] = _storage.allocate();
+      ASSERT_TRUE(entries[allocated] != NULL);
+      ++allocated;
+    }
+    EXPECT_NE(0u, _storage.block_count());
+    EXPECT_NE(0u, _storage.total_memory_usage());
+  }
+
+  EXPECT_LT(TestAccess::memory_per_block() * _storage.block_count(),
+            _storage.total_memory_usage());
+}
+
+#ifndef PRODUCT
+
+TEST_VM_F(OopStorageTestWithAllocation, print_storage) {
+  // Release the first 1/2
+  for (size_t i = 0; i < (_max_entries / 2); ++i) {
+    release_entry(_storage, _entries[i]);
+    _entries[i] = NULL;
+  }
+  // Release every other remaining
+  for (size_t i = _max_entries / 2; i < _max_entries; i += 2) {
+    release_entry(_storage, _entries[i]);
+    _entries[i] = NULL;
+  }
+
+  size_t expected_entries = _max_entries / 4;
+  EXPECT_EQ(expected_entries, _storage.allocation_count());
+
+  size_t entries_per_block = BitsPerWord;
+  size_t expected_blocks = (_max_entries + entries_per_block - 1) / entries_per_block;
+  EXPECT_EQ(expected_blocks, _storage.block_count());
+
+  size_t expected_empties = (_max_entries / 2) / entries_per_block;
+  EXPECT_EQ(expected_empties, _storage.empty_block_count());
+
+  size_t expected_used = expected_blocks - expected_empties;
+
+  double expected_usage = (100.0 * expected_entries) / (expected_used * entries_per_block);
+
+  {
+    ResourceMark rm;
+    stringStream expected_st;
+    expected_st.print("Test Storage: " SIZE_FORMAT
+                      " entries in " SIZE_FORMAT
+                      " blocks (%.F%%), " SIZE_FORMAT
+                      " empties, " SIZE_FORMAT " bytes",
+                      expected_entries,
+                      expected_used,
+                      expected_usage,
+                      expected_empties,
+                      _storage.total_memory_usage());
+    stringStream st;
+    _storage.print_on(&st);
+    EXPECT_STREQ(expected_st.as_string(), st.as_string());
+  }
+}
+
+#endif // !PRODUCT
+
+//////////////////////////////////////////////////////////////////////////////
+// Unit tests for block lists
+
+class OopStorageBlockListTest : public ::testing::Test {
+public:
+  OopStorageBlockListTest() {
+    for (size_t i = 0; i < nvalues; ++i) {
+      values[i] = OopBlock::new_block(pseudo_owner());
+    }
+  }
+
+  ~OopStorageBlockListTest() {
+    for (size_t i = 0; i < nvalues; ++i) {
+      OopBlock::delete_block(*values[i]);
+    }
+  }
+
+  static const size_t nvalues = 10;
+  OopBlock* values[nvalues];
+
+private:
+  // The only thing we actually care about is the address of the owner.
+  static const size_t pseudo_owner_size = sizeof(OopStorage) / sizeof(void*);
+  static const void* const _pseudo_owner[pseudo_owner_size];
+  static const OopStorage* pseudo_owner() {
+    return reinterpret_cast<const OopStorage*>(&_pseudo_owner);
+  }
+};
+
+const size_t OopStorageBlockListTest::nvalues;
+const void* const OopStorageBlockListTest::_pseudo_owner[] = {};
+
+TEST_F(OopStorageBlockListTest, empty_list) {
+  TestAccess::BlockList list(&OopBlock::get_active_entry);
+
+  EXPECT_TRUE(is_list_empty(list));
+  EXPECT_EQ(NULL_BLOCK, list.head());
+  EXPECT_EQ(NULL_BLOCK, list.chead());
+  EXPECT_EQ(NULL_BLOCK, list.ctail());
+}
+
+TEST_F(OopStorageBlockListTest, push_back) {
+  TestAccess::BlockList list(&OopBlock::get_active_entry);
+
+  for (size_t i = 0; i < nvalues; ++i) {
+    list.push_back(*values[i]);
+    EXPECT_FALSE(is_list_empty(list));
+    EXPECT_EQ(list.ctail(), values[i]);
+  }
+
+  EXPECT_EQ(list.chead(), list.head());
+  EXPECT_EQ(list.chead(), values[0]);
+  EXPECT_EQ(list.ctail(), values[nvalues - 1]);
+
+  const OopBlock* block = list.chead();
+  for (size_t i = 0; i < nvalues; ++i) {
+    EXPECT_EQ(block, values[i]);
+    block = list.next(*block);
+  }
+  EXPECT_EQ(NULL_BLOCK, block);
+
+  block = list.ctail();
+  for (size_t i = 0; i < nvalues; ++i) {
+    EXPECT_EQ(block, values[nvalues - i - 1]);
+    block = list.prev(*block);
+  }
+  EXPECT_EQ(NULL_BLOCK, block);
+
+  clear_list(list);
+}
+
+TEST_F(OopStorageBlockListTest, push_front) {
+  TestAccess::BlockList list(&OopBlock::get_active_entry);
+
+  for (size_t i = 0; i < nvalues; ++i) {
+    list.push_front(*values[i]);
+    EXPECT_FALSE(is_list_empty(list));
+    EXPECT_EQ(list.head(), values[i]);
+  }
+
+  EXPECT_EQ(list.chead(), list.head());
+  EXPECT_EQ(list.chead(), values[nvalues - 1]);
+  EXPECT_EQ(list.ctail(), values[0]);
+
+  const OopBlock* block = list.chead();
+  for (size_t i = 0; i < nvalues; ++i) {
+    EXPECT_EQ(block, values[nvalues - i - 1]);
+    block = list.next(*block);
+  }
+  EXPECT_EQ(NULL_BLOCK, block);
+
+  block = list.ctail();
+  for (size_t i = 0; i < nvalues; ++i) {
+    EXPECT_EQ(block, values[i]);
+    block = list.prev(*block);
+  }
+  EXPECT_EQ(NULL_BLOCK, block);
+
+  clear_list(list);
+}
+
+class OopStorageBlockListTestWithList : public OopStorageBlockListTest {
+public:
+  OopStorageBlockListTestWithList() : list(&OopBlock::get_active_entry) {
+    for (size_t i = 0; i < nvalues; ++i) {
+      list.push_back(*values[i]);
+    }
+  }
+
+  ~OopStorageBlockListTestWithList() {
+    clear_list(list);
+  }
+
+  TestAccess::BlockList list;
+};
+
+TEST_F(OopStorageBlockListTestWithList, unlink_front) {
+  EXPECT_EQ(list.chead(), values[0]);
+  EXPECT_EQ(list.ctail(), values[nvalues - 1]);
+
+  list.unlink(*values[0]);
+  EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));
+  EXPECT_EQ(NULL_BLOCK, list.prev(*values[0]));
+  EXPECT_EQ(list.chead(), values[1]);
+  EXPECT_EQ(list.ctail(), values[nvalues - 1]);
+
+  const OopBlock* block = list.chead();
+  for (size_t i = 1; i < nvalues; ++i) {
+    EXPECT_EQ(block, values[i]);
+    block = list.next(*block);
+  }
+  EXPECT_EQ(NULL_BLOCK, block);
+}
+
+TEST_F(OopStorageBlockListTestWithList, unlink_back) {
+  EXPECT_EQ(list.chead(), values[0]);
+
+  list.unlink(*values[nvalues - 1]);
+  EXPECT_EQ(NULL_BLOCK, list.next(*values[nvalues - 1]));
+  EXPECT_EQ(NULL_BLOCK, list.prev(*values[nvalues - 1]));
+  EXPECT_EQ(list.chead(), values[0]);
+  EXPECT_EQ(list.ctail(), values[nvalues - 2]);
+
+  const OopBlock* block = list.chead();
+  for (size_t i = 0; i < nvalues - 1; ++i) {
+    EXPECT_EQ(block, values[i]);
+    block = list.next(*block);
+  }
+  EXPECT_EQ(NULL_BLOCK, block);
+}
+
+TEST_F(OopStorageBlockListTestWithList, unlink_middle) {
+  EXPECT_EQ(list.chead(), values[0]);
+
+  size_t index = nvalues / 2;
+
+  list.unlink(*values[index]);
+  EXPECT_EQ(NULL_BLOCK, list.next(*values[index]));
+  EXPECT_EQ(NULL_BLOCK, list.prev(*values[index]));
+  EXPECT_EQ(list.chead(), values[0]);
+  EXPECT_EQ(list.ctail(), values[nvalues - 1]);
+
+  const OopBlock* block = list.chead();
+  for (size_t i = 0; i < index; ++i) {
+    EXPECT_EQ(block, values[i]);
+    block = list.next(*block);
+  }
+  for (size_t i = index + 1; i < nvalues; ++i) {
+    EXPECT_EQ(block, values[i]);
+    block = list.next(*block);
+  }
+  EXPECT_EQ(NULL_BLOCK, block);
+}
+
+TEST_F(OopStorageBlockListTest, single) {
+  TestAccess::BlockList list(&OopBlock::get_active_entry);
+
+  list.push_back(*values[0]);
+  EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));
+  EXPECT_EQ(NULL_BLOCK, list.prev(*values[0]));
+  EXPECT_EQ(list.chead(), values[0]);
+  EXPECT_EQ(list.ctail(), values[0]);
+
+  list.unlink(*values[0]);
+  EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));
+  EXPECT_EQ(NULL_BLOCK, list.prev(*values[0]));
+  EXPECT_EQ(NULL_BLOCK, list.chead());
+  EXPECT_EQ(NULL_BLOCK, list.ctail());
+}
+
+TEST_F(OopStorageBlockListTestWithList, two_lists) {
+  TestAccess::BlockList list2(&OopBlock::get_allocate_entry);
+  for (size_t i = 0; i < nvalues; ++i) {
+    list2.push_front(*values[i]);
+  }
+
+  const OopBlock* active_block = list.chead();
+  const OopBlock* allocate_block = list2.ctail();
+  for (size_t i = 0; i < nvalues; ++i) {
+    EXPECT_EQ(active_block, allocate_block);
+    active_block = list.next(*active_block);
+    allocate_block = list2.prev(*allocate_block);
+  }
+  EXPECT_EQ(NULL_BLOCK, active_block);
+  EXPECT_EQ(NULL_BLOCK, allocate_block);
+
+  for (size_t i = 0; i < nvalues; ++i) {
+    list2.unlink(*values[i]);
+  }
+  EXPECT_TRUE(is_list_empty(list2));
+
+  active_block = list.chead();
+  for (size_t i = 0; i < nvalues; ++i) {
+    EXPECT_EQ(active_block, values[i]);
+    active_block = list.next(*active_block);
+  }
+  EXPECT_EQ(NULL_BLOCK, active_block);
+}
+
--- a/test/hotspot/gtest/gtestMain.cpp	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/gtest/gtestMain.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -111,7 +111,11 @@
     const char* name = test_info.name();
     if (!_is_initialized && is_suffix("_test_vm", name)) {
       // we want to have hs_err and core files when we execute regular tests
-      ASSERT_EQ(0, init_jvm(_argc, _argv, false)) << "Could not initialize the JVM";
+      int ret_val = init_jvm(_argc, _argv, false);
+      if (ret_val != 0) {
+        ADD_FAILURE() << "Could not initialize the JVM";
+        exit(1);
+      }
       _is_initialized = true;
     }
   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/gtest/opto/test_mathexact.cpp	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,40 @@
+/*
+ * 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 "opto/mulnode.hpp"
+#include "opto/mathexactnode.hpp"
+#include "unittest.hpp"
+
+TEST_VM(opto, mathexact) {
+  ASSERT_FALSE(OverflowMulLNode::is_overflow(1, 1));
+  ASSERT_FALSE(OverflowMulLNode::is_overflow(1, min_jlong));
+  ASSERT_TRUE(OverflowMulLNode::is_overflow(-1, min_jlong));
+  ASSERT_FALSE(OverflowMulLNode::is_overflow(-1, max_jlong));
+  ASSERT_TRUE(OverflowMulLNode::is_overflow(max_jlong / 2 + 1, 2));
+  ASSERT_FALSE(OverflowMulLNode::is_overflow(min_jlong, 0));
+  ASSERT_FALSE(OverflowMulLNode::is_overflow(min_jlong + 1, -1));
+  ASSERT_TRUE(OverflowMulLNode::is_overflow(min_jlong + 1, 2));
+}
+
--- a/test/hotspot/jtreg/compiler/aot/DeoptimizationTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/DeoptimizationTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.aot.DeoptimizationTest
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *     sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname libDeoptimizationTest.so
+ * @run driver compiler.aot.AotCompiler -libname libDeoptimizationTest.so
  *     -class compiler.aot.DeoptimizationTest
  *     -compile compiler.aot.DeoptimizationTest.testMethod()D
  *     -extraopt -XX:-UseCompressedOops
--- a/test/hotspot/jtreg/compiler/aot/RecompilationTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/RecompilationTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.aot.RecompilationTest
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *     sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname libRecompilationTest1.so
+ * @run driver compiler.aot.AotCompiler -libname libRecompilationTest1.so
  *     -class compiler.whitebox.SimpleTestCaseHelper
  *     -extraopt -Dgraal.TieredAOT=true -extraopt -Dgraal.ProfileSimpleMethods=true
  *     -extraopt -Dgraal.ProbabilisticProfiling=false
@@ -44,7 +44,7 @@
  *     -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  *     -Dcompiler.aot.RecompilationTest.check_level=1
  *     compiler.aot.RecompilationTest
- * @run main compiler.aot.AotCompiler -libname libRecompilationTest2.so
+ * @run driver compiler.aot.AotCompiler -libname libRecompilationTest2.so
  *     -class compiler.whitebox.SimpleTestCaseHelper
  *     -extraopt -Dgraal.TieredAOT=false
  *     -extraopt -XX:+UnlockDiagnosticVMOptions -extraopt -XX:+WhiteBoxAPI -extraopt -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/compiler/aot/SharedUsageTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/SharedUsageTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.aot.SharedUsageTest
  *        compiler.aot.AotCompiler
- * @run main compiler.aot.AotCompiler -libname libSharedUsageTest.so
+ * @run driver compiler.aot.AotCompiler -libname libSharedUsageTest.so
  *      -class compiler.aot.SharedUsageTest
  *      -extraopt -XX:-UseCompressedOops
  * @run main/othervm -XX:+UseAOT -XX:AOTLibrary=./libSharedUsageTest.so
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeDynamic2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeDynamic2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,10 +30,10 @@
  * @build compiler.calls.common.InvokeDynamic
  *        compiler.calls.common.InvokeDynamicPatcher
  *        compiler.aot.AotCompiler
- * @run main compiler.calls.common.InvokeDynamicPatcher
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeDynamic2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeDynamic2AotTest.so
  *      -class compiler.calls.common.InvokeDynamic
  *      -extraopt -XX:+UnlockDiagnosticVMOptions -extraopt -XX:+WhiteBoxAPI -extraopt -Xbootclasspath/a:.
  * @run main/othervm -XX:+UseAOT -XX:AOTLibrary=./AotInvokeDynamic2AotTest.so
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeDynamic2CompiledTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeDynamic2CompiledTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,10 +30,10 @@
  * @build compiler.calls.common.InvokeDynamic
  *        compiler.calls.common.InvokeDynamicPatcher
  *        compiler.aot.AotCompiler
- * @run main compiler.calls.common.InvokeDynamicPatcher
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeDynamic2CompiledTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeDynamic2CompiledTest.so
  *      -class compiler.calls.common.InvokeDynamic
  *      -compile compiler.calls.common.InvokeDynamic.caller()V
  * @run main/othervm -Xbatch -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeDynamic2InterpretedTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeDynamic2InterpretedTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,10 +30,10 @@
  * @build compiler.calls.common.InvokeDynamic
  *        compiler.calls.common.InvokeDynamicPatcher
  *        compiler.aot.AotCompiler
- * @run main compiler.calls.common.InvokeDynamicPatcher
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname AotInvokeDynamic2InterpretedTest.so
  *      -class compiler.calls.common.InvokeDynamic
  *      -compile compiler.calls.common.InvokeDynamic.caller()V
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeDynamic2NativeTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeDynamic2NativeTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,10 +30,10 @@
  * @build compiler.calls.common.InvokeDynamic
  *        compiler.calls.common.InvokeDynamicPatcher
  *        compiler.aot.AotCompiler
- * @run main compiler.calls.common.InvokeDynamicPatcher
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeDynamic2NativeTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeDynamic2NativeTest.so
  *      -class compiler.calls.common.InvokeDynamic
  *      -compile compiler.calls.common.InvokeDynamic.caller()V
  * @run main/othervm/native -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeInterface2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeInterface2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeInterface
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeInterface2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeInterface2AotTest.so
  *      -class compiler.calls.common.InvokeInterface
  *      -extraopt -XX:+UnlockDiagnosticVMOptions -extraopt -XX:+WhiteBoxAPI -extraopt -Xbootclasspath/a:.
  * @run main/othervm -XX:+UseAOT -XX:AOTLibrary=./AotInvokeInterface2AotTest.so
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeInterface2CompiledTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeInterface2CompiledTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeInterface
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname AotInvokeInterface2CompiledTest.so
  *      -class compiler.calls.common.InvokeInterface
  *      -compile compiler.calls.common.InvokeInterface.caller()V
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeInterface2InterpretedTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeInterface2InterpretedTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeInterface
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname AotInvokeInterface2InterpretedTest.so
  *      -class compiler.calls.common.InvokeInterface
  *      -compile compiler.calls.common.InvokeInterface.caller()V
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeInterface2NativeTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeInterface2NativeTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeInterface
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeInterface2NativeTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeInterface2NativeTest.so
  *      -class compiler.calls.common.InvokeInterface
  *      -compile compiler.calls.common.InvokeInterface.caller()V
  * @run main/othervm/native -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeSpecial2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeSpecial2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeSpecial
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeSpecial2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeSpecial2AotTest.so
  *      -class compiler.calls.common.InvokeSpecial
  *      -extraopt -XX:+UnlockDiagnosticVMOptions -extraopt -XX:+WhiteBoxAPI -extraopt -Xbootclasspath/a:.
  * @run main/othervm -XX:+UseAOT -XX:AOTLibrary=./AotInvokeSpecial2AotTest.so
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeSpecial2CompiledTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeSpecial2CompiledTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeSpecial
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeSpecial2CompiledTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeSpecial2CompiledTest.so
  *      -class compiler.calls.common.InvokeSpecial
  *      -compile compiler.calls.common.InvokeSpecial.caller()V
  * @run main/othervm -Xbatch -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeSpecial2InterpretedTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeSpecial2InterpretedTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeSpecial
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname AotInvokeSpecial2InterpretedTest.so
  *      -class compiler.calls.common.InvokeSpecial
  *      -compile compiler.calls.common.InvokeSpecial.caller()V
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeSpecial2NativeTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeSpecial2NativeTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeSpecial
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeSpecial2NativeTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeSpecial2NativeTest.so
  *      -class compiler.calls.common.InvokeSpecial
  *      -compile compiler.calls.common.InvokeSpecial.caller()V
  * @run main/othervm/native -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeStatic2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeStatic2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeStatic
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeStatic2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeStatic2AotTest.so
  *      -class compiler.calls.common.InvokeStatic
  *      -extraopt -XX:+UnlockDiagnosticVMOptions -extraopt -XX:+WhiteBoxAPI -extraopt -Xbootclasspath/a:.
  * @run main/othervm -XX:+UseAOT -XX:AOTLibrary=./AotInvokeStatic2AotTest.so
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeStatic2CompiledTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeStatic2CompiledTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeStatic
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeStatic2CompiledTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeStatic2CompiledTest.so
  *      -class compiler.calls.common.InvokeStatic
  *      -compile compiler.calls.common.InvokeStatic.caller()V
  * @run main/othervm -Xbatch -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeStatic2InterpretedTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeStatic2InterpretedTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeStatic
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname AotInvokeStatic2InterpretedTest.so
  *      -class compiler.calls.common.InvokeStatic
  *      -compile compiler.calls.common.InvokeStatic.caller()V
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeStatic2NativeTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeStatic2NativeTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeStatic
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeStatic2NativeTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeStatic2NativeTest.so
  *      -class compiler.calls.common.InvokeStatic
  *      -compile compiler.calls.common.InvokeStatic.caller()V
  * @run main/othervm/native -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeVirtual2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeVirtual2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeVirtual
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeVirtual2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeVirtual2AotTest.so
  *      -class compiler.calls.common.InvokeVirtual
  *      -extraopt -XX:+UnlockDiagnosticVMOptions -extraopt -XX:+WhiteBoxAPI -extraopt -Xbootclasspath/a:.
  * @run main/othervm -XX:+UseAOT -XX:AOTLibrary=./AotInvokeVirtual2AotTest.so
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeVirtual2CompiledTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeVirtual2CompiledTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeVirtual
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeVirtual2CompiledTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeVirtual2CompiledTest.so
  *      -class compiler.calls.common.InvokeVirtual
  *      -compile compiler.calls.common.InvokeVirtual.caller()V
  * @run main/othervm -Xbatch -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeVirtual2InterpretedTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeVirtual2InterpretedTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeVirtual
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname AotInvokeVirtual2InterpretedTest.so
  *      -class compiler.calls.common.InvokeVirtual
  *      -compile compiler.calls.common.InvokeVirtual.caller()V
--- a/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeVirtual2NativeTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromAot/AotInvokeVirtual2NativeTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeVirtual
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname AotInvokeVirtual2NativeTest.so
+ * @run driver compiler.aot.AotCompiler -libname AotInvokeVirtual2NativeTest.so
  *      -class compiler.calls.common.InvokeVirtual
  *      -compile compiler.calls.common.InvokeVirtual.caller()V
  * @run main/othervm/native -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromCompiled/CompiledInvokeDynamic2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromCompiled/CompiledInvokeDynamic2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,10 +30,10 @@
  * @build compiler.calls.common.InvokeDynamic
  *        compiler.calls.common.InvokeDynamicPatcher
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.calls.common.InvokeDynamicPatcher
- * @run main compiler.aot.AotCompiler -libname CompiledInvokeDynamic2AotTest.so
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
+ * @run driver compiler.aot.AotCompiler -libname CompiledInvokeDynamic2AotTest.so
  *      -class compiler.calls.common.InvokeDynamic
  *      -compile compiler.calls.common.InvokeDynamic.callee.*
  * @run main/othervm -Xbatch -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromCompiled/CompiledInvokeInterface2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromCompiled/CompiledInvokeInterface2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeInterface
  *      compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname CompiledInvokeInterface2AotTest.so
  *      -class compiler.calls.common.InvokeInterface
  *      -compile compiler.calls.common.InvokeInterface.callee.*
--- a/test/hotspot/jtreg/compiler/aot/calls/fromCompiled/CompiledInvokeSpecial2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromCompiled/CompiledInvokeSpecial2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeSpecial
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname CompiledInvokeSpecial2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname CompiledInvokeSpecial2AotTest.so
  *      -class compiler.calls.common.InvokeSpecial
  *      -compile compiler.calls.common.InvokeSpecial.callee.*
  * @run main/othervm -Xbatch -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromCompiled/CompiledInvokeStatic2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromCompiled/CompiledInvokeStatic2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeStatic
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname CompiledInvokeStatic2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname CompiledInvokeStatic2AotTest.so
  *      -class compiler.calls.common.InvokeStatic
  *      -compile compiler.calls.common.InvokeStatic.callee.*
  * @run main/othervm -Xbatch -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromCompiled/CompiledInvokeVirtual2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromCompiled/CompiledInvokeVirtual2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeVirtual
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname CompiledInvokeVirtual2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname CompiledInvokeVirtual2AotTest.so
  *      -class compiler.calls.common.InvokeVirtual
  *      -compile compiler.calls.common.InvokeVirtual.callee.*
  * @run main/othervm -Xbatch -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromInterpreted/InterpretedInvokeDynamic2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromInterpreted/InterpretedInvokeDynamic2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,10 +30,10 @@
  * @build compiler.calls.common.InvokeDynamic
  *        compiler.calls.common.InvokeDynamicPatcher
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.calls.common.InvokeDynamicPatcher
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
+ * @run driver compiler.aot.AotCompiler
  *      -libname InterpretedInvokeDynamic2AotTest.so
  *      -class compiler.calls.common.InvokeDynamic
  *      -compile compiler.calls.common.InvokeDynamic.callee.*
--- a/test/hotspot/jtreg/compiler/aot/calls/fromInterpreted/InterpretedInvokeInterface2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromInterpreted/InterpretedInvokeInterface2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeInterface
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname InterpretedInvokeInterface2AotTest.so
  *      -class compiler.calls.common.InvokeInterface
  *      -compile compiler.calls.common.InvokeInterface.callee.*
--- a/test/hotspot/jtreg/compiler/aot/calls/fromInterpreted/InterpretedInvokeSpecial2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromInterpreted/InterpretedInvokeSpecial2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeSpecial
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname InterpretedInvokeSpecial2AotTest.so
  *      -class compiler.calls.common.InvokeSpecial
  *      -compile compiler.calls.common.InvokeSpecial.callee.*
--- a/test/hotspot/jtreg/compiler/aot/calls/fromInterpreted/InterpretedInvokeStatic2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromInterpreted/InterpretedInvokeStatic2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeStatic
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname InterpretedInvokeStatic2AotTest.so
  *      -class compiler.calls.common.InvokeStatic
  *      -compile compiler.calls.common.InvokeStatic.callee.*
--- a/test/hotspot/jtreg/compiler/aot/calls/fromInterpreted/InterpretedInvokeVirtual2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromInterpreted/InterpretedInvokeVirtual2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeVirtual
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler
  *      -libname InterpretedInvokeVirtual2AotTest.so
  *      -class compiler.calls.common.InvokeVirtual
  *      -compile compiler.calls.common.InvokeVirtual.callee.*
--- a/test/hotspot/jtreg/compiler/aot/calls/fromNative/NativeInvokeSpecial2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromNative/NativeInvokeSpecial2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeSpecial
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname NativeInvokeSpecial2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname NativeInvokeSpecial2AotTest.so
  *      -class compiler.calls.common.InvokeSpecial
  *      -compile compiler.calls.common.InvokeSpecial.callee.*
  * @run main/othervm/native -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromNative/NativeInvokeStatic2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromNative/NativeInvokeStatic2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeStatic
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname NativeInvokeStatic2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname NativeInvokeStatic2AotTest.so
  *      -class compiler.calls.common.InvokeStatic
  *      -compile compiler.calls.common.InvokeStatic.callee.*
  * @run main/othervm/native -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/aot/calls/fromNative/NativeInvokeVirtual2AotTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/aot/calls/fromNative/NativeInvokeVirtual2AotTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,9 +28,9 @@
  * @modules java.base/jdk.internal.misc
  * @build compiler.calls.common.InvokeVirtual
  *        compiler.aot.AotCompiler
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *      sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main compiler.aot.AotCompiler -libname NativeInvokeVirtual2AotTest.so
+ * @run driver compiler.aot.AotCompiler -libname NativeInvokeVirtual2AotTest.so
  *      -class compiler.calls.common.InvokeVirtual
  *      -compile compiler.calls.common.InvokeVirtual.callee.*
  * @run main/othervm/native -XX:+UseAOT
--- a/test/hotspot/jtreg/compiler/calls/fromCompiled/CompiledInvokeDynamic2CompiledTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/calls/fromCompiled/CompiledInvokeDynamic2CompiledTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  *          java.base/jdk.internal.org.objectweb.asm
  *
  * @build sun.hotspot.WhiteBox
- * @run main compiler.calls.common.InvokeDynamicPatcher
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/compiler/calls/fromCompiled/CompiledInvokeDynamic2InterpretedTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/calls/fromCompiled/CompiledInvokeDynamic2InterpretedTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  *          java.base/jdk.internal.org.objectweb.asm
  *
  * @build sun.hotspot.WhiteBox
- * @run main compiler.calls.common.InvokeDynamicPatcher
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/compiler/calls/fromCompiled/CompiledInvokeDynamic2NativeTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/calls/fromCompiled/CompiledInvokeDynamic2NativeTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  *          java.base/jdk.internal.org.objectweb.asm
  *
  * @build sun.hotspot.WhiteBox
- * @run main compiler.calls.common.InvokeDynamicPatcher
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/native -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2CompiledTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2CompiledTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  *          java.base/jdk.internal.org.objectweb.asm
  *
  * @build sun.hotspot.WhiteBox
- * @run main compiler.calls.common.InvokeDynamicPatcher
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2InterpretedTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2InterpretedTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  *          java.base/jdk.internal.org.objectweb.asm
  *
  * @build sun.hotspot.WhiteBox
- * @run main compiler.calls.common.InvokeDynamicPatcher
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2NativeTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2NativeTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  *          java.base/jdk.internal.org.objectweb.asm
  *
  * @build sun.hotspot.WhiteBox
- * @run main compiler.calls.common.InvokeDynamicPatcher
+ * @run driver compiler.calls.common.InvokeDynamicPatcher
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/native -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/compiler/ciReplay/TestDumpReplay.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/compiler/ciReplay/TestDumpReplay.java	Tue Jan 30 16:41:40 2018 +0100
@@ -26,7 +26,7 @@
  * @library /test/lib
  * @modules java.base/jdk.internal.misc:+open
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions
  *                   -Xbootclasspath/a:. -XX:+WhiteBoxAPI
  *                   -Xbatch -XX:-TieredCompilation -XX:+AlwaysIncrementalInline
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/compiler/intrinsics/mathexact/LongMulOverflowTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,64 @@
+/*
+ * 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 8191915
+ * @summary Regression test for multiplyExact intrinsic
+ * @library /test/lib /
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ *
+ * @run main/othervm -Xcomp -XX:-TieredCompilation compiler.intrinsics.mathexact.LongMulOverflowTest
+ */
+
+package compiler.intrinsics.mathexact;
+
+public class LongMulOverflowTest {
+    public static void main(String[] args) {
+        LongMulOverflowTest test = new LongMulOverflowTest();
+        for (int i = 0; i < 10; ++i) {
+            try {
+                test.runTest();
+                throw new RuntimeException("Error, runTest() did not overflow!");
+            } catch (ArithmeticException e) {
+                // success
+            }
+
+            try {
+                test.runTestOverflow();
+                throw new RuntimeException("Error, runTestOverflow() did not overflow!");
+            } catch (ArithmeticException e) {
+                // success
+            }
+        }
+    }
+
+    public void runTest() {
+        java.lang.Math.multiplyExact(Long.MIN_VALUE, 7);
+    }
+
+    public void runTestOverflow() {
+      java.lang.Math.multiplyExact((Long.MAX_VALUE / 2) + 1, 2);
+    }
+}
--- a/test/hotspot/jtreg/gc/TestAgeOutput.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/TestAgeOutput.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -XX:+UseSerialGC TestAgeOutput UseSerialGC
  * @run main/othervm -XX:+UseConcMarkSweepGC TestAgeOutput UseConcMarkSweepGC
  * @run main/othervm -XX:+UseG1GC TestAgeOutput UseG1GC
--- a/test/hotspot/jtreg/gc/TestNumWorkerOutput.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/TestNumWorkerOutput.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -XX:+UseConcMarkSweepGC TestNumWorkerOutput UseConcMarkSweepGC
  * @run main/othervm -XX:+UseG1GC TestNumWorkerOutput UseG1GC
  */
--- a/test/hotspot/jtreg/gc/TestSmallHeap.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/TestSmallHeap.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestSmallHeap
  */
 
--- a/test/hotspot/jtreg/gc/arguments/TestCMSHeapSizeFlags.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestCMSHeapSizeFlags.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm TestCMSHeapSizeFlags
  * @author thomas.schatzl@oracle.com
--- a/test/hotspot/jtreg/gc/arguments/TestG1HeapSizeFlags.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestG1HeapSizeFlags.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm TestG1HeapSizeFlags
  * @author thomas.schatzl@oracle.com
--- a/test/hotspot/jtreg/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver TestMinAndInitialSurvivorRatioFlags
  */
 
--- a/test/hotspot/jtreg/gc/arguments/TestMinInitialErgonomics.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestMinInitialErgonomics.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm TestMinInitialErgonomics
  * @author thomas.schatzl@oracle.com
--- a/test/hotspot/jtreg/gc/arguments/TestNewRatioFlag.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestNewRatioFlag.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver TestNewRatioFlag
  */
 
--- a/test/hotspot/jtreg/gc/arguments/TestNewSizeFlags.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestNewSizeFlags.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver/timeout=240  TestNewSizeFlags
  */
 
--- a/test/hotspot/jtreg/gc/arguments/TestParallelHeapSizeFlags.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestParallelHeapSizeFlags.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm TestParallelHeapSizeFlags
  * @author thomas.schatzl@oracle.com
--- a/test/hotspot/jtreg/gc/arguments/TestSerialHeapSizeFlags.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestSerialHeapSizeFlags.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm TestSerialHeapSizeFlags
  * @author thomas.schatzl@oracle.com
--- a/test/hotspot/jtreg/gc/arguments/TestSmallInitialHeapWithLargePageAndNUMA.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestSmallInitialHeapWithLargePageAndNUMA.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build TestSmallInitialHeapWithLargePageAndNUMA
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UseHugeTLBFS -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestSmallInitialHeapWithLargePageAndNUMA
 */
 
--- a/test/hotspot/jtreg/gc/arguments/TestSurvivorRatioFlag.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestSurvivorRatioFlag.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver TestSurvivorRatioFlag
  */
 
--- a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver TestTargetSurvivorRatioFlag
  */
 
--- a/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsErgo.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsErgo.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management/sun.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm TestUseCompressedOopsErgo -XX:+UseG1GC
  * @run main/othervm TestUseCompressedOopsErgo -XX:+UseParallelGC
--- a/test/hotspot/jtreg/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run driver TestCMSClassUnloadingEnabledHWM
  * @summary Test that -XX:-CMSClassUnloadingEnabled will trigger a Full GC when more than MetaspaceSize metadata is allocated.
--- a/test/hotspot/jtreg/gc/class_unloading/TestClassUnloadingDisabled.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/class_unloading/TestClassUnloadingDisabled.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
--- a/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run driver TestG1ClassUnloadingHWM
  * @summary Test that -XX:-ClassUnloadingWithConcurrentMark will trigger a Full GC when more than MetaspaceSize metadata is allocated.
--- a/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlCMS.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlCMS.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base
  * @library /test/lib /
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -XX:+UseConcMarkSweepGC
  *   -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlG1.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlG1.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base
  * @library /test/lib /
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run driver TestConcurrentPhaseControlG1
  */
--- a/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlG1Basics.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlG1Basics.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @modules java.base
  * @library /test/lib /
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -XX:+UseG1GC
  *   -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlParallel.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlParallel.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base
  * @library /test/lib /
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -XX:+UseParallelGC
  *   -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlSerial.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/concurrent_phase_control/TestConcurrentPhaseControlSerial.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base
  * @library /test/lib /
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -XX:+UseSerialGC
  *   -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver TestEagerReclaimHumongousRegionsLog
  */
 
--- a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main TestGCLogMessages
  */
 
--- a/test/hotspot/jtreg/gc/g1/TestHumongousCodeCacheRoots.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestHumongousCodeCacheRoots.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @summary Humongous objects may have references from the code cache
  * @run main TestHumongousCodeCacheRoots
--- a/test/hotspot/jtreg/gc/g1/TestJNIWeakG1/TestJNIWeakG1.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestJNIWeakG1/TestJNIWeakG1.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @modules java.base
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/native
  *    -Xbootclasspath/a:.
--- a/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @library /test/lib
  * @requires vm.gc.G1
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+IgnoreUnrecognizedVMOptions -XX:+UseLargePages TestLargePageUseForAuxMemory
  */
@@ -83,7 +83,6 @@
         // Test with large page enabled.
         pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                                    "-XX:G1HeapRegionSize=" + HEAP_REGION_SIZE,
-                                                   "-Xms" + heapsize,
                                                    "-Xmx" + heapsize,
                                                    "-Xlog:pagesize",
                                                    "-XX:+UseLargePages",
@@ -99,7 +98,6 @@
         // Test with large page disabled.
         pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
                                                    "-XX:G1HeapRegionSize=" + HEAP_REGION_SIZE,
-                                                   "-Xms" + heapsize,
                                                    "-Xmx" + heapsize,
                                                    "-Xlog:pagesize",
                                                    "-XX:-UseLargePages",
--- a/test/hotspot/jtreg/gc/g1/TestNoEagerReclaimOfHumongousRegions.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestNoEagerReclaimOfHumongousRegions.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -Xlog:gc,gc+humongous=debug -XX:+UseG1GC -XX:MaxTenuringThreshold=0 -XX:G1RSetSparseRegionEntries=32 -XX:G1HeapRegionSize=1m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestNoEagerReclaimOfHumongousRegions
  */
--- a/test/hotspot/jtreg/gc/g1/TestPLABOutput.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestPLABOutput.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver TestPLABOutput
  */
 
--- a/test/hotspot/jtreg/gc/g1/TestRegionLivenessPrint.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestRegionLivenessPrint.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC -Xmx128M -XX:G1HeapRegionSize=1m -Xlog:gc+liveness=trace TestRegionLivenessPrint
  */
--- a/test/hotspot/jtreg/gc/g1/TestRemsetLogging.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestRemsetLogging.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management/sun.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @summary Verify output of -Xlog:gc+remset*=trace
  * @run main TestRemsetLogging
--- a/test/hotspot/jtreg/gc/g1/TestRemsetLoggingPerRegion.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestRemsetLoggingPerRegion.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management/sun.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @summary Verify output of -Xlog:gc+remset*=trace in regards to per-region type output
  * @run main TestRemsetLoggingPerRegion
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData00.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData00.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/timeout=720 TestShrinkAuxiliaryData00
  */
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData05.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData05.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/timeout=720 TestShrinkAuxiliaryData05
  */
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData10.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData10.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/timeout=720 TestShrinkAuxiliaryData10
  */
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData15.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData15.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/timeout=720 TestShrinkAuxiliaryData15
  */
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData20.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData20.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
   *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/timeout=720 TestShrinkAuxiliaryData20
  */
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData25.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData25.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/timeout=720 TestShrinkAuxiliaryData25
  */
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData30.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData30.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/timeout=720 TestShrinkAuxiliaryData30
  */
--- a/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @requires vm.gc.G1
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver TestVerifyGCType
  */
 
--- a/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver gc.g1.mixedgc.TestLogging
  */
 
--- a/test/hotspot/jtreg/gc/g1/plab/TestPLABPromotion.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/plab/TestPLABPromotion.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/timeout=240 gc.g1.plab.TestPLABPromotion
  */
--- a/test/hotspot/jtreg/gc/g1/plab/TestPLABResize.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/g1/plab/TestPLABResize.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @modules java.base/jdk.internal.misc
  * @modules java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main gc.g1.plab.TestPLABResize
  */
--- a/test/hotspot/jtreg/gc/metaspace/TestCapacityUntilGCWrapAround.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/metaspace/TestCapacityUntilGCWrapAround.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestCapacityUntilGCWrapAround
  */
--- a/test/hotspot/jtreg/gc/metaspace/TestMetaspaceCMSCancel.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/metaspace/TestMetaspaceCMSCancel.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm TestMetaspaceCMSCancel
  */
 
--- a/test/hotspot/jtreg/gc/stress/TestMultiThreadStressRSet.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/stress/TestMultiThreadStressRSet.java	Tue Jan 30 16:41:40 2018 +0100
@@ -39,7 +39,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
  *   -XX:+UseG1GC -XX:G1SummarizeRSetStatsPeriod=1 -Xlog:gc
--- a/test/hotspot/jtreg/gc/stress/TestStressRSetCoarsening.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/stress/TestStressRSetCoarsening.java	Tue Jan 30 16:41:40 2018 +0100
@@ -36,7 +36,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=300
  *     -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestAllocationInEden.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestAllocationInEden.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromEdenToTenured.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromEdenToTenured.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionToSurvivor.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionToSurvivor.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
--- a/test/hotspot/jtreg/gc/whitebox/TestConcMarkCycleWB.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/whitebox/TestConcMarkCycleWB.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  *          java.management
  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC TestConcMarkCycleWB
  * @summary Verifies that ConcurrentMarking-related WB works properly
--- a/test/hotspot/jtreg/gc/whitebox/TestWBGC.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/gc/whitebox/TestWBGC.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run driver TestWBGC
  */
 import jdk.test.lib.Asserts;
--- a/test/hotspot/jtreg/runtime/8026365/InvokeSpecialAnonTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/8026365/InvokeSpecialAnonTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.org.objectweb.asm
  *          java.base/jdk.internal.misc
  * @compile -XDignore.symbol.file InvokeSpecialAnonTest.java
- * @run main ClassFileInstaller InvokeSpecialAnonTest AnonTester
+ * @run driver ClassFileInstaller InvokeSpecialAnonTest AnonTester
  * @run main/othervm -Xbootclasspath/a:. -Xverify:all InvokeSpecialAnonTest
  */
 import jdk.internal.org.objectweb.asm.*;
--- a/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveClass.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveClass.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @library /test/lib /runtime/testlibrary
  * @library classes
  * @build sun.hotspot.WhiteBox test.Empty
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI KeepAliveClass
  */
--- a/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveClassLoader.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveClassLoader.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @library /test/lib /runtime/testlibrary
  * @library classes
  * @build sun.hotspot.WhiteBox test.Empty
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI KeepAliveClassLoader
  */
--- a/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveObject.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveObject.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @library /test/lib /runtime/testlibrary
  * @library classes
  * @build sun.hotspot.WhiteBox test.Empty
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI KeepAliveObject
  */
--- a/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveSoftReference.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/ClassUnload/KeepAliveSoftReference.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @library /test/lib /runtime/testlibrary
  * @library classes
  * @build sun.hotspot.WhiteBox test.Empty
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI KeepAliveSoftReference
  */
--- a/test/hotspot/jtreg/runtime/ClassUnload/UnloadTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/ClassUnload/UnloadTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @library /runtime/testlibrary /test/lib
  * @library classes
  * @build sun.hotspot.WhiteBox test.Empty
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -Xmn8m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI UnloadTest
  */
--- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java	Tue Jan 30 16:41:40 2018 +0100
@@ -373,11 +373,12 @@
      * @throws Exception if java process can not be started
      */
     private boolean runJavaWithParam(String optionValue, boolean valid) throws Exception {
-        int exitCode;
+        int exitCode = 0;
         boolean result = true;
         String errorMessage = null;
+        String explicitGC = null;
         List<String> runJava = new ArrayList<>();
-        OutputAnalyzer out;
+        OutputAnalyzer out = null;
 
         if (VMType != null) {
             runJava.add(VMType);
@@ -388,7 +389,11 @@
               prepend.contains("-XX:+UseSerialGC") ||
               prepend.contains("-XX:+UseParallelGC") ||
               prepend.contains("-XX:+UseG1GC"))) {
-            runJava.add(GCType);
+            explicitGC = GCType;
+        }
+
+        if (explicitGC != null) {
+            runJava.add(explicitGC);
         }
 
         runJava.addAll(prepend);
@@ -398,15 +403,19 @@
         out = new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(runJava.toArray(new String[0])).start());
 
         exitCode = out.getExitValue();
+        String exitCodeString = null;
+        if (exitCode != 0) {
+            exitCodeString = exitCode + " [0x" + Integer.toHexString(exitCode).toUpperCase() + "]";
+        }
 
         if (out.getOutput().contains("A fatal error has been detected by the Java Runtime Environment")) {
             /* Always consider "fatal error" in output as fail */
-            errorMessage = "JVM output reports a fatal error. JVM exited with code " + exitCode + "!";
+            errorMessage = "JVM output reports a fatal error. JVM exited with code " + exitCodeString + "!";
         } else if (valid == true) {
             if (!allowedExitCodes.contains(exitCode)) {
-                errorMessage = "JVM exited with unexpected error code = " + exitCode;
+                errorMessage = "JVM exited with unexpected error code = " + exitCodeString;
             } else if ((exitCode != 0) && (out.getOutput().isEmpty() == true)) {
-                errorMessage = "JVM exited with error(exitcode == " + exitCode + "), but with empty stdout and stderr. " +
+                errorMessage = "JVM exited with error(exitcode == " + exitCodeString + "), but with empty stdout and stderr. " +
                        "Description of error is needed!";
             } else if (out.getOutput().contains("is outside the allowed range")) {
                 errorMessage = "JVM output contains \"is outside the allowed range\"";
@@ -418,7 +427,7 @@
             if (exitCode == 0) {
                 errorMessage = "JVM successfully exit";
             } else if (exitCode != 1) {
-                errorMessage = "JVM exited with code " + exitCode + " which not equal to 1";
+                errorMessage = "JVM exited with code " + exitCodeString + " which does not equal to 1";
             } else if (!out.getOutput().contains(errorMessageCommandLineValue)) {
                 errorMessage = "JVM output does not contain expected output \"" + errorMessageCommandLineValue + "\"";
             }
@@ -426,7 +435,7 @@
 
         if (errorMessage != null) {
             String fullOptionString = String.format("%s %s %s %s",
-                    VMType == null ? "" : VMType, GCType == null ? "" : GCType, prependString.toString(), optionValue).trim().replaceAll("  +", " ");
+                    VMType == null ? "" : VMType, explicitGC == null ? "" : explicitGC, prependString.toString(), optionValue).trim().replaceAll("  +", " ");
             failedMessage(name, fullOptionString, valid, errorMessage);
             printOutputContent(out);
             result = false;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/Dictionary/ClassForName.java	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,47 @@
+/*
+ * 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 java.net.URLClassLoader;
+
+/*
+ * This class is loaded by the custom URLClassLoader, and then calls
+ * Class.forName() with the protection domain for the checkPackageAccess
+ * call created from the code source jar file.
+ */
+public class ClassForName {
+    static {
+        if (!(ClassForName.class.getClassLoader() instanceof URLClassLoader)) {
+            throw new RuntimeException("Supposed to be loaded by URLClassLoader");
+        }
+    }
+
+    public ClassForName() {
+        try {
+            // class_loader = URLClassLoader, protection_domain = ClassForName.getProtectionDomain()
+            Class.forName(java.util.List.class.getName(), false,
+                          ClassLoader.getSystemClassLoader());
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,87 @@
+/*
+ * 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 8151486
+ * @summary Call Class.forName() on the system classloader from a class loaded
+ *          from a custom classloader, using the current class's protection domain.
+ * @library /test/jdk/lib/testlibrary
+ * @build jdk.testlibrary.Utils JarUtils
+ * @build ClassForName ProtectionDomainCacheTest
+ * @run main/othervm/policy=test.policy -XX:+UnlockDiagnosticVMOptions -XX:VerifySubSet=dictionary -XX:+VerifyAfterGC -Xlog:gc+verify=debug,protectiondomain=trace,class+unload:gc.log -Djava.security.manager ProtectionDomainCacheTest
+ */
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import jdk.testlibrary.Utils;
+
+/*
+ * Create .jar, load ClassForName from .jar using a URLClassLoader
+ */
+public class ProtectionDomainCacheTest {
+    private static final long TIMEOUT = (long)(5000.0 * Utils.TIMEOUT_FACTOR);
+    private static final String TESTCLASSES = System.getProperty("test.classes", ".");
+    private static final String CLASSFILENAME = "ClassForName.class";
+
+    // Use a new classloader to load the ClassForName class.
+    public static void loadAndRun(Path jarFilePath)
+            throws Exception {
+        ClassLoader classLoader = new URLClassLoader(
+                new URL[]{jarFilePath.toUri().toURL()}) {
+            @Override public String toString() { return "LeakedClassLoader"; }
+        };
+
+        Class<?> loadClass = Class.forName("ClassForName", true, classLoader);
+        loadClass.newInstance();
+
+        System.out.println("returning : " + classLoader);
+    }
+
+    public static void main(final String[] args) throws Exception {
+        // Create a temporary .jar file containing ClassForName.class
+        Path testClassesDir = Paths.get(TESTCLASSES);
+        Path jarFilePath = Files.createTempFile("cfn", ".jar");
+        JarUtils.createJarFile(jarFilePath, testClassesDir, CLASSFILENAME);
+        jarFilePath.toFile().deleteOnExit();
+
+        // Remove the ClassForName.class file that jtreg built, to make sure
+        // we're loading from the tmp .jar
+        Path classFile = FileSystems.getDefault().getPath(TESTCLASSES,
+                                                          CLASSFILENAME);
+        Files.delete(classFile);
+
+        loadAndRun(jarFilePath);
+
+        // Give the GC a chance to unload protection domains
+        for (int i = 0; i < 100; i++) {
+            System.gc();
+        }
+        System.out.println("All Classloaders and protection domain cache entries successfully unloaded");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/Dictionary/test.policy	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,6 @@
+grant {
+  permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete";
+  permission java.lang.RuntimePermission "createClassLoader";
+  permission java.lang.RuntimePermission "getClassLoader";
+  permission java.util.PropertyPermission "*", "read"; /* for Utils */
+};
--- a/test/hotspot/jtreg/runtime/NMT/ChangeTrackingLevel.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/ChangeTrackingLevel.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ChangeTrackingLevel
  */
--- a/test/hotspot/jtreg/runtime/NMT/CommitOverlappingRegions.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/CommitOverlappingRegions.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail CommitOverlappingRegions
  */
--- a/test/hotspot/jtreg/runtime/NMT/JcmdDetailDiff.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/JcmdDetailDiff.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail JcmdDetailDiff
  */
 
--- a/test/hotspot/jtreg/runtime/NMT/JcmdSummaryDiff.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/JcmdSummaryDiff.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=summary JcmdSummaryDiff
  */
 
--- a/test/hotspot/jtreg/runtime/NMT/MallocRoundingReportTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/MallocRoundingReportTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocRoundingReportTest
  *
  */
--- a/test/hotspot/jtreg/runtime/NMT/MallocSiteHashOverflow.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/MallocSiteHashOverflow.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocSiteHashOverflow
  */
 
--- a/test/hotspot/jtreg/runtime/NMT/MallocStressTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/MallocStressTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocStressTest
  */
 
--- a/test/hotspot/jtreg/runtime/NMT/MallocTestType.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/MallocTestType.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTestType
  */
--- a/test/hotspot/jtreg/runtime/NMT/MallocTrackingVerify.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/MallocTrackingVerify.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTrackingVerify
  *
  */
--- a/test/hotspot/jtreg/runtime/NMT/ReleaseCommittedMemory.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/ReleaseCommittedMemory.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ReleaseCommittedMemory
  */
--- a/test/hotspot/jtreg/runtime/NMT/ReleaseNoCommit.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/ReleaseNoCommit.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=summary ReleaseNoCommit
  */
 
--- a/test/hotspot/jtreg/runtime/NMT/SummarySanityCheck.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/SummarySanityCheck.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+WhiteBoxAPI SummarySanityCheck
  */
@@ -63,8 +63,8 @@
       throwTestException("Failed to parse jcmd output");
     }
 
-    int totalCommitted = 0, totalReserved = 0;
-    int totalCommittedSum = 0, totalReservedSum = 0;
+    long totalCommitted = 0, totalReserved = 0;
+    long totalCommittedSum = 0, totalReservedSum = 0;
 
     // Match '- <mtType> (reserved=<reserved>KB, committed=<committed>KB)
     Pattern mtTypePattern = Pattern.compile("-\\s+(?<typename>[\\w\\s]+)\\(reserved=(?<reserved>\\d+)KB,\\scommitted=(?<committed>\\d+)KB\\)");
@@ -76,16 +76,16 @@
         Matcher totalMemoryMatcher = totalMemoryPattern.matcher(lines[i]);
 
         if (totalMemoryMatcher.matches()) {
-          totalCommitted = Integer.parseInt(totalMemoryMatcher.group("committed"));
-          totalReserved = Integer.parseInt(totalMemoryMatcher.group("reserved"));
+          totalCommitted = Long.parseLong(totalMemoryMatcher.group("committed"));
+          totalReserved = Long.parseLong(totalMemoryMatcher.group("reserved"));
         } else {
           throwTestException("Failed to match the expected groups in 'Total' memory part");
         }
       } else if (lines[i].startsWith("-")) {
         Matcher typeMatcher = mtTypePattern.matcher(lines[i]);
         if (typeMatcher.matches()) {
-          int typeCommitted = Integer.parseInt(typeMatcher.group("committed"));
-          int typeReserved = Integer.parseInt(typeMatcher.group("reserved"));
+          long typeCommitted = Long.parseLong(typeMatcher.group("committed"));
+          long typeReserved = Long.parseLong(typeMatcher.group("reserved"));
 
           // Make sure reserved is always less or equals
           if (typeCommitted > typeReserved) {
@@ -103,12 +103,12 @@
     }
 
     // See if they add up correctly, rounding is a problem so make sure we're within +/- 8KB
-    int committedDiff = totalCommitted - totalCommittedSum;
+    long committedDiff = totalCommitted - totalCommittedSum;
     if (committedDiff > 8 || committedDiff < -8) {
       throwTestException("Total committed (" + totalCommitted + ") did not match the summarized committed (" + totalCommittedSum + ")" );
     }
 
-    int reservedDiff = totalReserved - totalReservedSum;
+    long reservedDiff = totalReserved - totalReservedSum;
     if (reservedDiff > 8 || reservedDiff < -8) {
       throwTestException("Total reserved (" + totalReserved + ") did not match the summarized reserved (" + totalReservedSum + ")" );
     }
--- a/test/hotspot/jtreg/runtime/NMT/ThreadedMallocTestType.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/ThreadedMallocTestType.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedMallocTestType
  */
--- a/test/hotspot/jtreg/runtime/NMT/ThreadedVirtualAllocTestType.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/ThreadedVirtualAllocTestType.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedVirtualAllocTestType
  */
--- a/test/hotspot/jtreg/runtime/NMT/VirtualAllocCommitUncommitRecommit.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/VirtualAllocCommitUncommitRecommit.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocCommitUncommitRecommit
  *
  */
--- a/test/hotspot/jtreg/runtime/NMT/VirtualAllocTestType.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/NMT/VirtualAllocTestType.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocTestType
  */
--- a/test/hotspot/jtreg/runtime/RedefineObject/TestRedefineObject.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/RedefineObject/TestRedefineObject.java	Tue Jan 30 16:41:40 2018 +0100
@@ -40,7 +40,7 @@
  *          java.instrument
  *          java.management
  * @build Agent
- * @run main ClassFileInstaller Agent
+ * @run driver ClassFileInstaller Agent
  * @run main TestRedefineObject
  * @run main/othervm -javaagent:agent.jar -Xlog:redefine+class+load=debug,redefine+class+timer=info Agent
  */
--- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main AssertSafepointCheckConsistency1
  */
--- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main AssertSafepointCheckConsistency2
  */
--- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main AssertSafepointCheckConsistency3
  */
--- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main AssertSafepointCheckConsistency4
  */
--- a/test/hotspot/jtreg/runtime/SharedArchiveFile/SharedStrings.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/SharedStrings.java	Tue Jan 30 16:41:40 2018 +0100
@@ -34,7 +34,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build SharedStringsWb sun.hotspot.WhiteBox
- * @run main ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox
  * @run main SharedStrings
  */
 
--- a/test/hotspot/jtreg/runtime/SharedArchiveFile/SpaceUtilizationCheck.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/SpaceUtilizationCheck.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SpaceUtilizationCheck
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/StackTrace/LargeClassTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,149 @@
+/*
+ * 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 8194246
+ * @summary JVM crashes on stack trace for large number of methods.
+ * @library /test/lib
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ *          java.base/jdk.internal.misc
+ * @compile LargeClassTest.java
+ * @run main LargeClassTest
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+import jdk.internal.org.objectweb.asm.FieldVisitor;
+import jdk.internal.org.objectweb.asm.Label;
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class LargeClassTest implements Opcodes {
+    public static void main(String... args) throws Exception {
+        writeClassFile();
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".",  "Large");
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+    }
+
+    // Writes a Large class with > signed 16 bit int methods
+    public static void writeClassFile() throws Exception {
+
+        ClassWriter cw = new ClassWriter(0);
+        FieldVisitor fv;
+        MethodVisitor mv;
+        AnnotationVisitor av0;
+
+        cw.visit(55, ACC_PUBLIC + ACC_SUPER, "Large", null, "java/lang/Object", null);
+
+        {
+          mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+          mv.visitCode();
+          mv.visitVarInsn(ALOAD, 0);
+          mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
+          mv.visitInsn(RETURN);
+          mv.visitMaxs(1, 1);
+          mv.visitEnd();
+        }
+        {
+          // public static void main(String[] args) {
+          //     Large large = new Large();
+          //     large.f_1(55);
+          // }
+          mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
+          mv.visitCode();
+          mv.visitTypeInsn(NEW, "Large");
+          mv.visitInsn(DUP);
+          mv.visitMethodInsn(INVOKESPECIAL, "Large", "<init>", "()V", false);
+          mv.visitVarInsn(ASTORE, 1);
+          mv.visitVarInsn(ALOAD, 1);
+          mv.visitIntInsn(BIPUSH, 55);
+          mv.visitMethodInsn(INVOKEVIRTUAL, "Large", "f_1", "(I)I", false);
+          mv.visitInsn(POP);
+          mv.visitInsn(RETURN);
+          mv.visitMaxs(2, 2);
+          mv.visitEnd();
+        }
+
+        // Write 33560 methods called f_$i
+        for (int i = 1000; i < 34560; i++)
+        {
+          mv = cw.visitMethod(ACC_PUBLIC, "f_" + i, "()V", null, null);
+          mv.visitCode();
+          mv.visitInsn(RETURN);
+          mv.visitMaxs(0, 1);
+          mv.visitEnd();
+        }
+        {
+          // public int f_1(int prior) {
+          //   int total = prior + new java.util.Random(1).nextInt();
+          //   return total + f_2(total);
+          // }
+          mv = cw.visitMethod(ACC_PUBLIC, "f_1", "(I)I", null, null);
+          mv.visitCode();
+          mv.visitVarInsn(ILOAD, 1);
+          mv.visitTypeInsn(NEW, "java/util/Random");
+          mv.visitInsn(DUP);
+          mv.visitInsn(LCONST_1);
+          mv.visitMethodInsn(INVOKESPECIAL, "java/util/Random", "<init>", "(J)V", false);
+          mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/Random", "nextInt", "()I", false);
+          mv.visitInsn(IADD);
+          mv.visitVarInsn(ISTORE, 2);
+          mv.visitVarInsn(ILOAD, 2);
+          mv.visitVarInsn(ALOAD, 0);
+          mv.visitVarInsn(ILOAD, 2);
+          mv.visitMethodInsn(INVOKEVIRTUAL, "Large", "f_2", "(I)I", false);
+          mv.visitInsn(IADD);
+          mv.visitInsn(IRETURN);
+          mv.visitMaxs(5, 3);
+          mv.visitEnd();
+        }
+        {
+          // public int f_2(int total) {
+          //   System.out.println(java.util.Arrays.toString(Thread.currentThread().getStackTrace()));
+          //   return 10;
+          // }
+          mv = cw.visitMethod(ACC_PUBLIC, "f_2", "(I)I", null, null);
+          mv.visitCode();
+          mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
+          mv.visitMethodInsn(INVOKESTATIC, "java/lang/Thread", "currentThread", "()Ljava/lang/Thread;", false);
+          mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Thread", "getStackTrace", "()[Ljava/lang/StackTraceElement;", false);
+          mv.visitMethodInsn(INVOKESTATIC, "java/util/Arrays", "toString", "([Ljava/lang/Object;)Ljava/lang/String;", false);
+          mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
+          mv.visitIntInsn(BIPUSH, 10);
+          mv.visitInsn(IRETURN);
+          mv.visitMaxs(2, 2);
+          mv.visitEnd();
+        }
+        cw.visitEnd();
+
+        try (FileOutputStream fos = new FileOutputStream(new File("Large.class"))) {
+          fos.write(cw.toByteArray());
+        }
+    }
+}
--- a/test/hotspot/jtreg/runtime/appcds/ClassLoaderTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/ClassLoaderTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -35,7 +35,7 @@
  * @compile test-classes/ForNameTest.java
  * @compile test-classes/BootClassPathAppendHelper.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main ClassLoaderTest
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/HelloExtTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/HelloExtTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -33,7 +33,7 @@
  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  * @compile test-classes/HelloExt.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main HelloExtTest
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/JvmtiAddPath.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/JvmtiAddPath.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  *          java.management
  *          jdk.jartool/sun.tools.jar
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @compile test-classes/Hello.java
  * @compile test-classes/JvmtiApp.java
  * @run main JvmtiAddPath
--- a/test/hotspot/jtreg/runtime/appcds/MismatchedUseAppCDS.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/MismatchedUseAppCDS.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  *          jdk.jartool/sun.tools.jar
  * @compile test-classes/CheckIfShared.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main MismatchedUseAppCDS
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/MultiProcessSharing.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/MultiProcessSharing.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  *          java.management
  *          jdk.jartool/sun.tools.jar
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @compile test-classes/MultiProcClass.java
  * @run main MultiProcessSharing
  */
--- a/test/hotspot/jtreg/runtime/appcds/RewriteBytecodesTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/RewriteBytecodesTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -33,7 +33,7 @@
  *          jdk.jartool/sun.tools.jar
  * @compile test-classes/RewriteBytecodes.java test-classes/Util.java test-classes/Super.java test-classes/Child.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main RewriteBytecodesTest
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java	Tue Jan 30 16:41:40 2018 +0100
@@ -34,7 +34,7 @@
  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  * @build sun.hotspot.WhiteBox
  * @compile test-classes/Hello.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SharedArchiveConsistency
  */
 import jdk.test.lib.process.OutputAnalyzer;
--- a/test/hotspot/jtreg/runtime/appcds/cacheObject/CheckCachedResolvedReferences.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/cacheObject/CheckCachedResolvedReferences.java	Tue Jan 30 16:41:40 2018 +0100
@@ -35,9 +35,9 @@
  * @build sun.hotspot.WhiteBox
  * @compile CheckCachedResolvedReferencesApp.java
  * @compile ../test-classes/Hello.java
- * @run main ClassFileInstaller -jar app.jar CheckCachedResolvedReferencesApp
- * @run main ClassFileInstaller -jar hello.jar Hello
- * @run main ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller -jar app.jar CheckCachedResolvedReferencesApp
+ * @run driver ClassFileInstaller -jar hello.jar Hello
+ * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
  * @run main CheckCachedResolvedReferences
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/cacheObject/GCStressTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/cacheObject/GCStressTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -34,8 +34,8 @@
  *          jdk.jartool/sun.tools.jar
  * @build sun.hotspot.WhiteBox
  * @compile GCStressApp.java
- * @run main ClassFileInstaller -jar gcstress.jar GCStressApp
- * @run main ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller -jar gcstress.jar GCStressApp
+ * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
  * @run main GCStressTest
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,9 +32,9 @@
  *          java.management
  * @compile test-classes/Hello.java test-classes/CustomLoadee.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller -jar hello.jar Hello
- * @run main ClassFileInstaller -jar hello_custom.jar CustomLoadee
- * @run main ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller -jar hello.jar Hello
+ * @run driver ClassFileInstaller -jar hello_custom.jar CustomLoadee
+ * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
  * @run main HelloCustom
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/LoaderSegregationTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/LoaderSegregationTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -40,7 +40,7 @@
  *          test-classes/OnlyUnregistered.java
  *          ../test-classes/Util.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main LoaderSegregationTest
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/SameNameInTwoLoadersTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/SameNameInTwoLoadersTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -37,7 +37,7 @@
  *     test-classes/CustomLoadee3.java
  *     test-classes/SameNameUnrelatedLoaders.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main SameNameInTwoLoadersTest
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/UnintendedLoadersTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/UnintendedLoadersTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -33,7 +33,7 @@
  *          jdk.jartool/sun.tools.jar
  * @compile test-classes/UnintendedLoaders.java test-classes/CustomLoadee.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main UnintendedLoadersTest
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/UnloadUnregisteredLoaderTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/UnloadUnregisteredLoaderTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -34,10 +34,10 @@
  *          jdk.jartool/sun.tools.jar
  * @build sun.hotspot.WhiteBox ClassUnloadCommon
  * @compile test-classes/UnloadUnregisteredLoader.java test-classes/CustomLoadee.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- * @run main ClassFileInstaller ClassUnloadCommon
- * @run main ClassFileInstaller ClassUnloadCommon$1
- * @run main ClassFileInstaller ClassUnloadCommon$TestFailure
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller ClassUnloadCommon
+ * @run driver ClassFileInstaller ClassUnloadCommon$1
+ * @run driver ClassFileInstaller ClassUnloadCommon$TestFailure
  * @run main UnloadUnregisteredLoaderTest
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/javaldr/ArrayTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/javaldr/ArrayTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  * @modules jdk.jartool/sun.tools.jar
  * @compile ArrayTestHelper.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main ArrayTest
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/javaldr/GCSharedStringsDuringDump.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/javaldr/GCSharedStringsDuringDump.java	Tue Jan 30 16:41:40 2018 +0100
@@ -35,7 +35,7 @@
  *          jdk.jartool/sun.tools.jar
  *          java.management
  * @build sun.hotspot.WhiteBox GCDuringDumpTransformer GCSharedStringsDuringDumpWb
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm/timeout=480 GCSharedStringsDuringDump
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java	Tue Jan 30 16:41:40 2018 +0100
@@ -33,7 +33,7 @@
  * @compile ../../test-classes/java/net/HttpCookie.jasm
  * @compile ../../test-classes/javax/activation/MimeType.jasm
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main DummyClassesInBootClassPath
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/limitmods/LimitModsTests.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/limitmods/LimitModsTests.java	Tue Jan 30 16:41:40 2018 +0100
@@ -35,7 +35,7 @@
  * @compile ../../test-classes/jdk/dynalink/DynamicLinker.jasm
  * @compile ../../test-classes/com/sun/tools/javac/Main.jasm
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main LimitModsTests
  * @summary AppCDS tests for excluding class in module by using --limit-modules.
  */
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/ExerciseGC.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/ExerciseGC.java	Tue Jan 30 16:41:40 2018 +0100
@@ -33,7 +33,7 @@
  * @modules java.management
  *          jdk.jartool/sun.tools.jar
  * @build HelloStringGC sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main ExerciseGC
  */
 public class ExerciseGC {
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/InternSharedString.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/InternSharedString.java	Tue Jan 30 16:41:40 2018 +0100
@@ -35,7 +35,7 @@
  *          jdk.jartool/sun.tools.jar
  * @compile InternStringTest.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main InternSharedString
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/LockSharedStrings.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/LockSharedStrings.java	Tue Jan 30 16:41:40 2018 +0100
@@ -35,7 +35,7 @@
  *          jdk.jartool/sun.tools.jar
  * @compile LockStringTest.java LockStringValueTest.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main LockSharedStrings
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/SharedStringsBasicPlus.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/SharedStringsBasicPlus.java	Tue Jan 30 16:41:40 2018 +0100
@@ -34,7 +34,7 @@
  * @modules java.management
  *          jdk.jartool/sun.tools.jar
  * @build HelloStringPlus sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main SharedStringsBasicPlus
  */
 
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/SharedStringsWbTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/SharedStringsWbTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -34,7 +34,7 @@
  * @modules java.management
  *          jdk.jartool/sun.tools.jar
  * @build sun.hotspot.WhiteBox SharedStringsWb
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main SharedStringsWbTest
  */
 
--- a/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -37,7 +37,7 @@
  * @requires vm.debug
  * @library /testlibrary /test/lib
  * @build HandshakeTransitionTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI HandshakeTransitionTest
  */
--- a/test/hotspot/jtreg/runtime/handshake/HandshakeWalkExitTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/handshake/HandshakeWalkExitTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @summary This test tries to stress the handshakes with new and exiting threads
  * @library /testlibrary /test/lib
  * @build HandshakeWalkExitTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI HandshakeWalkExitTest
  */
--- a/test/hotspot/jtreg/runtime/handshake/HandshakeWalkOneExitTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/handshake/HandshakeWalkOneExitTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @summary This test tries to stress the handshakes with new and exiting threads
  * @library /testlibrary /test/lib
  * @build HandshakeWalkOneExitTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI HandshakeWalkOneExitTest
  */
--- a/test/hotspot/jtreg/runtime/handshake/HandshakeWalkStackFallbackTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/handshake/HandshakeWalkStackFallbackTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @summary This test the global safepoint fallback path for handshakes
  * @library /testlibrary /test/lib
  * @build HandshakeWalkStackTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-ThreadLocalHandshakes HandshakeWalkStackTest
  */
--- a/test/hotspot/jtreg/runtime/handshake/HandshakeWalkStackTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/handshake/HandshakeWalkStackTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -26,7 +26,7 @@
  * @test HandshakeWalkStackTest
  * @library /testlibrary /test/lib
  * @build HandshakeWalkStackTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI HandshakeWalkStackTest
  */
--- a/test/hotspot/jtreg/runtime/interned/SanityTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/interned/SanityTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SanityTest
  */
--- a/test/hotspot/jtreg/runtime/memory/ReadFromNoaccessArea.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/memory/ReadFromNoaccessArea.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ReadFromNoaccessArea
  */
--- a/test/hotspot/jtreg/runtime/memory/ReadVMPageSize.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/memory/ReadVMPageSize.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm  -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI  ReadVMPageSize
  */
 
--- a/test/hotspot/jtreg/runtime/memory/ReserveMemory.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/memory/ReserveMemory.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ReserveMemory
  */
--- a/test/hotspot/jtreg/runtime/memory/RunUnitTestsConcurrently.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/memory/RunUnitTestsConcurrently.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI RunUnitTestsConcurrently 30 15000
  */
--- a/test/hotspot/jtreg/runtime/memory/StressVirtualSpaceResize.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/memory/StressVirtualSpaceResize.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI StressVirtualSpaceResize
  */
--- a/test/hotspot/jtreg/runtime/modules/AccessCheckAllUnnamed.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/AccessCheckAllUnnamed.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckAllUnnamed
  */
--- a/test/hotspot/jtreg/runtime/modules/AccessCheckExp.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/AccessCheckExp.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckExp
  */
--- a/test/hotspot/jtreg/runtime/modules/AccessCheckJavaBase.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/AccessCheckJavaBase.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @compile p2/c2.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckJavaBase
  */
--- a/test/hotspot/jtreg/runtime/modules/AccessCheckOpen.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/AccessCheckOpen.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckOpen
  */
--- a/test/hotspot/jtreg/runtime/modules/AccessCheckRead.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/AccessCheckRead.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckRead
  */
--- a/test/hotspot/jtreg/runtime/modules/AccessCheckSuper.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/AccessCheckSuper.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @compile p3/c3.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckSuper
  */
--- a/test/hotspot/jtreg/runtime/modules/AccessCheckUnnamed.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/AccessCheckUnnamed.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckUnnamed
  */
--- a/test/hotspot/jtreg/runtime/modules/AccessCheckWorks.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/AccessCheckWorks.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckWorks
  */
--- a/test/hotspot/jtreg/runtime/modules/CCE_module_msg.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/CCE_module_msg.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @compile p4/c4.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI CCE_module_msg
  */
--- a/test/hotspot/jtreg/runtime/modules/ExportTwice.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/ExportTwice.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ExportTwice
  */
--- a/test/hotspot/jtreg/runtime/modules/JVMAddModuleExportToAllUnnamed.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/JVMAddModuleExportToAllUnnamed.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @compile p2/c2.java
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @compile/module=java.base java/lang/ModuleHelper.java
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExportToAllUnnamed
--- a/test/hotspot/jtreg/runtime/modules/JVMAddModuleExports.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/JVMAddModuleExports.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @library /test/lib ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExports
  */
--- a/test/hotspot/jtreg/runtime/modules/JVMAddModuleExportsToAll.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/JVMAddModuleExportsToAll.java	Tue Jan 30 16:41:40 2018 +0100
@@ -31,7 +31,7 @@
  * @compile p1/c1.java
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExportsToAll
  */
--- a/test/hotspot/jtreg/runtime/modules/JVMAddReadsModule.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/JVMAddReadsModule.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @library /test/lib ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddReadsModule
  */
--- a/test/hotspot/jtreg/runtime/modules/JVMDefineModule.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/JVMDefineModule.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @library /test/lib ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMDefineModule
  */
--- a/test/hotspot/jtreg/runtime/modules/LoadUnloadModuleStress.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/modules/LoadUnloadModuleStress.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @library /test/lib ..
  * @build sun.hotspot.WhiteBox
  * @compile/module=java.base java/lang/ModuleHelper.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx64m -Xmx64m LoadUnloadModuleStress 15000
  */
--- a/test/hotspot/jtreg/runtime/whitebox/WBStackSize.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/runtime/whitebox/WBStackSize.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xss512k WBStackSize
  */
--- a/test/hotspot/jtreg/sanity/MismatchedWhiteBox/WhiteBox.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/sanity/MismatchedWhiteBox/WhiteBox.java	Tue Jan 30 16:41:40 2018 +0100
@@ -29,7 +29,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @compile WhiteBox.java
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-CheckIntrinsics sun.hotspot.WhiteBox
  */
 
--- a/test/hotspot/jtreg/sanity/WBApi.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/sanity/WBApi.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI WBApi
  */
--- a/test/hotspot/jtreg/serviceability/ParserTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/serviceability/ParserTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -27,7 +27,7 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ParserTest
  */
--- a/test/hotspot/jtreg/serviceability/dcmd/jvmti/LoadAgentDcmdTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/serviceability/dcmd/jvmti/LoadAgentDcmdTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -43,7 +43,7 @@
  *          java.management
  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  * @build SimpleJvmtiAgent
- * @run main ClassFileInstaller SimpleJvmtiAgent
+ * @run driver ClassFileInstaller SimpleJvmtiAgent
  * @run testng/othervm LoadAgentDcmdTest
  */
 public class LoadAgentDcmdTest {
--- a/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java	Tue Jan 30 16:41:40 2018 +0100
@@ -37,7 +37,7 @@
  *          java.management
  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  * @build GetObjectSizeClassAgent
- * @run main ClassFileInstaller GetObjectSizeClassAgent
+ * @run driver ClassFileInstaller GetObjectSizeClassAgent
  * @run main GetObjectSizeClass
  */
 public class GetObjectSizeClass {
--- a/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeOverflow.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeOverflow.java	Tue Jan 30 16:41:40 2018 +0100
@@ -38,7 +38,7 @@
  *          java.management
  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  * @build GetObjectSizeOverflowAgent
- * @run main ClassFileInstaller GetObjectSizeOverflowAgent
+ * @run driver ClassFileInstaller GetObjectSizeOverflowAgent
  * @run main GetObjectSizeOverflow
  */
 public class GetObjectSizeOverflow {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorStackDepthInfo/GetOwnedMonitorStackDepthInfoTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,99 @@
+/*
+ * 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 8153629
+ * @summary Need to cover JVMTI's GetOwnedMonitorStackDepthInfo function
+ * @compile GetOwnedMonitorStackDepthInfoTest.java
+ * @run main/othervm/native -agentlib:GetOwnedMonitorStackDepthInfoTest GetOwnedMonitorStackDepthInfoTest
+ */
+
+
+public class GetOwnedMonitorStackDepthInfoTest {
+
+    static {
+        try {
+            System.loadLibrary("GetOwnedMonitorStackDepthInfoTest");
+        } catch (UnsatisfiedLinkError ule) {
+            System.err.println("Could not load GetOwnedMonitorStackDepthInfoTest library");
+            System.err.println("java.library.path: "
+                    + System.getProperty("java.library.path"));
+            throw ule;
+        }
+    }
+
+    private static native int verifyOwnedMonitors();
+
+    private static volatile int results = -1;
+
+
+    public static void main(String[] args) throws Exception {
+
+        new GetOwnedMonitorStackDepthInfoTest().runTest();
+
+    }
+
+    public void runTest() throws Exception {
+        final Object lock1 = new Lock1();
+        Thread t1 = new Thread(() -> {
+            synchronized (lock1) {
+                System.out.println("Thread in sync section 1: "
+                        + Thread.currentThread().getName());
+                test1();
+            }
+        });
+
+        t1.start();
+        t1.join();
+
+        if (results != 0) {
+            throw new RuntimeException("FAILED status returned from the agent");
+        }
+
+    }
+
+    private synchronized void test1() {
+        test2();
+    }
+
+    private void test2() {
+        Object lock2 = new Lock2();
+        synchronized (lock2) {
+            System.out.println("Thread in sync section 2: "
+                    + Thread.currentThread().getName());
+            results = verifyOwnedMonitors();
+        }
+
+    }
+
+    private static class Lock1 {
+
+    }
+
+    private static class Lock2 {
+
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorStackDepthInfo/libGetOwnedMonitorStackDepthInfoTest.c	Tue Jan 30 16:41:40 2018 +0100
@@ -0,0 +1,242 @@
+/*
+ * 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"
+#include "jni.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JNI_ENV_ARG
+
+#ifdef __cplusplus
+#define JNI_ENV_ARG(x, y) y
+#define JNI_ENV_PTR(x) x
+#else
+#define JNI_ENV_ARG(x,y) x, y
+#define JNI_ENV_PTR(x) (*x)
+#endif
+
+#endif
+
+#define PASSED 0
+#define FAILED 2
+
+#define TEST_CLASS  "GetOwnedMonitorStackDepthInfoTest"
+#define LOCK1_CLASS "GetOwnedMonitorStackDepthInfoTest$Lock1"
+#define LOCK2_CLASS "GetOwnedMonitorStackDepthInfoTest$Lock2"
+
+#define TEST_OBJECT_LOCK_DEPTH 2
+#define LOCK1_DEPTH 3
+#define LOCK2_DEPTH 1
+#define EXP_MONITOR_COUNT 3
+
+static jvmtiEnv *jvmti;
+
+static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
+
+static void ShowErrorMessage(jvmtiEnv *jvmti, jvmtiError errCode, const char *message) {
+    char *errMsg;
+    jvmtiError result;
+
+    result = (*jvmti)->GetErrorName(jvmti, errCode, &errMsg);
+    if (result == JVMTI_ERROR_NONE) {
+        fprintf(stderr, "%s: %s (%d)\n", message, errMsg, errCode);
+        (*jvmti)->Deallocate(jvmti, (unsigned char *)errMsg);
+    } else {
+        fprintf(stderr, "%s (%d)\n", message, errCode);
+    }
+}
+
+static jboolean CheckLockObject(JNIEnv *env, jobject monitor, jclass testClass) {
+    return (*env)->IsInstanceOf(env, monitor, testClass);
+}
+
+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) {
+    jint res;
+    JNIEnv *env;
+
+    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &env),
+                                   JNI_VERSION_9);
+    if (res != JNI_OK || env == NULL) {
+        fprintf(stderr, "Error: GetEnv call failed(%d)!\n", res);
+        return JNI_ERR;
+    }
+
+    return JNI_VERSION_9;
+}
+
+static
+jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
+    jint res;
+    jvmtiError err;
+    jvmtiCapabilities caps;
+
+    printf("Agent_OnLoad started\n");
+
+    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
+                                   JVMTI_VERSION_9);
+    if (res != JNI_OK || jvmti == NULL) {
+        fprintf(stderr, "Error: wrong result of a valid call to GetEnv!\n");
+        return JNI_ERR;
+    }
+
+    err = (*jvmti)->GetPotentialCapabilities(jvmti, &caps);
+    if (err != JVMTI_ERROR_NONE) {
+        ShowErrorMessage(jvmti, err,
+                         "Agent_OnLoad: error in JVMTI GetPotentialCapabilities");
+        return JNI_ERR;
+    }
+
+    err = (*jvmti)->AddCapabilities(jvmti, &caps);
+    if (err != JVMTI_ERROR_NONE) {
+        ShowErrorMessage(jvmti, err,
+                         "Agent_OnLoad: error in JVMTI AddCapabilities");
+        return JNI_ERR;
+    }
+
+    err = (*jvmti)->GetCapabilities(jvmti, &caps);
+    if (err != JVMTI_ERROR_NONE) {
+        ShowErrorMessage(jvmti, err,
+                         "Agent_OnLoad: error in JVMTI GetCapabilities");
+        return JNI_ERR;
+    }
+
+    if (!caps.can_get_owned_monitor_stack_depth_info) {
+        fprintf(stderr, "Warning: GetOwnedMonitorStackDepthInfo is not implemented\n");
+        return JNI_ERR;
+    }
+
+    printf("Agent_OnLoad finished\n");
+    return JNI_OK;
+}
+
+JNIEXPORT jint JNICALL
+Java_GetOwnedMonitorStackDepthInfoTest_verifyOwnedMonitors(JNIEnv *env, jclass cls) {
+    jthread thread;
+    jvmtiError err;
+    jvmtiThreadInfo threadInfo;
+    jint monitorCount;
+    jvmtiMonitorStackDepthInfo* stackDepthInfo;
+    jclass testClass;
+    jclass lock1Class;
+    jclass lock2Class;
+
+    jint status = PASSED;
+
+    jint idx = 0;
+
+    testClass = (*env)->FindClass(env, TEST_CLASS);
+    if (testClass == NULL) {
+        fprintf(stderr, "Error: Could not load class %s!\n", TEST_CLASS);
+        return FAILED;
+    }
+
+    lock1Class = (*env)->FindClass(env, LOCK1_CLASS);
+    if (lock1Class == NULL) {
+        fprintf(stderr, "Error: Could not load class %s!\n", LOCK1_CLASS);
+        return FAILED;
+    }
+
+    lock2Class = (*env)->FindClass(env, LOCK2_CLASS);
+    if (lock2Class == NULL) {
+        fprintf(stderr, "Error: Could not load class %s!\n", LOCK2_CLASS);
+        return FAILED;
+    }
+
+    err = (*jvmti) -> GetCurrentThread(jvmti, &thread);
+    if (err != JVMTI_ERROR_NONE) {
+        ShowErrorMessage(jvmti, err,
+                "VerifyOwnedMonitors: error in JVMTI GetCurrentThread");
+        return FAILED;
+    }
+    err = (*jvmti)->GetThreadInfo(jvmti, thread, &threadInfo);
+    if (err != JVMTI_ERROR_NONE) {
+        ShowErrorMessage(jvmti, err,
+                "VerifyOwnedMonitors: error in JVMTI GetThreadInfo");
+        return FAILED;
+    }
+
+    err = (*jvmti)->GetOwnedMonitorStackDepthInfo(jvmti, thread, &monitorCount, &stackDepthInfo);
+    if (err != JVMTI_ERROR_NONE) {
+        ShowErrorMessage(jvmti, err,
+                "VerifyOwnedMonitors: error in JVMTI GetOwnedMonitorStackDepthInfo");
+        return FAILED;
+    }
+
+    printf("VerifyOwnedMonitors: %s owns %d monitor(s)\n", threadInfo.name, monitorCount);
+
+    if (monitorCount != EXP_MONITOR_COUNT) {
+        fprintf(stderr, "VerifyOwnedMonitors: FAIL: invalid monitorCount, expected: %d, found: %d.\n",
+                EXP_MONITOR_COUNT, monitorCount);
+        status = FAILED;
+    }
+    for (idx = 0; idx < monitorCount; idx++) {
+        if (CheckLockObject(env, stackDepthInfo[idx].monitor, testClass) == JNI_TRUE) {
+            if (stackDepthInfo[idx].stack_depth != TEST_OBJECT_LOCK_DEPTH) {
+                fprintf(stderr, "VerifyOwnedMonitors: FAIL: invalid stack_depth for %s monitor, expected: %d, found: %d.\n",
+                        TEST_CLASS, TEST_OBJECT_LOCK_DEPTH, stackDepthInfo[idx].stack_depth);
+                status = FAILED;
+            }
+        } else if (CheckLockObject(env, stackDepthInfo[idx].monitor, lock1Class) == JNI_TRUE) {
+            if (stackDepthInfo[idx].stack_depth != LOCK1_DEPTH) {
+                fprintf(stderr, "VerifyOwnedMonitors: FAIL: invalid stack_depth for %s monitor, expected: %d, found: %d.\n",
+                        LOCK1_CLASS, LOCK1_DEPTH, stackDepthInfo[idx].stack_depth);
+                status = FAILED;
+            }
+        } else if (CheckLockObject(env, stackDepthInfo[idx].monitor, lock2Class) == JNI_TRUE) {
+            if (stackDepthInfo[idx].stack_depth != LOCK2_DEPTH) {
+                fprintf(stderr, "VerifyOwnedMonitors: FAIL: invalid stack_depth for %s monitor, expected: %d, found: %d.\n",
+                        LOCK2_CLASS, LOCK2_DEPTH, stackDepthInfo[idx].stack_depth);
+                status = FAILED;
+            }
+        } else {
+            fprintf(stderr, "VerifyOwnedMonitors: "
+                    "FAIL: monitor should be instance of %s, %s, or %s\n", TEST_CLASS, LOCK1_CLASS, LOCK2_CLASS);
+            status = FAILED;
+
+        }
+    }
+
+    (*jvmti)->Deallocate(jvmti, (unsigned char *) stackDepthInfo);
+    (*jvmti)->Deallocate(jvmti, (unsigned char *) threadInfo.name);
+    return status;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- a/test/hotspot/jtreg/testlibrary_tests/TestPlatformIsTieredSupported.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/testlibrary_tests/TestPlatformIsTieredSupported.java	Tue Jan 30 16:41:40 2018 +0100
@@ -32,7 +32,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:+TieredCompilation
--- a/test/hotspot/jtreg/testlibrary_tests/whitebox/BlobSanityTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/testlibrary_tests/whitebox/BlobSanityTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI BlobSanityTest
  * @summary sanity testing of allocateCodeBlob, freeCodeBlob and getCodeBlob
--- a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/BooleanTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/BooleanTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -30,7 +30,7 @@
  *          java.management/sun.management
  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI BooleanTest
  * @summary testing of WB::set/getBooleanVMFlag()
--- a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/DoubleTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/DoubleTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI DoubleTest
  * @summary testing of WB::set/getDoubleVMFlag()
--- a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/IntxTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/IntxTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xint -XX:-ProfileInterpreter IntxTest
  * @summary testing of WB::set/getIntxVMFlag()
--- a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/SizeTTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/SizeTTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management/sun.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions SizeTTest
  * @summary testing of WB::set/getSizeTVMFlag()
--- a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/StringTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/StringTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI StringTest
  * @summary testing of WB::set/getStringVMFlag()
--- a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/Uint64Test.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/Uint64Test.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  * @modules java.management/sun.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI Uint64Test
  * @summary testing of WB::set/getUint64VMFlag()
--- a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/UintxTest.java	Thu Jan 25 15:18:13 2018 -0800
+++ b/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/UintxTest.java	Tue Jan 30 16:41:40 2018 +0100
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  *          java.management/sun.management
  * @build sun.hotspot.WhiteBox
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI UintxTest
  * @summary testing of WB::set/getUintxVMFlag()