# HG changeset patch # User aph # Date 1576177532 18000 # Thu Dec 12 14:05:32 2019 -0500 # Node ID cc15d91bac2d15ef2ba8aff68c7126985c4264f7 # Parent 27d52615ba1b9d0538e29d51e3d7d85c5d3c112a 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 --- a/src/hotspot/cpu/aarch64/aarch64.ad +++ b/src/hotspot/cpu/aarch64/aarch64.ad @@ -2545,15 +2545,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; @@ -2566,8 +2578,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)); @@ -2633,152 +2652,169 @@ // 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); - %} - - enc_class aarch64_enc_ldrsb(iRegI dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrb(iRegI dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrb(iRegL dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrshw(iRegI dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrsh(iRegI dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrh(iRegI dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrh(iRegL dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrw(iRegI dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrw(iRegL dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrsw(iRegL dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldr(iRegL dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrs(vRegF dst, memory mem) %{ + 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_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); - %} - - enc_class aarch64_enc_ldrd(vRegD dst, memory mem) %{ + 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_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); - %} - - 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, - $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp); - %} - - enc_class aarch64_enc_ldrvD(vecD dst, memory mem) %{ - FloatRegister dst_reg = as_FloatRegister($dst$$reg); - loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldr, dst_reg, MacroAssembler::D, - $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp); - %} - - enc_class aarch64_enc_ldrvQ(vecX dst, memory mem) %{ - FloatRegister dst_reg = as_FloatRegister($dst$$reg); - loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldr, dst_reg, MacroAssembler::Q, - $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp); - %} - - enc_class aarch64_enc_strb(iRegI src, memory mem) %{ + 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); - %} - - enc_class aarch64_enc_strb0(memory mem) %{ + 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); - %} - - 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) %{ + 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); - %} - - enc_class aarch64_enc_strh0(memory mem) %{ + 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); - %} - - enc_class aarch64_enc_strw(iRegI src, memory mem) %{ + 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); - %} - - enc_class aarch64_enc_strw0(memory mem) %{ + 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); - %} - - enc_class aarch64_enc_str(iRegL src, memory mem) %{ + 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 @@ -2789,25 +2825,87 @@ 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) %{ + 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); - %} - - enc_class aarch64_enc_strs(vRegF src, memory mem) %{ + 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); - %} - - enc_class aarch64_enc_strd(vRegD src, memory mem) %{ + 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); + 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, + $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp); + %} + + enc_class aarch64_enc_ldrvD(vecD dst, memory mem) %{ + FloatRegister dst_reg = as_FloatRegister($dst$$reg); + loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldr, dst_reg, MacroAssembler::D, + $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp); + %} + + enc_class aarch64_enc_ldrvQ(vecX dst, memory mem) %{ + FloatRegister dst_reg = as_FloatRegister($dst$$reg); + loadStore(MacroAssembler(&cbuf), &MacroAssembler::ldr, dst_reg, MacroAssembler::Q, + $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp); %} enc_class aarch64_enc_strvS(vecD src, memory mem) %{ @@ -2828,8 +2926,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) %{ @@ -2959,7 +3055,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); @@ -2988,7 +3084,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); @@ -4116,7 +4212,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); @@ -4156,7 +4272,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); @@ -5301,7 +5437,7 @@ %} %} -operand indOffI4(iRegP reg, immIOffset4 off) +operand indOffI1(iRegP reg, immIOffset1 off) %{ constraint(ALLOC_IN_RC(ptr_reg)); match(AddP reg off); @@ -5315,7 +5451,7 @@ %} %} -operand indOffI8(iRegP reg, immIOffset8 off) +operand indOffI2(iRegP reg, immIOffset2 off) %{ constraint(ALLOC_IN_RC(ptr_reg)); match(AddP reg off); @@ -5329,7 +5465,7 @@ %} %} -operand indOffI16(iRegP reg, immIOffset16 off) +operand indOffI4(iRegP reg, immIOffset4 off) %{ constraint(ALLOC_IN_RC(ptr_reg)); match(AddP reg off); @@ -5343,6 +5479,34 @@ %} %} +operand indOffI8(iRegP reg, immIOffset8 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 indOffI16(iRegP reg, immIOffset16 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 indOffL(iRegP reg, immLoffset off) %{ constraint(ALLOC_IN_RC(ptr_reg)); @@ -5357,6 +5521,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)); @@ -5752,9 +5944,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 @@ -6738,7 +6945,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)); @@ -6752,7 +6959,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))); @@ -6766,7 +6973,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)); @@ -6780,7 +6987,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))); @@ -6794,7 +7001,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)); @@ -6808,7 +7015,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))); @@ -6822,7 +7029,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)); @@ -6836,7 +7043,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))); @@ -6850,7 +7057,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)); @@ -6864,7 +7071,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))); @@ -6878,7 +7085,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())); @@ -6892,7 +7099,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)); @@ -6906,7 +7113,7 @@ %} // Load Range -instruct loadRange(iRegINoSp dst, memory mem) +instruct loadRange(iRegINoSp dst, memory8 mem) %{ match(Set dst (LoadRange mem)); @@ -6919,7 +7126,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)); @@ -6933,7 +7140,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)); @@ -6947,7 +7154,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)); @@ -6961,7 +7168,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)); @@ -6975,7 +7182,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)); @@ -6989,7 +7196,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)); @@ -7207,7 +7414,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)); @@ -7222,7 +7429,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)); @@ -7237,7 +7444,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)); @@ -7251,7 +7458,7 @@ %} -instruct storeimmB0(immI0 zero, memory mem) +instruct storeimmB0(immI0 zero, memory1 mem) %{ match(Set mem (StoreB mem zero)); predicate(!needs_releasing_store(n)); @@ -7265,7 +7472,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)); @@ -7278,7 +7485,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)); @@ -7293,7 +7500,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)); @@ -7306,7 +7513,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)); @@ -7320,7 +7527,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)); @@ -7334,7 +7541,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)); @@ -7348,7 +7555,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)); @@ -7362,7 +7569,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)); @@ -7376,7 +7583,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)); @@ -7389,7 +7596,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 && @@ -7405,7 +7612,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)); @@ -7422,7 +7629,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)); @@ -7436,7 +7643,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)); @@ -7455,7 +7662,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); @@ -7951,7 +8158,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); @@ -7964,7 +8171,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, sizeof (jfloat)); __ cnt($tmp$$FloatRegister, __ T8B, $tmp$$FloatRegister); __ addv($tmp$$FloatRegister, __ T8B, $tmp$$FloatRegister); __ mov($dst$$Register, $tmp$$FloatRegister, __ T1D, 0); @@ -7994,7 +8201,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); @@ -8007,7 +8214,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, sizeof (jdouble)); __ cnt($tmp$$FloatRegister, __ T8B, $tmp$$FloatRegister); __ addv($tmp$$FloatRegister, __ T8B, $tmp$$FloatRegister); __ mov($dst$$Register, $tmp$$FloatRegister, __ T1D, 0); @@ -8410,7 +8617,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 --- 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 --- 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 --- 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 --- 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 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp @@ -133,6 +133,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 --- /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(); + } + } +} + +