8235385: AArch64: Crash on aarch64 JDK due to long offset

Reviewed-by: adinn
diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad
index 7171628..d7e6866 100644
--- a/src/hotspot/cpu/aarch64/aarch64.ad
+++ b/src/hotspot/cpu/aarch64/aarch64.ad
@@ -2441,15 +2441,27 @@
   // offsets is something of a kludge.
   static void loadStore(MacroAssembler masm, mem_insn insn,
                         Register reg, int opcode,
-                        Register base, int index, int size, int disp)
+                        Register base, int index, int scale, int disp,
+                        int size_in_memory)
   {
-    Address addr = mem2address(opcode, base, index, size, disp);
+    Address addr = mem2address(opcode, base, index, scale, disp);
+    if (addr.getMode() == Address::base_plus_offset) {
+      /* If we get an out-of-range offset it is a bug in the compiler,
+         so we assert here. */
+      assert(Address::offset_ok_for_immed(addr.offset(), exact_log2(size_in_memory)),
+             "c2 compiler bug");
+      /* Fix up any out-of-range offsets. */
+      assert_different_registers(rscratch1, base);
+      assert_different_registers(rscratch1, reg);
+      addr = masm.legitimize_address(addr, size_in_memory, rscratch1);
+    }
     (masm.*insn)(reg, addr);
   }
 
   static void loadStore(MacroAssembler masm, mem_float_insn insn,
                         FloatRegister reg, int opcode,
-                        Register base, int index, int size, int disp)
+                        Register base, int index, int size, int disp,
+                        int size_in_memory)
   {
     Address::extend scale;
 
@@ -2462,8 +2474,15 @@
       scale = Address::lsl(size);
     }
 
-     if (index == -1) {
-      (masm.*insn)(reg, Address(base, disp));
+    if (index == -1) {
+      /* If we get an out-of-range offset it is a bug in the compiler,
+         so we assert here. */
+      assert(Address::offset_ok_for_immed(disp, exact_log2(size_in_memory)), "c2 compiler bug");
+      /* Fix up any out-of-range offsets. */
+      assert_different_registers(rscratch1, base);
+      Address addr = Address(base, disp);
+      addr = masm.legitimize_address(addr, size_in_memory, rscratch1);
+      (masm.*insn)(reg, addr);
     } else {
       assert(disp == 0, "unsupported address mode: disp = %d", disp);
       (masm.*insn)(reg, Address(base, as_Register(index), scale));
@@ -2529,90 +2548,244 @@
 
   // BEGIN Non-volatile memory access
 
-  enc_class aarch64_enc_ldrsbw(iRegI dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrsbw(iRegI dst, memory1 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrsbw, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1);
   %}
 
-  enc_class aarch64_enc_ldrsb(iRegI dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrsb(iRegI dst, memory1 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrsb, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1);
   %}
 
-  enc_class aarch64_enc_ldrb(iRegI dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrb(iRegI dst, memory1 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrb, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1);
   %}
 
-  enc_class aarch64_enc_ldrb(iRegL dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrb(iRegL dst, memory1 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrb, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1);
   %}
 
-  enc_class aarch64_enc_ldrshw(iRegI dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrshw(iRegI dst, memory2 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrshw, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2);
   %}
 
-  enc_class aarch64_enc_ldrsh(iRegI dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrsh(iRegI dst, memory2 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrsh, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2);
   %}
 
-  enc_class aarch64_enc_ldrh(iRegI dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrh(iRegI dst, memory2 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrh, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2);
   %}
 
-  enc_class aarch64_enc_ldrh(iRegL dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrh(iRegL dst, memory2 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrh, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2);
   %}
 
-  enc_class aarch64_enc_ldrw(iRegI dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrw(iRegI dst, memory4 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrw, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
   %}
 
-  enc_class aarch64_enc_ldrw(iRegL dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrw(iRegL dst, memory4 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrw, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
   %}
 
-  enc_class aarch64_enc_ldrsw(iRegL dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrsw(iRegL dst, memory4 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrsw, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
   %}
 
-  enc_class aarch64_enc_ldr(iRegL dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldr(iRegL dst, memory8 mem) %{
     Register dst_reg = as_Register($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldr, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8);
   %}
 
-  enc_class aarch64_enc_ldrs(vRegF dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrs(vRegF dst, memory4 mem) %{
     FloatRegister dst_reg = as_FloatRegister($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrs, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
   %}
 
-  enc_class aarch64_enc_ldrd(vRegD dst, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_ldrd(vRegD dst, memory8 mem) %{
     FloatRegister dst_reg = as_FloatRegister($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrd, dst_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8);
   %}
 
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strb(iRegI src, memory1 mem) %{
+    Register src_reg = as_Register($src$$reg);
+    loadStore(MacroAssembler(&cbuf), &MacroAssembler::strb, src_reg, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strb0(memory1 mem) %{
+    MacroAssembler _masm(&cbuf);
+    loadStore(_masm, &MacroAssembler::strb, zr, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strh(iRegI src, memory2 mem) %{
+    Register src_reg = as_Register($src$$reg);
+    loadStore(MacroAssembler(&cbuf), &MacroAssembler::strh, src_reg, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strh0(memory2 mem) %{
+    MacroAssembler _masm(&cbuf);
+    loadStore(_masm, &MacroAssembler::strh, zr, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strw(iRegI src, memory4 mem) %{
+    Register src_reg = as_Register($src$$reg);
+    loadStore(MacroAssembler(&cbuf), &MacroAssembler::strw, src_reg, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strw0(memory4 mem) %{
+    MacroAssembler _masm(&cbuf);
+    loadStore(_masm, &MacroAssembler::strw, zr, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_str(iRegL src, memory8 mem) %{
+    Register src_reg = as_Register($src$$reg);
+    // we sometimes get asked to store the stack pointer into the
+    // current thread -- we cannot do that directly on AArch64
+    if (src_reg == r31_sp) {
+      MacroAssembler _masm(&cbuf);
+      assert(as_Register($mem$$base) == rthread, "unexpected store for sp");
+      __ mov(rscratch2, sp);
+      src_reg = rscratch2;
+    }
+    loadStore(MacroAssembler(&cbuf), &MacroAssembler::str, src_reg, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_str0(memory8 mem) %{
+    MacroAssembler _masm(&cbuf);
+    loadStore(_masm, &MacroAssembler::str, zr, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strs(vRegF src, memory4 mem) %{
+    FloatRegister src_reg = as_FloatRegister($src$$reg);
+    loadStore(MacroAssembler(&cbuf), &MacroAssembler::strs, src_reg, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strd(vRegD src, memory8 mem) %{
+    FloatRegister src_reg = as_FloatRegister($src$$reg);
+    loadStore(MacroAssembler(&cbuf), &MacroAssembler::strd, src_reg, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strw_immn(immN src, memory1 mem) %{
+    MacroAssembler _masm(&cbuf);
+    address con = (address)$src$$constant;
+    // need to do this the hard way until we can manage relocs
+    // for 32 bit constants
+    __ movoop(rscratch2, (jobject)con);
+    if (con) __ encode_heap_oop_not_null(rscratch2);
+    loadStore(_masm, &MacroAssembler::strw, rscratch2, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strw_immnk(immN src, memory4 mem) %{
+    MacroAssembler _masm(&cbuf);
+    address con = (address)$src$$constant;
+    // need to do this the hard way until we can manage relocs
+    // for 32 bit constants
+    __ movoop(rscratch2, (jobject)con);
+    __ encode_klass_not_null(rscratch2);
+    loadStore(_masm, &MacroAssembler::strw, rscratch2, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
+  %}
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strb0_ordered(memory4 mem) %{
+      MacroAssembler _masm(&cbuf);
+      __ membar(Assembler::StoreStore);
+      loadStore(_masm, &MacroAssembler::strb, zr, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1);
+  %}
+
+  // END Non-volatile memory access
+
+  // Vector loads and stores
   enc_class aarch64_enc_ldrvS(vecD dst, memory mem) %{
     FloatRegister dst_reg = as_FloatRegister($dst$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldr, dst_reg, MacroAssembler::S,
@@ -2631,81 +2804,6 @@
        $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
   %}
 
-  enc_class aarch64_enc_strb(iRegI src, memory mem) %{
-    Register src_reg = as_Register($src$$reg);
-    loadStore(MacroAssembler(&cbuf), &MacroAssembler::strb, src_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
-  enc_class aarch64_enc_strb0(memory mem) %{
-    MacroAssembler _masm(&cbuf);
-    loadStore(_masm, &MacroAssembler::strb, zr, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
-  enc_class aarch64_enc_strb0_ordered(memory mem) %{
-    MacroAssembler _masm(&cbuf);
-    __ membar(Assembler::StoreStore);
-    loadStore(_masm, &MacroAssembler::strb, zr, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
-  enc_class aarch64_enc_strh(iRegI src, memory mem) %{
-    Register src_reg = as_Register($src$$reg);
-    loadStore(MacroAssembler(&cbuf), &MacroAssembler::strh, src_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
-  enc_class aarch64_enc_strh0(memory mem) %{
-    MacroAssembler _masm(&cbuf);
-    loadStore(_masm, &MacroAssembler::strh, zr, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
-  enc_class aarch64_enc_strw(iRegI src, memory mem) %{
-    Register src_reg = as_Register($src$$reg);
-    loadStore(MacroAssembler(&cbuf), &MacroAssembler::strw, src_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
-  enc_class aarch64_enc_strw0(memory mem) %{
-    MacroAssembler _masm(&cbuf);
-    loadStore(_masm, &MacroAssembler::strw, zr, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
-  enc_class aarch64_enc_str(iRegL src, memory mem) %{
-    Register src_reg = as_Register($src$$reg);
-    // we sometimes get asked to store the stack pointer into the
-    // current thread -- we cannot do that directly on AArch64
-    if (src_reg == r31_sp) {
-      MacroAssembler _masm(&cbuf);
-      assert(as_Register($mem$$base) == rthread, "unexpected store for sp");
-      __ mov(rscratch2, sp);
-      src_reg = rscratch2;
-    }
-    loadStore(MacroAssembler(&cbuf), &MacroAssembler::str, src_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
-  enc_class aarch64_enc_str0(memory mem) %{
-    MacroAssembler _masm(&cbuf);
-    loadStore(_masm, &MacroAssembler::str, zr, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
-  enc_class aarch64_enc_strs(vRegF src, memory mem) %{
-    FloatRegister src_reg = as_FloatRegister($src$$reg);
-    loadStore(MacroAssembler(&cbuf), &MacroAssembler::strs, src_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
-  enc_class aarch64_enc_strd(vRegD src, memory mem) %{
-    FloatRegister src_reg = as_FloatRegister($src$$reg);
-    loadStore(MacroAssembler(&cbuf), &MacroAssembler::strd, src_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
-  %}
-
   enc_class aarch64_enc_strvS(vecD src, memory mem) %{
     FloatRegister src_reg = as_FloatRegister($src$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::str, src_reg, MacroAssembler::S,
@@ -2724,8 +2822,6 @@
        $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
   %}
 
-  // END Non-volatile memory access
-
   // volatile loads and stores
 
   enc_class aarch64_enc_stlrb(iRegI src, memory mem) %{
@@ -2855,7 +2951,7 @@
 
   // synchronized read/update encodings
 
-  enc_class aarch64_enc_ldaxr(iRegL dst, memory mem) %{
+  enc_class aarch64_enc_ldaxr(iRegL dst, memory8 mem) %{
     MacroAssembler _masm(&cbuf);
     Register dst_reg = as_Register($dst$$reg);
     Register base = as_Register($mem$$base);
@@ -2884,7 +2980,7 @@
     }
   %}
 
-  enc_class aarch64_enc_stlxr(iRegLNoSp src, memory mem) %{
+  enc_class aarch64_enc_stlxr(iRegLNoSp src, memory8 mem) %{
     MacroAssembler _masm(&cbuf);
     Register src_reg = as_Register($src$$reg);
     Register base = as_Register($mem$$base);
@@ -4012,7 +4108,27 @@
 // Offset for scaled or unscaled immediate loads and stores
 operand immIOffset()
 %{
-  predicate(Address::offset_ok_for_immed(n->get_int()));
+  predicate(Address::offset_ok_for_immed(n->get_int(), 0));
+  match(ConI);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
+operand immIOffset1()
+%{
+  predicate(Address::offset_ok_for_immed(n->get_int(), 0));
+  match(ConI);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
+operand immIOffset2()
+%{
+  predicate(Address::offset_ok_for_immed(n->get_int(), 1));
   match(ConI);
 
   op_cost(0);
@@ -4052,7 +4168,27 @@
 
 operand immLoffset()
 %{
-  predicate(Address::offset_ok_for_immed(n->get_long()));
+  predicate(Address::offset_ok_for_immed(n->get_long(), 0));
+  match(ConL);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
+operand immLoffset1()
+%{
+  predicate(Address::offset_ok_for_immed(n->get_long(), 0));
+  match(ConL);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
+operand immLoffset2()
+%{
+  predicate(Address::offset_ok_for_immed(n->get_long(), 1));
   match(ConL);
 
   op_cost(0);
@@ -5197,6 +5333,34 @@
   %}
 %}
 
+operand indOffI1(iRegP reg, immIOffset1 off)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg off);
+  op_cost(0);
+  format %{ "[$reg, $off]" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index(0xffffffff);
+    scale(0x0);
+    disp($off);
+  %}
+%}
+
+operand indOffI2(iRegP reg, immIOffset2 off)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg off);
+  op_cost(0);
+  format %{ "[$reg, $off]" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index(0xffffffff);
+    scale(0x0);
+    disp($off);
+  %}
+%}
+
 operand indOffI4(iRegP reg, immIOffset4 off)
 %{
   constraint(ALLOC_IN_RC(ptr_reg));
@@ -5253,6 +5417,34 @@
   %}
 %}
 
+operand indOffL1(iRegP reg, immLoffset1 off)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg off);
+  op_cost(0);
+  format %{ "[$reg, $off]" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index(0xffffffff);
+    scale(0x0);
+    disp($off);
+  %}
+%}
+
+operand indOffL2(iRegP reg, immLoffset2 off)
+%{
+  constraint(ALLOC_IN_RC(ptr_reg));
+  match(AddP reg off);
+  op_cost(0);
+  format %{ "[$reg, $off]" %}
+  interface(MEMORY_INTER) %{
+    base($reg);
+    index(0xffffffff);
+    scale(0x0);
+    disp($off);
+  %}
+%}
+
 operand indOffL4(iRegP reg, immLoffset4 off)
 %{
   constraint(ALLOC_IN_RC(ptr_reg));
@@ -5648,9 +5840,24 @@
 // memory is used to define read/write location for load/store
 // instruction defs. we can turn a memory op into an Address
 
-opclass memory(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI, indOffL,
+opclass memory1(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI1, indOffL1,
+               indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN);
+
+opclass memory2(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI2, indOffL2,
+               indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN);
+
+opclass memory4(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI4, indOffL4,
                indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indOffIN, indOffLN);
 
+opclass memory8(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI8, indOffL8,
+               indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indOffIN, indOffLN);
+
+// All of the memory operands. For the pipeline description.
+opclass memory(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex,
+               indOffI1, indOffL1, indOffI2, indOffL2, indOffI4, indOffL4, indOffI8, indOffL8,
+               indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indOffIN, indOffLN);
+
+
 // iRegIorL2I is used for src inputs in rules for 32 bit int (I)
 // operations. it allows the src to be either an iRegI or a (ConvL2I
 // iRegL). in the latter case the l2i normally planted for a ConvL2I
@@ -6634,7 +6841,7 @@
 // Load Instructions
 
 // Load Byte (8 bit signed)
-instruct loadB(iRegINoSp dst, memory mem)
+instruct loadB(iRegINoSp dst, memory1 mem)
 %{
   match(Set dst (LoadB mem));
   predicate(!needs_acquiring_load(n));
@@ -6648,7 +6855,7 @@
 %}
 
 // Load Byte (8 bit signed) into long
-instruct loadB2L(iRegLNoSp dst, memory mem)
+instruct loadB2L(iRegLNoSp dst, memory1 mem)
 %{
   match(Set dst (ConvI2L (LoadB mem)));
   predicate(!needs_acquiring_load(n->in(1)));
@@ -6662,7 +6869,7 @@
 %}
 
 // Load Byte (8 bit unsigned)
-instruct loadUB(iRegINoSp dst, memory mem)
+instruct loadUB(iRegINoSp dst, memory1 mem)
 %{
   match(Set dst (LoadUB mem));
   predicate(!needs_acquiring_load(n));
@@ -6676,7 +6883,7 @@
 %}
 
 // Load Byte (8 bit unsigned) into long
-instruct loadUB2L(iRegLNoSp dst, memory mem)
+instruct loadUB2L(iRegLNoSp dst, memory1 mem)
 %{
   match(Set dst (ConvI2L (LoadUB mem)));
   predicate(!needs_acquiring_load(n->in(1)));
@@ -6690,7 +6897,7 @@
 %}
 
 // Load Short (16 bit signed)
-instruct loadS(iRegINoSp dst, memory mem)
+instruct loadS(iRegINoSp dst, memory2 mem)
 %{
   match(Set dst (LoadS mem));
   predicate(!needs_acquiring_load(n));
@@ -6704,7 +6911,7 @@
 %}
 
 // Load Short (16 bit signed) into long
-instruct loadS2L(iRegLNoSp dst, memory mem)
+instruct loadS2L(iRegLNoSp dst, memory2 mem)
 %{
   match(Set dst (ConvI2L (LoadS mem)));
   predicate(!needs_acquiring_load(n->in(1)));
@@ -6718,7 +6925,7 @@
 %}
 
 // Load Char (16 bit unsigned)
-instruct loadUS(iRegINoSp dst, memory mem)
+instruct loadUS(iRegINoSp dst, memory2 mem)
 %{
   match(Set dst (LoadUS mem));
   predicate(!needs_acquiring_load(n));
@@ -6732,7 +6939,7 @@
 %}
 
 // Load Short/Char (16 bit unsigned) into long
-instruct loadUS2L(iRegLNoSp dst, memory mem)
+instruct loadUS2L(iRegLNoSp dst, memory2 mem)
 %{
   match(Set dst (ConvI2L (LoadUS mem)));
   predicate(!needs_acquiring_load(n->in(1)));
@@ -6746,7 +6953,7 @@
 %}
 
 // Load Integer (32 bit signed)
-instruct loadI(iRegINoSp dst, memory mem)
+instruct loadI(iRegINoSp dst, memory4 mem)
 %{
   match(Set dst (LoadI mem));
   predicate(!needs_acquiring_load(n));
@@ -6760,7 +6967,7 @@
 %}
 
 // Load Integer (32 bit signed) into long
-instruct loadI2L(iRegLNoSp dst, memory mem)
+instruct loadI2L(iRegLNoSp dst, memory4 mem)
 %{
   match(Set dst (ConvI2L (LoadI mem)));
   predicate(!needs_acquiring_load(n->in(1)));
@@ -6774,7 +6981,7 @@
 %}
 
 // Load Integer (32 bit unsigned) into long
-instruct loadUI2L(iRegLNoSp dst, memory mem, immL_32bits mask)
+instruct loadUI2L(iRegLNoSp dst, memory4 mem, immL_32bits mask)
 %{
   match(Set dst (AndL (ConvI2L (LoadI mem)) mask));
   predicate(!needs_acquiring_load(n->in(1)->in(1)->as_Load()));
@@ -6788,7 +6995,7 @@
 %}
 
 // Load Long (64 bit signed)
-instruct loadL(iRegLNoSp dst, memory mem)
+instruct loadL(iRegLNoSp dst, memory8 mem)
 %{
   match(Set dst (LoadL mem));
   predicate(!needs_acquiring_load(n));
@@ -6802,7 +7009,7 @@
 %}
 
 // Load Range
-instruct loadRange(iRegINoSp dst, memory mem)
+instruct loadRange(iRegINoSp dst, memory4 mem)
 %{
   match(Set dst (LoadRange mem));
 
@@ -6815,7 +7022,7 @@
 %}
 
 // Load Pointer
-instruct loadP(iRegPNoSp dst, memory mem)
+instruct loadP(iRegPNoSp dst, memory8 mem)
 %{
   match(Set dst (LoadP mem));
   predicate(!needs_acquiring_load(n) && (n->as_Load()->barrier_data() == 0));
@@ -6829,7 +7036,7 @@
 %}
 
 // Load Compressed Pointer
-instruct loadN(iRegNNoSp dst, memory mem)
+instruct loadN(iRegNNoSp dst, memory4 mem)
 %{
   match(Set dst (LoadN mem));
   predicate(!needs_acquiring_load(n));
@@ -6843,7 +7050,7 @@
 %}
 
 // Load Klass Pointer
-instruct loadKlass(iRegPNoSp dst, memory mem)
+instruct loadKlass(iRegPNoSp dst, memory8 mem)
 %{
   match(Set dst (LoadKlass mem));
   predicate(!needs_acquiring_load(n));
@@ -6857,7 +7064,7 @@
 %}
 
 // Load Narrow Klass Pointer
-instruct loadNKlass(iRegNNoSp dst, memory mem)
+instruct loadNKlass(iRegNNoSp dst, memory4 mem)
 %{
   match(Set dst (LoadNKlass mem));
   predicate(!needs_acquiring_load(n));
@@ -6871,7 +7078,7 @@
 %}
 
 // Load Float
-instruct loadF(vRegF dst, memory mem)
+instruct loadF(vRegF dst, memory4 mem)
 %{
   match(Set dst (LoadF mem));
   predicate(!needs_acquiring_load(n));
@@ -6885,7 +7092,7 @@
 %}
 
 // Load Double
-instruct loadD(vRegD dst, memory mem)
+instruct loadD(vRegD dst, memory8 mem)
 %{
   match(Set dst (LoadD mem));
   predicate(!needs_acquiring_load(n));
@@ -7103,7 +7310,7 @@
 // Store Instructions
 
 // Store CMS card-mark Immediate
-instruct storeimmCM0(immI0 zero, memory mem)
+instruct storeimmCM0(immI0 zero, memory1 mem)
 %{
   match(Set mem (StoreCM mem zero));
 
@@ -7118,7 +7325,7 @@
 
 // Store CMS card-mark Immediate with intervening StoreStore
 // needed when using CMS with no conditional card marking
-instruct storeimmCM0_ordered(immI0 zero, memory mem)
+instruct storeimmCM0_ordered(immI0 zero, memory1 mem)
 %{
   match(Set mem (StoreCM mem zero));
 
@@ -7133,7 +7340,7 @@
 %}
 
 // Store Byte
-instruct storeB(iRegIorL2I src, memory mem)
+instruct storeB(iRegIorL2I src, memory1 mem)
 %{
   match(Set mem (StoreB mem src));
   predicate(!needs_releasing_store(n));
@@ -7147,7 +7354,7 @@
 %}
 
 
-instruct storeimmB0(immI0 zero, memory mem)
+instruct storeimmB0(immI0 zero, memory1 mem)
 %{
   match(Set mem (StoreB mem zero));
   predicate(!needs_releasing_store(n));
@@ -7161,7 +7368,7 @@
 %}
 
 // Store Char/Short
-instruct storeC(iRegIorL2I src, memory mem)
+instruct storeC(iRegIorL2I src, memory2 mem)
 %{
   match(Set mem (StoreC mem src));
   predicate(!needs_releasing_store(n));
@@ -7174,7 +7381,7 @@
   ins_pipe(istore_reg_mem);
 %}
 
-instruct storeimmC0(immI0 zero, memory mem)
+instruct storeimmC0(immI0 zero, memory2 mem)
 %{
   match(Set mem (StoreC mem zero));
   predicate(!needs_releasing_store(n));
@@ -7189,7 +7396,7 @@
 
 // Store Integer
 
-instruct storeI(iRegIorL2I src, memory mem)
+instruct storeI(iRegIorL2I src, memory4 mem)
 %{
   match(Set mem(StoreI mem src));
   predicate(!needs_releasing_store(n));
@@ -7202,7 +7409,7 @@
   ins_pipe(istore_reg_mem);
 %}
 
-instruct storeimmI0(immI0 zero, memory mem)
+instruct storeimmI0(immI0 zero, memory4 mem)
 %{
   match(Set mem(StoreI mem zero));
   predicate(!needs_releasing_store(n));
@@ -7216,7 +7423,7 @@
 %}
 
 // Store Long (64 bit signed)
-instruct storeL(iRegL src, memory mem)
+instruct storeL(iRegL src, memory8 mem)
 %{
   match(Set mem (StoreL mem src));
   predicate(!needs_releasing_store(n));
@@ -7230,7 +7437,7 @@
 %}
 
 // Store Long (64 bit signed)
-instruct storeimmL0(immL0 zero, memory mem)
+instruct storeimmL0(immL0 zero, memory8 mem)
 %{
   match(Set mem (StoreL mem zero));
   predicate(!needs_releasing_store(n));
@@ -7244,7 +7451,7 @@
 %}
 
 // Store Pointer
-instruct storeP(iRegP src, memory mem)
+instruct storeP(iRegP src, memory8 mem)
 %{
   match(Set mem (StoreP mem src));
   predicate(!needs_releasing_store(n));
@@ -7258,7 +7465,7 @@
 %}
 
 // Store Pointer
-instruct storeimmP0(immP0 zero, memory mem)
+instruct storeimmP0(immP0 zero, memory8 mem)
 %{
   match(Set mem (StoreP mem zero));
   predicate(!needs_releasing_store(n));
@@ -7272,7 +7479,7 @@
 %}
 
 // Store Compressed Pointer
-instruct storeN(iRegN src, memory mem)
+instruct storeN(iRegN src, memory4 mem)
 %{
   match(Set mem (StoreN mem src));
   predicate(!needs_releasing_store(n));
@@ -7285,7 +7492,7 @@
   ins_pipe(istore_reg_mem);
 %}
 
-instruct storeImmN0(iRegIHeapbase heapbase, immN0 zero, memory mem)
+instruct storeImmN0(iRegIHeapbase heapbase, immN0 zero, memory4 mem)
 %{
   match(Set mem (StoreN mem zero));
   predicate(CompressedOops::base() == NULL &&
@@ -7301,7 +7508,7 @@
 %}
 
 // Store Float
-instruct storeF(vRegF src, memory mem)
+instruct storeF(vRegF src, memory4 mem)
 %{
   match(Set mem (StoreF mem src));
   predicate(!needs_releasing_store(n));
@@ -7318,7 +7525,7 @@
 // implement storeImmF0 and storeFImmPacked
 
 // Store Double
-instruct storeD(vRegD src, memory mem)
+instruct storeD(vRegD src, memory8 mem)
 %{
   match(Set mem (StoreD mem src));
   predicate(!needs_releasing_store(n));
@@ -7332,7 +7539,7 @@
 %}
 
 // Store Compressed Klass Pointer
-instruct storeNKlass(iRegN src, memory mem)
+instruct storeNKlass(iRegN src, memory4 mem)
 %{
   predicate(!needs_releasing_store(n));
   match(Set mem (StoreNKlass mem src));
@@ -7351,7 +7558,7 @@
 // prefetch instructions
 // Must be safe to execute with invalid address (cannot fault).
 
-instruct prefetchalloc( memory mem ) %{
+instruct prefetchalloc( memory8 mem ) %{
   match(PrefetchAllocation mem);
 
   ins_cost(INSN_COST);
@@ -7847,7 +8054,7 @@
   ins_pipe(pipe_class_default);
 %}
 
-instruct popCountI_mem(iRegINoSp dst, memory mem, vRegF tmp) %{
+instruct popCountI_mem(iRegINoSp dst, memory4 mem, vRegF tmp) %{
   predicate(UsePopCountInstruction);
   match(Set dst (PopCountI (LoadI mem)));
   effect(TEMP tmp);
@@ -7860,7 +8067,7 @@
   ins_encode %{
     FloatRegister tmp_reg = as_FloatRegister($tmp$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrs, tmp_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+              as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4);
     __ cnt($tmp$$FloatRegister, __ T8B, $tmp$$FloatRegister);
     __ addv($tmp$$FloatRegister, __ T8B, $tmp$$FloatRegister);
     __ mov($dst$$Register, $tmp$$FloatRegister, __ T1D, 0);
@@ -7890,7 +8097,7 @@
   ins_pipe(pipe_class_default);
 %}
 
-instruct popCountL_mem(iRegINoSp dst, memory mem, vRegD tmp) %{
+instruct popCountL_mem(iRegINoSp dst, memory8 mem, vRegD tmp) %{
   predicate(UsePopCountInstruction);
   match(Set dst (PopCountL (LoadL mem)));
   effect(TEMP tmp);
@@ -7903,7 +8110,7 @@
   ins_encode %{
     FloatRegister tmp_reg = as_FloatRegister($tmp$$reg);
     loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldrd, tmp_reg, $mem->opcode(),
-               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp);
+              as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8);
     __ cnt($tmp$$FloatRegister, __ T8B, $tmp$$FloatRegister);
     __ addv($tmp$$FloatRegister, __ T8B, $tmp$$FloatRegister);
     __ mov($dst$$Register, $tmp$$FloatRegister, __ T1D, 0);
@@ -8306,7 +8513,7 @@
 // Sets flag (EQ) on success.
 // implemented using stlxr on AArch64.
 
-instruct storePConditional(memory heap_top_ptr, iRegP oldval, iRegP newval, rFlagsReg cr)
+instruct storePConditional(memory8 heap_top_ptr, iRegP oldval, iRegP newval, rFlagsReg cr)
 %{
   match(Set cr (StorePConditional heap_top_ptr (Binary oldval newval)));
 
diff --git a/src/hotspot/cpu/aarch64/ad_encode.m4 b/src/hotspot/cpu/aarch64/ad_encode.m4
index 44e259a..c8a80b0 100644
--- a/src/hotspot/cpu/aarch64/ad_encode.m4
+++ b/src/hotspot/cpu/aarch64/ad_encode.m4
@@ -1,4 +1,4 @@
-dnl Copyright (c) 2014, Red Hat Inc. All rights reserved.
+dnl Copyright (c) 2014, 2019, Red Hat Inc. All rights reserved.
 dnl DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 dnl
 dnl This code is free software; you can redistribute it and/or modify it
@@ -24,44 +24,50 @@
 dnl patterns used in aarch64.ad.
 dnl
 define(choose, `loadStore($1, &MacroAssembler::$3, $2, $4,
-               $5, $6, $7, $8);dnl
+               $5, $6, $7, $8, $9);dnl
 
   %}')dnl
 define(access, `
     $3Register $1_reg = as_$3Register($$1$$reg);
     $4choose(MacroAssembler(&cbuf), $1_reg,$2,$mem->opcode(),
-        as_Register($mem$$base),$mem$$index,$mem$$scale,$mem$$disp)')dnl
+        as_Register($mem$$base),$mem$$index,$mem$$scale,$mem$$disp,$5)')dnl
 define(load,`
-  enc_class aarch64_enc_$2($1 dst, memory mem) %{dnl
-access(dst,$2,$3)')dnl
-load(iRegI,ldrsbw)
-load(iRegI,ldrsb)
-load(iRegI,ldrb)
-load(iRegL,ldrb)
-load(iRegI,ldrshw)
-load(iRegI,ldrsh)
-load(iRegI,ldrh)
-load(iRegL,ldrh)
-load(iRegI,ldrw)
-load(iRegL,ldrw)
-load(iRegL,ldrsw)
-load(iRegL,ldr)
-load(vRegF,ldrs,Float)
-load(vRegD,ldrd,Float)
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_$2($1 dst, memory$5 mem) %{dnl
+access(dst,$2,$3,$4,$5)')dnl
+load(iRegI,ldrsbw,,,1)
+load(iRegI,ldrsb,,,1)
+load(iRegI,ldrb,,,1)
+load(iRegL,ldrb,,,1)
+load(iRegI,ldrshw,,,2)
+load(iRegI,ldrsh,,,2)
+load(iRegI,ldrh,,,2)
+load(iRegL,ldrh,,,2)
+load(iRegI,ldrw,,,4)
+load(iRegL,ldrw,,,4)
+load(iRegL,ldrsw,,,4)
+load(iRegL,ldr,,,8)
+load(vRegF,ldrs,Float,,4)
+load(vRegD,ldrd,Float,,8)
 define(STORE,`
-  enc_class aarch64_enc_$2($1 src, memory mem) %{dnl
-access(src,$2,$3,$4)')dnl
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_$2($1 src, memory$5 mem) %{dnl
+access(src,$2,$3,$4,$5)')dnl
 define(STORE0,`
-  enc_class aarch64_enc_$2`'0(memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_$2`'0(memory$4 mem) %{
     MacroAssembler _masm(&cbuf);
     choose(_masm,zr,$2,$mem->opcode(),
-        as_$3Register($mem$$base),$mem$$index,$mem$$scale,$mem$$disp)')dnl
-STORE(iRegI,strb)
-STORE0(iRegI,strb)
-STORE(iRegI,strh)
-STORE0(iRegI,strh)
-STORE(iRegI,strw)
-STORE0(iRegI,strw)
+        as_$3Register($mem$$base),$mem$$index,$mem$$scale,$mem$$disp,$4)')dnl
+STORE(iRegI,strb,,,1)
+STORE0(iRegI,strb,,1)
+STORE(iRegI,strh,,,2)
+STORE0(iRegI,strh,,2)
+STORE(iRegI,strw,,,4)
+STORE0(iRegI,strw,,4)
 STORE(iRegL,str,,
 `// we sometimes get asked to store the stack pointer into the
     // current thread -- we cannot do that directly on AArch64
@@ -71,12 +77,14 @@
       __ mov(rscratch2, sp);
       src_reg = rscratch2;
     }
-    ')
-STORE0(iRegL,str)
-STORE(vRegF,strs,Float)
-STORE(vRegD,strd,Float)
+    ',8)
+STORE0(iRegL,str,,8)
+STORE(vRegF,strs,Float,,4)
+STORE(vRegD,strd,Float,,8)
 
-  enc_class aarch64_enc_strw_immn(immN src, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strw_immn(immN src, memory1 mem) %{
     MacroAssembler _masm(&cbuf);
     address con = (address)$src$$constant;
     // need to do this the hard way until we can manage relocs
@@ -84,9 +92,11 @@
     __ movoop(rscratch2, (jobject)con);
     if (con) __ encode_heap_oop_not_null(rscratch2);
     choose(_masm,rscratch2,strw,$mem->opcode(),
-        as_Register($mem$$base),$mem$$index,$mem$$scale,$mem$$disp)
+        as_Register($mem$$base),$mem$$index,$mem$$scale,$mem$$disp, 4)
 
-  enc_class aarch64_enc_strw_immnk(immN src, memory mem) %{
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strw_immnk(immN src, memory4 mem) %{
     MacroAssembler _masm(&cbuf);
     address con = (address)$src$$constant;
     // need to do this the hard way until we can manage relocs
@@ -94,5 +104,14 @@
     __ movoop(rscratch2, (jobject)con);
     __ encode_klass_not_null(rscratch2);
     choose(_masm,rscratch2,strw,$mem->opcode(),
-        as_Register($mem$$base),$mem$$index,$mem$$scale,$mem$$disp)
+        as_Register($mem$$base),$mem$$index,$mem$$scale,$mem$$disp, 4)
+
+  // This encoding class is generated automatically from ad_encode.m4.
+  // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE
+  enc_class aarch64_enc_strb0_ordered(memory4 mem) %{
+      MacroAssembler _masm(&cbuf);
+      __ membar(Assembler::StoreStore);
+      loadStore(_masm, &MacroAssembler::strb, zr, $mem->opcode(),
+               as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1);
+  %}
 
diff --git a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp
index ba670a1..735e8ab 100644
--- a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp
+++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp
@@ -554,7 +554,7 @@
 
   void lea(MacroAssembler *, Register) const;
 
-  static bool offset_ok_for_immed(long offset, int shift = 0) {
+  static bool offset_ok_for_immed(long offset, int shift) {
     unsigned mask = (1 << shift) - 1;
     if (offset < 0 || offset & mask) {
       return (uabs(offset) < (1 << (20 - 12))); // Unscaled offset
diff --git a/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad b/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad
index 5470456..220cae2 100644
--- a/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad
+++ b/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad
@@ -47,7 +47,7 @@
 %}
 
 // Load Pointer
-instruct zLoadP(iRegPNoSp dst, memory mem, rFlagsReg cr)
+instruct zLoadP(iRegPNoSp dst, memory8 mem, rFlagsReg cr)
 %{
   match(Set dst (LoadP mem));
   predicate(UseZGC && !needs_acquiring_load(n) && (n->as_Load()->barrier_data() == ZLoadBarrierStrong));
@@ -69,7 +69,7 @@
 %}
 
 // Load Weak Pointer
-instruct zLoadWeakP(iRegPNoSp dst, memory mem, rFlagsReg cr)
+instruct zLoadWeakP(iRegPNoSp dst, memory8 mem, rFlagsReg cr)
 %{
   match(Set dst (LoadP mem));
   predicate(UseZGC && !needs_acquiring_load(n) && (n->as_Load()->barrier_data() == ZLoadBarrierWeak));
diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
index 17ff982..34b6c75 100644
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
@@ -1741,7 +1741,7 @@
   {
     unsigned long word_offset = byte_offset >> shift;
     unsigned long masked_offset = word_offset & 0xfff000;
-    if (Address::offset_ok_for_immed(word_offset - masked_offset)
+    if (Address::offset_ok_for_immed(word_offset - masked_offset, 0)
         && Assembler::operand_valid_for_add_sub_immediate(masked_offset << shift)) {
       add(Rd, base, masked_offset << shift);
       word_offset -= masked_offset;
diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
index b79ceda..34973d4 100644
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
@@ -136,6 +136,20 @@
     a.lea(this, r);
   }
 
+  /* Sometimes we get misaligned loads and stores, usually from Unsafe
+     accesses, and these can exceed the offset range. */
+  Address legitimize_address(const Address &a, int size, Register scratch) {
+    if (a.getMode() == Address::base_plus_offset) {
+      if (! Address::offset_ok_for_immed(a.offset(), exact_log2(size))) {
+        block_comment("legitimize_address {");
+        lea(scratch, a);
+        block_comment("} legitimize_address");
+        return Address(scratch);
+      }
+    }
+    return a;
+  }
+
   void addmw(Address a, Register incr, Register scratch) {
     ldrw(scratch, a);
     addw(scratch, scratch, incr);
diff --git a/test/hotspot/jtreg/compiler/unsafe/MisalignedAccesses.java b/test/hotspot/jtreg/compiler/unsafe/MisalignedAccesses.java
new file mode 100644
index 0000000..5f1d4ac
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/unsafe/MisalignedAccesses.java
@@ -0,0 +1,767 @@
+/*
+ * 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
+ * @bug 8235385
+ * @summary Crash on aarch64 JDK due to long offset
+ *
+ * @modules jdk.unsupported/sun.misc
+ * @run testng/othervm -Diters=20000 -XX:-TieredCompilation  compiler.unsafe.MisalignedAccesses
+ */
+
+package compiler.unsafe;
+
+import org.testng.annotations.Test;
+
+import java.lang.reflect.Field;
+
+import static org.testng.Assert.*;
+
+public class MisalignedAccesses {
+    static final int ITERS = Integer.getInteger("iters", 1);
+
+    static final sun.misc.Unsafe UNSAFE;
+
+    static final long BYTE_ARRAY_OFFSET;
+
+    static final byte[] byteArray = new byte[4096];
+
+    static {
+        try {
+            Field f = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
+            f.setAccessible(true);
+            UNSAFE = (sun.misc.Unsafe) f.get(null);
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to get Unsafe instance.", e);
+        }
+        BYTE_ARRAY_OFFSET = UNSAFE.arrayBaseOffset(byte[].class);
+    }
+
+    @Test
+    static long testBytes() {
+        long sum = 0;
+        sum += UNSAFE.getByte(byteArray, 1 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 38 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 75 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 112 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 149 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 186 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 223 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 260 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 297 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 334 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 371 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 408 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 445 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 482 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 519 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 556 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 593 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 630 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 667 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 704 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 741 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 778 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 815 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 852 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 889 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 926 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 963 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1000 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1037 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1074 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1111 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1148 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1185 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1222 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1259 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1296 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1333 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1370 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1407 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1444 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1481 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1518 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1555 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1592 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1629 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1666 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1703 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1740 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1777 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1814 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1851 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1888 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1925 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1962 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 1999 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2036 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2073 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2110 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2147 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2184 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2221 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2258 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2295 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2332 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2369 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2406 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2443 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2480 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2517 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2554 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2591 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2628 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2665 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2702 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2739 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2776 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2813 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2850 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2887 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2924 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2961 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 2998 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3035 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3072 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3109 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3146 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3183 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3220 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3257 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3294 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3331 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3368 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3405 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3442 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3479 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3516 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3553 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3590 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3627 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3664 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3701 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3738 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3775 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3812 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3849 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3886 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3923 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3960 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getByte(byteArray, 3997 + BYTE_ARRAY_OFFSET);
+        return sum;
+    }
+
+    @Test
+    static long testShorts() {
+        long sum = 0;
+        sum += UNSAFE.getShort(byteArray, 1 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 38 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 75 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 112 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 149 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 186 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 223 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 260 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 297 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 334 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 371 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 408 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 445 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 482 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 519 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 556 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 593 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 630 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 667 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 704 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 741 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 778 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 815 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 852 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 889 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 926 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 963 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1000 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1037 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1074 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1111 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1148 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1185 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1222 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1259 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1296 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1333 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1370 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1407 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1444 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1481 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1518 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1555 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1592 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1629 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1666 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1703 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1740 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1777 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1814 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1851 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1888 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1925 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1962 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 1999 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2036 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2073 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2110 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2147 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2184 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2221 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2258 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2295 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2332 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2369 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2406 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2443 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2480 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2517 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2554 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2591 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2628 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2665 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2702 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2739 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2776 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2813 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2850 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2887 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2924 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2961 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 2998 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3035 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3072 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3109 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3146 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3183 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3220 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3257 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3294 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3331 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3368 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3405 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3442 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3479 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3516 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3553 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3590 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3627 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3664 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3701 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3738 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3775 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3812 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3849 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3886 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3923 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3960 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getShort(byteArray, 3997 + BYTE_ARRAY_OFFSET);
+        return sum;
+    }
+
+    @Test
+    static long testInts() {
+        long sum = 0;
+        sum += UNSAFE.getInt(byteArray, 1 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 38 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 75 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 112 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 149 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 186 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 223 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 260 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 297 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 334 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 371 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 408 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 445 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 482 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 519 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 556 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 593 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 630 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 667 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 704 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 741 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 778 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 815 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 852 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 889 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 926 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 963 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1000 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1037 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1074 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1111 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1148 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1185 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1222 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1259 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1296 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1333 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1370 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1407 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1444 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1481 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1518 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1555 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1592 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1629 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1666 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1703 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1740 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1777 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1814 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1851 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1888 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1925 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1962 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 1999 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2036 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2073 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2110 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2147 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2184 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2221 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2258 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2295 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2332 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2369 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2406 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2443 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2480 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2517 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2554 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2591 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2628 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2665 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2702 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2739 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2776 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2813 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2850 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2887 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2924 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2961 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 2998 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3035 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3072 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3109 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3146 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3183 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3220 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3257 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3294 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3331 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3368 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3405 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3442 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3479 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3516 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3553 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3590 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3627 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3664 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3701 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3738 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3775 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3812 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3849 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3886 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3923 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3960 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getInt(byteArray, 3997 + BYTE_ARRAY_OFFSET);
+        return sum;
+    }
+
+    @Test
+    static long testLongs() {
+        long sum = 0;
+        sum += UNSAFE.getLong(byteArray, 1 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 38 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 75 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 112 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 149 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 186 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 223 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 260 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 297 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 334 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 371 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 408 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 445 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 482 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 519 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 556 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 593 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 630 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 667 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 704 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 741 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 778 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 815 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 852 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 889 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 926 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 963 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1000 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1037 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1074 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1111 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1148 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1185 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1222 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1259 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1296 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1333 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1370 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1407 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1444 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1481 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1518 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1555 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1592 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1629 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1666 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1703 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1740 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1777 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1814 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1851 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1888 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1925 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1962 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 1999 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2036 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2073 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2110 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2147 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2184 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2221 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2258 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2295 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2332 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2369 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2406 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2443 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2480 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2517 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2554 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2591 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2628 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2665 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2702 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2739 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2776 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2813 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2850 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2887 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2924 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2961 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 2998 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3035 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3072 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3109 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3146 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3183 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3220 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3257 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3294 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3331 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3368 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3405 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3442 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3479 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3516 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3553 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3590 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3627 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3664 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3701 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3738 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3775 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3812 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3849 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3886 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3923 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3960 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getLong(byteArray, 3997 + BYTE_ARRAY_OFFSET);
+        return sum;
+    }
+
+    @Test
+    static long testFloats() {
+        long sum = 0;
+        sum += UNSAFE.getFloat(byteArray, 1 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 38 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 75 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 112 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 149 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 186 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 223 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 260 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 297 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 334 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 371 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 408 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 445 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 482 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 519 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 556 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 593 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 630 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 667 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 704 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 741 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 778 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 815 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 852 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 889 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 926 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 963 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1000 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1037 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1074 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1111 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1148 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1185 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1222 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1259 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1296 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1333 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1370 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1407 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1444 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1481 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1518 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1555 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1592 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1629 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1666 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1703 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1740 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1777 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1814 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1851 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1888 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1925 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1962 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 1999 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2036 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2073 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2110 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2147 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2184 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2221 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2258 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2295 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2332 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2369 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2406 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2443 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2480 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2517 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2554 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2591 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2628 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2665 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2702 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2739 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2776 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2813 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2850 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2887 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2924 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2961 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 2998 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3035 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3072 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3109 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3146 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3183 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3220 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3257 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3294 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3331 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3368 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3405 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3442 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3479 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3516 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3553 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3590 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3627 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3664 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3701 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3738 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3775 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3812 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3849 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3886 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3923 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3960 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getFloat(byteArray, 3997 + BYTE_ARRAY_OFFSET);
+        return sum;
+    }
+
+    @Test
+    static long testDoubles() {
+        long sum = 0;
+        sum += UNSAFE.getDouble(byteArray, 1 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 38 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 75 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 112 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 149 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 186 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 223 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 260 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 297 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 334 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 371 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 408 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 445 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 482 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 519 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 556 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 593 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 630 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 667 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 704 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 741 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 778 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 815 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 852 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 889 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 926 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 963 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1000 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1037 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1074 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1111 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1148 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1185 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1222 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1259 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1296 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1333 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1370 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1407 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1444 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1481 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1518 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1555 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1592 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1629 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1666 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1703 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1740 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1777 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1814 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1851 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1888 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1925 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1962 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 1999 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2036 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2073 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2110 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2147 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2184 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2221 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2258 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2295 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2332 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2369 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2406 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2443 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2480 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2517 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2554 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2591 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2628 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2665 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2702 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2739 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2776 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2813 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2850 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2887 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2924 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2961 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 2998 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3035 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3072 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3109 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3146 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3183 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3220 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3257 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3294 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3331 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3368 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3405 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3442 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3479 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3516 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3553 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3590 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3627 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3664 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3701 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3738 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3775 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3812 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3849 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3886 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3923 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3960 + BYTE_ARRAY_OFFSET);
+        sum += UNSAFE.getDouble(byteArray, 3997 + BYTE_ARRAY_OFFSET);
+        return sum;
+    }
+
+
+    static volatile long result;
+
+    public static void main(String[] args) {
+        for (int i = 0; i < ITERS; i++) {
+            result += testBytes();
+            result += testShorts();
+            result += testInts();
+            result += testLongs();
+            result += testFloats();
+            result += testDoubles();
+        }
+    }
+}
+
+