Merge aefimov-dns-client-branch
authoraefimov
Fri, 08 Nov 2019 14:49:00 +0000
branchaefimov-dns-client-branch
changeset 58983 956b1255a5ec
parent 58971 465a15dd6bed (current diff)
parent 58982 c709424ad48f (diff)
child 58984 15e026239a6c
Merge
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/PrintRegionClosure.java
test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.sh
test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.sh
test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.sh
test/jdk/jdk/jfr/event/io/MakeJAR.sh
test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.sh
test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.flags
test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.sh
test/jdk/jdk/jfr/javaagent/JavaAgentBuilder.java
--- a/src/hotspot/cpu/x86/assembler_x86.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/cpu/x86/assembler_x86.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -4227,7 +4227,7 @@
 void Assembler::vpshufb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
   assert(vector_len == AVX_128bit? VM_Version::supports_avx() :
          vector_len == AVX_256bit? VM_Version::supports_avx2() :
-         0, "");
+         vector_len == AVX_512bit? VM_Version::supports_avx512bw() : 0, "");
   InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true);
   int encode = simd_prefix_and_encode(dst, nds, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
   emit_int8(0x00);
@@ -7197,7 +7197,6 @@
   emit_int8(0x7C);
   emit_int8((unsigned char)(0xC0 | encode));
 }
-
 void Assembler::evpgatherdd(XMMRegister dst, KRegister mask, Address src, int vector_len) {
   assert(VM_Version::supports_evex(), "");
   assert(dst != xnoreg, "sanity");
@@ -7212,7 +7211,6 @@
   emit_int8((unsigned char)0x90);
   emit_operand(dst, src);
 }
-
 // Carry-Less Multiplication Quadword
 void Assembler::pclmulqdq(XMMRegister dst, XMMRegister src, int mask) {
   assert(VM_Version::supports_clmul(), "");
--- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -3770,6 +3770,16 @@
   }
 }
 
+void MacroAssembler::vpaddd(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len, Register rscratch) {
+  assert(UseAVX > 0, "requires some form of AVX");
+  if (reachable(src)) {
+    Assembler::vpaddd(dst, nds, as_Address(src), vector_len);
+  } else {
+    lea(rscratch, src);
+    Assembler::vpaddd(dst, nds, Address(rscratch, 0), vector_len);
+  }
+}
+
 void MacroAssembler::vabsss(XMMRegister dst, XMMRegister nds, XMMRegister src, AddressLiteral negate_field, int vector_len) {
   assert(((dst->encoding() < 16 && src->encoding() < 16 && nds->encoding() < 16) || VM_Version::supports_avx512vldq()),"XMM register should be 0-15");
   vandps(dst, nds, negate_field, vector_len);
--- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -993,6 +993,8 @@
 public:
   void aesecb_encrypt(Register source_addr, Register dest_addr, Register key, Register len);
   void aesecb_decrypt(Register source_addr, Register dest_addr, Register key, Register len);
+  void aesctr_encrypt(Register src_addr, Register dest_addr, Register key, Register counter,
+                      Register len_reg, Register used, Register used_addr, Register saved_encCounter_start);
 
 #endif
 
@@ -1238,6 +1240,10 @@
   void vpaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
   void vpaddw(XMMRegister dst, XMMRegister nds, Address src, int vector_len);
 
+  void vpaddd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { Assembler::vpaddd(dst, nds, src, vector_len); }
+  void vpaddd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { Assembler::vpaddd(dst, nds, src, vector_len); }
+  void vpaddd(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len, Register rscratch);
+
   void vpand(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { Assembler::vpand(dst, nds, src, vector_len); }
   void vpand(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { Assembler::vpand(dst, nds, src, vector_len); }
   void vpand(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len, Register scratch_reg = rscratch1);
--- a/src/hotspot/cpu/x86/macroAssembler_x86_aes.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/cpu/x86/macroAssembler_x86_aes.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2018, Intel Corporation.
+* Copyright (c) 2019, Intel Corporation.
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
@@ -778,4 +778,493 @@
     vpxor(xmm3, xmm3, xmm3, Assembler::AVX_128bit);
     vpxor(xmm15, xmm15, xmm15, Assembler::AVX_128bit);
 }
+
+// AES Counter Mode using VAES instructions
+void MacroAssembler::aesctr_encrypt(Register src_addr, Register dest_addr, Register key, Register counter,
+    Register len_reg, Register used, Register used_addr, Register saved_encCounter_start) {
+
+    const Register rounds = 0;
+    const Register pos = r12;
+
+    Label PRELOOP_START, EXIT_PRELOOP, REMAINDER, REMAINDER_16, LOOP, END, EXIT, END_LOOP,
+    AES192, AES256, AES192_REMAINDER16, REMAINDER16_END_LOOP, AES256_REMAINDER16,
+    REMAINDER_8, REMAINDER_4, AES192_REMAINDER8, REMAINDER_LOOP, AES256_REMINDER,
+    AES192_REMAINDER, END_REMAINDER_LOOP, AES256_REMAINDER8, REMAINDER8_END_LOOP,
+    AES192_REMAINDER4, AES256_REMAINDER4, AES256_REMAINDER, END_REMAINDER4, EXTRACT_TAILBYTES,
+    EXTRACT_TAIL_4BYTES, EXTRACT_TAIL_2BYTES, EXTRACT_TAIL_1BYTE, STORE_CTR;
+
+    cmpl(len_reg, 0);
+    jcc(Assembler::belowEqual, EXIT);
+
+    movl(pos, 0);
+    // if the number of used encrypted counter bytes < 16,
+    // XOR PT with saved encrypted counter to obtain CT
+    bind(PRELOOP_START);
+    cmpl(used, 16);
+    jcc(Assembler::aboveEqual, EXIT_PRELOOP);
+    movb(rbx, Address(saved_encCounter_start, used));
+    xorb(rbx, Address(src_addr, pos));
+    movb(Address(dest_addr, pos), rbx);
+    addptr(pos, 1);
+    addptr(used, 1);
+    decrement(len_reg);
+    jmp(PRELOOP_START);
+
+    bind(EXIT_PRELOOP);
+    movl(Address(used_addr, 0), used);
+
+    // Calculate number of rounds i.e. 10, 12, 14,  based on key length(128, 192, 256).
+    movl(rounds, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT)));
+
+    vpxor(xmm0, xmm0, xmm0, Assembler::AVX_128bit);
+    // Move initial counter value in xmm0
+    movdqu(xmm0, Address(counter, 0));
+    // broadcast counter value to zmm8
+    evshufi64x2(xmm8, xmm0, xmm0, 0, Assembler::AVX_512bit);
+
+    // load lbswap mask
+    evmovdquq(xmm16, ExternalAddress(StubRoutines::x86::counter_mask_addr()), Assembler::AVX_512bit, r15);
+
+    //shuffle counter using lbswap_mask
+    vpshufb(xmm8, xmm8, xmm16, Assembler::AVX_512bit);
+
+    // pre-increment and propagate counter values to zmm9-zmm15 registers.
+    // Linc0 increments the zmm8 by 1 (initial value being 0), Linc4 increments the counters zmm9-zmm15 by 4
+    // The counter is incremented after each block i.e. 16 bytes is processed;
+    // each zmm register has 4 counter values as its MSB
+    // the counters are incremented in parallel
+    vpaddd(xmm8, xmm8, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 64), Assembler::AVX_512bit, r15);//linc0
+    vpaddd(xmm9, xmm8, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 128), Assembler::AVX_512bit, r15);//linc4(rip)
+    vpaddd(xmm10, xmm9, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 128), Assembler::AVX_512bit, r15);//Linc4(rip)
+    vpaddd(xmm11, xmm10, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 128), Assembler::AVX_512bit, r15);//Linc4(rip)
+    vpaddd(xmm12, xmm11, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 128), Assembler::AVX_512bit, r15);//Linc4(rip)
+    vpaddd(xmm13, xmm12, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 128), Assembler::AVX_512bit, r15);//Linc4(rip)
+    vpaddd(xmm14, xmm13, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 128), Assembler::AVX_512bit, r15);//Linc4(rip)
+    vpaddd(xmm15, xmm14, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 128), Assembler::AVX_512bit, r15);//Linc4(rip)
+
+    // load linc32 mask in zmm register.linc32 increments counter by 32
+    evmovdquq(xmm19, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 256), Assembler::AVX_512bit, r15);//Linc32
+
+    // xmm31 contains the key shuffle mask.
+    movdqu(xmm31, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr()));
+    // Load key function loads 128 bit key and shuffles it. Then we broadcast the shuffled key to convert it into a 512 bit value.
+    // For broadcasting the values to ZMM, vshufi64 is used instead of evbroadcasti64x2 as the source in this case is ZMM register
+    // that holds shuffled key value.
+    ev_load_key(xmm20, key, 0, xmm31);
+    ev_load_key(xmm21, key, 1 * 16, xmm31);
+    ev_load_key(xmm22, key, 2 * 16, xmm31);
+    ev_load_key(xmm23, key, 3 * 16, xmm31);
+    ev_load_key(xmm24, key, 4 * 16, xmm31);
+    ev_load_key(xmm25, key, 5 * 16, xmm31);
+    ev_load_key(xmm26, key, 6 * 16, xmm31);
+    ev_load_key(xmm27, key, 7 * 16, xmm31);
+    ev_load_key(xmm28, key, 8 * 16, xmm31);
+    ev_load_key(xmm29, key, 9 * 16, xmm31);
+    ev_load_key(xmm30, key, 10 * 16, xmm31);
+
+    // Process 32 blocks or 512 bytes of data
+    bind(LOOP);
+    cmpl(len_reg, 512);
+    jcc(Assembler::less, REMAINDER);
+    subq(len_reg, 512);
+    //Shuffle counter and Exor it with roundkey1. Result is stored in zmm0-7
+    vpshufb(xmm0, xmm8, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm0, xmm0, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm1, xmm9, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm1, xmm1, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm2, xmm10, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm2, xmm2, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm3, xmm11, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm3, xmm3, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm4, xmm12, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm4, xmm4, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm5, xmm13, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm5, xmm5, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm6, xmm14, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm6, xmm6, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm7, xmm15, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm7, xmm7, xmm20, Assembler::AVX_512bit);
+    // Perform AES encode operations and put results in zmm0-zmm7.
+    // This is followed by incrementing counter values in zmm8-zmm15.
+    // Since we will be processing 32 blocks at a time, the counter is incremented by 32.
+    roundEnc(xmm21, 7);
+    vpaddq(xmm8, xmm8, xmm19, Assembler::AVX_512bit);
+    roundEnc(xmm22, 7);
+    vpaddq(xmm9, xmm9, xmm19, Assembler::AVX_512bit);
+    roundEnc(xmm23, 7);
+    vpaddq(xmm10, xmm10, xmm19, Assembler::AVX_512bit);
+    roundEnc(xmm24, 7);
+    vpaddq(xmm11, xmm11, xmm19, Assembler::AVX_512bit);
+    roundEnc(xmm25, 7);
+    vpaddq(xmm12, xmm12, xmm19, Assembler::AVX_512bit);
+    roundEnc(xmm26, 7);
+    vpaddq(xmm13, xmm13, xmm19, Assembler::AVX_512bit);
+    roundEnc(xmm27, 7);
+    vpaddq(xmm14, xmm14, xmm19, Assembler::AVX_512bit);
+    roundEnc(xmm28, 7);
+    vpaddq(xmm15, xmm15, xmm19, Assembler::AVX_512bit);
+    roundEnc(xmm29, 7);
+
+    cmpl(rounds, 52);
+    jcc(Assembler::aboveEqual, AES192);
+    lastroundEnc(xmm30, 7);
+    jmp(END_LOOP);
+
+    bind(AES192);
+    roundEnc(xmm30, 7);
+    ev_load_key(xmm18, key, 11 * 16, xmm31);
+    roundEnc(xmm18, 7);
+    cmpl(rounds, 60);
+    jcc(Assembler::aboveEqual, AES256);
+    ev_load_key(xmm18, key, 12 * 16, xmm31);
+    lastroundEnc(xmm18, 7);
+    jmp(END_LOOP);
+
+    bind(AES256);
+    ev_load_key(xmm18, key, 12 * 16, xmm31);
+    roundEnc(xmm18, 7);
+    ev_load_key(xmm18, key, 13 * 16, xmm31);
+    roundEnc(xmm18, 7);
+    ev_load_key(xmm18, key, 14 * 16, xmm31);
+    lastroundEnc(xmm18, 7);
+
+    // After AES encode rounds, the encrypted block cipher lies in zmm0-zmm7
+    // xor encrypted block cipher and input plaintext and store resultant ciphertext
+    bind(END_LOOP);
+    evpxorq(xmm0, xmm0, Address(src_addr, pos, Address::times_1, 0 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 0), xmm0, Assembler::AVX_512bit);
+    evpxorq(xmm1, xmm1, Address(src_addr, pos, Address::times_1, 1 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 64), xmm1, Assembler::AVX_512bit);
+    evpxorq(xmm2, xmm2, Address(src_addr, pos, Address::times_1, 2 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 2 * 64), xmm2, Assembler::AVX_512bit);
+    evpxorq(xmm3, xmm3, Address(src_addr, pos, Address::times_1, 3 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 3 * 64), xmm3, Assembler::AVX_512bit);
+    evpxorq(xmm4, xmm4, Address(src_addr, pos, Address::times_1, 4 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 4 * 64), xmm4, Assembler::AVX_512bit);
+    evpxorq(xmm5, xmm5, Address(src_addr, pos, Address::times_1, 5 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 5 * 64), xmm5, Assembler::AVX_512bit);
+    evpxorq(xmm6, xmm6, Address(src_addr, pos, Address::times_1, 6 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 6 * 64), xmm6, Assembler::AVX_512bit);
+    evpxorq(xmm7, xmm7, Address(src_addr, pos, Address::times_1, 7 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 7 * 64), xmm7, Assembler::AVX_512bit);
+    addq(pos, 512);
+    jmp(LOOP);
+
+    // Encode 256, 128, 64 or 16 bytes at a time if length is less than 512 bytes
+    bind(REMAINDER);
+    cmpl(len_reg, 0);
+    jcc(Assembler::equal, END);
+    cmpl(len_reg, 256);
+    jcc(Assembler::aboveEqual, REMAINDER_16);
+    cmpl(len_reg, 128);
+    jcc(Assembler::aboveEqual, REMAINDER_8);
+    cmpl(len_reg, 64);
+    jcc(Assembler::aboveEqual, REMAINDER_4);
+    // At this point, we will process 16 bytes of data at a time.
+    // So load xmm19 with counter increment value as 1
+    evmovdquq(xmm19, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 80), Assembler::AVX_128bit, r15);
+    jmp(REMAINDER_LOOP);
+
+    // Each ZMM register can be used to encode 64 bytes of data, so we have 4 ZMM registers to encode 256 bytes of data
+    bind(REMAINDER_16);
+    subq(len_reg, 256);
+    // As we process 16 blocks at a time, load mask for incrementing the counter value by 16
+    evmovdquq(xmm19, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 320), Assembler::AVX_512bit, r15);//Linc16(rip)
+    // shuffle counter and XOR counter with roundkey1
+    vpshufb(xmm0, xmm8, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm0, xmm0, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm1, xmm9, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm1, xmm1, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm2, xmm10, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm2, xmm2, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm3, xmm11, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm3, xmm3, xmm20, Assembler::AVX_512bit);
+    // Increment counter values by 16
+    vpaddq(xmm8, xmm8, xmm19, Assembler::AVX_512bit);
+    vpaddq(xmm9, xmm9, xmm19, Assembler::AVX_512bit);
+    // AES encode rounds
+    roundEnc(xmm21, 3);
+    roundEnc(xmm22, 3);
+    roundEnc(xmm23, 3);
+    roundEnc(xmm24, 3);
+    roundEnc(xmm25, 3);
+    roundEnc(xmm26, 3);
+    roundEnc(xmm27, 3);
+    roundEnc(xmm28, 3);
+    roundEnc(xmm29, 3);
+
+    cmpl(rounds, 52);
+    jcc(Assembler::aboveEqual, AES192_REMAINDER16);
+    lastroundEnc(xmm30, 3);
+    jmp(REMAINDER16_END_LOOP);
+
+    bind(AES192_REMAINDER16);
+    roundEnc(xmm30, 3);
+    ev_load_key(xmm18, key, 11 * 16, xmm31);
+    roundEnc(xmm18, 3);
+    ev_load_key(xmm5, key, 12 * 16, xmm31);
+
+    cmpl(rounds, 60);
+    jcc(Assembler::aboveEqual, AES256_REMAINDER16);
+    lastroundEnc(xmm5, 3);
+    jmp(REMAINDER16_END_LOOP);
+    bind(AES256_REMAINDER16);
+    roundEnc(xmm5, 3);
+    ev_load_key(xmm6, key, 13 * 16, xmm31);
+    roundEnc(xmm6, 3);
+    ev_load_key(xmm7, key, 14 * 16, xmm31);
+    lastroundEnc(xmm7, 3);
+
+    // After AES encode rounds, the encrypted block cipher lies in zmm0-zmm3
+    // xor 256 bytes of PT with the encrypted counters to produce CT.
+    bind(REMAINDER16_END_LOOP);
+    evpxorq(xmm0, xmm0, Address(src_addr, pos, Address::times_1, 0), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 0), xmm0, Assembler::AVX_512bit);
+    evpxorq(xmm1, xmm1, Address(src_addr, pos, Address::times_1, 1 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 1 * 64), xmm1, Assembler::AVX_512bit);
+    evpxorq(xmm2, xmm2, Address(src_addr, pos, Address::times_1, 2 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 2 * 64), xmm2, Assembler::AVX_512bit);
+    evpxorq(xmm3, xmm3, Address(src_addr, pos, Address::times_1, 3 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 3 * 64), xmm3, Assembler::AVX_512bit);
+    addq(pos, 256);
+
+    cmpl(len_reg, 128);
+    jcc(Assembler::aboveEqual, REMAINDER_8);
+
+    cmpl(len_reg, 64);
+    jcc(Assembler::aboveEqual, REMAINDER_4);
+    //load mask for incrementing the counter value by 1
+    evmovdquq(xmm19, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 80), Assembler::AVX_128bit, r15);//Linc0 + 16(rip)
+    jmp(REMAINDER_LOOP);
+
+    // Each ZMM register can be used to encode 64 bytes of data, so we have 2 ZMM registers to encode 128 bytes of data
+    bind(REMAINDER_8);
+    subq(len_reg, 128);
+    // As we process 8 blocks at a time, load mask for incrementing the counter value by 8
+    evmovdquq(xmm19, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 192), Assembler::AVX_512bit, r15);//Linc8(rip)
+    // shuffle counters and xor with roundkey1
+    vpshufb(xmm0, xmm8, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm0, xmm0, xmm20, Assembler::AVX_512bit);
+    vpshufb(xmm1, xmm9, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm1, xmm1, xmm20, Assembler::AVX_512bit);
+    // increment counter by 8
+    vpaddq(xmm8, xmm8, xmm19, Assembler::AVX_512bit);
+    // AES encode
+    roundEnc(xmm21, 1);
+    roundEnc(xmm22, 1);
+    roundEnc(xmm23, 1);
+    roundEnc(xmm24, 1);
+    roundEnc(xmm25, 1);
+    roundEnc(xmm26, 1);
+    roundEnc(xmm27, 1);
+    roundEnc(xmm28, 1);
+    roundEnc(xmm29, 1);
+
+    cmpl(rounds, 52);
+    jcc(Assembler::aboveEqual, AES192_REMAINDER8);
+    lastroundEnc(xmm30, 1);
+    jmp(REMAINDER8_END_LOOP);
+
+    bind(AES192_REMAINDER8);
+    roundEnc(xmm30, 1);
+    ev_load_key(xmm18, key, 11 * 16, xmm31);
+    roundEnc(xmm18, 1);
+    ev_load_key(xmm5, key, 12 * 16, xmm31);
+    cmpl(rounds, 60);
+    jcc(Assembler::aboveEqual, AES256_REMAINDER8);
+    lastroundEnc(xmm5, 1);
+    jmp(REMAINDER8_END_LOOP);
+
+    bind(AES256_REMAINDER8);
+    roundEnc(xmm5, 1);
+    ev_load_key(xmm6, key, 13 * 16, xmm31);
+    roundEnc(xmm6, 1);
+    ev_load_key(xmm7, key, 14 * 16, xmm31);
+    lastroundEnc(xmm7, 1);
+
+    bind(REMAINDER8_END_LOOP);
+    // After AES encode rounds, the encrypted block cipher lies in zmm0-zmm1
+    // XOR PT with the encrypted counter and store as CT
+    evpxorq(xmm0, xmm0, Address(src_addr, pos, Address::times_1, 0 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 0 * 64), xmm0, Assembler::AVX_512bit);
+    evpxorq(xmm1, xmm1, Address(src_addr, pos, Address::times_1, 1 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 1 * 64), xmm1, Assembler::AVX_512bit);
+    addq(pos, 128);
+
+    cmpl(len_reg, 64);
+    jcc(Assembler::aboveEqual, REMAINDER_4);
+    // load mask for incrementing the counter value by 1
+    evmovdquq(xmm19, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 80), Assembler::AVX_128bit, r15);//Linc0 + 16(rip)
+    jmp(REMAINDER_LOOP);
+
+    // Each ZMM register can be used to encode 64 bytes of data, so we have 1 ZMM register used in this block of code
+    bind(REMAINDER_4);
+    subq(len_reg, 64);
+    // As we process 4 blocks at a time, load mask for incrementing the counter value by 4
+    evmovdquq(xmm19, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 128), Assembler::AVX_512bit, r15);//Linc4(rip)
+    // XOR counter with first roundkey
+    vpshufb(xmm0, xmm8, xmm16, Assembler::AVX_512bit);
+    evpxorq(xmm0, xmm0, xmm20, Assembler::AVX_512bit);
+    // Increment counter
+    vpaddq(xmm8, xmm8, xmm19, Assembler::AVX_512bit);
+    vaesenc(xmm0, xmm0, xmm21, Assembler::AVX_512bit);
+    vaesenc(xmm0, xmm0, xmm22, Assembler::AVX_512bit);
+    vaesenc(xmm0, xmm0, xmm23, Assembler::AVX_512bit);
+    vaesenc(xmm0, xmm0, xmm24, Assembler::AVX_512bit);
+    vaesenc(xmm0, xmm0, xmm25, Assembler::AVX_512bit);
+    vaesenc(xmm0, xmm0, xmm26, Assembler::AVX_512bit);
+    vaesenc(xmm0, xmm0, xmm27, Assembler::AVX_512bit);
+    vaesenc(xmm0, xmm0, xmm28, Assembler::AVX_512bit);
+    vaesenc(xmm0, xmm0, xmm29, Assembler::AVX_512bit);
+    cmpl(rounds, 52);
+    jcc(Assembler::aboveEqual, AES192_REMAINDER4);
+    vaesenclast(xmm0, xmm0, xmm30, Assembler::AVX_512bit);
+    jmp(END_REMAINDER4);
+
+    bind(AES192_REMAINDER4);
+    vaesenc(xmm0, xmm0, xmm30, Assembler::AVX_512bit);
+    ev_load_key(xmm18, key, 11 * 16, xmm31);
+    vaesenc(xmm0, xmm0, xmm18, Assembler::AVX_512bit);
+    ev_load_key(xmm5, key, 12 * 16, xmm31);
+
+    cmpl(rounds, 60);
+    jcc(Assembler::aboveEqual, AES256_REMAINDER4);
+    vaesenclast(xmm0, xmm0, xmm5, Assembler::AVX_512bit);
+    jmp(END_REMAINDER4);
+
+    bind(AES256_REMAINDER4);
+    vaesenc(xmm0, xmm0, xmm5, Assembler::AVX_512bit);
+    ev_load_key(xmm6, key, 13 * 16, xmm31);
+    vaesenc(xmm0, xmm0, xmm6, Assembler::AVX_512bit);
+    ev_load_key(xmm7, key, 14 * 16, xmm31);
+    vaesenclast(xmm0, xmm0, xmm7, Assembler::AVX_512bit);
+    // After AES encode rounds, the encrypted block cipher lies in zmm0.
+    // XOR encrypted block cipher with PT and store 64 bytes of ciphertext
+    bind(END_REMAINDER4);
+    evpxorq(xmm0, xmm0, Address(src_addr, pos, Address::times_1, 0 * 64), Assembler::AVX_512bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 0), xmm0, Assembler::AVX_512bit);
+    addq(pos, 64);
+    // load mask for incrementing the counter value by 1
+    evmovdquq(xmm19, ExternalAddress(StubRoutines::x86::counter_mask_addr() + 80), Assembler::AVX_128bit, r15);//Linc0 + 16(rip)
+
+    // For a single block, the AES rounds start here.
+    bind(REMAINDER_LOOP);
+    cmpl(len_reg, 0);
+    jcc(Assembler::belowEqual, END);
+    // XOR counter with first roundkey
+    vpshufb(xmm0, xmm8, xmm16, Assembler::AVX_128bit);
+    evpxorq(xmm0, xmm0, xmm20, Assembler::AVX_128bit);
+    vaesenc(xmm0, xmm0, xmm21, Assembler::AVX_128bit);
+    // Increment counter by 1
+    vpaddq(xmm8, xmm8, xmm19, Assembler::AVX_128bit);
+    vaesenc(xmm0, xmm0, xmm22, Assembler::AVX_128bit);
+    vaesenc(xmm0, xmm0, xmm23, Assembler::AVX_128bit);
+    vaesenc(xmm0, xmm0, xmm24, Assembler::AVX_128bit);
+    vaesenc(xmm0, xmm0, xmm25, Assembler::AVX_128bit);
+    vaesenc(xmm0, xmm0, xmm26, Assembler::AVX_128bit);
+    vaesenc(xmm0, xmm0, xmm27, Assembler::AVX_128bit);
+    vaesenc(xmm0, xmm0, xmm28, Assembler::AVX_128bit);
+    vaesenc(xmm0, xmm0, xmm29, Assembler::AVX_128bit);
+
+    cmpl(rounds, 52);
+    jcc(Assembler::aboveEqual, AES192_REMAINDER);
+    vaesenclast(xmm0, xmm0, xmm30, Assembler::AVX_128bit);
+    jmp(END_REMAINDER_LOOP);
+
+    bind(AES192_REMAINDER);
+    vaesenc(xmm0, xmm0, xmm30, Assembler::AVX_128bit);
+    ev_load_key(xmm18, key, 11 * 16, xmm31);
+    vaesenc(xmm0, xmm0, xmm18, Assembler::AVX_128bit);
+    ev_load_key(xmm5, key, 12 * 16, xmm31);
+    cmpl(rounds, 60);
+    jcc(Assembler::aboveEqual, AES256_REMAINDER);
+    vaesenclast(xmm0, xmm0, xmm5, Assembler::AVX_128bit);
+    jmp(END_REMAINDER_LOOP);
+
+    bind(AES256_REMAINDER);
+    vaesenc(xmm0, xmm0, xmm5, Assembler::AVX_128bit);
+    ev_load_key(xmm6, key, 13 * 16, xmm31);
+    vaesenc(xmm0, xmm0, xmm6, Assembler::AVX_128bit);
+    ev_load_key(xmm7, key, 14 * 16, xmm31);
+    vaesenclast(xmm0, xmm0, xmm7, Assembler::AVX_128bit);
+
+    bind(END_REMAINDER_LOOP);
+    // If the length register is less than the blockSize i.e. 16
+    // then we store only those bytes of the CT to the destination
+    // corresponding to the length register value
+    // extracting the exact number of bytes is handled by EXTRACT_TAILBYTES
+    cmpl(len_reg, 16);
+    jcc(Assembler::less, EXTRACT_TAILBYTES);
+    subl(len_reg, 16);
+    // After AES encode rounds, the encrypted block cipher lies in xmm0.
+    // If the length register is equal to 16 bytes, store CT in dest after XOR operation.
+    evpxorq(xmm0, xmm0, Address(src_addr, pos, Address::times_1, 0), Assembler::AVX_128bit);
+    evmovdquq(Address(dest_addr, pos, Address::times_1, 0), xmm0, Assembler::AVX_128bit);
+    addl(pos, 16);
+
+    jmp(REMAINDER_LOOP);
+
+    bind(EXTRACT_TAILBYTES);
+    // Save encrypted counter value in xmm0 for next invocation, before XOR operation
+    movdqu(Address(saved_encCounter_start, 0), xmm0);
+    // XOR encryted block cipher in xmm0 with PT to produce CT
+    evpxorq(xmm0, xmm0, Address(src_addr, pos, Address::times_1, 0), Assembler::AVX_128bit);
+    // extract upto 15 bytes of CT from xmm0 as specified by length register
+    testptr(len_reg, 8);
+    jcc(Assembler::zero, EXTRACT_TAIL_4BYTES);
+    pextrq(Address(dest_addr, pos), xmm0, 0);
+    psrldq(xmm0, 8);
+    addl(pos, 8);
+    bind(EXTRACT_TAIL_4BYTES);
+    testptr(len_reg, 4);
+    jcc(Assembler::zero, EXTRACT_TAIL_2BYTES);
+    pextrd(Address(dest_addr, pos), xmm0, 0);
+    psrldq(xmm0, 4);
+    addq(pos, 4);
+    bind(EXTRACT_TAIL_2BYTES);
+    testptr(len_reg, 2);
+    jcc(Assembler::zero, EXTRACT_TAIL_1BYTE);
+    pextrw(Address(dest_addr, pos), xmm0, 0);
+    psrldq(xmm0, 2);
+    addl(pos, 2);
+    bind(EXTRACT_TAIL_1BYTE);
+    testptr(len_reg, 1);
+    jcc(Assembler::zero, END);
+    pextrb(Address(dest_addr, pos), xmm0, 0);
+    addl(pos, 1);
+
+    bind(END);
+    // If there are no tail bytes, store counter value and exit
+    cmpl(len_reg, 0);
+    jcc(Assembler::equal, STORE_CTR);
+    movl(Address(used_addr, 0), len_reg);
+
+    bind(STORE_CTR);
+    //shuffle updated counter and store it
+    vpshufb(xmm8, xmm8, xmm16, Assembler::AVX_128bit);
+    movdqu(Address(counter, 0), xmm8);
+    // Zero out counter and key registers
+    evpxorq(xmm8, xmm8, xmm8, Assembler::AVX_512bit);
+    evpxorq(xmm20, xmm20, xmm20, Assembler::AVX_512bit);
+    evpxorq(xmm21, xmm21, xmm21, Assembler::AVX_512bit);
+    evpxorq(xmm22, xmm22, xmm22, Assembler::AVX_512bit);
+    evpxorq(xmm23, xmm23, xmm23, Assembler::AVX_512bit);
+    evpxorq(xmm24, xmm24, xmm24, Assembler::AVX_512bit);
+    evpxorq(xmm25, xmm25, xmm25, Assembler::AVX_512bit);
+    evpxorq(xmm26, xmm26, xmm26, Assembler::AVX_512bit);
+    evpxorq(xmm27, xmm27, xmm27, Assembler::AVX_512bit);
+    evpxorq(xmm28, xmm28, xmm28, Assembler::AVX_512bit);
+    evpxorq(xmm29, xmm29, xmm29, Assembler::AVX_512bit);
+    evpxorq(xmm30, xmm30, xmm30, Assembler::AVX_512bit);
+    cmpl(rounds, 44);
+    jcc(Assembler::belowEqual, EXIT);
+    evpxorq(xmm18, xmm18, xmm18, Assembler::AVX_512bit);
+    evpxorq(xmm5, xmm5, xmm5, Assembler::AVX_512bit);
+    cmpl(rounds, 52);
+    jcc(Assembler::belowEqual, EXIT);
+    evpxorq(xmm6, xmm6, xmm6, Assembler::AVX_512bit);
+    evpxorq(xmm7, xmm7, xmm7, Assembler::AVX_512bit);
+    bind(EXIT);
+}
+
 #endif // _LP64
--- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -3982,6 +3982,123 @@
     return start;
   }
 
+  // This mask is used for incrementing counter value(linc0, linc4, etc.)
+  address counter_mask_addr() {
+    __ align(64);
+    StubCodeMark mark(this, "StubRoutines", "counter_mask_addr");
+    address start = __ pc();
+    __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none);//lbswapmask
+    __ emit_data64(0x0001020304050607, relocInfo::none);
+    __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none);
+    __ emit_data64(0x0001020304050607, relocInfo::none);
+    __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none);
+    __ emit_data64(0x0001020304050607, relocInfo::none);
+    __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none);
+    __ emit_data64(0x0001020304050607, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);//linc0 = counter_mask_addr+64
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000001, relocInfo::none);//counter_mask_addr() + 80
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000002, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000003, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000004, relocInfo::none);//linc4 = counter_mask_addr() + 128
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000004, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000004, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000004, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000008, relocInfo::none);//linc8 = counter_mask_addr() + 192
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000008, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000008, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000008, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000020, relocInfo::none);//linc32 = counter_mask_addr() + 256
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000020, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000020, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000020, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000010, relocInfo::none);//linc16 = counter_mask_addr() + 320
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000010, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000010, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0x0000000000000010, relocInfo::none);
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    return start;
+  }
+
+ // Vector AES Counter implementation
+  address generate_counterMode_VectorAESCrypt()  {
+    __ align(CodeEntryAlignment);
+    StubCodeMark mark(this, "StubRoutines", "counterMode_AESCrypt");
+    address start = __ pc();
+    const Register from = c_rarg0; // source array address
+    const Register to = c_rarg1; // destination array address
+    const Register key = c_rarg2; // key array address r8
+    const Register counter = c_rarg3; // counter byte array initialized from counter array address
+    // and updated with the incremented counter in the end
+#ifndef _WIN64
+    const Register len_reg = c_rarg4;
+    const Register saved_encCounter_start = c_rarg5;
+    const Register used_addr = r10;
+    const Address  used_mem(rbp, 2 * wordSize);
+    const Register used = r11;
+#else
+    const Address len_mem(rbp, 6 * wordSize); // length is on stack on Win64
+    const Address saved_encCounter_mem(rbp, 7 * wordSize); // saved encrypted counter is on stack on Win64
+    const Address used_mem(rbp, 8 * wordSize); // used length is on stack on Win64
+    const Register len_reg = r10; // pick the first volatile windows register
+    const Register saved_encCounter_start = r11;
+    const Register used_addr = r13;
+    const Register used = r14;
+#endif
+    __ enter();
+   // Save state before entering routine
+    __ push(r12);
+    __ push(r13);
+    __ push(r14);
+    __ push(r15);
+#ifdef _WIN64
+    // on win64, fill len_reg from stack position
+    __ movl(len_reg, len_mem);
+    __ movptr(saved_encCounter_start, saved_encCounter_mem);
+    __ movptr(used_addr, used_mem);
+    __ movl(used, Address(used_addr, 0));
+#else
+    __ push(len_reg); // Save
+    __ movptr(used_addr, used_mem);
+    __ movl(used, Address(used_addr, 0));
+#endif
+    __ push(rbx);
+    __ aesctr_encrypt(from, to, key, counter, len_reg, used, used_addr, saved_encCounter_start);
+    // Restore state before leaving routine
+    __ pop(rbx);
+#ifdef _WIN64
+    __ movl(rax, len_mem); // return length
+#else
+    __ pop(rax); // return length
+#endif
+    __ pop(r15);
+    __ pop(r14);
+    __ pop(r13);
+    __ pop(r12);
+
+    __ leave(); // required for proper stackwalking of RuntimeStub frame
+    __ ret(0);
+    return start;
+  }
+
   // This is a version of CTR/AES crypt which does 6 blocks in a loop at a time
   // to hide instruction latency
   //
@@ -6111,9 +6228,14 @@
         StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt_Parallel();
       }
     }
-    if (UseAESCTRIntrinsics){
-      StubRoutines::x86::_counter_shuffle_mask_addr = generate_counter_shuffle_mask();
-      StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel();
+    if (UseAESCTRIntrinsics) {
+      if (VM_Version::supports_vaes() && VM_Version::supports_avx512bw() && VM_Version::supports_avx512vl()) {
+        StubRoutines::x86::_counter_mask_addr = counter_mask_addr();
+        StubRoutines::_counterMode_AESCrypt = generate_counterMode_VectorAESCrypt();
+      } else {
+        StubRoutines::x86::_counter_shuffle_mask_addr = generate_counter_shuffle_mask();
+        StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel();
+      }
     }
 
     if (UseSHA1Intrinsics) {
--- a/src/hotspot/cpu/x86/stubRoutines_x86.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/cpu/x86/stubRoutines_x86.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -62,7 +62,7 @@
 address StubRoutines::x86::_left_shift_mask = NULL;
 address StubRoutines::x86::_and_mask = NULL;
 address StubRoutines::x86::_url_charset = NULL;
-
+address StubRoutines::x86::_counter_mask_addr = NULL;
 #endif
 address StubRoutines::x86::_pshuffle_byte_flip_mask_addr = NULL;
 
--- a/src/hotspot/cpu/x86/stubRoutines_x86.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/cpu/x86/stubRoutines_x86.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -154,6 +154,7 @@
   static address _k512_W_addr;
   // byte flip mask for sha512
   static address _pshuffle_byte_flip_mask_addr_sha512;
+  static address _counter_mask_addr;
   // Masks for base64
   static address _base64_charset;
   static address _bswap_mask;
@@ -258,6 +259,7 @@
   static address base64_right_shift_mask_addr() { return _right_shift_mask; }
   static address base64_left_shift_mask_addr() { return _left_shift_mask; }
   static address base64_and_mask_addr() { return _and_mask; }
+  static address counter_mask_addr() { return _counter_mask_addr; }
 #endif
   static address pshuffle_byte_flip_mask_addr() { return _pshuffle_byte_flip_mask_addr; }
   static void generate_CRC32C_table(bool is_pclmulqdq_supported);
--- a/src/hotspot/share/aot/aotCodeHeap.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/aot/aotCodeHeap.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -34,6 +34,7 @@
 #include "interpreter/abstractInterpreter.hpp"
 #include "jvmci/compilerRuntime.hpp"
 #include "jvmci/jvmciRuntime.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/universe.hpp"
 #include "oops/compressedOops.hpp"
--- a/src/hotspot/share/c1/c1_Canonicalizer.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/c1/c1_Canonicalizer.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -354,25 +354,21 @@
     }
     if (t2->is_constant()) {
       if (t->tag() == intTag) {
-        int value = t->as_IntConstant()->value();
-        int shift = t2->as_IntConstant()->value() & 31;
-        jint mask = ~(~0 << (32 - shift));
-        if (shift == 0) mask = ~0;
+        jint value = t->as_IntConstant()->value();
+        jint shift = t2->as_IntConstant()->value();
         switch (x->op()) {
-          case Bytecodes::_ishl:  set_constant(value << shift); return;
-          case Bytecodes::_ishr:  set_constant(value >> shift); return;
-          case Bytecodes::_iushr: set_constant((value >> shift) & mask); return;
+          case Bytecodes::_ishl:  set_constant(java_shift_left(value, shift)); return;
+          case Bytecodes::_ishr:  set_constant(java_shift_right(value, shift)); return;
+          case Bytecodes::_iushr: set_constant(java_shift_right_unsigned(value, shift)); return;
           default:                break;
         }
       } else if (t->tag() == longTag) {
         jlong value = t->as_LongConstant()->value();
-        int shift = t2->as_IntConstant()->value() & 63;
-        jlong mask = ~(~jlong_cast(0) << (64 - shift));
-        if (shift == 0) mask = ~jlong_cast(0);
+        jint shift = t2->as_IntConstant()->value();
         switch (x->op()) {
-          case Bytecodes::_lshl:  set_constant(value << shift); return;
-          case Bytecodes::_lshr:  set_constant(value >> shift); return;
-          case Bytecodes::_lushr: set_constant((value >> shift) & mask); return;
+          case Bytecodes::_lshl:  set_constant(java_shift_left(value, shift)); return;
+          case Bytecodes::_lshr:  set_constant(java_shift_right(value, shift)); return;
+          case Bytecodes::_lushr: set_constant(java_shift_right_unsigned(value, shift)); return;
           default:                break;
         }
       }
--- a/src/hotspot/share/compiler/compilerDirectives.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/compiler/compilerDirectives.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -61,11 +61,12 @@
     cflags(PrintIntrinsics,         bool, PrintIntrinsics, PrintIntrinsics) \
 NOT_PRODUCT(cflags(TraceOptoPipelining, bool, TraceOptoPipelining, TraceOptoPipelining)) \
 NOT_PRODUCT(cflags(TraceOptoOutput,     bool, TraceOptoOutput, TraceOptoOutput)) \
+NOT_PRODUCT(cflags(PrintIdeal,          bool, PrintIdeal, PrintIdeal)) \
+NOT_PRODUCT(cflags(IGVPrintLevel,       intx, PrintIdealGraphLevel, IGVPrintLevel)) \
     cflags(TraceSpilling,           bool, TraceSpilling, TraceSpilling) \
     cflags(Vectorize,               bool, false, Vectorize) \
     cflags(VectorizeDebug,          uintx, 0, VectorizeDebug) \
     cflags(CloneMapDebug,           bool, false, CloneMapDebug) \
-    cflags(IGVPrintLevel,           intx, PrintIdealGraphLevel, IGVPrintLevel) \
     cflags(MaxNodeLimit,            intx, MaxNodeLimit, MaxNodeLimit)
 #else
   #define compilerdirectives_c2_flags(cflags)
--- a/src/hotspot/share/gc/cms/compactibleFreeListSpace.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/cms/compactibleFreeListSpace.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -32,7 +32,7 @@
 #include "gc/shared/collectedHeap.inline.hpp"
 #include "gc/shared/genOopClosures.inline.hpp"
 #include "gc/shared/space.inline.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "logging/log.hpp"
 #include "logging/logStream.hpp"
 #include "memory/allocation.inline.hpp"
--- a/src/hotspot/share/gc/cms/parNewGeneration.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/cms/parNewGeneration.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -44,7 +44,7 @@
 #include "gc/shared/referencePolicy.hpp"
 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
 #include "gc/shared/space.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "gc/shared/strongRootsScope.hpp"
 #include "gc/shared/taskqueue.inline.hpp"
 #include "gc/shared/weakProcessor.hpp"
--- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -25,8 +25,7 @@
 #include "precompiled.hpp"
 #include "gc/g1/g1BlockOffsetTable.inline.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/heapRegion.hpp"
-#include "gc/shared/space.hpp"
+#include "gc/g1/heapRegion.inline.hpp"
 #include "logging/log.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/java.hpp"
@@ -74,12 +73,12 @@
 // G1BlockOffsetTablePart
 //////////////////////////////////////////////////////////////////////
 
-G1BlockOffsetTablePart::G1BlockOffsetTablePart(G1BlockOffsetTable* array, G1ContiguousSpace* gsp) :
+G1BlockOffsetTablePart::G1BlockOffsetTablePart(G1BlockOffsetTable* array, HeapRegion* hr) :
   _next_offset_threshold(NULL),
   _next_offset_index(0),
   DEBUG_ONLY(_object_can_span(false) COMMA)
   _bot(array),
-  _space(gsp)
+  _hr(hr)
 {
 }
 
@@ -141,7 +140,7 @@
   if (start_card > end_card) {
     return;
   }
-  assert(start_card > _bot->index_for(_space->bottom()), "Cannot be first card");
+  assert(start_card > _bot->index_for(_hr->bottom()), "Cannot be first card");
   assert(_bot->offset_array(start_card-1) <= BOTConstants::N_words,
          "Offset card has an unexpected value");
   size_t start_card_for_region = start_card;
@@ -224,7 +223,7 @@
          "next_boundary is beyond the end of the covered region "
          " next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT,
          p2i(next_boundary), p2i(_bot->_reserved.end()));
-  if (addr >= _space->top()) return _space->top();
+  if (addr >= _hr->top()) return _hr->top();
   while (next_boundary < addr) {
     while (n <= next_boundary) {
       q = n;
@@ -326,9 +325,9 @@
 }
 
 void G1BlockOffsetTablePart::verify() const {
-  assert(_space->bottom() < _space->top(), "Only non-empty regions should be verified.");
-  size_t start_card = _bot->index_for(_space->bottom());
-  size_t end_card = _bot->index_for(_space->top() - 1);
+  assert(_hr->bottom() < _hr->top(), "Only non-empty regions should be verified.");
+  size_t start_card = _bot->index_for(_hr->bottom());
+  size_t end_card = _bot->index_for(_hr->top() - 1);
 
   for (size_t current_card = start_card; current_card < end_card; current_card++) {
     u_char entry = _bot->offset_array(current_card);
@@ -342,9 +341,9 @@
         HeapWord* obj = obj_end;
         size_t obj_size = block_size(obj);
         obj_end = obj + obj_size;
-        guarantee(obj_end > obj && obj_end <= _space->top(),
+        guarantee(obj_end > obj && obj_end <= _hr->top(),
                   "Invalid object end. obj: " PTR_FORMAT " obj_size: " SIZE_FORMAT " obj_end: " PTR_FORMAT " top: " PTR_FORMAT,
-                  p2i(obj), obj_size, p2i(obj_end), p2i(_space->top()));
+                  p2i(obj), obj_size, p2i(obj_end), p2i(_hr->top()));
       }
     } else {
       // Because we refine the BOT based on which cards are dirty there is not much we can verify here.
@@ -359,9 +358,9 @@
                 start_card, current_card, backskip);
 
       HeapWord* backskip_address = _bot->address_for_index(current_card - backskip);
-      guarantee(backskip_address >= _space->bottom(),
+      guarantee(backskip_address >= _hr->bottom(),
                 "Going backwards beyond bottom of the region: bottom: " PTR_FORMAT ", backskip_address: " PTR_FORMAT,
-                p2i(_space->bottom()), p2i(backskip_address));
+                p2i(_hr->bottom()), p2i(backskip_address));
     }
   }
 }
@@ -373,13 +372,12 @@
 #endif
 
 #ifndef PRODUCT
-void
-G1BlockOffsetTablePart::print_on(outputStream* out) {
-  size_t from_index = _bot->index_for(_space->bottom());
-  size_t to_index = _bot->index_for(_space->end());
+void G1BlockOffsetTablePart::print_on(outputStream* out) {
+  size_t from_index = _bot->index_for(_hr->bottom());
+  size_t to_index = _bot->index_for(_hr->end());
   out->print_cr(">> BOT for area [" PTR_FORMAT "," PTR_FORMAT ") "
                 "cards [" SIZE_FORMAT "," SIZE_FORMAT ")",
-                p2i(_space->bottom()), p2i(_space->end()), from_index, to_index);
+                p2i(_hr->bottom()), p2i(_hr->end()), from_index, to_index);
   for (size_t i = from_index; i < to_index; ++i) {
     out->print_cr("  entry " SIZE_FORMAT_W(8) " | " PTR_FORMAT " : %3u",
                   i, p2i(_bot->address_for_index(i)),
@@ -391,7 +389,7 @@
 #endif // !PRODUCT
 
 HeapWord* G1BlockOffsetTablePart::initialize_threshold_raw() {
-  _next_offset_index = _bot->index_for_raw(_space->bottom());
+  _next_offset_index = _bot->index_for_raw(_hr->bottom());
   _next_offset_index++;
   _next_offset_threshold =
     _bot->address_for_index_raw(_next_offset_index);
@@ -399,14 +397,14 @@
 }
 
 void G1BlockOffsetTablePart::zero_bottom_entry_raw() {
-  size_t bottom_index = _bot->index_for_raw(_space->bottom());
-  assert(_bot->address_for_index_raw(bottom_index) == _space->bottom(),
+  size_t bottom_index = _bot->index_for_raw(_hr->bottom());
+  assert(_bot->address_for_index_raw(bottom_index) == _hr->bottom(),
          "Precondition of call");
   _bot->set_offset_array_raw(bottom_index, 0);
 }
 
 HeapWord* G1BlockOffsetTablePart::initialize_threshold() {
-  _next_offset_index = _bot->index_for(_space->bottom());
+  _next_offset_index = _bot->index_for(_hr->bottom());
   _next_offset_index++;
   _next_offset_threshold =
     _bot->address_for_index(_next_offset_index);
@@ -416,7 +414,7 @@
 void G1BlockOffsetTablePart::set_for_starts_humongous(HeapWord* obj_top, size_t fill_size) {
   // The first BOT entry should have offset 0.
   reset_bot();
-  alloc_block(_space->bottom(), obj_top);
+  alloc_block(_hr->bottom(), obj_top);
   if (fill_size > 0) {
     alloc_block(obj_top, fill_size);
   }
--- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -33,14 +33,14 @@
 
 // Forward declarations
 class G1BlockOffsetTable;
-class G1ContiguousSpace;
+class HeapRegion;
 
 // This implementation of "G1BlockOffsetTable" divides the covered region
 // into "N"-word subregions (where "N" = 2^"LogN".  An array with an entry
 // for each such subregion indicates how far back one must go to find the
 // start of the chunk that includes the first word of the subregion.
 //
-// Each G1BlockOffsetTablePart is owned by a G1ContiguousSpace.
+// Each G1BlockOffsetTablePart is owned by a HeapRegion.
 
 class G1BlockOffsetTable: public CHeapObj<mtGC> {
   friend class G1BlockOffsetTablePart;
@@ -120,8 +120,8 @@
   // This is the global BlockOffsetTable.
   G1BlockOffsetTable* _bot;
 
-  // The space that owns this subregion.
-  G1ContiguousSpace* _space;
+  // The region that owns this subregion.
+  HeapRegion* _hr;
 
   // Sets the entries
   // corresponding to the cards starting at "start" and ending at "end"
@@ -183,7 +183,7 @@
 
 public:
   //  The elements of the array are initialized to zero.
-  G1BlockOffsetTablePart(G1BlockOffsetTable* array, G1ContiguousSpace* gsp);
+  G1BlockOffsetTablePart(G1BlockOffsetTable* array, HeapRegion* hr);
 
   void verify() const;
 
--- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -28,11 +28,10 @@
 #include "gc/g1/g1BlockOffsetTable.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "gc/shared/memset_with_concurrent_readers.hpp"
-#include "gc/shared/space.hpp"
 #include "runtime/atomic.hpp"
 
 inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) {
-  if (addr >= _space->bottom() && addr < _space->end()) {
+  if (addr >= _hr->bottom() && addr < _hr->end()) {
     HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
     return forward_to_block_containing_addr(q, addr);
   } else {
@@ -41,7 +40,7 @@
 }
 
 inline HeapWord* G1BlockOffsetTablePart::block_start_const(const void* addr) const {
-  if (addr >= _space->bottom() && addr < _space->end()) {
+  if (addr >= _hr->bottom() && addr < _hr->end()) {
     HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
     HeapWord* n = q + block_size(q);
     return forward_to_block_containing_addr_const(q, n, addr);
@@ -107,15 +106,15 @@
 }
 
 inline size_t G1BlockOffsetTablePart::block_size(const HeapWord* p) const {
-  return _space->block_size(p);
+  return _hr->block_size(p);
 }
 
 inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr,
                                                                bool has_max_index,
                                                                size_t max_index) const {
-  assert(_object_can_span || _bot->offset_array(_bot->index_for(_space->bottom())) == 0,
+  assert(_object_can_span || _bot->offset_array(_bot->index_for(_hr->bottom())) == 0,
          "Object crossed region boundary, found offset %u instead of 0",
-         (uint) _bot->offset_array(_bot->index_for(_space->bottom())));
+         (uint) _bot->offset_array(_bot->index_for(_hr->bottom())));
   size_t index = _bot->index_for(addr);
   // We must make sure that the offset table entry we use is valid.  If
   // "addr" is past the end, start at the last known one and go forward.
@@ -140,7 +139,7 @@
 
 inline HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
                                                                                 const void* addr) const {
-  if (addr >= _space->top()) return _space->top();
+  if (addr >= _hr->top()) return _hr->top();
   while (n <= addr) {
     q = n;
     oop obj = oop(q);
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -664,8 +664,6 @@
         next_region = NULL;
       }
       curr_region->set_top(top);
-      curr_region->set_first_dead(top);
-      curr_region->set_end_of_live(top);
       curr_region = next_region;
     }
 
@@ -3978,7 +3976,7 @@
       }
 
       if (!r->evacuation_failed()) {
-        assert(r->not_empty(), "Region %u is an empty region in the collection set.", r->hrm_index());
+        assert(!r->is_empty(), "Region %u is an empty region in the collection set.", r->hrm_index());
         _before_used_bytes += r->used();
         g1h->free_region(r,
                          &_local_free_list,
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -32,6 +32,7 @@
 #include "gc/g1/heapRegionSet.hpp"
 #include "gc/shared/taskqueue.hpp"
 #include "gc/shared/verifyOption.hpp"
+#include "gc/shared/workgroup.hpp"
 #include "memory/allocation.hpp"
 #include "utilities/compilerWarnings.hpp"
 
--- a/src/hotspot/share/gc/g1/g1YoungGenSizer.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/g1/g1YoungGenSizer.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -28,6 +28,7 @@
 #include "gc/g1/g1YoungGenSizer.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "logging/log.hpp"
+#include "runtime/globals_extension.hpp"
 
 G1YoungGenSizer::G1YoungGenSizer() : _sizer_kind(SizerDefaults),
   _use_adaptive_sizing(true), _min_desired_young_length(0), _max_desired_young_length(0) {
--- a/src/hotspot/share/gc/g1/heapRegion.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/g1/heapRegion.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -35,7 +35,6 @@
 #include "gc/g1/heapRegionRemSet.hpp"
 #include "gc/g1/heapRegionTracer.hpp"
 #include "gc/shared/genOopClosures.inline.hpp"
-#include "gc/shared/space.inline.hpp"
 #include "logging/log.hpp"
 #include "logging/logStream.hpp"
 #include "memory/iterator.inline.hpp"
@@ -45,7 +44,6 @@
 #include "oops/oop.inline.hpp"
 #include "runtime/atomic.hpp"
 #include "runtime/orderAccess.hpp"
-#include "utilities/growableArray.hpp"
 
 int    HeapRegion::LogOfHRGrainBytes = 0;
 int    HeapRegion::LogOfHRGrainWords = 0;
@@ -234,21 +232,27 @@
 HeapRegion::HeapRegion(uint hrm_index,
                        G1BlockOffsetTable* bot,
                        MemRegion mr) :
-    G1ContiguousSpace(bot),
-    _rem_set(NULL),
-    _hrm_index(hrm_index),
-    _type(),
-    _humongous_start_region(NULL),
-    _evacuation_failed(false),
-    _next(NULL), _prev(NULL),
+  _bottom(NULL),
+  _end(NULL),
+  _top(NULL),
+  _compaction_top(NULL),
+  _bot_part(bot, this),
+  _par_alloc_lock(Mutex::leaf, "HeapRegion par alloc lock", true),
+  _pre_dummy_top(NULL),
+  _rem_set(NULL),
+  _hrm_index(hrm_index),
+  _type(),
+  _humongous_start_region(NULL),
+  _evacuation_failed(false),
+  _next(NULL), _prev(NULL),
 #ifdef ASSERT
-    _containing_set(NULL),
+  _containing_set(NULL),
 #endif
-    _prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0),
-    _index_in_opt_cset(InvalidCSetIndex), _young_index_in_cset(-1),
-    _surv_rate_group(NULL), _age_index(-1),
-    _prev_top_at_mark_start(NULL), _next_top_at_mark_start(NULL),
-    _recorded_rs_length(0), _predicted_elapsed_time_ms(0)
+  _prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0),
+  _index_in_opt_cset(InvalidCSetIndex), _young_index_in_cset(-1),
+  _surv_rate_group(NULL), _age_index(-1),
+  _prev_top_at_mark_start(NULL), _next_top_at_mark_start(NULL),
+  _recorded_rs_length(0), _predicted_elapsed_time_ms(0)
 {
   _rem_set = new HeapRegionRemSet(bot, this);
 
@@ -258,10 +262,20 @@
 void HeapRegion::initialize(MemRegion mr, bool clear_space, bool mangle_space) {
   assert(_rem_set->is_empty(), "Remembered set must be empty");
 
-  G1ContiguousSpace::initialize(mr, clear_space, mangle_space);
+  assert(Universe::on_page_boundary(mr.start()) && Universe::on_page_boundary(mr.end()),
+         "invalid space boundaries");
+
+  set_bottom(mr.start());
+  set_end(mr.end());
+  if (clear_space) {
+    clear(mangle_space);
+  }
+
+  set_top(bottom());
+  set_compaction_top(bottom());
+  reset_bot();
 
   hr_clear(false /*par*/, false /*clear_space*/);
-  set_top(bottom());
 }
 
 void HeapRegion::report_region_type_change(G1HeapRegionTraceType::Type to) {
@@ -444,6 +458,7 @@
 }
 
 void HeapRegion::print() const { print_on(tty); }
+
 void HeapRegion::print_on(outputStream* st) const {
   st->print("|%4u", this->_hrm_index);
   st->print("|" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT,
@@ -636,9 +651,6 @@
   debug_only(virtual bool should_verify_oops() { return false; })
 };
 
-// This really ought to be commoned up into OffsetTableContigSpace somehow.
-// We would need a mechanism to make that code skip dead objects.
-
 void HeapRegion::verify(VerifyOption vo,
                         bool* failures) const {
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
@@ -828,51 +840,32 @@
   guarantee(!failures, "HeapRegion RemSet verification failed");
 }
 
-void HeapRegion::prepare_for_compaction(CompactPoint* cp) {
-  // Not used for G1 anymore, but pure virtual in Space.
-  ShouldNotReachHere();
+void HeapRegion::clear(bool mangle_space) {
+  set_top(bottom());
+  set_compaction_top(bottom());
+
+  if (ZapUnusedHeapArea && mangle_space) {
+    mangle_unused_area();
+  }
+  reset_bot();
 }
 
-// G1OffsetTableContigSpace code; copied from space.cpp.  Hope this can go
-// away eventually.
-
-void G1ContiguousSpace::clear(bool mangle_space) {
-  set_top(bottom());
-  CompactibleSpace::clear(mangle_space);
-  reset_bot();
-}
 #ifndef PRODUCT
-void G1ContiguousSpace::mangle_unused_area() {
-  mangle_unused_area_complete();
-}
-
-void G1ContiguousSpace::mangle_unused_area_complete() {
+void HeapRegion::mangle_unused_area() {
   SpaceMangler::mangle_region(MemRegion(top(), end()));
 }
 #endif
 
-void G1ContiguousSpace::print() const {
-  print_short();
-  tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", "
-                INTPTR_FORMAT ", " INTPTR_FORMAT ")",
-                p2i(bottom()), p2i(top()), p2i(_bot_part.threshold()), p2i(end()));
-}
-
-HeapWord* G1ContiguousSpace::initialize_threshold() {
+HeapWord* HeapRegion::initialize_threshold() {
   return _bot_part.initialize_threshold();
 }
 
-HeapWord* G1ContiguousSpace::cross_threshold(HeapWord* start,
-                                                    HeapWord* end) {
+HeapWord* HeapRegion::cross_threshold(HeapWord* start, HeapWord* end) {
   _bot_part.alloc_block(start, end);
   return _bot_part.threshold();
 }
 
-void G1ContiguousSpace::safe_object_iterate(ObjectClosure* blk) {
-  object_iterate(blk);
-}
-
-void G1ContiguousSpace::object_iterate(ObjectClosure* blk) {
+void HeapRegion::object_iterate(ObjectClosure* blk) {
   HeapWord* p = bottom();
   while (p < top()) {
     if (block_is_obj(p)) {
@@ -881,18 +874,3 @@
     p += block_size(p);
   }
 }
-
-G1ContiguousSpace::G1ContiguousSpace(G1BlockOffsetTable* bot) :
-  _top(NULL),
-  _bot_part(bot, this),
-  _par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true),
-  _pre_dummy_top(NULL)
-{
-}
-
-void G1ContiguousSpace::initialize(MemRegion mr, bool clear_space, bool mangle_space) {
-  CompactibleSpace::initialize(mr, clear_space, mangle_space);
-  _top = bottom();
-  set_saved_mark_word(NULL);
-  reset_bot();
-}
--- a/src/hotspot/share/gc/g1/heapRegion.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/g1/heapRegion.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -31,34 +31,13 @@
 #include "gc/g1/heapRegionType.hpp"
 #include "gc/g1/survRateGroup.hpp"
 #include "gc/shared/ageTable.hpp"
-#include "gc/shared/cardTable.hpp"
+#include "gc/shared/spaceDecorator.hpp"
 #include "gc/shared/verifyOption.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "runtime/mutex.hpp"
 #include "utilities/macros.hpp"
 
-// A HeapRegion is the smallest piece of a G1CollectedHeap that
-// can be collected independently.
-
-// NOTE: Although a HeapRegion is a Space, its
-// Space::initDirtyCardClosure method must not be called.
-// The problem is that the existence of this method breaks
-// the independence of barrier sets from remembered sets.
-// The solution is to remove this method from the definition
-// of a Space.
-
-// Each heap region is self contained. top() and end() can never
-// be set beyond the end of the region. For humongous objects,
-// the first region is a StartsHumongous region. If the humongous
-// object is larger than a heap region, the following regions will
-// be of type ContinuesHumongous. In this case the top() of the
-// StartHumongous region and all ContinuesHumongous regions except
-// the last will point to their own end. The last ContinuesHumongous
-// region may have top() equal the end of object if there isn't
-// room for filler objects to pad out to the end of the region.
-
 class G1CollectedHeap;
 class G1CMBitMap;
-class G1IsAliveAndApplyClosure;
 class HeapRegionRemSet;
 class HeapRegion;
 class HeapRegionSetBase;
@@ -73,31 +52,27 @@
 // sentinel value for hrm_index
 #define G1_NO_HRM_INDEX ((uint) -1)
 
-// The complicating factor is that BlockOffsetTable diverged
-// significantly, and we need functionality that is only in the G1 version.
-// So I copied that code, which led to an alternate G1 version of
-// OffsetTableContigSpace.  If the two versions of BlockOffsetTable could
-// be reconciled, then G1OffsetTableContigSpace could go away.
+// A HeapRegion is the smallest piece of a G1CollectedHeap that
+// can be collected independently.
 
-// The idea behind time stamps is the following. We want to keep track of
-// the highest address where it's safe to scan objects for each region.
-// This is only relevant for current GC alloc regions so we keep a time stamp
-// per region to determine if the region has been allocated during the current
-// GC or not. If the time stamp is current we report a scan_top value which
-// was saved at the end of the previous GC for retained alloc regions and which is
-// equal to the bottom for all other regions.
-// There is a race between card scanners and allocating gc workers where we must ensure
-// that card scanners do not read the memory allocated by the gc workers.
-// In order to enforce that, we must not return a value of _top which is more recent than the
-// time stamp. This is due to the fact that a region may become a gc alloc region at
-// some point after we've read the timestamp value as being < the current time stamp.
-// The time stamps are re-initialized to zero at cleanup and at Full GCs.
-// The current scheme that uses sequential unsigned ints will fail only if we have 4b
-// evacuation pauses between two cleanups, which is _highly_ unlikely.
-class G1ContiguousSpace: public CompactibleSpace {
+// Each heap region is self contained. top() and end() can never
+// be set beyond the end of the region. For humongous objects,
+// the first region is a StartsHumongous region. If the humongous
+// object is larger than a heap region, the following regions will
+// be of type ContinuesHumongous. In this case the top() of the
+// StartHumongous region and all ContinuesHumongous regions except
+// the last will point to their own end. The last ContinuesHumongous
+// region may have top() equal the end of object if there isn't
+// room for filler objects to pad out to the end of the region.
+class HeapRegion : public CHeapObj<mtGC> {
   friend class VMStructs;
+
+  HeapWord* _bottom;
+  HeapWord* _end;
+
   HeapWord* volatile _top;
- protected:
+  HeapWord* _compaction_top;
+
   G1BlockOffsetTablePart _bot_part;
   Mutex _par_alloc_lock;
   // When we need to retire an allocation region, while other threads
@@ -108,43 +83,57 @@
   // into the region was and this is what this keeps track.
   HeapWord* _pre_dummy_top;
 
- public:
-  G1ContiguousSpace(G1BlockOffsetTable* bot);
+public:
+  void set_bottom(HeapWord* value) { _bottom = value; }
+  HeapWord* bottom() const         { return _bottom; }
+
+  void set_end(HeapWord* value)    { _end = value; }
+  HeapWord* end() const            { return _end;    }
+
+  void set_compaction_top(HeapWord* compaction_top) { _compaction_top = compaction_top; }
+  HeapWord* compaction_top() const { return _compaction_top; }
 
   void set_top(HeapWord* value) { _top = value; }
   HeapWord* top() const { return _top; }
 
- protected:
-  // Reset the G1ContiguousSpace.
-  virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
+  // Returns true iff the given the heap  region contains the
+  // given address as part of an allocated object. This may
+  // be a potentially, so we restrict its use to assertion checks only.
+  bool is_in(const void* p) const {
+    return is_in_reserved(p);
+  }
+  bool is_in(oop obj) const {
+    return is_in((void*)obj);
+  }
+  // Returns true iff the given reserved memory of the space contains the
+  // given address.
+  bool is_in_reserved(const void* p) const { return _bottom <= p && p < _end; }
 
-  HeapWord* volatile* top_addr() { return &_top; }
-  // Try to allocate at least min_word_size and up to desired_size from this Space.
+  size_t capacity()     const { return byte_size(bottom(), end()); }
+  size_t used() const { return byte_size(bottom(), top()); }
+  size_t free() const { return byte_size(top(), end()); }
+
+  bool is_empty() const { return used() == 0; }
+
+private:
+  void reset_after_compaction() { set_top(compaction_top()); }
+
+  // Try to allocate at least min_word_size and up to desired_size from this region.
   // Returns NULL if not possible, otherwise sets actual_word_size to the amount of
   // space allocated.
-  // This version assumes that all allocation requests to this Space are properly
+  // This version assumes that all allocation requests to this HeapRegion are properly
   // synchronized.
   inline HeapWord* allocate_impl(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
-  // Try to allocate at least min_word_size and up to desired_size from this Space.
+  // Try to allocate at least min_word_size and up to desired_size from this HeapRegion.
   // Returns NULL if not possible, otherwise sets actual_word_size to the amount of
   // space allocated.
   // This version synchronizes with other calls to par_allocate_impl().
   inline HeapWord* par_allocate_impl(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
 
- public:
-  void reset_after_compaction() { set_top(compaction_top()); }
-
-  size_t used() const { return byte_size(bottom(), top()); }
-  size_t free() const { return byte_size(top(), end()); }
-  bool is_free_block(const HeapWord* p) const { return p >= top(); }
+  void mangle_unused_area() PRODUCT_RETURN;
 
-  MemRegion used_region() const { return MemRegion(bottom(), top()); }
-
+public:
   void object_iterate(ObjectClosure* blk);
-  void safe_object_iterate(ObjectClosure* blk);
-
-  void mangle_unused_area() PRODUCT_RETURN;
-  void mangle_unused_area_complete() PRODUCT_RETURN;
 
   // See the comment above in the declaration of _pre_dummy_top for an
   // explanation of what it is.
@@ -152,32 +141,31 @@
     assert(is_in(pre_dummy_top) && pre_dummy_top <= top(), "pre-condition");
     _pre_dummy_top = pre_dummy_top;
   }
+
   HeapWord* pre_dummy_top() {
     return (_pre_dummy_top == NULL) ? top() : _pre_dummy_top;
   }
   void reset_pre_dummy_top() { _pre_dummy_top = NULL; }
 
-  virtual void clear(bool mangle_space);
+  void clear(bool mangle_space);
 
   HeapWord* block_start(const void* p);
   HeapWord* block_start_const(const void* p) const;
 
   // Allocation (return NULL if full).  Assumes the caller has established
-  // mutually exclusive access to the space.
+  // mutually exclusive access to the HeapRegion.
   HeapWord* allocate(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
   // Allocation (return NULL if full).  Enforces mutual exclusion internally.
   HeapWord* par_allocate(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
 
-  virtual HeapWord* allocate(size_t word_size);
-  virtual HeapWord* par_allocate(size_t word_size);
+  HeapWord* allocate(size_t word_size);
+  HeapWord* par_allocate(size_t word_size);
 
   HeapWord* saved_mark_word() const { ShouldNotReachHere(); return NULL; }
 
   // MarkSweep support phase3
-  virtual HeapWord* initialize_threshold();
-  virtual HeapWord* cross_threshold(HeapWord* start, HeapWord* end);
-
-  virtual void print() const;
+  HeapWord* initialize_threshold();
+  HeapWord* cross_threshold(HeapWord* start, HeapWord* end);
 
   void reset_bot() {
     _bot_part.reset_bot();
@@ -186,34 +174,11 @@
   void print_bot_on(outputStream* out) {
     _bot_part.print_on(out);
   }
-};
 
-class HeapRegion: public G1ContiguousSpace {
-  friend class VMStructs;
-  // Allow scan_and_forward to call (private) overrides for auxiliary functions on this class
-  template <typename SpaceType>
-  friend void CompactibleSpace::scan_and_forward(SpaceType* space, CompactPoint* cp);
- private:
-
+private:
   // The remembered set for this region.
-  // (Might want to make this "inline" later, to avoid some alloc failure
-  // issues.)
   HeapRegionRemSet* _rem_set;
 
-  // Auxiliary functions for scan_and_forward support.
-  // See comments for CompactibleSpace for more information.
-  inline HeapWord* scan_limit() const {
-    return top();
-  }
-
-  inline bool scanned_block_is_obj(const HeapWord* addr) const {
-    return true; // Always true, since scan_limit is top
-  }
-
-  inline size_t scanned_block_size(const HeapWord* addr) const {
-    return HeapRegion::block_size(addr); // Avoid virtual call
-  }
-
   void report_region_type_change(G1HeapRegionTraceType::Type to);
 
   // Returns whether the given object address refers to a dead object, and either the
@@ -223,7 +188,6 @@
   // - not called on humongous objects or archive regions
   inline bool is_obj_dead_with_size(const oop obj, const G1CMBitMap* const prev_bitmap, size_t* size) const;
 
- protected:
   // The index of this region in the heap region sequence.
   uint  _hrm_index;
 
@@ -269,8 +233,6 @@
   // "next" is the top at the start of the in-progress marking (if any.)
   HeapWord* _prev_top_at_mark_start;
   HeapWord* _next_top_at_mark_start;
-  // If a collection pause is in progress, this is the top at the start
-  // of that pause.
 
   void init_top_at_mark_start() {
     assert(_prev_marked_bytes == 0 &&
@@ -306,16 +268,14 @@
   // Returns the block size of the given (dead, potentially having its class unloaded) object
   // starting at p extending to at most the prev TAMS using the given mark bitmap.
   inline size_t block_size_using_bitmap(const HeapWord* p, const G1CMBitMap* const prev_bitmap) const;
- public:
-  HeapRegion(uint hrm_index,
-             G1BlockOffsetTable* bot,
-             MemRegion mr);
+public:
+  HeapRegion(uint hrm_index, G1BlockOffsetTable* bot, MemRegion mr);
 
   // Initializing the HeapRegion not only resets the data structure, but also
   // resets the BOT for that heap region.
   // The default values for clear_space means that we will do the clearing if
   // there's clearing to be done ourselves. We also always mangle the space.
-  virtual void initialize(MemRegion mr, bool clear_space = false, bool mangle_space = SpaceDecorator::Mangle);
+  void initialize(MemRegion mr, bool clear_space = false, bool mangle_space = SpaceDecorator::Mangle);
 
   static int    LogOfHRGrainBytes;
   static int    LogOfHRGrainWords;
@@ -364,8 +324,6 @@
   // objects to call size_t ApplyToMarkedClosure::apply(oop) for.
   template<typename ApplyToMarkedClosure>
   inline void apply_to_marked_objects(G1CMBitMap* bitmap, ApplyToMarkedClosure* closure);
-  // Override for scan_and_forward support.
-  void prepare_for_compaction(CompactPoint* cp);
   // Update heap region to be consistent after compaction.
   void complete_compaction();
 
@@ -707,8 +665,8 @@
   // full GC.
   void verify(VerifyOption vo, bool *failures) const;
 
-  // Override; it uses the "prev" marking information
-  virtual void verify() const;
+  // Verify using the "prev" marking information
+  void verify() const;
 
   void verify_rem_set(VerifyOption vo, bool *failures) const;
   void verify_rem_set() const;
@@ -724,7 +682,7 @@
   bool _is_complete;
   void set_incomplete() { _is_complete = false; }
 
- public:
+public:
   HeapRegionClosure(): _is_complete(true) {}
 
   // Typically called on each region until it returns true.
--- a/src/hotspot/share/gc/g1/heapRegion.inline.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/g1/heapRegion.inline.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -29,22 +29,22 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
 #include "gc/g1/heapRegion.hpp"
-#include "gc/shared/space.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/atomic.hpp"
 #include "runtime/prefetch.inline.hpp"
 #include "utilities/align.hpp"
+#include "utilities/globalDefinitions.hpp"
 
-inline HeapWord* G1ContiguousSpace::allocate_impl(size_t min_word_size,
-                                                  size_t desired_word_size,
-                                                  size_t* actual_size) {
+inline HeapWord* HeapRegion::allocate_impl(size_t min_word_size,
+                                           size_t desired_word_size,
+                                           size_t* actual_size) {
   HeapWord* obj = top();
   size_t available = pointer_delta(end(), obj);
   size_t want_to_allocate = MIN2(available, desired_word_size);
   if (want_to_allocate >= min_word_size) {
     HeapWord* new_top = obj + want_to_allocate;
     set_top(new_top);
-    assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
+    assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment");
     *actual_size = want_to_allocate;
     return obj;
   } else {
@@ -52,21 +52,21 @@
   }
 }
 
-inline HeapWord* G1ContiguousSpace::par_allocate_impl(size_t min_word_size,
-                                                      size_t desired_word_size,
-                                                      size_t* actual_size) {
+inline HeapWord* HeapRegion::par_allocate_impl(size_t min_word_size,
+                                               size_t desired_word_size,
+                                               size_t* actual_size) {
   do {
     HeapWord* obj = top();
     size_t available = pointer_delta(end(), obj);
     size_t want_to_allocate = MIN2(available, desired_word_size);
     if (want_to_allocate >= min_word_size) {
       HeapWord* new_top = obj + want_to_allocate;
-      HeapWord* result = Atomic::cmpxchg(new_top, top_addr(), obj);
+      HeapWord* result = Atomic::cmpxchg(new_top, &_top, obj);
       // result can be one of two:
       //  the old top value: the exchange succeeded
       //  otherwise: the new value of the top is returned.
       if (result == obj) {
-        assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
+        assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment");
         *actual_size = want_to_allocate;
         return obj;
       }
@@ -76,9 +76,9 @@
   } while (true);
 }
 
-inline HeapWord* G1ContiguousSpace::allocate(size_t min_word_size,
-                                             size_t desired_word_size,
-                                             size_t* actual_size) {
+inline HeapWord* HeapRegion::allocate(size_t min_word_size,
+                                      size_t desired_word_size,
+                                      size_t* actual_size) {
   HeapWord* res = allocate_impl(min_word_size, desired_word_size, actual_size);
   if (res != NULL) {
     _bot_part.alloc_block(res, *actual_size);
@@ -86,12 +86,12 @@
   return res;
 }
 
-inline HeapWord* G1ContiguousSpace::allocate(size_t word_size) {
+inline HeapWord* HeapRegion::allocate(size_t word_size) {
   size_t temp;
   return allocate(word_size, word_size, &temp);
 }
 
-inline HeapWord* G1ContiguousSpace::par_allocate(size_t word_size) {
+inline HeapWord* HeapRegion::par_allocate(size_t word_size) {
   size_t temp;
   return par_allocate(word_size, word_size, &temp);
 }
@@ -99,19 +99,18 @@
 // Because of the requirement of keeping "_offsets" up to date with the
 // allocations, we sequentialize these with a lock.  Therefore, best if
 // this is used for larger LAB allocations only.
-inline HeapWord* G1ContiguousSpace::par_allocate(size_t min_word_size,
-                                                 size_t desired_word_size,
-                                                 size_t* actual_size) {
+inline HeapWord* HeapRegion::par_allocate(size_t min_word_size,
+                                          size_t desired_word_size,
+                                          size_t* actual_size) {
   MutexLocker x(&_par_alloc_lock);
   return allocate(min_word_size, desired_word_size, actual_size);
 }
 
-inline HeapWord* G1ContiguousSpace::block_start(const void* p) {
+inline HeapWord* HeapRegion::block_start(const void* p) {
   return _bot_part.block_start(p);
 }
 
-inline HeapWord*
-G1ContiguousSpace::block_start_const(const void* p) const {
+inline HeapWord* HeapRegion::block_start_const(const void* p) const {
   return _bot_part.block_start_const(p);
 }
 
@@ -134,8 +133,7 @@
   return obj_is_dead;
 }
 
-inline bool
-HeapRegion::block_is_obj(const HeapWord* p) const {
+inline bool HeapRegion::block_is_obj(const HeapWord* p) const {
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 
   if (!this->is_in(p)) {
@@ -185,7 +183,7 @@
 inline void HeapRegion::complete_compaction() {
   // Reset space and bot after compaction is complete if needed.
   reset_after_compaction();
-  if (used_region().is_empty()) {
+  if (is_empty()) {
     reset_bot();
   }
 
@@ -202,7 +200,7 @@
 
 template<typename ApplyToMarkedClosure>
 inline void HeapRegion::apply_to_marked_objects(G1CMBitMap* bitmap, ApplyToMarkedClosure* closure) {
-  HeapWord* limit = scan_limit();
+  HeapWord* limit = top();
   HeapWord* next_addr = bottom();
 
   while (next_addr < limit) {
--- a/src/hotspot/share/gc/g1/vmStructs_g1.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/g1/vmStructs_g1.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -37,11 +37,14 @@
   static_field(HeapRegion, GrainBytes,        size_t)                         \
   static_field(HeapRegion, LogOfHRGrainBytes, int)                            \
                                                                               \
-  nonstatic_field(HeapRegion, _type,          HeapRegionType)                 \
+  nonstatic_field(HeapRegion, _type,           HeapRegionType)                \
+  nonstatic_field(HeapRegion, _bottom,         HeapWord*)                     \
+  nonstatic_field(HeapRegion, _top,            HeapWord* volatile)            \
+  nonstatic_field(HeapRegion, _end,            HeapWord*)                     \
+  nonstatic_field(HeapRegion, _compaction_top, HeapWord*)                     \
                                                                               \
   nonstatic_field(HeapRegionType, _tag,       HeapRegionType::Tag volatile)   \
                                                                               \
-  nonstatic_field(G1ContiguousSpace, _top,              HeapWord* volatile)   \
                                                                               \
   nonstatic_field(G1HeapRegionTable, _base,             address)              \
   nonstatic_field(G1HeapRegionTable, _length,           size_t)               \
@@ -94,8 +97,7 @@
                                                                               \
   declare_type(G1CollectedHeap, CollectedHeap)                                \
                                                                               \
-  declare_type(G1ContiguousSpace, CompactibleSpace)                           \
-  declare_type(HeapRegion, G1ContiguousSpace)                                 \
+  declare_toplevel_type(HeapRegion)                                           \
   declare_toplevel_type(HeapRegionManager)                                    \
   declare_toplevel_type(HeapRegionSetBase)                                    \
   declare_toplevel_type(G1MonitoringSupport)                                  \
--- a/src/hotspot/share/gc/parallel/asPSYoungGen.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/parallel/asPSYoungGen.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -30,7 +30,7 @@
 #include "gc/parallel/psYoungGen.hpp"
 #include "gc/shared/gcUtil.hpp"
 #include "gc/shared/genArguments.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/java.hpp"
 #include "utilities/align.hpp"
--- a/src/hotspot/share/gc/parallel/mutableSpace.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/parallel/mutableSpace.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -24,7 +24,7 @@
 
 #include "precompiled.hpp"
 #include "gc/parallel/mutableSpace.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "memory/iterator.inline.hpp"
 #include "memory/universe.hpp"
 #include "oops/oop.inline.hpp"
--- a/src/hotspot/share/gc/parallel/psMarkSweep.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/parallel/psMarkSweep.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -48,7 +48,7 @@
 #include "gc/shared/referencePolicy.hpp"
 #include "gc/shared/referenceProcessor.hpp"
 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "gc/shared/weakProcessor.hpp"
 #include "memory/universe.hpp"
 #include "logging/log.hpp"
--- a/src/hotspot/share/gc/parallel/psMarkSweepDecorator.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/parallel/psMarkSweepDecorator.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -31,7 +31,7 @@
 #include "gc/parallel/psMarkSweepDecorator.hpp"
 #include "gc/parallel/psParallelCompact.inline.hpp"
 #include "gc/serial/markSweep.inline.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "memory/iterator.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/prefetch.inline.hpp"
--- a/src/hotspot/share/gc/parallel/psOldGen.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/parallel/psOldGen.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -33,7 +33,7 @@
 #include "gc/parallel/psOldGen.hpp"
 #include "gc/shared/cardTableBarrierSet.hpp"
 #include "gc/shared/gcLocker.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "logging/log.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/java.hpp"
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -52,7 +52,7 @@
 #include "gc/shared/referencePolicy.hpp"
 #include "gc/shared/referenceProcessor.hpp"
 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "gc/shared/weakProcessor.hpp"
 #include "gc/shared/workerPolicy.hpp"
 #include "gc/shared/workgroup.hpp"
--- a/src/hotspot/share/gc/parallel/psScavenge.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/parallel/psScavenge.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -48,7 +48,7 @@
 #include "gc/shared/referenceProcessor.hpp"
 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
 #include "gc/shared/scavengableNMethods.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "gc/shared/weakProcessor.hpp"
 #include "gc/shared/workerPolicy.hpp"
 #include "gc/shared/workgroup.hpp"
--- a/src/hotspot/share/gc/parallel/psYoungGen.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/parallel/psYoungGen.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -30,7 +30,7 @@
 #include "gc/parallel/psYoungGen.hpp"
 #include "gc/shared/gcUtil.hpp"
 #include "gc/shared/genArguments.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "logging/log.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/java.hpp"
--- a/src/hotspot/share/gc/serial/defNewGeneration.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -43,7 +43,7 @@
 #include "gc/shared/referencePolicy.hpp"
 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
 #include "gc/shared/space.inline.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "gc/shared/strongRootsScope.hpp"
 #include "gc/shared/weakProcessor.hpp"
 #include "logging/log.hpp"
--- a/src/hotspot/share/gc/shared/generation.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/shared/generation.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -35,7 +35,7 @@
 #include "gc/shared/generation.hpp"
 #include "gc/shared/generationSpec.hpp"
 #include "gc/shared/space.inline.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "logging/log.hpp"
 #include "memory/allocation.inline.hpp"
 #include "oops/oop.inline.hpp"
--- a/src/hotspot/share/gc/shared/space.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/shared/space.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -31,7 +31,7 @@
 #include "gc/shared/genOopClosures.inline.hpp"
 #include "gc/shared/space.hpp"
 #include "gc/shared/space.inline.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "memory/iterator.inline.hpp"
 #include "memory/universe.hpp"
 #include "oops/oop.inline.hpp"
--- a/src/hotspot/share/gc/shared/spaceDecorator.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/shared/spaceDecorator.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -23,8 +23,9 @@
  */
 
 #include "precompiled.hpp"
+#include "gc/parallel/mutableSpace.hpp"
 #include "gc/shared/space.inline.hpp"
-#include "gc/shared/spaceDecorator.hpp"
+#include "gc/shared/spaceDecorator.inline.hpp"
 #include "logging/log.hpp"
 #include "utilities/copy.hpp"
 
--- a/src/hotspot/share/gc/shared/spaceDecorator.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/gc/shared/spaceDecorator.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -25,8 +25,8 @@
 #ifndef SHARE_GC_SHARED_SPACEDECORATOR_HPP
 #define SHARE_GC_SHARED_SPACEDECORATOR_HPP
 
-#include "gc/parallel/mutableSpace.hpp"
-#include "gc/shared/space.hpp"
+#include "memory/allocation.hpp"
+#include "memory/memRegion.hpp"
 #include "utilities/globalDefinitions.hpp"
 
 class SpaceDecorator: public AllStatic {
@@ -120,6 +120,7 @@
 };
 
 class ContiguousSpace;
+class MutableSpace;
 
 // For use with GenCollectedHeap's
 class GenSpaceMangler: public SpaceMangler {
@@ -127,8 +128,8 @@
 
   ContiguousSpace* sp() { return _sp; }
 
-  HeapWord* top() const { return _sp->top(); }
-  HeapWord* end() const { return _sp->end(); }
+  HeapWord* top() const;
+  HeapWord* end() const;
 
  public:
   GenSpaceMangler(ContiguousSpace* sp) : SpaceMangler(), _sp(sp) {}
@@ -140,8 +141,8 @@
 
   MutableSpace* sp() { return _sp; }
 
-  HeapWord* top() const { return _sp->top(); }
-  HeapWord* end() const { return _sp->end(); }
+  HeapWord* top() const;
+  HeapWord* end() const;
 
  public:
   MutableSpaceMangler(MutableSpace* sp) : SpaceMangler(), _sp(sp) {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/spaceDecorator.inline.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2019, 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_SPACEDECORATOR_INLINE_HPP
+#define SHARE_GC_SHARED_SPACEDECORATOR_INLINE_HPP
+
+#include "gc/parallel/mutableSpace.hpp"
+#include "gc/shared/space.hpp"
+#include "gc/shared/spaceDecorator.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+inline HeapWord* GenSpaceMangler::top() const { return _sp->top(); }
+inline HeapWord* GenSpaceMangler::end() const { return _sp->end(); }
+
+inline HeapWord* MutableSpaceMangler::top() const { return _sp->top(); }
+inline HeapWord* MutableSpaceMangler::end() const { return _sp->end(); }
+
+#endif // SHARE_GC_SHARED_SPACEDECORATOR_INLINE_HPP
--- a/src/hotspot/share/opto/compile.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/opto/compile.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -648,6 +648,7 @@
                   _has_reserved_stack_access(target->has_reserved_stack_access()),
 #ifndef PRODUCT
                   _trace_opto_output(directive->TraceOptoOutputOption),
+                  _print_ideal(directive->PrintIdealOption),
 #endif
                   _has_method_handle_invokes(false),
                   _clinit_barrier_on_entry(false),
@@ -873,7 +874,7 @@
   NOT_PRODUCT( verify_graph_edges(); )
 
 #ifndef PRODUCT
-  if (PrintIdeal) {
+  if (print_ideal()) {
     ttyLocker ttyl;  // keep the following output all in one block
     // This output goes directly to the tty, not the compiler log.
     // To enable tools to match it up with the compilation activity,
@@ -983,6 +984,7 @@
     _has_reserved_stack_access(false),
 #ifndef PRODUCT
     _trace_opto_output(directive->TraceOptoOutputOption),
+    _print_ideal(directive->PrintIdealOption),
 #endif
     _has_method_handle_invokes(false),
     _clinit_barrier_on_entry(false),
@@ -1653,6 +1655,7 @@
 }
 
 void Compile::AliasType::Init(int i, const TypePtr* at) {
+  assert(AliasIdxTop <= i && i < Compile::current()->_max_alias_types, "Invalid alias index");
   _index = i;
   _adr_type = at;
   _field = NULL;
--- a/src/hotspot/share/opto/compile.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/opto/compile.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -408,6 +408,7 @@
   bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
 #ifndef PRODUCT
   bool                  _trace_opto_output;
+  bool                  _print_ideal;
   bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
 #endif
   bool                  _has_irreducible_loop;  // Found irreducible loops
@@ -724,6 +725,7 @@
 
 #ifndef PRODUCT
   bool          trace_opto_output() const       { return _trace_opto_output; }
+  bool          print_ideal() const             { return _print_ideal; }
   bool              parsed_irreducible_loop() const { return _parsed_irreducible_loop; }
   void          set_parsed_irreducible_loop(bool z) { _parsed_irreducible_loop = z; }
   int _in_dump_cnt;  // Required for dumping ir nodes.
--- a/src/hotspot/share/opto/gcm.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/opto/gcm.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -510,6 +510,7 @@
   // do not need anti-dependence edges.
   int load_alias_idx = C->get_alias_index(load->adr_type());
 #ifdef ASSERT
+  assert(Compile::AliasIdxTop <= load_alias_idx && load_alias_idx < C->num_alias_types(), "Invalid alias index");
   if (load_alias_idx == Compile::AliasIdxBot && C->AliasLevel() > 0 &&
       (PrintOpto || VerifyAliases ||
        (PrintMiscellaneous && (WizardMode || Verbose)))) {
@@ -522,18 +523,6 @@
     if (VerifyAliases)  assert(load_alias_idx != Compile::AliasIdxBot, "");
   }
 #endif
-  assert(load_alias_idx || (load->is_Mach() && load->as_Mach()->ideal_Opcode() == Op_StrComp),
-         "String compare is only known 'load' that does not conflict with any stores");
-  assert(load_alias_idx || (load->is_Mach() && load->as_Mach()->ideal_Opcode() == Op_StrEquals),
-         "String equals is a 'load' that does not conflict with any stores");
-  assert(load_alias_idx || (load->is_Mach() && load->as_Mach()->ideal_Opcode() == Op_StrIndexOf),
-         "String indexOf is a 'load' that does not conflict with any stores");
-  assert(load_alias_idx || (load->is_Mach() && load->as_Mach()->ideal_Opcode() == Op_StrIndexOfChar),
-         "String indexOfChar is a 'load' that does not conflict with any stores");
-  assert(load_alias_idx || (load->is_Mach() && load->as_Mach()->ideal_Opcode() == Op_AryEq),
-         "Arrays equals is a 'load' that does not conflict with any stores");
-  assert(load_alias_idx || (load->is_Mach() && load->as_Mach()->ideal_Opcode() == Op_HasNegatives),
-         "HasNegatives is a 'load' that does not conflict with any stores");
 
   if (!C->alias_type(load_alias_idx)->is_rewritable()) {
     // It is impossible to spoil this load by putting stores before it,
--- a/src/hotspot/share/utilities/globalDefinitions.hpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/hotspot/share/utilities/globalDefinitions.hpp	Fri Nov 08 14:49:00 2019 +0000
@@ -1110,6 +1110,33 @@
 
 #undef JAVA_INTEGER_OP
 
+// Provide integer shift operations with Java semantics.  No overflow
+// issues - left shifts simply discard shifted out bits.  No undefined
+// behavior for large or negative shift quantities; instead the actual
+// shift distance is the argument modulo the lhs value's size in bits.
+// No undefined or implementation defined behavior for shifting negative
+// values; left shift discards bits, right shift sign extends.  We use
+// the same safe conversion technique as above for java_add and friends.
+#define JAVA_INTEGER_SHIFT_OP(OP, NAME, TYPE, XTYPE)    \
+inline TYPE NAME (TYPE lhs, jint rhs) {                 \
+  const uint rhs_mask = (sizeof(TYPE) * 8) - 1;         \
+  STATIC_ASSERT(rhs_mask == 31 || rhs_mask == 63);      \
+  XTYPE xres = static_cast<XTYPE>(lhs);                 \
+  xres OP ## = (rhs & rhs_mask);                        \
+  return reinterpret_cast<TYPE&>(xres);                 \
+}
+
+JAVA_INTEGER_SHIFT_OP(<<, java_shift_left, jint, juint)
+JAVA_INTEGER_SHIFT_OP(<<, java_shift_left, jlong, julong)
+// For signed shift right, assume C++ implementation >> sign extends.
+JAVA_INTEGER_SHIFT_OP(>>, java_shift_right, jint, jint)
+JAVA_INTEGER_SHIFT_OP(>>, java_shift_right, jlong, jlong)
+// For >>> use C++ unsigned >>.
+JAVA_INTEGER_SHIFT_OP(>>, java_shift_right_unsigned, jint, juint)
+JAVA_INTEGER_SHIFT_OP(>>, java_shift_right_unsigned, jlong, julong)
+
+#undef JAVA_INTEGER_SHIFT_OP
+
 //----------------------------------------------------------------------------------------------------
 // The goal of this code is to provide saturating operations for int/uint.
 // Checks overflow conditions and saturates the result to min_jint/max_jint.
--- a/src/java.base/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/java.base/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java	Fri Nov 08 14:49:00 2019 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, 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
@@ -33,6 +33,7 @@
 import java.text.spi.NumberFormatProvider;
 import java.util.Collections;
 import java.util.Calendar;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.Map;
@@ -550,15 +551,33 @@
             }
 
             @Override
-            public String getDisplayName(String calType, int field, int value,
-                                         int style, Locale locale) {
-                return null;
+            public String getDisplayName(String calendarType, int field,
+                                         int value, int style, Locale locale) {
+                String[] names = getCalendarDisplayStrings(locale.toLanguageTag(),
+                        field, style);
+                if (names != null && value >= 0 && value < names.length) {
+                    return names[value];
+                } else {
+                    return null;
+                }
             }
 
             @Override
-            public Map<String, Integer> getDisplayNames(String calType,
-                                         int field, int style, Locale locale) {
-                return null;
+            public Map<String, Integer> getDisplayNames(String calendarType,
+                                                        int field, int style, Locale locale) {
+                Map<String, Integer> map = null;
+                String[] names = getCalendarDisplayStrings(locale.toLanguageTag(),
+                        field, style);
+                if (names != null) {
+                    map = new HashMap<>((int)Math.ceil(names.length / 0.75));
+                    for (int value = 0; value < names.length; value++) {
+                        if (names[value] != null) {
+                            map.put(names[value], value);
+                        }
+                    }
+                    map = map.isEmpty() ? null : map;
+                }
+                return map;
             }
         };
     }
@@ -901,6 +920,9 @@
     // For CalendarDataProvider
     private static native int getCalendarInt(String langTag, int type);
 
+    // For CalendarNameProvider
+    private static native String[] getCalendarDisplayStrings(String langTag, int field, int style);
+
     // For Locale/CurrencyNameProvider
     private static native String getDisplayString(String langTag, int key, String value);
 
--- a/src/java.base/macosx/native/libjava/HostLocaleProviderAdapter_md.c	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/java.base/macosx/native/libjava/HostLocaleProviderAdapter_md.c	Fri Nov 08 14:49:00 2019 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, 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
@@ -30,11 +30,20 @@
 
 #define BUFLEN 256
 
+// java.util.Calendar constants
+#define CALENDAR_FIELD_ERA              0           // Calendar.ERA
+#define CALENDAR_FIELD_DAY_OF_WEEK      7           // Calendar.DAY_OF_WEEK
+#define CALENDAR_FIELD_AM_PM            9           // Calendar.AM_PM
+#define JAPANESE_MEIJI_INDEX            232
+
 static CFDateFormatterStyle convertDateFormatterStyle(jint javaStyle);
 static CFNumberFormatterStyle convertNumberFormatterStyle(jint javaStyle);
 static void copyArrayElements(JNIEnv *env, CFArrayRef cfarray, jobjectArray jarray, CFIndex sindex, int dindex, int count);
 static jstring getNumberSymbolString(JNIEnv *env, jstring jlangtag, jstring jdefault, CFStringRef type);
 static jchar getNumberSymbolChar(JNIEnv *env, jstring jlangtag, jchar jdefault, CFStringRef type);
+jobjectArray getErasImpl(JNIEnv *env, jstring jlangtag, jint style, jobjectArray eras);
+jobjectArray getWeekdaysImpl(JNIEnv *env, jclass cls, jstring jlangtag, jint style, jobjectArray wdays);
+jobjectArray getAmPmImpl(JNIEnv *env, jclass cls, jstring jlangtag, jint style, jobjectArray ampms);
 
 // from java_props_macosx.c
 extern char * getMacOSXLocale(int cat);
@@ -131,41 +140,7 @@
  */
 JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getAmPmStrings
   (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) {
-    CFLocaleRef cflocale = CFLocaleCopyCurrent();
-    jstring tmp_string;
-    if (cflocale != NULL) {
-        CFDateFormatterRef df = CFDateFormatterCreate(kCFAllocatorDefault,
-                                                  cflocale,
-                                                  kCFDateFormatterFullStyle,
-                                                  kCFDateFormatterFullStyle);
-        if (df != NULL) {
-            char buf[BUFLEN];
-            CFStringRef amStr = CFDateFormatterCopyProperty(df, kCFDateFormatterAMSymbol);
-            if (amStr != NULL) {
-                CFStringGetCString(amStr, buf, BUFLEN, kCFStringEncodingUTF8);
-                CFRelease(amStr);
-                tmp_string = (*env)->NewStringUTF(env, buf);
-                if (tmp_string != NULL) {
-                    (*env)->SetObjectArrayElement(env, ampms, 0, tmp_string);
-                }
-            }
-            if (!(*env)->ExceptionCheck(env)){
-                CFStringRef pmStr = CFDateFormatterCopyProperty(df, kCFDateFormatterPMSymbol);
-                if (pmStr != NULL) {
-                    CFStringGetCString(pmStr, buf, BUFLEN, kCFStringEncodingUTF8);
-                    CFRelease(pmStr);
-                    tmp_string = (*env)->NewStringUTF(env, buf);
-                    if (tmp_string != NULL) {
-                        (*env)->SetObjectArrayElement(env, ampms, 1, tmp_string);
-                    }
-                }
-            }
-            CFRelease(df);
-        }
-        CFRelease(cflocale);
-    }
-
-    return ampms;
+      return getAmPmImpl(env, cls, jlangtag, 0, ampms);
 }
 
 /*
@@ -175,24 +150,7 @@
  */
 JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getEras
   (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray eras) {
-    CFLocaleRef cflocale = CFLocaleCopyCurrent();
-    if (cflocale != NULL) {
-        CFDateFormatterRef df = CFDateFormatterCreate(kCFAllocatorDefault,
-                                                  cflocale,
-                                                  kCFDateFormatterFullStyle,
-                                                  kCFDateFormatterFullStyle);
-        if (df != NULL) {
-            CFArrayRef cferas = CFDateFormatterCopyProperty(df, kCFDateFormatterEraSymbols);
-            if (cferas != NULL) {
-                copyArrayElements(env, cferas, eras, 0, 0, CFArrayGetCount(cferas));
-                CFRelease(cferas);
-            }
-            CFRelease(df);
-        }
-        CFRelease(cflocale);
-    }
-
-    return eras;
+    return getErasImpl(env, jlangtag, 0, eras);
 }
 
 /*
@@ -255,25 +213,8 @@
  * Signature: (Ljava/lang/String;[Ljava/lang/String;)[Ljava/lang/String;
  */
 JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getWeekdays
-  (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray wdays) {
-    CFLocaleRef cflocale = CFLocaleCopyCurrent();
-    if (cflocale != NULL) {
-        CFDateFormatterRef df = CFDateFormatterCreate(kCFAllocatorDefault,
-                                                  cflocale,
-                                                  kCFDateFormatterFullStyle,
-                                                  kCFDateFormatterFullStyle);
-        if (df != NULL) {
-            CFArrayRef cfwdays = CFDateFormatterCopyProperty(df, kCFDateFormatterWeekdaySymbols);
-            if (cfwdays != NULL) {
-                copyArrayElements(env, cfwdays, wdays, 0, 1, CFArrayGetCount(cfwdays));
-                CFRelease(cfwdays);
-            }
-            CFRelease(df);
-        }
-        CFRelease(cflocale);
-    }
-
-    return wdays;
+    (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray wdays) {
+    return getWeekdaysImpl(env, cls, jlangtag, 0, wdays);
 }
 
 /*
@@ -508,6 +449,29 @@
 
 /*
  * Class:     sun_util_locale_provider_HostLocaleProviderAdapterImpl
+ * Method:    getCalendarDisplayStrings
+ * Signature: (Ljava/lang/String;III)[Ljava/lang/String;
+ */
+JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarDisplayStrings
+  (JNIEnv *env, jclass cls, jstring jlangtag, jint field, jint style) {
+    switch (field) {
+    case CALENDAR_FIELD_ERA:
+        return getErasImpl(env, jlangtag, style, NULL);
+
+    case CALENDAR_FIELD_DAY_OF_WEEK:
+        return getWeekdaysImpl(env, cls, jlangtag, style, NULL);
+
+    case CALENDAR_FIELD_AM_PM:
+        return getAmPmImpl(env, cls, jlangtag, style, NULL);
+
+    default:
+        // not supported
+        return NULL;
+    }
+}
+
+/*
+ * Class:     sun_util_locale_provider_HostLocaleProviderAdapterImpl
  * Method:    getDisplayString
  * Signature: (Ljava/lang/String;ILjava/lang/String;)Ljava/lang/String;
  */
@@ -725,3 +689,104 @@
 
     return ret;
 }
+
+jobjectArray getErasImpl(JNIEnv *env, jstring jlangtag, jint style, jobjectArray eras) {
+    jobjectArray ret = eras;
+    CFLocaleRef cflocale = CFLocaleCopyCurrent();
+    if (cflocale != NULL) {
+        CFDateFormatterRef df = CFDateFormatterCreate(kCFAllocatorDefault,
+                                                  cflocale,
+                                                  convertDateFormatterStyle(style),
+                                                  convertDateFormatterStyle(style));
+        if (df != NULL) {
+            CFArrayRef cferas = CFDateFormatterCopyProperty(df, kCFDateFormatterEraSymbols);
+            if (cferas != NULL) {
+                int eraCount = CFArrayGetCount(cferas);
+
+                if (eras == NULL) {
+                    ret = (*env)->NewObjectArray(env, (jsize)eraCount,
+                        (*env)->FindClass(env, "java/lang/String"), NULL);
+                }
+                CFTypeRef cal = CFLocaleGetValue(cflocale, kCFLocaleCalendarIdentifier);
+                int sindex = cal == kCFJapaneseCalendar ? JAPANESE_MEIJI_INDEX : 0;
+                int dindex = cal == kCFJapaneseCalendar ? 1 : 0; // 0 is "BeforeMeiji" in JCal
+                copyArrayElements(env, cferas, ret, sindex, dindex, eraCount - sindex);
+                CFRelease(cferas);
+            }
+            CFRelease(df);
+        }
+        CFRelease(cflocale);
+    }
+
+    return ret;
+}
+
+jobjectArray getWeekdaysImpl(JNIEnv *env, jclass cls, jstring jlangtag, jint style, jobjectArray wdays) {
+    jobjectArray ret = wdays;
+    CFLocaleRef cflocale = CFLocaleCopyCurrent();
+    if (cflocale != NULL) {
+        CFDateFormatterRef df = CFDateFormatterCreate(kCFAllocatorDefault,
+                                                  cflocale,
+                                                  convertDateFormatterStyle(style),
+                                                  convertDateFormatterStyle(style));
+        if (df != NULL) {
+            CFArrayRef cfwdays = CFDateFormatterCopyProperty(df, kCFDateFormatterWeekdaySymbols);
+            if (cfwdays != NULL) {
+                int dayCount = CFArrayGetCount(cfwdays);
+
+                if (wdays == NULL) {
+                    ret = (*env)->NewObjectArray(env, dayCount + 1,
+                        (*env)->FindClass(env, "java/lang/String"), NULL);
+                }
+                copyArrayElements(env, cfwdays, ret, 0, 1, dayCount);
+                CFRelease(cfwdays);
+            }
+            CFRelease(df);
+        }
+        CFRelease(cflocale);
+    }
+
+    return ret;
+}
+
+jobjectArray getAmPmImpl(JNIEnv *env, jclass cls, jstring jlangtag, jint style, jobjectArray ampms) {
+    CFLocaleRef cflocale = CFLocaleCopyCurrent();
+    jstring tmp_string;
+    if (cflocale != NULL) {
+        CFDateFormatterRef df = CFDateFormatterCreate(kCFAllocatorDefault,
+                                                  cflocale,
+                                                  convertDateFormatterStyle(style),
+                                                  convertDateFormatterStyle(style));
+        if (df != NULL) {
+            char buf[BUFLEN];
+            if (ampms == NULL) {
+                ampms = (*env)->NewObjectArray(env, 2,
+                    (*env)->FindClass(env, "java/lang/String"), NULL);
+            }
+            CFStringRef amStr = CFDateFormatterCopyProperty(df, kCFDateFormatterAMSymbol);
+            if (amStr != NULL) {
+                CFStringGetCString(amStr, buf, BUFLEN, kCFStringEncodingUTF8);
+                CFRelease(amStr);
+                tmp_string = (*env)->NewStringUTF(env, buf);
+                if (tmp_string != NULL) {
+                    (*env)->SetObjectArrayElement(env, ampms, 0, tmp_string);
+                }
+            }
+            if (!(*env)->ExceptionCheck(env)){
+                CFStringRef pmStr = CFDateFormatterCopyProperty(df, kCFDateFormatterPMSymbol);
+                if (pmStr != NULL) {
+                    CFStringGetCString(pmStr, buf, BUFLEN, kCFStringEncodingUTF8);
+                    CFRelease(pmStr);
+                    tmp_string = (*env)->NewStringUTF(env, buf);
+                    if (tmp_string != NULL) {
+                        (*env)->SetObjectArrayElement(env, ampms, 1, tmp_string);
+                    }
+                }
+            }
+            CFRelease(df);
+        }
+        CFRelease(cflocale);
+    }
+
+    return ampms;
+}
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/G1CollectedHeap.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/G1CollectedHeap.java	Fri Nov 08 14:49:00 2019 +0000
@@ -30,11 +30,11 @@
 import java.util.Observer;
 
 import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.gc.g1.HeapRegionClosure;
+import sun.jvm.hotspot.gc.g1.PrintRegionClosure;
 import sun.jvm.hotspot.gc.shared.CollectedHeap;
 import sun.jvm.hotspot.gc.shared.CollectedHeapName;
 import sun.jvm.hotspot.gc.shared.LiveRegionsClosure;
-import sun.jvm.hotspot.gc.shared.PrintRegionClosure;
-import sun.jvm.hotspot.gc.shared.SpaceClosure;
 import sun.jvm.hotspot.memory.MemRegion;
 import sun.jvm.hotspot.runtime.VM;
 import sun.jvm.hotspot.runtime.VMObjectFactory;
@@ -126,11 +126,11 @@
         return hrm().heapRegionIterator();
     }
 
-    public void heapRegionIterate(SpaceClosure scl) {
+    public void heapRegionIterate(HeapRegionClosure hrcl) {
         Iterator<HeapRegion> iter = heapRegionIterator();
         while (iter.hasNext()) {
             HeapRegion hr = iter.next();
-            scl.doSpace(hr);
+            hrcl.doHeapRegion(hr);
         }
     }
 
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/HeapRegion.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/HeapRegion.java	Fri Nov 08 14:49:00 2019 +0000
@@ -45,9 +45,12 @@
 // any of its fields but only iterate over it.
 
 public class HeapRegion extends CompactibleSpace implements LiveRegionsProvider {
-    // static int GrainBytes;
+    private static AddressField bottomField;
+    static private AddressField topField;
+    private static AddressField endField;
+    private static AddressField compactionTopField;
+
     static private CIntegerField grainBytesField;
-    static private AddressField topField;
     private static long typeFieldOffset;
     private static long pointerSize;
 
@@ -64,8 +67,12 @@
     static private synchronized void initialize(TypeDataBase db) {
         Type type = db.lookupType("HeapRegion");
 
+        bottomField = type.getAddressField("_bottom");
+        topField = type.getAddressField("_top");
+        endField = type.getAddressField("_end");
+        compactionTopField = type.getAddressField("_compaction_top");
+
         grainBytesField = type.getCIntegerField("GrainBytes");
-        topField = type.getAddressField("_top");
         typeFieldOffset = type.getField("_type").getOffset();
 
         pointerSize = db.lookupType("HeapRegion*").getSize();
@@ -82,9 +89,11 @@
         type = (HeapRegionType)VMObjectFactory.newObject(HeapRegionType.class, typeAddr);
     }
 
-    public Address top() {
-        return topField.getValue(addr);
-    }
+    public Address bottom()        { return bottomField.getValue(addr); }
+    public Address top()           { return topField.getValue(addr); }
+    public Address end()           { return endField.getValue(addr); }
+
+    public Address compactionTop() { return compactionTopField.getValue(addr); }
 
     @Override
     public List<MemRegion> getLiveRegions() {
@@ -93,12 +102,16 @@
         return res;
     }
 
-    @Override
+    /** Returns a subregion of the space containing all the objects in
+        the space. */
+    public MemRegion usedRegion() {
+        return new MemRegion(bottom(), end());
+    }
+
     public long used() {
         return top().minus(bottom());
     }
 
-    @Override
     public long free() {
         return end().minus(top());
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/HeapRegionClosure.java	Fri Nov 08 14:49:00 2019 +0000
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2019, 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.g1;
+
+public interface HeapRegionClosure {
+    public void doHeapRegion(HeapRegion hr);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/PrintRegionClosure.java	Fri Nov 08 14:49:00 2019 +0000
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018, 2019, 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.g1;
+
+import java.io.PrintStream;
+import sun.jvm.hotspot.gc.g1.HeapRegion;
+
+public class PrintRegionClosure implements HeapRegionClosure {
+    private PrintStream tty;
+
+    public PrintRegionClosure(PrintStream tty) {
+        this.tty = tty;
+    }
+
+    public void doHeapRegion(HeapRegion hr) {
+        hr.printOn(tty);
+    }
+}
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/PrintRegionClosure.java	Thu Nov 07 18:46:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * 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.io.PrintStream;
-import sun.jvm.hotspot.gc.g1.HeapRegion;
-
-public class PrintRegionClosure implements SpaceClosure {
-  private PrintStream tty;
-
-  public PrintRegionClosure(PrintStream tty) {
-    this.tty = tty;
-  }
-
-  public void doSpace(Space hr) {
-    ((HeapRegion)hr).printOn(tty);
-  }
-}
--- a/test/hotspot/gtest/gc/g1/test_g1HeapVerifier.cpp	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/hotspot/gtest/gc/g1/test_g1HeapVerifier.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -26,6 +26,7 @@
 #include "gc/g1/g1Arguments.hpp"
 #include "gc/g1/g1HeapVerifier.hpp"
 #include "logging/logConfiguration.hpp"
+#include "logging/logTag.hpp"
 #include "logging/logTestFixture.hpp"
 #include "unittest.hpp"
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/gtest/utilities/test_java_arithmetic.cpp	Fri Nov 08 14:49:00 2019 +0000
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "memory/allocation.hpp"
+#include "utilities/globalDefinitions.hpp"
+#include "unittest.hpp"
+
+class TestJavaArithSupport : public AllStatic {
+public:
+  template<typename T> struct BinOpData { T x; T y; T r; };
+  template<typename T> struct ShiftOpData { T x; jint shift; T r; };
+};
+
+typedef TestJavaArithSupport::BinOpData<jint> BinOpJintData;
+typedef TestJavaArithSupport::BinOpData<jlong> BinOpJlongData;
+
+typedef TestJavaArithSupport::ShiftOpData<jint> ShiftOpJintData;
+typedef TestJavaArithSupport::ShiftOpData<jlong> ShiftOpJlongData;
+
+const BinOpJintData add_jint_data[] = {
+  { 0, 0, 0 },
+  { 0, 1, 1 },
+  { 0, -1, -1 },
+  { max_jint, 1, min_jint },
+  { max_jint, -1, max_jint - 1 },
+  { min_jint, 1, min_jint + 1 },
+  { min_jint, -1, max_jint },
+  { max_jint, 10, min_jint + 9 },
+  { max_jint, -10, max_jint - 10 },
+  { min_jint, 10, min_jint + 10 },
+  { min_jint, -10, max_jint - 9 },
+  { max_jint, max_jint, -2 },
+  { min_jint, min_jint, 0 }
+};
+
+const BinOpJlongData add_jlong_data[] = {
+  { 0, 0, 0 },
+  { 0, 1, 1 },
+  { 0, -1, -1 },
+  { max_jlong, 1, min_jlong },
+  { max_jlong, -1, max_jlong - 1 },
+  { min_jlong, 1, min_jlong + 1 },
+  { min_jlong, -1, max_jlong },
+  { max_jlong, 10, min_jlong + 9 },
+  { max_jlong, -10, max_jlong - 10 },
+  { min_jlong, 10, min_jlong + 10 },
+  { min_jlong, -10, max_jlong - 9 },
+  { max_jlong, max_jlong, -2 },
+  { min_jlong, min_jlong, 0 }
+};
+
+TEST(TestJavaArithmetic, add_sub_jint) {
+  const volatile BinOpJintData* data = add_jint_data;
+  for (size_t i = 0; i < ARRAY_SIZE(add_jint_data); ++i) {
+    ASSERT_EQ(data[i].r, java_add(data[i].x, data[i].y));
+    ASSERT_EQ(data[i].r, java_add(data[i].y, data[i].x));
+    ASSERT_EQ(data[i].x, java_subtract(data[i].r, data[i].y));
+    ASSERT_EQ(data[i].y, java_subtract(data[i].r, data[i].x));
+  }
+}
+
+TEST(TestJavaArithmetic, add_sub_jlong) {
+  const volatile BinOpJlongData* data = add_jlong_data;
+  for (size_t i = 0; i < ARRAY_SIZE(add_jlong_data); ++i) {
+    ASSERT_EQ(data[i].r, java_add(data[i].x, data[i].y));
+    ASSERT_EQ(data[i].r, java_add(data[i].y, data[i].x));
+    ASSERT_EQ(data[i].x, java_subtract(data[i].r, data[i].y));
+    ASSERT_EQ(data[i].y, java_subtract(data[i].r, data[i].x));
+  }
+}
+
+static const BinOpJintData mul_jint_data[] = {
+  { 0, 0, 0 },
+  { 0, 1, 0 },
+  { 0, max_jint, 0 },
+  { 0, min_jint, 0 },
+  { 1, 1, 1 },
+  { 1, max_jint, max_jint },
+  { 1, min_jint, min_jint },
+  { -1, 1, -1 },
+  { -1, max_jint, min_jint + 1 },
+  { 5, max_jint, max_jint - 4 },
+  { -5, max_jint, min_jint + 5 },
+  { max_jint, max_jint, 1 },
+  { max_jint, min_jint, min_jint },
+  { min_jint, min_jint, 0 }
+};
+
+static const BinOpJlongData mul_jlong_data[] = {
+  { 0, 0, 0 },
+  { 0, 1, 0 },
+  { 0, max_jlong, 0 },
+  { 0, min_jlong, 0 },
+  { 1, 1, 1 },
+  { 1, max_jlong, max_jlong },
+  { 1, min_jlong, min_jlong },
+  { -1, 1, -1 },
+  { -1, max_jlong, min_jlong + 1 },
+  { 5, max_jlong, max_jlong - 4 },
+  { -5, max_jlong, min_jlong + 5 },
+  { max_jlong, max_jlong, 1 },
+  { max_jlong, min_jlong, min_jlong },
+  { min_jlong, min_jlong, 0 }
+};
+
+TEST(TestJavaArithmetic, mul_jint) {
+  const volatile BinOpJintData* data = mul_jint_data;
+  for (size_t i = 0; i < ARRAY_SIZE(mul_jint_data); ++i) {
+    ASSERT_EQ(data[i].r, java_multiply(data[i].x, data[i].y));
+    ASSERT_EQ(data[i].r, java_multiply(data[i].y, data[i].x));
+  }
+}
+
+TEST(TestJavaArithmetic, mul_jlong) {
+  const volatile BinOpJlongData* data = mul_jlong_data;
+  for (size_t i = 0; i < ARRAY_SIZE(mul_jlong_data); ++i) {
+    ASSERT_EQ(data[i].r, java_multiply(data[i].x, data[i].y));
+    ASSERT_EQ(data[i].r, java_multiply(data[i].y, data[i].x));
+  }
+}
+
+static const ShiftOpJintData asl_jint_data[] = {
+  { 0, 0, 0 },
+  { 0, 10, 0 },
+  { 0, 50, 0 },
+  { 1, 0, 1 },
+  { 1, 10, (jint)1 << 10 },
+  { 1, 50, (jint)1 << 18 },
+  { 5, 0, 5 },
+  { 5, 10, (jint)5 << 10 },
+  { 5, 50, (jint)5 << 18 },
+  { -1, 0, -1 },
+  { -1, 10, (jint)-1 * (1 << 10) },
+  { -1, 50, (jint)-1 * (1 << 18) },
+  { -5, 0, -5 },
+  { -5, 10, (jint)-5 * (1 << 10) },
+  { -5, 50, (jint)-5 * (1 << 18) },
+  { max_jint, 0, max_jint },
+  { max_jint, 10, (jint)0xFFFFFC00 },
+  { max_jint, 50, (jint)0xFFFC0000 },
+  { min_jint, 0, min_jint },
+  { min_jint, 10, 0 },
+  { min_jint, 50, 0 }
+};
+
+static const ShiftOpJlongData asl_jlong_data[] = {
+  { 0, 0, 0 },
+  { 0, 10, 0 },
+  { 0, 82, 0 },
+  { 1, 0, 1 },
+  { 1, 10, (jlong)1 << 10 },
+  { 1, 82, (jlong)1 << 18 },
+  { 5, 0, 5 },
+  { 5, 10, (jlong)5 << 10 },
+  { 5, 82, (jlong)5 << 18 },
+  { -1, 0, -1 },
+  { -1, 10, (jlong)-1 * (1 << 10) },
+  { -1, 82, (jlong)-1 * (1 << 18) },
+  { -5, 0, -5 },
+  { -5, 10, (jlong)-5 * (1 << 10) },
+  { -5, 82, (jlong)-5 * (1 << 18) },
+  { max_jlong, 0, max_jlong },
+  { max_jlong, 10, (jlong)0xFFFFFFFFFFFFFC00 },
+  { max_jlong, 82, (jlong)0xFFFFFFFFFFFC0000 },
+  { min_jlong, 0, min_jlong },
+  { min_jlong, 10, 0 },
+  { min_jlong, 82, 0 }
+};
+
+TEST(TestJavaArithmetic, shift_left_jint) {
+  const volatile ShiftOpJintData* data = asl_jint_data;
+  for (size_t i = 0; i < ARRAY_SIZE(asl_jint_data); ++i) {
+    ASSERT_EQ(data[i].r, java_shift_left(data[i].x, data[i].shift));
+  }
+}
+
+TEST(TestJavaArithmetic, shift_left_jlong) {
+  const volatile ShiftOpJlongData* data = asl_jlong_data;
+  for (size_t i = 0; i < ARRAY_SIZE(asl_jlong_data); ++i) {
+    ASSERT_EQ(data[i].r, java_shift_left(data[i].x, data[i].shift));
+  }
+}
+
+static const ShiftOpJintData asr_jint_data[] = {
+  { 0, 0, 0 },
+  { 0, 10, 0 },
+  { 0, 50, 0 },
+  { 1, 0, 1 },
+  { 1, 10, 0 },
+  { 1, 50, 0 },
+  { 5, 0, 5 },
+  { 5, 1, 2 },
+  { 5, 10, 0 },
+  { 5, 33, 2 },
+  { 5, 50, 0 },
+  { -1, 0, -1 },
+  { -1, 10, -1 },
+  { -1, 50, -1 },
+  { -5, 0, -5 },
+  { -5, 1, -3 },
+  { -5, 10, -1 },
+  { -5, 33, -3 },
+  { -5, 50, -1 },
+  { max_jint, 0, max_jint },
+  { max_jint, 10, (jint)0x001FFFFF },
+  { max_jint, 50, (jint)0x00001FFF },
+  { min_jint, 0, min_jint },
+  { min_jint, 10, (jint)0xFFE00000 },
+  { min_jint, 50, (jint)0xFFFFE000 }
+};
+
+static const ShiftOpJlongData asr_jlong_data[] = {
+  { 0, 0, 0 },
+  { 0, 10, 0 },
+  { 0, 82, 0 },
+  { 1, 0, 1 },
+  { 1, 10, 0 },
+  { 1, 82, 0 },
+  { 5, 0, 5 },
+  { 5, 1, 2 },
+  { 5, 10, 0 },
+  { 5, 65, 2 },
+  { 5, 82, 0 },
+  { -1, 0, -1 },
+  { -1, 10, -1 },
+  { -1, 82, -1 },
+  { -5, 0, -5 },
+  { -5, 1, -3 },
+  { -5, 10, -1 },
+  { -5, 65, -3 },
+  { -5, 82, -1 },
+  { max_jlong, 0, max_jlong },
+  { max_jlong, 10, (jlong)0x001FFFFFFFFFFFFF },
+  { max_jlong, 82, (jlong)0x00001FFFFFFFFFFF },
+  { min_jlong, 0, min_jlong },
+  { min_jlong, 10, (jlong)0xFFE0000000000000 },
+  { min_jlong, 82, (jlong)0xFFFFE00000000000 }
+};
+
+TEST(TestJavaArithmetic, shift_right_jint) {
+  const volatile ShiftOpJintData* data = asr_jint_data;
+  for (size_t i = 0; i < ARRAY_SIZE(asr_jint_data); ++i) {
+    ASSERT_EQ(data[i].r, java_shift_right(data[i].x, data[i].shift));
+  }
+}
+
+TEST(TestJavaArithmetic, shift_right_jlong) {
+  const volatile ShiftOpJlongData* data = asr_jlong_data;
+  for (size_t i = 0; i < ARRAY_SIZE(asr_jlong_data); ++i) {
+    ASSERT_EQ(data[i].r, java_shift_right(data[i].x, data[i].shift));
+  }
+}
+
+static const ShiftOpJintData lsr_jint_data[] = {
+  { 0, 0, 0 },
+  { 0, 10, 0 },
+  { 0, 50, 0 },
+  { 1, 0, 1 },
+  { 1, 10, 0 },
+  { 1, 50, 0 },
+  { 5, 0, 5 },
+  { 5, 1, 2 },
+  { 5, 10, 0 },
+  { 5, 33, 2 },
+  { 5, 50, 0 },
+  { -1, 0, -1 },
+  { -1, 10, (jint)0x003FFFFF },
+  { -1, 50, (jint)0x00003FFF },
+  { -5, 0, -5 },
+  { -5, 1, (jint)0x7FFFFFFD },
+  { -5, 10, (jint)0x003FFFFF },
+  { -5, 50, (jint)0x00003FFF },
+  { max_jint, 0, max_jint },
+  { max_jint, 1, (jint)0x3FFFFFFF },
+  { max_jint, 10, (jint)0x001FFFFF },
+  { max_jint, 50, (jint)0x00001FFF },
+  { min_jint, 0, min_jint },
+  { min_jint, 1, (jint)0x40000000 },
+  { min_jint, 10, (jint)0x00200000 },
+  { min_jint, 50, (jint)0x00002000 }
+};
+
+static const ShiftOpJlongData lsr_jlong_data[] = {
+  { 0, 0, 0 },
+  { 0, 10, 0 },
+  { 0, 82, 0 },
+  { 1, 0, 1 },
+  { 1, 10, 0 },
+  { 1, 82, 0 },
+  { 5, 0, 5 },
+  { 5, 1, 2 },
+  { 5, 10, 0 },
+  { 5, 65, 2 },
+  { 5, 82, 0 },
+  { -1, 0, -1 },
+  { -1, 10, (jlong)0x003FFFFFFFFFFFFF },
+  { -1, 82, (jlong)0x00003FFFFFFFFFFF },
+  { -5, 0, -5 },
+  { -5, 1, (jlong)0x7FFFFFFFFFFFFFFD },
+  { -5, 10, (jlong)0x003FFFFFFFFFFFFF },
+  { -5, 82, (jlong)0x00003FFFFFFFFFFF },
+  { max_jlong, 0, max_jlong },
+  { max_jlong, 1, (jlong)0x3FFFFFFFFFFFFFFF },
+  { max_jlong, 10, (jlong)0x001FFFFFFFFFFFFF },
+  { max_jlong, 82, (jlong)0x00001FFFFFFFFFFF },
+  { min_jlong, 0, min_jlong },
+  { min_jlong, 1, (jlong)0x4000000000000000 },
+  { min_jlong, 10, (jlong)0x0020000000000000 },
+  { min_jlong, 82, (jlong)0x0000200000000000 }
+};
+
+TEST(TestJavaArithmetic, shift_right_unsigned_jint) {
+  const volatile ShiftOpJintData* data = lsr_jint_data;
+  for (size_t i = 0; i < ARRAY_SIZE(lsr_jint_data); ++i) {
+    ASSERT_EQ(data[i].r, java_shift_right_unsigned(data[i].x, data[i].shift));
+  }
+}
+
+TEST(TestJavaArithmetic, shift_right_unsigned_jlong) {
+  const volatile ShiftOpJlongData* data = lsr_jlong_data;
+  for (size_t i = 0; i < ARRAY_SIZE(lsr_jlong_data); ++i) {
+    ASSERT_EQ(data[i].r, java_shift_right_unsigned(data[i].x, data[i].shift));
+  }
+}
--- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java	Fri Nov 08 14:49:00 2019 +0000
@@ -20,6 +20,22 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
+/*
+ * @test
+ * @requires vm.jvmci
+ * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot
+ *          jdk.internal.vm.ci/jdk.vm.ci.runtime
+ *          jdk.internal.vm.ci/jdk.vm.ci.meta
+ *          jdk.internal.vm.ci/jdk.vm.ci.code
+ *          jdk.internal.vm.ci/jdk.vm.ci.common
+ * @library /compiler/jvmci/jdk.vm.ci.hotspot.test/src
+ *          /compiler/jvmci/jdk.vm.ci.code.test/src
+ * @run testng/othervm
+ *      -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler
+ *      jdk.vm.ci.hotspot.test.TestHotSpotJVMCIRuntime
+ */
+
 package jdk.vm.ci.hotspot.test;
 
 import java.util.ArrayList;
@@ -27,8 +43,8 @@
 import java.util.List;
 import java.util.function.Predicate;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
 import jdk.vm.ci.meta.MetaAccessProvider;
@@ -74,7 +90,7 @@
             if (expect instanceof Integer) {
                 Assert.fail("expected " + expect + ", got " + e + " for bytes == " + Arrays.toString(bytes));
             } else {
-                Assert.assertTrue(e.toString(), ((Class<?>) expect).isInstance(e));
+                Assert.assertTrue(((Class<?>) expect).isInstance(e), e.toString());
             }
         }
     }
@@ -98,20 +114,12 @@
             // Extension classes not available
         }
         ClassLoader jvmciLoader = HotSpotJVMCIRuntime.class.getClassLoader();
-        ClassLoader extLoader = getExtensionLoader();
+        ClassLoader platformLoader = ClassLoader.getPlatformClassLoader();
         for (Class<?> c : classes) {
             ClassLoader cl = c.getClassLoader();
-            boolean expected = cl == null || cl == jvmciLoader || cl == extLoader;
+            boolean expected = cl == null || cl == jvmciLoader || cl == platformLoader;
             boolean actual = predicate.test(metaAccess.lookupJavaType(c));
-            Assert.assertEquals(c + ": cl=" + cl, expected, actual);
+            Assert.assertEquals(expected, actual, c + ": cl=" + cl);
         }
     }
-
-    private static ClassLoader getExtensionLoader() throws Exception {
-        Object launcher = Class.forName("sun.misc.Launcher").getMethod("getLauncher").invoke(null);
-        ClassLoader appLoader = (ClassLoader) launcher.getClass().getMethod("getClassLoader").invoke(launcher);
-        ClassLoader extLoader = appLoader.getParent();
-        assert extLoader.getClass().getName().equals("sun.misc.Launcher$ExtClassLoader") : extLoader;
-        return extLoader;
-    }
 }
--- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotSpeculationLog.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotSpeculationLog.java	Fri Nov 08 14:49:00 2019 +0000
@@ -20,13 +20,25 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
+/*
+ * @test
+ * @requires vm.jvmci
+ * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot
+ *          jdk.internal.vm.ci/jdk.vm.ci.meta
+ * @library /compiler/jvmci/jdk.vm.ci.hotspot.test/src
+ * @run testng/othervm
+ *      -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler
+ *      jdk.vm.ci.hotspot.test.TestHotSpotSpeculationLog
+ */
+
 package jdk.vm.ci.hotspot.test;
 
 import java.util.function.Supplier;
 
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.SkipException;
+import org.testng.annotations.Test;
 
 import jdk.vm.ci.hotspot.HotSpotSpeculationLog;
 import jdk.vm.ci.meta.SpeculationLog;
@@ -87,16 +99,20 @@
         SpeculationLog.Speculation s2 = log.speculate(reason2);
 
         boolean added = log.addFailedSpeculation(s1);
-        Assume.assumeTrue(added);
+        if (!added) {
+            throw new SkipException("log.addFailedSpeculation(s1) is false");
+        }
+
         log.collectFailedSpeculations();
         Assert.assertFalse(log.maySpeculate(reason1));
         Assert.assertTrue(log.maySpeculate(reason2));
 
         added = log.addFailedSpeculation(s2);
-        Assume.assumeTrue(added);
+        if (!added) {
+            throw new SkipException("log.addFailedSpeculation(s2) is false");
+        }
         log.collectFailedSpeculations();
-        Assume.assumeTrue(added);
         Assert.assertFalse(log.maySpeculate(reason1));
-        Assert.assertFalse(log.toString(), log.maySpeculate(reason2));
+        Assert.assertFalse(log.maySpeculate(reason2), log.toString());
     }
 }
--- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestServices.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestServices.java	Fri Nov 08 14:49:00 2019 +0000
@@ -20,6 +20,17 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
+/*
+ * @test
+ * @requires vm.jvmci
+ * @modules jdk.internal.vm.ci/jdk.vm.ci.services:+open
+ * @library /compiler/jvmci/jdk.vm.ci.hotspot.test/src
+ * @run testng/othervm
+ *      -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler
+ *      jdk.vm.ci.hotspot.test.TestServices
+ */
+
 package jdk.vm.ci.hotspot.test;
 
 import java.lang.reflect.Field;
@@ -27,8 +38,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
 import jdk.vm.ci.services.Services;
 
--- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestTranslatedException.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestTranslatedException.java	Fri Nov 08 14:49:00 2019 +0000
@@ -20,6 +20,18 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
+/*
+ * @test
+ * @requires vm.jvmci
+ * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot:open
+ * @library /compiler/jvmci/jdk.vm.ci.hotspot.test/src
+ * @ignore 8233745
+ * @run testng/othervm
+ *      -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler
+ *      jdk.vm.ci.hotspot.test.TestTranslatedException
+ */
+
 package jdk.vm.ci.hotspot.test;
 
 import java.io.ByteArrayOutputStream;
@@ -27,8 +39,8 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
 public class TestTranslatedException {
 
@@ -71,6 +83,6 @@
                         "jdk.vm.ci.hotspot.TranslatedException: [java.lang.ClassNotFoundException: jdk/vm/ci/hotspot/test/TestTranslatedException$Untranslatable]",
                         "jdk.vm.ci.hotspot.test.TestTranslatedException$Untranslatable: test exception");
 
-        Assert.assertEquals("before:\n" + before + "\nafter:\n" + after, before, after);
+        Assert.assertEquals(before, after);
     }
 }
--- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/VirtualObjectLayoutTest.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/VirtualObjectLayoutTest.java	Fri Nov 08 14:49:00 2019 +0000
@@ -20,10 +20,26 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
+/*
+ * @test
+ * @requires vm.jvmci
+ * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot
+ *          jdk.internal.vm.ci/jdk.vm.ci.runtime
+ *          jdk.internal.vm.ci/jdk.vm.ci.meta
+ *          jdk.internal.vm.ci/jdk.vm.ci.code
+ *          jdk.internal.vm.ci/jdk.vm.ci.common
+ * @library /compiler/jvmci/jdk.vm.ci.hotspot.test/src
+ *          /compiler/jvmci/jdk.vm.ci.code.test/src
+ * @run testng/othervm
+ *      -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler
+ *      jdk.vm.ci.hotspot.test.VirtualObjectLayoutTest
+ */
+
 package jdk.vm.ci.hotspot.test;
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
 import jdk.vm.ci.code.VirtualObject;
 import jdk.vm.ci.code.test.VirtualObjectTestBase;
@@ -43,10 +59,10 @@
         try {
             HotSpotCompiledCode.verifyVirtualObject(virtual);
         } catch (JVMCIError e) {
-            Assert.assertTrue("Unexpected error verifying " + virtual, error);
+            Assert.assertTrue(error, "Unexpected error verifying " + virtual);
             return;
         }
-        Assert.assertFalse("Expected error but passed verifying " + virtual, error);
+        Assert.assertFalse(error, "Expected error but passed verifying " + virtual);
     }
 
     @Test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/cds/appcds/FieldLayoutFlags.java	Fri Nov 08 14:49:00 2019 +0000
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/*
+ * @test
+ * @summary VM should work even if different field layout options are chosen between dump time and run time.
+ * @bug 8233086
+ * @requires vm.cds
+ * @modules java.base/jdk.internal.misc
+ * @modules java.base/jdk.internal.vm.annotation
+ * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes
+ * @build FieldLayoutApp
+ * @run driver ClassFileInstaller -jar field_layout.jar
+ *     FieldLayoutApp
+ *     FieldLayoutApp$TestObject
+ *     FieldLayoutApp$Base1
+ *     FieldLayoutApp$Base2
+ *     FieldLayoutApp$Child1
+ *     FieldLayoutApp$Child2
+ * @run driver FieldLayoutFlags
+ */
+
+import jdk.test.lib.Platform;
+
+public class FieldLayoutFlags {
+    static final String[][] flags = {
+        // Dump time                             // Run time
+        {},                                      {},   // All defaults. Ensure that the test itself is correct.
+        {"-XX:FieldsAllocationStyle=0"},         {"-XX:FieldsAllocationStyle=1"},
+        {"-XX:FieldsAllocationStyle=0"},         {"-XX:FieldsAllocationStyle=2"},
+        {"-XX:FieldsAllocationStyle=1"},         {"-XX:FieldsAllocationStyle=0"},
+        {"-XX:FieldsAllocationStyle=1"},         {"-XX:FieldsAllocationStyle=2"},
+        {"-XX:FieldsAllocationStyle=2"},         {"-XX:FieldsAllocationStyle=0"},
+        {"-XX:FieldsAllocationStyle=2"},         {"-XX:FieldsAllocationStyle=1"},
+
+        {"-XX:+CompactFields"},                  {"-XX:-CompactFields"},
+        {"-XX:-CompactFields"},                  {"-XX:+CompactFields"},
+
+        {"-XX:+EnableContended"},                {"-XX:-EnableContended"},
+        {"-XX:-EnableContended"},                {"-XX:+EnableContended"},
+
+        {"-XX:ContendedPaddingWidth=128"},       {"-XX:ContendedPaddingWidth=256"},
+        {"-XX:ContendedPaddingWidth=256"},       {"-XX:ContendedPaddingWidth=128"},
+    };
+
+    static final String appJar = ClassFileInstaller.getJarPath("field_layout.jar");
+
+    public static void main(String[] args) throws Exception {
+        for (int i = 0; i < flags.length; i += 2) {
+            String[] dumpFlags = flags[i+0];
+            String[] runFlags  = flags[i+1];
+
+            System.out.println("====================================================== Cases " + i + " and " + (i + 1));
+            logFlags("Dump:", dumpFlags);
+            logFlags("Run :", runFlags);
+
+            testDump(dontRestrict(dumpFlags));
+            testRun (dontRestrict(runFlags));
+        }
+    }
+
+    static void logFlags(String which, String[] flags) {
+        System.out.print(which);
+        String prefix = " ";
+        for (String s : flags) {
+            System.out.print(prefix);
+            System.out.print(s);
+            prefix = ", ";
+        }
+        System.out.println();
+    }
+
+    // Don't restrict @Contended to trusted classes, so we can use it in FieldLayoutApp
+    static String[] dontRestrict(String args[]) {
+        return TestCommon.concat("-XX:-RestrictContended", args);
+    }
+
+    static void testDump(String[] dumpFlags) throws Exception {
+        String classlist[] = new String[] {
+            "FieldLayoutApp",
+            "FieldLayoutApp$TestObject",
+            "FieldLayoutApp$Base1",
+            "FieldLayoutApp$Base2",
+
+            /*
+             * Note, the following classes are not archived, and will be loaded
+             * dynamically at run time. We check that their field layout is compatible with
+             * their super classes, which are archived.
+             */
+            // "FieldLayoutApp$Child1",
+            // "FieldLayoutApp$Child2",
+        };
+
+        TestCommon.testDump(appJar, classlist, dumpFlags);
+    }
+
+    static void testRun(String[] runFlags) throws Exception {
+        String[] cmds = TestCommon.concat(runFlags, "-cp", appJar);
+        if (Platform.isDebugBuild()) {
+            cmds = TestCommon.concat(cmds, "-XX:+PrintFieldLayout");
+        }
+        cmds = TestCommon.concat(cmds, "FieldLayoutApp");
+
+        TestCommon.run(cmds).assertNormalExit();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/cds/appcds/test-classes/FieldLayoutApp.java	Fri Nov 08 14:49:00 2019 +0000
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+import java.util.ArrayList;
+import jdk.internal.vm.annotation.Contended;
+
+public class FieldLayoutApp {
+    public static void main(String args[]) {
+        ArrayList<TestObject> list = new ArrayList<>();
+
+        for (int i=0; i<400; i++) {
+            list.add(new Base1());
+            list.add(new Child1());
+            list.add(new Base2());
+            list.add(new Child2());
+        }
+
+        verifyAll(list);
+
+        // Make sure the oopmaps are laid out correctly.
+        System.gc();
+        verifyAll(list);
+    }
+
+    static void verifyAll(ArrayList<TestObject> list) {
+        for (TestObject obj : list) {
+            obj.verify();
+        }
+    }
+
+    static long lastUID = 0;
+    synchronized static long makeUID() {
+        return ++lastUID;
+    }
+
+    synchronized static void verifyUID(long uid) {
+        if (uid <= 0 || uid > lastUID) {
+            error("Unexpected UID " + uid + ", must be > 0 and <= " + lastUID);
+        }
+    }
+
+    static void error(String s) {
+        throw new RuntimeException(s);
+    }
+
+    static void ensure(boolean b) {
+        if (!b) {
+            error("Assertion failed");
+        }
+    }
+
+    static String makeString(long n) {
+        return Long.toString(n);
+    }
+
+    static class TestObject {
+        void verify() {}
+    }
+
+    static class Base1 extends TestObject {
+        byte b1, b2;
+        String s1;
+        byte b3, b4;
+        String s2;
+        long uid;
+        long l1;
+        int i1;
+        long l2;
+        int i2;
+
+        Base1() {
+            uid = makeUID();
+            b1 = 1;
+            b2 = 2;
+            b3 = 3;
+            b4 = 4;
+            s1 = makeString(uid + 1);
+            s2 = makeString(uid + 2);
+            i1 = 101;
+            i2 = 102;
+            l1 = 1001;
+            l2 = 1002;
+        }
+
+        void verify() {
+            super.verify();
+            ensure(b1 == 1);
+            ensure(b2 == 2);
+            ensure(b3 == 3);
+            ensure(b4 == 4);
+            verifyUID(uid);
+            ensure(s1.equals(makeString(uid + 1)));
+            ensure(s2.equals(makeString(uid + 2)));
+            ensure(i1 == 101);
+            ensure(i2 == 102);
+            ensure(l1 == 1001);
+            ensure(l2 == 1002);
+        }
+    }
+
+    // Base1 is archived but Child1 is loaded dynamically at runtime. Base1 may be
+    // archived with different field layout options that those used during runtime.
+    static class Child1 extends Base1 {
+        byte cb1, cb2;
+        String cs1;
+        byte cb3, cb4;
+        String cs2;
+        long cuid;
+        long cl1;
+        int ci1;
+        long cl2;
+        int ci2;
+
+        Child1() {
+            cuid = makeUID();
+            cb1 = 1;
+            cb2 = 2;
+            cb3 = 3;
+            cb4 = 4;
+            cs1 = makeString(cuid + 1);
+            cs2 = makeString(cuid + 2);
+            ci1 = 101;
+            ci2 = 102;
+            cl1 = 1001;
+            cl2 = 1002;
+        }
+
+        void verify() {
+            super.verify();
+            ensure(cb1 == 1);
+            ensure(cb2 == 2);
+            ensure(cb3 == 3);
+            ensure(cb4 == 4);
+            verifyUID(uid);
+            ensure(cs1.equals(makeString(cuid + 1)));
+            ensure(cs2.equals(makeString(cuid + 2)));
+            ensure(ci1 == 101);
+            ensure(ci2 == 102);
+            ensure(cl1 == 1001);
+            ensure(cl2 == 1002);
+
+            // Check the fields declared by the super class:
+            ensure(b1 == 1); // javac should generate a FieldRef of FieldLayoutApp$Child1.b1:B,
+                             // even though b1 is declared in the super class.
+            ensure(b2 == 2);
+            ensure(b3 == 3);
+            ensure(b4 == 4);
+            verifyUID(uid);
+            ensure(s1.equals(makeString(uid + 1)));
+            ensure(s2.equals(makeString(uid + 2)));
+
+            ensure(i1 == 101);
+            ensure(i2 == 102);
+            ensure(l1 == 1001);
+            ensure(l2 == 1002);
+        }
+    }
+
+    // Same as Base1 - minus the i1, i2, l1, l2 fields, plus some @Contended annotations
+    static class Base2 extends TestObject {
+        byte b1, b2;
+        String s1;
+        @Contended byte b3, b4;
+        @Contended String s2;
+        long uid;
+
+        Base2() {
+            uid = makeUID();
+            b1 = 1;
+            b2 = 2;
+            b3 = 3;
+            b4 = 4;
+            s1 = makeString(uid + 1);
+            s2 = makeString(uid + 2);
+        }
+
+        void verify() {
+            super.verify();
+            ensure(b1 == 1);
+            ensure(b2 == 2);
+            ensure(b3 == 3);
+            ensure(b4 == 4);
+            verifyUID(uid);
+            ensure(s1.equals(makeString(uid + 1)));
+            ensure(s2.equals(makeString(uid + 2)));
+        }
+    }
+
+    // Same as Child2 - minus the ci1, ci2, cl1, cl2 fields, plus some @Contended annotations
+    //
+    // Base2 is archived but Child2 is loaded dynamically at runtime. Base2 may be
+    // archived with different field layout options that those used during runtime.
+    static class Child2 extends Base2 {
+        byte cb1, cb2;
+        @Contended String cs1;
+        byte cb3, cb4;
+        String cs2;
+        @Contended long cuid;
+
+        Child2() {
+            cuid = makeUID();
+            cb1 = 1;
+            cb2 = 2;
+            cb3 = 3;
+            cb4 = 4;
+            cs1 = makeString(cuid + 1);
+            cs2 = makeString(cuid + 2);
+        }
+
+        void verify() {
+            super.verify();
+            ensure(cb1 == 1);
+            ensure(cb2 == 2);
+            ensure(cb3 == 3);
+            ensure(cb4 == 4);
+            verifyUID(uid);
+            ensure(cs1.equals(makeString(cuid + 1)));
+            ensure(cs2.equals(makeString(cuid + 2)));
+
+            // Check the fields declared by the super class:
+            ensure(b1 == 1); // javac should generate a FieldRef of FieldLayoutApp$Child2.b1:B,
+                             // even though b1 is declared in the super class.
+            ensure(b2 == 2);
+            ensure(b3 == 3);
+            ensure(b4 == 4);
+            verifyUID(uid);
+            ensure(s1.equals(makeString(uid + 1)));
+            ensure(s2.equals(makeString(uid + 2)));
+        }
+    }
+}
+
+
--- a/test/jdk/java/nio/file/etc/MacVolumesTest.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/jdk/java/nio/file/etc/MacVolumesTest.java	Fri Nov 08 14:49:00 2019 +0000
@@ -109,7 +109,7 @@
 
     private static final void checkDataVolume() throws IOException {
         System.out.format("--- Checking data volume %s ---%n", DATA_VOLUME);
-        Path data = Path.of(DATA_VOLUME, "tmp");
+        Path data = Path.of(DATA_VOLUME, "private", "tmp");
         if (Files.getFileStore(data).isReadOnly()) {
             throw new RuntimeException("Data volume is read-only");
         }
--- a/test/jdk/java/util/Locale/LocaleProviders.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/jdk/java/util/Locale/LocaleProviders.java	Fri Nov 08 14:49:00 2019 +0000
@@ -29,6 +29,7 @@
 public class LocaleProviders {
 
     private static final boolean IS_WINDOWS = System.getProperty("os.name").startsWith("Windows");
+    private static final boolean IS_MAC = System.getProperty("os.name").startsWith("Mac");
 
     public static void main(String[] args) {
         String methodName = args[0];
@@ -82,6 +83,10 @@
                 bug8228465Test();
                 break;
 
+            case "bug8232871Test":
+                bug8232871Test();
+                break;
+
             default:
                 throw new RuntimeException("Test method '"+methodName+"' not found.");
         }
@@ -286,4 +291,40 @@
             }
         }
     }
+
+    static void bug8232871Test() {
+        LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(CalendarNameProvider.class, Locale.US);
+        LocaleProviderAdapter.Type type = lda.getAdapterType();
+        var lang = Locale.getDefault().getLanguage();
+        var cal = Calendar.getInstance();
+        var calType = cal.getCalendarType();
+        var expected = "\u4ee4\u548c1\u5e745\u67081\u65e5 \u6c34\u66dc\u65e5 \u5348\u524d0:00:00 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593";
+
+        if (type == LocaleProviderAdapter.Type.HOST &&
+            IS_MAC &&
+            lang.equals("ja") &&
+            calType.equals("japanese")) {
+            cal.set(1, 4, 1, 0, 0, 0);
+            cal.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
+            DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL,
+                            Locale.JAPAN);
+            df.setCalendar(cal);
+            var result = df.format(cal.getTime());
+            if (result.equals(expected)) {
+                System.out.println("bug8232871Test succeeded.");
+            } else {
+                throw new RuntimeException(
+                            "Japanese calendar names mismatch. result: " +
+                            result +
+                            ", expected: " +
+                            expected);
+            }
+        } else {
+            System.out.println("Test ignored. Either :-\n" +
+                "OS is not macOS, or\n" +
+                "provider is not HOST: " + type + ", or\n" +
+                "Language is not Japanese: " + lang + ", or\n" +
+                "native calendar is not JapaneseCalendar: " + calType);
+        }
+    }
 }
--- a/test/jdk/java/util/Locale/LocaleProvidersRun.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/jdk/java/util/Locale/LocaleProvidersRun.java	Fri Nov 08 14:49:00 2019 +0000
@@ -25,7 +25,7 @@
  * @test
  * @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8008577
  *      8010666 8013086 8013233 8013903 8015960 8028771 8054482 8062006
- *      8150432 8215913 8220227 8228465
+ *      8150432 8215913 8220227 8228465 8232871
  * @summary tests for "java.locale.providers" system property
  * @library /test/lib
  * @build LocaleProviders
@@ -156,6 +156,9 @@
 
         //testing 8228465 fix. (Windows only)
         testRun("HOST", "bug8228465Test", "", "", "");
+
+        //testing 8232871 fix. (macOS only)
+        testRun("HOST", "bug8232871Test", "", "", "");
     }
 
     private static void testRun(String prefList, String methodName,
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java	Fri Nov 08 14:49:00 2019 +0000
@@ -30,6 +30,20 @@
 import jdk.test.lib.jfr.GCHelper;
 import sun.hotspot.WhiteBox;
 
+/*
+ * @test TestGCHeapConfigurationEventWith32BitOops
+ * @key jfr
+ * @requires vm.hasJFR
+ * @requires vm.gc == "Parallel" | vm.gc == null
+ * @requires os.family == "linux" | os.family == "windows"
+ * @requires sun.arch.data.model == "64"
+ * @library /test/lib /test/jdk
+ * @build sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx100m -Xms100m -XX:InitialHeapSize=100m -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWith32BitOops
+ */
+
+
 /* See the shell script wrapper for the flags used when invoking the JVM */
 public class TestGCHeapConfigurationEventWith32BitOops extends GCHeapConfigurationEventTester {
     public static void main(String[] args) throws Exception {
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.sh	Thu Nov 07 18:46:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#
-# 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
-# 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 TestGCHeapConfigurationEventWith32BitOops
-# @key jfr
-# @requires vm.hasJFR
-# @requires vm.gc == "Parallel" | vm.gc == null
-# @library /test/lib /test/jdk
-# @build jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWith32BitOops sun.hotspot.WhiteBox
-# @run main ClassFileInstaller sun.hotspot.WhiteBox
-# @run shell TestGCHeapConfigurationEventWith32BitOops.sh
-
-uses_64_bit_testjava() {
-  ${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1 | grep '64-Bit' > /dev/null
-}
-
-uses_windows_or_linux() {
-    case `uname -s` in
-      Linux | CYGWIN* | Windows* )
-        return 0
-        ;;
-    esac
-    return 1
-}
-
-TEST='jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWith32BitOops'
-
-OPTIONS='-XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx100m -Xms100m -XX:InitialHeapSize=100m -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI'
-
-if [ -z "${TESTCLASSPATH}" ]; then
-    echo "Using TESTCLASSES"
-    MY_CLASSPATH=${TESTCLASSES}
-else
-    echo "Using TESTCLASSPATH"
-    MY_CLASSPATH=${TESTCLASSPATH}
-fi
-
-if uses_windows_or_linux && uses_64_bit_testjava; then
-  printenv
-  echo "${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}"
-  ${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}
-fi
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java	Fri Nov 08 14:49:00 2019 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, 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,6 +28,19 @@
 import jdk.jfr.consumer.RecordedEvent;
 import jdk.test.lib.jfr.EventVerifier;
 
+/*
+ * @test TestGCHeapConfigurationEventWith32BitOops
+ * @key jfr
+ * @requires vm.hasJFR
+ * @requires vm.gc == "Parallel" | vm.gc == null
+ * @requires os.family == "linux" | os.family == "windows"
+ * @requires sun.arch.data.model == "64"
+ * @library /test/lib /test/jdk
+ * @build sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx31g jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithHeapBasedOops
+ */
+
 /* See the shell script wrapper for the flags used when invoking the JVM */
 public class TestGCHeapConfigurationEventWithHeapBasedOops extends GCHeapConfigurationEventTester {
     public static void main(String[] args) throws Exception {
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.sh	Thu Nov 07 18:46:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-#
-# 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
-# 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 TestGCHeapConfigurationEventWithHeapBasedOops
-# @key jfr
-# @requires vm.hasJFR
-# @requires vm.gc == "Parallel" | vm.gc == null
-# @library /test/lib /test/jdk
-# @build jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithHeapBasedOops
-# @run shell TestGCHeapConfigurationEventWithHeapBasedOops.sh
-
-uses_64_bit_testjava() {
-  ${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1 | grep '64-Bit' > /dev/null
-}
-
-uses_windows_or_linux() {
-    case `uname -s` in
-      Linux | CYGWIN* | Windows* )
-        return 0
-        ;;
-    esac
-    return 1
-}
-
-TEST='jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithHeapBasedOops'
-
-# NOTE: Can't use 32g heap with UseCompressedOops. Hopefully the 31g heap will
-# force HeapBased compressed oops to be enalbed by hoping that there isn't
-# enough space in the lowest 1 GB of the virtual address space.
-OPTIONS='-XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -Xmx31g -XX:+UseCompressedOops'
-
-if [ -z "${TESTCLASSPATH}" ]; then
-    echo "Using TESTCLASSES"
-    MY_CLASSPATH=${TESTCLASSES}
-else
-    echo "Using TESTCLASSPATH"
-    MY_CLASSPATH=${TESTCLASSPATH}
-fi
-
-if uses_windows_or_linux && uses_64_bit_testjava; then
-  printenv
-  echo "${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}"
-  ${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}
-fi
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java	Fri Nov 08 14:49:00 2019 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, 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,6 +28,17 @@
 import jdk.jfr.consumer.RecordedEvent;
 import jdk.test.lib.jfr.EventVerifier;
 
+/*
+ * @test TestGCHeapConfigurationEventWithZeroBasedOops
+ * @key jfr
+ * @requires vm.hasJFR
+ * @requires vm.gc == "Parallel" | vm.gc == null
+ * @requires os.family == "linux" | os.family == "windows"
+ * @requires sun.arch.data.model == "64"
+ * @library /test/lib /test/jdk
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx4g jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithZeroBasedOops
+ */
+
 /* See the shell script wrapper for the flags used when invoking the JVM */
 public class TestGCHeapConfigurationEventWithZeroBasedOops extends GCHeapConfigurationEventTester {
     public static void main(String[] args) throws Exception {
--- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.sh	Thu Nov 07 18:46:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-#
-# 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
-# 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 TestGCHeapConfigurationEventWithZeroBasedOops
-# @key jfr
-# @requires vm.hasJFR
-# @requires vm.gc == "Parallel" | vm.gc == null
-# @library /test/lib /test/jdk
-# @build jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithZeroBasedOops
-# @run shell TestGCHeapConfigurationEventWithZeroBasedOops.sh
-
-uses_64_bit_testjava() {
-  ${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1 | grep '64-Bit' > /dev/null
-}
-
-uses_windows_or_linux() {
-    case `uname -s` in
-      Linux | CYGWIN* | Windows* )
-        return 0
-        ;;
-    esac
-    return 1
-}
-
-TEST='jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithZeroBasedOops'
-
-OPTIONS='-XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx4g'
-
-if [ -z "${TESTCLASSPATH}" ]; then
-    echo "Using TESTCLASSES"
-    MY_CLASSPATH=${TESTCLASSES}
-else
-    echo "Using TESTCLASSPATH"
-    MY_CLASSPATH=${TESTCLASSPATH}
-fi
-
-if uses_windows_or_linux && uses_64_bit_testjava; then
-  printenv
-  echo "${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}"
-  ${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}
-fi
--- a/test/jdk/jdk/jfr/event/io/EvilInstrument.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/jdk/jdk/jfr/event/io/EvilInstrument.java	Fri Nov 08 14:49:00 2019 +0000
@@ -53,7 +53,8 @@
  * @modules java.instrument
  *
  * @build jdk.jfr.event.io.EvilInstrument
- * @run shell MakeJAR.sh EvilInstrument 'Can-Redefine-Classes: true'
+ * @run driver jdk.test.lib.util.JavaAgentBuilder
+ *             jdk.jfr.event.io.EvilInstrument EvilInstrument.jar
  * @run main/othervm -javaagent:EvilInstrument.jar jdk.jfr.event.io.EvilInstrument
  */
 
--- a/test/jdk/jdk/jfr/event/io/MakeJAR.sh	Thu Nov 07 18:46:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#!/bin/sh
-
-AGENT="$1"
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ -z "${COMPILEJAVA}" ]
-then
-  COMPILEJAVA=${TESTJAVA}
-fi
-
-JAVAC="${COMPILEJAVA}/bin/javac -g"
-JAR="${COMPILEJAVA}/bin/jar"
-
-cp ${TESTSRC}/${AGENT}.java .
-${JAVAC} -cp ${TESTCLASSPATH} ${AGENT}.java
-
-echo "Manifest-Version: 1.0"    >  ${AGENT}.mf
-echo Premain-Class: jdk.jfr.event.io.${AGENT} >> ${AGENT}.mf
-shift
-while [ $# != 0 ] ; do
-  echo $1 >> ${AGENT}.mf
-  shift
-done
-
-
-${JAR} cvfm ${AGENT}.jar ${AGENT}.mf ${AGENT}*.class
--- a/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java	Fri Nov 08 14:49:00 2019 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, 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,30 +36,51 @@
 import jdk.jfr.consumer.RecordedEvent;
 import jdk.test.lib.jfr.EventNames;
 import jdk.test.lib.jfr.Events;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
+/**
+ * @test
+ * @key jfr
+ * @requires vm.hasJFR
+ * @library /test/lib
+ * @run main jdk.jfr.event.os.TestInitialEnvironmentVariable
+ */
 public class TestInitialEnvironmentVariable {
     private final static String EVENT_NAME = EventNames.InitialEnvironmentVariable;
 
     public static void main(String[] args) throws Exception {
-        Map<String, String> env = new HashMap<>();
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(Test.class.getName());
+        setEnv(pb.environment());
+        (new OutputAnalyzer(pb.start())).shouldHaveExitValue(0);
+    }
+
+    static void setEnv(Map<String, String> env) {
         env.put("keytest1", "value1");
         env.put("keytest2", "value 2");
+    }
 
-        Recording recording = new Recording();
-        recording.enable(EVENT_NAME);
-        recording.start();
-        recording.stop();
-        List<RecordedEvent> events = Events.fromRecording(recording);
-        Events.hasEvents(events);
-        for (RecordedEvent event : events) {
-            System.out.println("Event: " + event);
-            String key = Events.assertField(event, "key").notNull().getValue();
-            String value = Events.assertField(event, "value").notNull().getValue();
-            if (env.containsKey(key)) {
-                assertEquals(value, env.get(key), "Wrong value for key: " + key);
-                env.remove(key);
+    static class Test {
+        public static void main(String[] args) throws Exception {
+            Map<String, String> env = new HashMap<>();
+            setEnv(env);
+
+            Recording recording = new Recording();
+            recording.enable(EVENT_NAME);
+            recording.start();
+            recording.stop();
+            List<RecordedEvent> events = Events.fromRecording(recording);
+            Events.hasEvents(events);
+            for (RecordedEvent event : events) {
+                System.out.println("Event: " + event);
+                String key = Events.assertField(event, "key").notNull().getValue();
+                String value = Events.assertField(event, "value").notNull().getValue();
+                if (env.containsKey(key)) {
+                    assertEquals(value, env.get(key), "Wrong value for key: " + key);
+                    env.remove(key);
+                }
             }
+            assertTrue(env.isEmpty(), "Missing env keys " + env.keySet());
         }
-        assertTrue(env.isEmpty(), "Missing env keys " + env.keySet());
     }
 }
--- a/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.sh	Thu Nov 07 18:46:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-#
-# 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
-# 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
-# @key jfr
-# @requires vm.hasJFR
-# @library /test/lib
-# @build jdk.jfr.event.os.TestInitialEnvironmentVariable
-# @run shell TestInitialEnvironmentVariable.sh
-
-echo -------------------------------------------------------------
-echo "TESTCLASSES='$TESTCLASSES'"
-echo "TESTSRC='$TESTSRC'"
-echo Launching test for `basename $0 .sh`
-echo -------------------------------------------------------------
-keytest1="value1";export keytest1
-keytest2="value 2";export keytest2
-${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} jdk.jfr.event.os.TestInitialEnvironmentVariable
-exit $?
--- a/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.flags	Thu Nov 07 18:46:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-+FlightRecorder
\ No newline at end of file
--- a/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java	Thu Nov 07 18:46:06 2019 +0000
+++ b/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.java	Fri Nov 08 14:49:00 2019 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,10 @@
 
 package jdk.jfr.event.runtime;
 
-
-
 import java.lang.management.ManagementFactory;
 import java.lang.management.RuntimeMXBean;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -39,13 +39,21 @@
 import jdk.test.lib.jfr.Events;
 
 /**
- * The test will verify that JVM Information event values are delivered
- * and compare them with the RuntimeMXBean's values.
+ * @test
+ * @key jfr
+ * @requires vm.hasJFR
+ * @library /test/lib
+ * @run driver jdk.jfr.event.runtime.TestVMInfoEvent generateFlagsFile
+ * @run main/othervm -XX:Flags=TestVMInfoEvent.flags -Xmx500m jdk.jfr.event.runtime.TestVMInfoEvent arg1 arg2
  */
 public class TestVMInfoEvent {
     private final static String EVENT_NAME = EventNames.JVMInformation;
 
     public static void main(String[] args) throws Exception {
+        if( (args.length > 0) && ("generateFlagsFile".equals(args[0])) ) {
+            generateFlagsFile();
+            return;
+        }
         RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean();
         Recording recording = new Recording();
         recording.enable(EVENT_NAME);
@@ -76,4 +84,7 @@
         }
     }
 
+    public static void generateFlagsFile() throws Exception {
+        Files.writeString(Paths.get("", "TestVMInfoEvent.flags"), "+UseSerialGC");
+    }
 }
--- a/test/jdk/jdk/jfr/event/runtime/TestVMInfoEvent.sh	Thu Nov 07 18:46:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#
-# 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
-# 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
-# @key jfr
-# @requires vm.hasJFR
-# @library /test/lib /test/jdk
-# @build jdk.jfr.event.runtime.TestVMInfoEvent
-# @run shell TestVMInfoEvent.sh
-
-echo -------------------------------------------------------------
-echo Launching test for `basename $0 .sh`
-echo -------------------------------------------------------------
-
-${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -XX:Flags=${TESTSRC}/TestVMInfoEvent.flags jdk.jfr.event.runtime.TestVMInfoEvent arg1 arg2
-exit $?
--- a/test/jdk/jdk/jfr/javaagent/JavaAgentBuilder.java	Thu Nov 07 18:46:06 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.test.lib.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import jdk.test.lib.Utils;
-import jdk.test.lib.util.JarUtils;
-
-/**
- * A builder for a common Java agent.
- * Can be used directly from the jtreg test header to
- * build a java agent before the test is executed.
- *
- * E.g.:
- * @run driver jdk.test.lib.util.JavaAgentBuilder
- *             jdk.jfr.javaagent.EventEmitterAgent EventEmitterAgent.jar
- *
- */
-public class JavaAgentBuilder {
-
-    /**
-     * Build a java agent jar file with a given agent class.
-     *
-     * @param args[0]    fully qualified name of an agent class
-     * @param args[1]    file name of the agent jar to be created
-     * @throws IOException
-     */
-    public static void main(String... args) throws IOException {
-        String agentClass = args[0];
-        String agentJar = args[1];
-        System.out.println("Building " + agentJar + " with agent class " + agentClass);
-        build(agentClass, agentJar);
-    }
-
-    /**
-     * Build a java agent jar file with a given agent class.
-     * The agent class will be added as both premain class and agent class.
-     *
-     * @param agentClass fully qualified name of an agent class
-     * @param agentJar   file name of the agent jar to be created
-     *                   the file will be placed in a current work directory
-     * @throws IOException
-     */
-    public static void build(String agentClass, String agentJar) throws IOException {
-        Manifest mf = new Manifest();
-        Attributes attrs = mf.getMainAttributes();
-        attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
-        attrs.putValue("Premain-Class", agentClass);
-        attrs.putValue("Agent-Class", agentClass);
-
-        Path jarFile = Paths.get(".", agentJar);
-        String testClasses = Utils.TEST_CLASSES;
-        String agentPath = agentClass.replace(".", File.separator) + ".class";
-        Path agentFile = Paths.get(testClasses, agentPath);
-        Path dir = Paths.get(testClasses);
-        JarUtils.createJarFile(jarFile, mf, dir, agentFile);
-        System.out.println("Agent built:" + jarFile.toAbsolutePath());
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/util/JavaAgentBuilder.java	Fri Nov 08 14:49:00 2019 +0000
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import jdk.test.lib.Utils;
+import jdk.test.lib.util.JarUtils;
+
+/**
+ * A builder for a common Java agent.
+ * Can be used directly from the jtreg test header to
+ * build a java agent before the test is executed.
+ *
+ * E.g.:
+ * @run driver jdk.test.lib.util.JavaAgentBuilder
+ *             jdk.jfr.javaagent.EventEmitterAgent EventEmitterAgent.jar
+ *
+ */
+public class JavaAgentBuilder {
+
+    /**
+     * Build a java agent jar file with a given agent class.
+     *
+     * @param args[0]    fully qualified name of an agent class
+     * @param args[1]    file name of the agent jar to be created
+     * @throws IOException
+     */
+    public static void main(String... args) throws IOException {
+        String agentClass = args[0];
+        String agentJar = args[1];
+        System.out.println("Building " + agentJar + " with agent class " + agentClass);
+        build(agentClass, agentJar);
+    }
+
+    /**
+     * Build a java agent jar file with a given agent class.
+     * The agent class will be added as both premain class and agent class.
+     *
+     * @param agentClass fully qualified name of an agent class
+     * @param agentJar   file name of the agent jar to be created
+     *                   the file will be placed in a current work directory
+     * @throws IOException
+     */
+    public static void build(String agentClass, String agentJar) throws IOException {
+        Manifest mf = new Manifest();
+        Attributes attrs = mf.getMainAttributes();
+        attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        attrs.putValue("Premain-Class", agentClass);
+        attrs.putValue("Agent-Class", agentClass);
+
+        Path jarFile = Paths.get(".", agentJar);
+        String testClasses = Utils.TEST_CLASSES;
+        String agentPath = agentClass.replace(".", File.separator) + ".class";
+        Path agentFile = Paths.get(testClasses, agentPath);
+        Path dir = Paths.get(testClasses);
+        JarUtils.createJarFile(jarFile, mf, dir, agentFile);
+        System.out.println("Agent built:" + jarFile.toAbsolutePath());
+    }
+}