changeset 39419:cc993a4ab581

8157726: VarHandles/Unsafe should support sub-word atomic ops Reviewed-by: psandoz, vlivanov, lagergren
author shade
date Wed, 15 Jun 2016 11:21:36 +0300
parents 6b03cc6f758a
children 987528901b83
files hotspot/src/cpu/x86/vm/assembler_x86.cpp hotspot/src/cpu/x86/vm/assembler_x86.hpp hotspot/src/cpu/x86/vm/x86_32.ad hotspot/src/cpu/x86/vm/x86_64.ad hotspot/src/share/vm/adlc/formssel.cpp hotspot/src/share/vm/classfile/vmSymbols.hpp hotspot/src/share/vm/opto/c2compiler.cpp hotspot/src/share/vm/opto/classes.hpp hotspot/src/share/vm/opto/compile.cpp hotspot/src/share/vm/opto/library_call.cpp hotspot/src/share/vm/opto/loopTransform.cpp hotspot/src/share/vm/opto/matcher.cpp hotspot/src/share/vm/opto/memnode.hpp hotspot/src/share/vm/runtime/vmStructs.cpp hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template hotspot/test/compiler/unsafe/generate-unsafe-access-tests.sh
diffstat 27 files changed, 1333 insertions(+), 244 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Wed Jun 15 11:21:36 2016 +0300
@@ -1173,6 +1173,23 @@
   emit_arith_operand(0x81, rax, dst, imm32);
 }
 
+void Assembler::addb(Address dst, int imm8) {
+  InstructionMark im(this);
+  prefix(dst);
+  emit_int8((unsigned char)0x80);
+  emit_operand(rax, dst, 1);
+  emit_int8(imm8);
+}
+
+void Assembler::addw(Address dst, int imm16) {
+  InstructionMark im(this);
+  emit_int8(0x66);
+  prefix(dst);
+  emit_int8((unsigned char)0x81);
+  emit_operand(rax, dst, 2);
+  emit_int16(imm16);
+}
+
 void Assembler::addl(Address dst, Register src) {
   InstructionMark im(this);
   prefix(dst, src);
@@ -4567,6 +4584,23 @@
   emit_int8((unsigned char)(imm8 & 0xFF));
 }
 
+void Assembler::xaddb(Address dst, Register src) {
+  InstructionMark im(this);
+  prefix(dst, src, true);
+  emit_int8(0x0F);
+  emit_int8((unsigned char)0xC0);
+  emit_operand(src, dst);
+}
+
+void Assembler::xaddw(Address dst, Register src) {
+  InstructionMark im(this);
+  emit_int8(0x66);
+  prefix(dst, src);
+  emit_int8(0x0F);
+  emit_int8((unsigned char)0xC1);
+  emit_operand(src, dst);
+}
+
 void Assembler::xaddl(Address dst, Register src) {
   InstructionMark im(this);
   prefix(dst, src);
@@ -4593,6 +4627,21 @@
   }
 }
 
+void Assembler::xchgb(Register dst, Address src) { // xchg
+  InstructionMark im(this);
+  prefix(src, dst, true);
+  emit_int8((unsigned char)0x86);
+  emit_operand(dst, src);
+}
+
+void Assembler::xchgw(Register dst, Address src) { // xchg
+  InstructionMark im(this);
+  emit_int8(0x66);
+  prefix(src, dst);
+  emit_int8((unsigned char)0x87);
+  emit_operand(dst, src);
+}
+
 void Assembler::xchgl(Register dst, Address src) { // xchg
   InstructionMark im(this);
   prefix(src, dst);
--- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp	Wed Jun 15 11:21:36 2016 +0300
@@ -881,6 +881,9 @@
   void adcq(Register dst, Address src);
   void adcq(Register dst, Register src);
 
+  void addb(Address dst, int imm8);
+  void addw(Address dst, int imm16);
+
   void addl(Address dst, int32_t imm32);
   void addl(Address dst, Register src);
   void addl(Register dst, int32_t imm32);
@@ -1816,12 +1819,15 @@
 
   void xabort(int8_t imm8);
 
+  void xaddb(Address dst, Register src);
+  void xaddw(Address dst, Register src);
   void xaddl(Address dst, Register src);
-
   void xaddq(Address dst, Register src);
 
   void xbegin(Label& abort, relocInfo::relocType rtype = relocInfo::none);
 
+  void xchgb(Register reg, Address adr);
+  void xchgw(Register reg, Address adr);
   void xchgl(Register reg, Address adr);
   void xchgl(Register dst, Register src);
 
--- a/hotspot/src/cpu/x86/vm/x86_32.ad	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad	Wed Jun 15 11:21:36 2016 +0300
@@ -2127,6 +2127,31 @@
     emit_rm( cbuf, 0x0, 1, $mem_ptr$$reg );
   %}
 
+  enc_class enc_cmpxchgb(eSIRegP mem_ptr) %{
+    // [Lock]
+    if( os::is_MP() )
+      emit_opcode(cbuf,0xF0);
+
+    // CMPXCHGB [Eptr]
+    emit_opcode(cbuf,0x0F);
+    emit_opcode(cbuf,0xB0);
+    emit_rm( cbuf, 0x0, 1, $mem_ptr$$reg );
+  %}
+
+  enc_class enc_cmpxchgw(eSIRegP mem_ptr) %{
+    // [Lock]
+    if( os::is_MP() )
+      emit_opcode(cbuf,0xF0);
+
+    // 16-bit mode
+    emit_opcode(cbuf, 0x66);
+
+    // CMPXCHGW [Eptr]
+    emit_opcode(cbuf,0x0F);
+    emit_opcode(cbuf,0xB1);
+    emit_rm( cbuf, 0x0, 1, $mem_ptr$$reg );
+  %}
+
   enc_class enc_flags_ne_to_boolean( iRegI res ) %{
     int res_encoding = $res$$reg;
 
@@ -7262,6 +7287,34 @@
   ins_pipe( pipe_cmpxchg );
 %}
 
+instruct compareAndSwapB( rRegI res, pRegP mem_ptr, eAXRegI oldval, eCXRegI newval, eFlagsReg cr ) %{
+  match(Set res (CompareAndSwapB mem_ptr (Binary oldval newval)));
+  match(Set res (WeakCompareAndSwapB mem_ptr (Binary oldval newval)));
+  effect(KILL cr, KILL oldval);
+  format %{ "CMPXCHGB [$mem_ptr],$newval\t# If EAX==[$mem_ptr] Then store $newval into [$mem_ptr]\n\t"
+            "MOV    $res,0\n\t"
+            "JNE,s  fail\n\t"
+            "MOV    $res,1\n"
+          "fail:" %}
+  ins_encode( enc_cmpxchgb(mem_ptr),
+              enc_flags_ne_to_boolean(res) );
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct compareAndSwapS( rRegI res, pRegP mem_ptr, eAXRegI oldval, eCXRegI newval, eFlagsReg cr ) %{
+  match(Set res (CompareAndSwapS mem_ptr (Binary oldval newval)));
+  match(Set res (WeakCompareAndSwapS mem_ptr (Binary oldval newval)));
+  effect(KILL cr, KILL oldval);
+  format %{ "CMPXCHGW [$mem_ptr],$newval\t# If EAX==[$mem_ptr] Then store $newval into [$mem_ptr]\n\t"
+            "MOV    $res,0\n\t"
+            "JNE,s  fail\n\t"
+            "MOV    $res,1\n"
+          "fail:" %}
+  ins_encode( enc_cmpxchgw(mem_ptr),
+              enc_flags_ne_to_boolean(res) );
+  ins_pipe( pipe_cmpxchg );
+%}
+
 instruct compareAndSwapI( rRegI res, pRegP mem_ptr, eAXRegI oldval, eCXRegI newval, eFlagsReg cr) %{
   match(Set res (CompareAndSwapI mem_ptr (Binary oldval newval)));
   match(Set res (WeakCompareAndSwapI mem_ptr (Binary oldval newval)));
@@ -7292,6 +7345,22 @@
   ins_pipe( pipe_cmpxchg );
 %}
 
+instruct compareAndExchangeB( pRegP mem_ptr, eAXRegI oldval, eCXRegI newval, eFlagsReg cr) %{
+  match(Set oldval (CompareAndExchangeB mem_ptr (Binary oldval newval)));
+  effect(KILL cr);
+  format %{ "CMPXCHGB [$mem_ptr],$newval\t# If EAX==[$mem_ptr] Then store $newval into [$mem_ptr]\n\t" %}
+  ins_encode( enc_cmpxchgb(mem_ptr) );
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct compareAndExchangeS( pRegP mem_ptr, eAXRegI oldval, eCXRegI newval, eFlagsReg cr) %{
+  match(Set oldval (CompareAndExchangeS mem_ptr (Binary oldval newval)));
+  effect(KILL cr);
+  format %{ "CMPXCHGW [$mem_ptr],$newval\t# If EAX==[$mem_ptr] Then store $newval into [$mem_ptr]\n\t" %}
+  ins_encode( enc_cmpxchgw(mem_ptr) );
+  ins_pipe( pipe_cmpxchg );
+%}
+
 instruct compareAndExchangeI( pRegP mem_ptr, eAXRegI oldval, eCXRegI newval, eFlagsReg cr) %{
   match(Set oldval (CompareAndExchangeI mem_ptr (Binary oldval newval)));
   effect(KILL cr);
@@ -7300,6 +7369,53 @@
   ins_pipe( pipe_cmpxchg );
 %}
 
+instruct xaddB_no_res( memory mem, Universe dummy, immI add, eFlagsReg cr) %{
+  predicate(n->as_LoadStore()->result_not_used());
+  match(Set dummy (GetAndAddB mem add));
+  effect(KILL cr);
+  format %{ "ADDB  [$mem],$add" %}
+  ins_encode %{
+    if (os::is_MP()) { __ lock(); }
+    __ addb($mem$$Address, $add$$constant);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
+// Important to match to xRegI: only 8-bit regs.
+instruct xaddB( memory mem, xRegI newval, eFlagsReg cr) %{
+  match(Set newval (GetAndAddB mem newval));
+  effect(KILL cr);
+  format %{ "XADDB  [$mem],$newval" %}
+  ins_encode %{
+    if (os::is_MP()) { __ lock(); }
+    __ xaddb($mem$$Address, $newval$$Register);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct xaddS_no_res( memory mem, Universe dummy, immI add, eFlagsReg cr) %{
+  predicate(n->as_LoadStore()->result_not_used());
+  match(Set dummy (GetAndAddS mem add));
+  effect(KILL cr);
+  format %{ "ADDS  [$mem],$add" %}
+  ins_encode %{
+    if (os::is_MP()) { __ lock(); }
+    __ addw($mem$$Address, $add$$constant);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct xaddS( memory mem, rRegI newval, eFlagsReg cr) %{
+  match(Set newval (GetAndAddS mem newval));
+  effect(KILL cr);
+  format %{ "XADDS  [$mem],$newval" %}
+  ins_encode %{
+    if (os::is_MP()) { __ lock(); }
+    __ xaddw($mem$$Address, $newval$$Register);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
 instruct xaddI_no_res( memory mem, Universe dummy, immI add, eFlagsReg cr) %{
   predicate(n->as_LoadStore()->result_not_used());
   match(Set dummy (GetAndAddI mem add));
@@ -7323,6 +7439,25 @@
   ins_pipe( pipe_cmpxchg );
 %}
 
+// Important to match to xRegI: only 8-bit regs.
+instruct xchgB( memory mem, xRegI newval) %{
+  match(Set newval (GetAndSetB mem newval));
+  format %{ "XCHGB  $newval,[$mem]" %}
+  ins_encode %{
+    __ xchgb($newval$$Register, $mem$$Address);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct xchgS( memory mem, rRegI newval) %{
+  match(Set newval (GetAndSetS mem newval));
+  format %{ "XCHGW  $newval,[$mem]" %}
+  ins_encode %{
+    __ xchgw($newval$$Register, $mem$$Address);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
 instruct xchgI( memory mem, rRegI newval) %{
   match(Set newval (GetAndSetI mem newval));
   format %{ "XCHGL  $newval,[$mem]" %}
--- a/hotspot/src/cpu/x86/vm/x86_64.ad	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad	Wed Jun 15 11:21:36 2016 +0300
@@ -7340,6 +7340,54 @@
   ins_pipe( pipe_cmpxchg );
 %}
 
+instruct compareAndSwapB(rRegI res,
+                         memory mem_ptr,
+                         rax_RegI oldval, rRegI newval,
+                         rFlagsReg cr)
+%{
+  match(Set res (CompareAndSwapB mem_ptr (Binary oldval newval)));
+  match(Set res (WeakCompareAndSwapB mem_ptr (Binary oldval newval)));
+  effect(KILL cr, KILL oldval);
+
+  format %{ "cmpxchgb $mem_ptr,$newval\t# "
+            "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"
+            "sete    $res\n\t"
+            "movzbl  $res, $res" %}
+  opcode(0x0F, 0xB0);
+  ins_encode(lock_prefix,
+             REX_reg_mem(newval, mem_ptr),
+             OpcP, OpcS,
+             reg_mem(newval, mem_ptr),
+             REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete
+             REX_reg_breg(res, res), // movzbl
+             Opcode(0xF), Opcode(0xB6), reg_reg(res, res));
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct compareAndSwapS(rRegI res,
+                         memory mem_ptr,
+                         rax_RegI oldval, rRegI newval,
+                         rFlagsReg cr)
+%{
+  match(Set res (CompareAndSwapS mem_ptr (Binary oldval newval)));
+  match(Set res (WeakCompareAndSwapS mem_ptr (Binary oldval newval)));
+  effect(KILL cr, KILL oldval);
+
+  format %{ "cmpxchgw $mem_ptr,$newval\t# "
+            "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"
+            "sete    $res\n\t"
+            "movzbl  $res, $res" %}
+  opcode(0x0F, 0xB1);
+  ins_encode(lock_prefix,
+             SizePrefix,
+             REX_reg_mem(newval, mem_ptr),          
+             OpcP, OpcS,
+             reg_mem(newval, mem_ptr),
+             REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete
+             REX_reg_breg(res, res), // movzbl
+             Opcode(0xF), Opcode(0xB6), reg_reg(res, res));
+  ins_pipe( pipe_cmpxchg );
+%}
 
 instruct compareAndSwapN(rRegI res,
                           memory mem_ptr,
@@ -7364,6 +7412,45 @@
   ins_pipe( pipe_cmpxchg );
 %}
 
+instruct compareAndExchangeB(
+                         memory mem_ptr,
+                         rax_RegI oldval, rRegI newval,
+                         rFlagsReg cr)
+%{
+  match(Set oldval (CompareAndExchangeB mem_ptr (Binary oldval newval)));
+  effect(KILL cr);
+
+  format %{ "cmpxchgb $mem_ptr,$newval\t# "
+            "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"  %}
+  opcode(0x0F, 0xB0);
+  ins_encode(lock_prefix,
+             REX_reg_mem(newval, mem_ptr),
+             OpcP, OpcS,
+             reg_mem(newval, mem_ptr) // lock cmpxchg
+             );
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct compareAndExchangeS(
+                         memory mem_ptr,
+                         rax_RegI oldval, rRegI newval,
+                         rFlagsReg cr)
+%{
+  match(Set oldval (CompareAndExchangeS mem_ptr (Binary oldval newval)));
+  effect(KILL cr);
+
+  format %{ "cmpxchgw $mem_ptr,$newval\t# "
+            "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"  %}
+  opcode(0x0F, 0xB1);
+  ins_encode(lock_prefix,
+             SizePrefix,
+             REX_reg_mem(newval, mem_ptr),
+             OpcP, OpcS,
+             reg_mem(newval, mem_ptr) // lock cmpxchg
+             );
+  ins_pipe( pipe_cmpxchg );
+%}
+
 instruct compareAndExchangeI(
                          memory mem_ptr,
                          rax_RegI oldval, rRegI newval,
@@ -7441,6 +7528,52 @@
   ins_pipe( pipe_cmpxchg );
 %}
 
+instruct xaddB_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
+  predicate(n->as_LoadStore()->result_not_used());
+  match(Set dummy (GetAndAddB mem add));
+  effect(KILL cr);
+  format %{ "ADDB  [$mem],$add" %}
+  ins_encode %{
+    if (os::is_MP()) { __ lock(); }
+    __ addb($mem$$Address, $add$$constant);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct xaddB( memory mem, rRegI newval, rFlagsReg cr) %{
+  match(Set newval (GetAndAddB mem newval));
+  effect(KILL cr);
+  format %{ "XADDB  [$mem],$newval" %}
+  ins_encode %{
+    if (os::is_MP()) { __ lock(); }
+    __ xaddb($mem$$Address, $newval$$Register);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct xaddS_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
+  predicate(n->as_LoadStore()->result_not_used());
+  match(Set dummy (GetAndAddS mem add));
+  effect(KILL cr);
+  format %{ "ADDW  [$mem],$add" %}
+  ins_encode %{
+    if (os::is_MP()) { __ lock(); }
+    __ addw($mem$$Address, $add$$constant);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct xaddS( memory mem, rRegI newval, rFlagsReg cr) %{
+  match(Set newval (GetAndAddS mem newval));
+  effect(KILL cr);
+  format %{ "XADDW  [$mem],$newval" %}
+  ins_encode %{
+    if (os::is_MP()) { __ lock(); }
+    __ xaddw($mem$$Address, $newval$$Register);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
 instruct xaddI_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
   predicate(n->as_LoadStore()->result_not_used());
   match(Set dummy (GetAndAddI mem add));
@@ -7487,6 +7620,24 @@
   ins_pipe( pipe_cmpxchg );
 %}
 
+instruct xchgB( memory mem, rRegI newval) %{
+  match(Set newval (GetAndSetB mem newval));
+  format %{ "XCHGB  $newval,[$mem]" %}
+  ins_encode %{
+    __ xchgb($newval$$Register, $mem$$Address);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
+instruct xchgS( memory mem, rRegI newval) %{
+  match(Set newval (GetAndSetS mem newval));
+  format %{ "XCHGW  $newval,[$mem]" %}
+  ins_encode %{
+    __ xchgw($newval$$Register, $mem$$Address);
+  %}
+  ins_pipe( pipe_cmpxchg );
+%}
+
 instruct xchgI( memory mem, rRegI newval) %{
   match(Set newval (GetAndSetI mem newval));
   format %{ "XCHGL  $newval,[$mem]" %}
--- a/hotspot/src/share/vm/adlc/formssel.cpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/share/vm/adlc/formssel.cpp	Wed Jun 15 11:21:36 2016 +0300
@@ -3491,13 +3491,13 @@
     "LoadRange", "LoadKlass", "LoadNKlass", "LoadL_unaligned", "LoadD_unaligned",
     "LoadPLocked",
     "StorePConditional", "StoreIConditional", "StoreLConditional",
-    "CompareAndSwapI", "CompareAndSwapL", "CompareAndSwapP", "CompareAndSwapN",
-    "WeakCompareAndSwapI", "WeakCompareAndSwapL", "WeakCompareAndSwapP", "WeakCompareAndSwapN",
-    "CompareAndExchangeI", "CompareAndExchangeL", "CompareAndExchangeP", "CompareAndExchangeN",
+    "CompareAndSwapB", "CompareAndSwapS", "CompareAndSwapI", "CompareAndSwapL", "CompareAndSwapP", "CompareAndSwapN",
+    "WeakCompareAndSwapB", "WeakCompareAndSwapS", "WeakCompareAndSwapI", "WeakCompareAndSwapL", "WeakCompareAndSwapP", "WeakCompareAndSwapN",
+    "CompareAndExchangeB", "CompareAndExchangeS", "CompareAndExchangeI", "CompareAndExchangeL", "CompareAndExchangeP", "CompareAndExchangeN",
     "StoreCM",
     "ClearArray",
-    "GetAndAddI", "GetAndSetI", "GetAndSetP",
-    "GetAndAddL", "GetAndSetL", "GetAndSetN",
+    "GetAndSetB", "GetAndSetS", "GetAndAddI", "GetAndSetI", "GetAndSetP",
+    "GetAndAddB", "GetAndAddS", "GetAndAddL", "GetAndSetL", "GetAndSetN",
   };
   int cnt = sizeof(needs_ideal_memory_list)/sizeof(char*);
   if( strcmp(_opType,"PrefetchAllocation")==0 )
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jun 15 11:21:36 2016 +0300
@@ -1239,6 +1239,10 @@
   do_signature(compareAndExchangeLong_signature,   "(Ljava/lang/Object;JJJ)J")                                          \
   do_signature(compareAndSwapInt_signature,        "(Ljava/lang/Object;JII)Z")                                          \
   do_signature(compareAndExchangeInt_signature,    "(Ljava/lang/Object;JII)I")                                          \
+  do_signature(compareAndSwapByte_signature,       "(Ljava/lang/Object;JBB)Z")                                          \
+  do_signature(compareAndExchangeByte_signature,   "(Ljava/lang/Object;JBB)B")                                          \
+  do_signature(compareAndSwapShort_signature,      "(Ljava/lang/Object;JSS)Z")                                          \
+  do_signature(compareAndExchangeShort_signature,  "(Ljava/lang/Object;JSS)S")                                          \
                                                                                                                         \
   do_name(compareAndSwapObject_name,             "compareAndSwapObject")                                                \
   do_name(compareAndExchangeObjectVolatile_name, "compareAndExchangeObjectVolatile")                                    \
@@ -1252,6 +1256,14 @@
   do_name(compareAndExchangeIntVolatile_name,    "compareAndExchangeIntVolatile")                                       \
   do_name(compareAndExchangeIntAcquire_name,     "compareAndExchangeIntAcquire")                                        \
   do_name(compareAndExchangeIntRelease_name,     "compareAndExchangeIntRelease")                                        \
+  do_name(compareAndSwapByte_name,               "compareAndSwapByte")                                                  \
+  do_name(compareAndExchangeByteVolatile_name,   "compareAndExchangeByteVolatile")                                      \
+  do_name(compareAndExchangeByteAcquire_name,    "compareAndExchangeByteAcquire")                                       \
+  do_name(compareAndExchangeByteRelease_name,    "compareAndExchangeByteRelease")                                       \
+  do_name(compareAndSwapShort_name,              "compareAndSwapShort")                                                 \
+  do_name(compareAndExchangeShortVolatile_name,  "compareAndExchangeShortVolatile")                                     \
+  do_name(compareAndExchangeShortAcquire_name,   "compareAndExchangeShortAcquire")                                      \
+  do_name(compareAndExchangeShortRelease_name,   "compareAndExchangeShortRelease")                                      \
                                                                                                                         \
   do_name(weakCompareAndSwapObject_name,         "weakCompareAndSwapObject")                                            \
   do_name(weakCompareAndSwapObjectAcquire_name,  "weakCompareAndSwapObjectAcquire")                                     \
@@ -1265,6 +1277,14 @@
   do_name(weakCompareAndSwapIntAcquire_name,     "weakCompareAndSwapIntAcquire")                                        \
   do_name(weakCompareAndSwapIntRelease_name,     "weakCompareAndSwapIntRelease")                                        \
   do_name(weakCompareAndSwapIntVolatile_name,    "weakCompareAndSwapIntVolatile")                                       \
+  do_name(weakCompareAndSwapByte_name,           "weakCompareAndSwapByte")                                              \
+  do_name(weakCompareAndSwapByteAcquire_name,    "weakCompareAndSwapByteAcquire")                                       \
+  do_name(weakCompareAndSwapByteRelease_name,    "weakCompareAndSwapByteRelease")                                       \
+  do_name(weakCompareAndSwapByteVolatile_name,   "weakCompareAndSwapByteVolatile")                                      \
+  do_name(weakCompareAndSwapShort_name,          "weakCompareAndSwapShort")                                             \
+  do_name(weakCompareAndSwapShortAcquire_name,   "weakCompareAndSwapShortAcquire")                                      \
+  do_name(weakCompareAndSwapShortRelease_name,   "weakCompareAndSwapShortRelease")                                      \
+  do_name(weakCompareAndSwapShortVolatile_name,  "weakCompareAndSwapShortVolatile")                                     \
                                                                                                                         \
   do_intrinsic(_compareAndSwapObject,             jdk_internal_misc_Unsafe,  compareAndSwapObject_name,             compareAndSwapObject_signature,     F_RN) \
   do_intrinsic(_compareAndExchangeObjectVolatile, jdk_internal_misc_Unsafe,  compareAndExchangeObjectVolatile_name, compareAndExchangeObject_signature, F_RN) \
@@ -1278,7 +1298,15 @@
   do_intrinsic(_compareAndExchangeIntVolatile,    jdk_internal_misc_Unsafe,  compareAndExchangeIntVolatile_name,    compareAndExchangeInt_signature,    F_RN) \
   do_intrinsic(_compareAndExchangeIntAcquire,     jdk_internal_misc_Unsafe,  compareAndExchangeIntAcquire_name,     compareAndExchangeInt_signature,    F_R)  \
   do_intrinsic(_compareAndExchangeIntRelease,     jdk_internal_misc_Unsafe,  compareAndExchangeIntRelease_name,     compareAndExchangeInt_signature,    F_R)  \
-                                                                                                                                                              \
+  do_intrinsic(_compareAndSwapByte,               jdk_internal_misc_Unsafe,  compareAndSwapByte_name,               compareAndSwapByte_signature,       F_R)  \
+  do_intrinsic(_compareAndExchangeByteVolatile,   jdk_internal_misc_Unsafe,  compareAndExchangeByteVolatile_name,   compareAndExchangeByte_signature,   F_R)  \
+  do_intrinsic(_compareAndExchangeByteAcquire,    jdk_internal_misc_Unsafe,  compareAndExchangeByteAcquire_name,    compareAndExchangeByte_signature,   F_R)  \
+  do_intrinsic(_compareAndExchangeByteRelease,    jdk_internal_misc_Unsafe,  compareAndExchangeByteRelease_name,    compareAndExchangeByte_signature,   F_R)  \
+  do_intrinsic(_compareAndSwapShort,              jdk_internal_misc_Unsafe,  compareAndSwapShort_name,              compareAndSwapShort_signature,      F_R)  \
+  do_intrinsic(_compareAndExchangeShortVolatile,  jdk_internal_misc_Unsafe,  compareAndExchangeShortVolatile_name,  compareAndExchangeShort_signature,  F_R)  \
+  do_intrinsic(_compareAndExchangeShortAcquire,   jdk_internal_misc_Unsafe,  compareAndExchangeShortAcquire_name,   compareAndExchangeShort_signature,  F_R)  \
+  do_intrinsic(_compareAndExchangeShortRelease,   jdk_internal_misc_Unsafe,  compareAndExchangeShortRelease_name,   compareAndExchangeShort_signature,  F_R)  \
+                                                                                                                                                             \
   do_intrinsic(_weakCompareAndSwapObject,         jdk_internal_misc_Unsafe,  weakCompareAndSwapObject_name,         compareAndSwapObject_signature,     F_R) \
   do_intrinsic(_weakCompareAndSwapObjectAcquire,  jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectAcquire_name,  compareAndSwapObject_signature,     F_R) \
   do_intrinsic(_weakCompareAndSwapObjectRelease,  jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectRelease_name,  compareAndSwapObject_signature,     F_R) \
@@ -1291,19 +1319,39 @@
   do_intrinsic(_weakCompareAndSwapIntAcquire,     jdk_internal_misc_Unsafe,  weakCompareAndSwapIntAcquire_name,     compareAndSwapInt_signature,        F_R) \
   do_intrinsic(_weakCompareAndSwapIntRelease,     jdk_internal_misc_Unsafe,  weakCompareAndSwapIntRelease_name,     compareAndSwapInt_signature,        F_R) \
   do_intrinsic(_weakCompareAndSwapIntVolatile,    jdk_internal_misc_Unsafe,  weakCompareAndSwapIntVolatile_name,    compareAndSwapInt_signature,        F_R) \
-                                                                                                                        \
+  do_intrinsic(_weakCompareAndSwapByte,           jdk_internal_misc_Unsafe,  weakCompareAndSwapByte_name,           compareAndSwapByte_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSwapByteAcquire,    jdk_internal_misc_Unsafe,  weakCompareAndSwapByteAcquire_name,    compareAndSwapByte_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSwapByteRelease,    jdk_internal_misc_Unsafe,  weakCompareAndSwapByteRelease_name,    compareAndSwapByte_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSwapByteVolatile,   jdk_internal_misc_Unsafe,  weakCompareAndSwapByteVolatile_name,   compareAndSwapByte_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSwapShort,          jdk_internal_misc_Unsafe,  weakCompareAndSwapShort_name,          compareAndSwapShort_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSwapShortAcquire,   jdk_internal_misc_Unsafe,  weakCompareAndSwapShortAcquire_name,   compareAndSwapShort_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSwapShortRelease,   jdk_internal_misc_Unsafe,  weakCompareAndSwapShortRelease_name,   compareAndSwapShort_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSwapShortVolatile,  jdk_internal_misc_Unsafe,  weakCompareAndSwapShortVolatile_name,  compareAndSwapShort_signature,      F_R) \
+                           \
   do_intrinsic(_getAndAddInt,             jdk_internal_misc_Unsafe,     getAndAddInt_name, getAndAddInt_signature, F_R)       \
    do_name(     getAndAddInt_name,                                      "getAndAddInt")                                       \
    do_signature(getAndAddInt_signature,                                 "(Ljava/lang/Object;JI)I" )                           \
   do_intrinsic(_getAndAddLong,            jdk_internal_misc_Unsafe,     getAndAddLong_name, getAndAddLong_signature, F_R)     \
    do_name(     getAndAddLong_name,                                     "getAndAddLong")                                      \
    do_signature(getAndAddLong_signature,                                "(Ljava/lang/Object;JJ)J" )                           \
+  do_intrinsic(_getAndAddByte,            jdk_internal_misc_Unsafe,     getAndAddByte_name, getAndAddByte_signature, F_R)     \
+   do_name(     getAndAddByte_name,                                     "getAndAddByte")                                      \
+   do_signature(getAndAddByte_signature,                                "(Ljava/lang/Object;JB)B" )                           \
+  do_intrinsic(_getAndAddShort,           jdk_internal_misc_Unsafe,     getAndAddShort_name, getAndAddShort_signature, F_R)   \
+   do_name(     getAndAddShort_name,                                    "getAndAddShort")                                     \
+   do_signature(getAndAddShort_signature,                               "(Ljava/lang/Object;JS)S" )                           \
   do_intrinsic(_getAndSetInt,             jdk_internal_misc_Unsafe,     getAndSetInt_name, getAndSetInt_signature, F_R)       \
    do_name(     getAndSetInt_name,                                      "getAndSetInt")                                       \
    do_alias(    getAndSetInt_signature,                                 /*"(Ljava/lang/Object;JI)I"*/ getAndAddInt_signature)   \
   do_intrinsic(_getAndSetLong,            jdk_internal_misc_Unsafe,     getAndSetLong_name, getAndSetLong_signature, F_R)     \
    do_name(     getAndSetLong_name,                                     "getAndSetLong")                                      \
    do_alias(    getAndSetLong_signature,                                /*"(Ljava/lang/Object;JJ)J"*/ getAndAddLong_signature)  \
+  do_intrinsic(_getAndSetByte,            jdk_internal_misc_Unsafe,     getAndSetByte_name, getAndSetByte_signature, F_R)     \
+   do_name(     getAndSetByte_name,                                     "getAndSetByte")                                      \
+   do_alias(    getAndSetByte_signature,                                /*"(Ljava/lang/Object;JB)B"*/ getAndAddByte_signature)  \
+  do_intrinsic(_getAndSetShort,           jdk_internal_misc_Unsafe,     getAndSetShort_name, getAndSetShort_signature, F_R)   \
+   do_name(     getAndSetShort_name,                                    "getAndSetShort")                                     \
+   do_alias(    getAndSetShort_signature,                               /*"(Ljava/lang/Object;JS)S"*/ getAndAddShort_signature) \
   do_intrinsic(_getAndSetObject,          jdk_internal_misc_Unsafe,     getAndSetObject_name, getAndSetObject_signature,  F_R)\
    do_name(     getAndSetObject_name,                                   "getAndSetObject")                                    \
    do_signature(getAndSetObject_signature,                              "(Ljava/lang/Object;JLjava/lang/Object;)Ljava/lang/Object;" ) \
--- a/hotspot/src/share/vm/opto/c2compiler.cpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp	Wed Jun 15 11:21:36 2016 +0300
@@ -256,6 +256,7 @@
   case vmIntrinsics::_weakCompareAndSwapObject:
   case vmIntrinsics::_weakCompareAndSwapObjectAcquire:
   case vmIntrinsics::_weakCompareAndSwapObjectRelease:
+  case vmIntrinsics::_weakCompareAndSwapObjectVolatile:
 #ifdef _LP64
     if ( UseCompressedOops && !Matcher::match_rule_supported(Op_WeakCompareAndSwapN)) return false;
     if (!UseCompressedOops && !Matcher::match_rule_supported(Op_WeakCompareAndSwapP)) return false;
@@ -270,6 +271,7 @@
   case vmIntrinsics::_weakCompareAndSwapLong:
   case vmIntrinsics::_weakCompareAndSwapLongAcquire:
   case vmIntrinsics::_weakCompareAndSwapLongRelease:
+  case vmIntrinsics::_weakCompareAndSwapLongVolatile:
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapL)) return false;
     break;
 
@@ -280,9 +282,32 @@
   case vmIntrinsics::_weakCompareAndSwapInt:
   case vmIntrinsics::_weakCompareAndSwapIntAcquire:
   case vmIntrinsics::_weakCompareAndSwapIntRelease:
+  case vmIntrinsics::_weakCompareAndSwapIntVolatile:
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapL)) return false;
     break;
 
+  /* CompareAndSwap, Byte: */
+  case vmIntrinsics::_compareAndSwapByte:
+    if (!Matcher::match_rule_supported(Op_CompareAndSwapB)) return false;
+    break;
+  case vmIntrinsics::_weakCompareAndSwapByte:
+  case vmIntrinsics::_weakCompareAndSwapByteAcquire:
+  case vmIntrinsics::_weakCompareAndSwapByteRelease:
+  case vmIntrinsics::_weakCompareAndSwapByteVolatile:
+    if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapB)) return false;
+    break;
+
+  /* CompareAndSwap, Short: */
+  case vmIntrinsics::_compareAndSwapShort:
+    if (!Matcher::match_rule_supported(Op_CompareAndSwapS)) return false;
+    break;
+  case vmIntrinsics::_weakCompareAndSwapShort:
+  case vmIntrinsics::_weakCompareAndSwapShortAcquire:
+  case vmIntrinsics::_weakCompareAndSwapShortRelease:
+  case vmIntrinsics::_weakCompareAndSwapShortVolatile:
+    if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapS)) return false;
+    break;
+
   /* CompareAndExchange, Object: */
   case vmIntrinsics::_compareAndExchangeObjectVolatile:
   case vmIntrinsics::_compareAndExchangeObjectAcquire:
@@ -309,12 +334,39 @@
     if (!Matcher::match_rule_supported(Op_CompareAndExchangeI)) return false;
     break;
 
+  /* CompareAndExchange, Byte: */
+  case vmIntrinsics::_compareAndExchangeByteVolatile:
+  case vmIntrinsics::_compareAndExchangeByteAcquire:
+  case vmIntrinsics::_compareAndExchangeByteRelease:
+    if (!Matcher::match_rule_supported(Op_CompareAndExchangeB)) return false;
+    break;
+
+  /* CompareAndExchange, Short: */
+  case vmIntrinsics::_compareAndExchangeShortVolatile:
+  case vmIntrinsics::_compareAndExchangeShortAcquire:
+  case vmIntrinsics::_compareAndExchangeShortRelease:
+    if (!Matcher::match_rule_supported(Op_CompareAndExchangeS)) return false;
+    break;
+
+  case vmIntrinsics::_getAndAddByte:
+    if (!Matcher::match_rule_supported(Op_GetAndAddB)) return false;
+    break;
+  case vmIntrinsics::_getAndAddShort:
+    if (!Matcher::match_rule_supported(Op_GetAndAddS)) return false;
+    break;
   case vmIntrinsics::_getAndAddInt:
     if (!Matcher::match_rule_supported(Op_GetAndAddI)) return false;
     break;
   case vmIntrinsics::_getAndAddLong:
     if (!Matcher::match_rule_supported(Op_GetAndAddL)) return false;
     break;
+
+  case vmIntrinsics::_getAndSetByte:
+    if (!Matcher::match_rule_supported(Op_GetAndSetB)) return false;
+    break;
+  case vmIntrinsics::_getAndSetShort:
+    if (!Matcher::match_rule_supported(Op_GetAndSetS)) return false;
+    break;
   case vmIntrinsics::_getAndSetInt:
     if (!Matcher::match_rule_supported(Op_GetAndSetI)) return false;
     break;
--- a/hotspot/src/share/vm/opto/classes.hpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/share/vm/opto/classes.hpp	Wed Jun 15 11:21:36 2016 +0300
@@ -81,20 +81,30 @@
 macro(CmpLTMask)
 macro(CmpP)
 macro(CmpU)
+macro(CompareAndSwapB)
+macro(CompareAndSwapS)
 macro(CompareAndSwapI)
 macro(CompareAndSwapL)
 macro(CompareAndSwapP)
 macro(CompareAndSwapN)
+macro(WeakCompareAndSwapB)
+macro(WeakCompareAndSwapS)
 macro(WeakCompareAndSwapI)
 macro(WeakCompareAndSwapL)
 macro(WeakCompareAndSwapP)
 macro(WeakCompareAndSwapN)
+macro(CompareAndExchangeB)
+macro(CompareAndExchangeS)
 macro(CompareAndExchangeI)
 macro(CompareAndExchangeL)
 macro(CompareAndExchangeP)
 macro(CompareAndExchangeN)
+macro(GetAndAddB)
+macro(GetAndAddS)
 macro(GetAndAddI)
 macro(GetAndAddL)
+macro(GetAndSetB)
+macro(GetAndSetS)
 macro(GetAndSetI)
 macro(GetAndSetL)
 macro(GetAndSetP)
--- a/hotspot/src/share/vm/opto/compile.cpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/share/vm/opto/compile.cpp	Wed Jun 15 11:21:36 2016 +0300
@@ -2794,20 +2794,30 @@
   case Op_StoreL:
   case Op_StoreIConditional:
   case Op_StoreLConditional:
+  case Op_CompareAndSwapB:
+  case Op_CompareAndSwapS:
   case Op_CompareAndSwapI:
   case Op_CompareAndSwapL:
   case Op_CompareAndSwapP:
   case Op_CompareAndSwapN:
+  case Op_WeakCompareAndSwapB:
+  case Op_WeakCompareAndSwapS:
   case Op_WeakCompareAndSwapI:
   case Op_WeakCompareAndSwapL:
   case Op_WeakCompareAndSwapP:
   case Op_WeakCompareAndSwapN:
+  case Op_CompareAndExchangeB:
+  case Op_CompareAndExchangeS:
   case Op_CompareAndExchangeI:
   case Op_CompareAndExchangeL:
   case Op_CompareAndExchangeP:
   case Op_CompareAndExchangeN:
+  case Op_GetAndAddS:
+  case Op_GetAndAddB:
   case Op_GetAndAddI:
   case Op_GetAndAddL:
+  case Op_GetAndSetS:
+  case Op_GetAndSetB:
   case Op_GetAndSetI:
   case Op_GetAndSetL:
   case Op_GetAndSetP:
--- a/hotspot/src/share/vm/opto/library_call.cpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Wed Jun 15 11:21:36 2016 +0300
@@ -645,6 +645,8 @@
   case vmIntrinsics::_putDoubleOpaque:          return inline_unsafe_access( is_store, T_DOUBLE,   Opaque, false);
 
   case vmIntrinsics::_compareAndSwapObject:             return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap,      Volatile);
+  case vmIntrinsics::_compareAndSwapByte:               return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap,      Volatile);
+  case vmIntrinsics::_compareAndSwapShort:              return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap,      Volatile);
   case vmIntrinsics::_compareAndSwapInt:                return inline_unsafe_load_store(T_INT,    LS_cmp_swap,      Volatile);
   case vmIntrinsics::_compareAndSwapLong:               return inline_unsafe_load_store(T_LONG,   LS_cmp_swap,      Volatile);
 
@@ -652,6 +654,14 @@
   case vmIntrinsics::_weakCompareAndSwapObjectAcquire:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Acquire);
   case vmIntrinsics::_weakCompareAndSwapObjectRelease:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Release);
   case vmIntrinsics::_weakCompareAndSwapObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Volatile);
+  case vmIntrinsics::_weakCompareAndSwapByte:           return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSwapByteAcquire:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSwapByteRelease:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSwapByteVolatile:   return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Volatile);
+  case vmIntrinsics::_weakCompareAndSwapShort:          return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSwapShortAcquire:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSwapShortRelease:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSwapShortVolatile:  return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Volatile);
   case vmIntrinsics::_weakCompareAndSwapInt:            return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Relaxed);
   case vmIntrinsics::_weakCompareAndSwapIntAcquire:     return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Acquire);
   case vmIntrinsics::_weakCompareAndSwapIntRelease:     return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Release);
@@ -664,6 +674,12 @@
   case vmIntrinsics::_compareAndExchangeObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeObjectAcquire:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeObjectRelease:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Release);
+  case vmIntrinsics::_compareAndExchangeByteVolatile:   return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndExchangeByteAcquire:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Acquire);
+  case vmIntrinsics::_compareAndExchangeByteRelease:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Release);
+  case vmIntrinsics::_compareAndExchangeShortVolatile:  return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndExchangeShortAcquire:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Acquire);
+  case vmIntrinsics::_compareAndExchangeShortRelease:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Release);
   case vmIntrinsics::_compareAndExchangeIntVolatile:    return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeIntAcquire:     return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeIntRelease:     return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Release);
@@ -671,8 +687,13 @@
   case vmIntrinsics::_compareAndExchangeLongAcquire:    return inline_unsafe_load_store(T_LONG,   LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeLongRelease:    return inline_unsafe_load_store(T_LONG,   LS_cmp_exchange,  Release);
 
+  case vmIntrinsics::_getAndAddByte:                    return inline_unsafe_load_store(T_BYTE,   LS_get_add,       Volatile);
+  case vmIntrinsics::_getAndAddShort:                   return inline_unsafe_load_store(T_SHORT,  LS_get_add,       Volatile);
   case vmIntrinsics::_getAndAddInt:                     return inline_unsafe_load_store(T_INT,    LS_get_add,       Volatile);
   case vmIntrinsics::_getAndAddLong:                    return inline_unsafe_load_store(T_LONG,   LS_get_add,       Volatile);
+
+  case vmIntrinsics::_getAndSetByte:                    return inline_unsafe_load_store(T_BYTE,   LS_get_set,       Volatile);
+  case vmIntrinsics::_getAndSetShort:                   return inline_unsafe_load_store(T_SHORT,  LS_get_set,       Volatile);
   case vmIntrinsics::_getAndSetInt:                     return inline_unsafe_load_store(T_INT,    LS_get_set,       Volatile);
   case vmIntrinsics::_getAndSetLong:                    return inline_unsafe_load_store(T_LONG,   LS_get_set,       Volatile);
   case vmIntrinsics::_getAndSetObject:                  return inline_unsafe_load_store(T_OBJECT, LS_get_set,       Volatile);
@@ -2849,6 +2870,48 @@
   // longs, and Object. Adding others should be straightforward.
   Node* load_store = NULL;
   switch(type) {
+  case T_BYTE:
+    switch(kind) {
+      case LS_get_add:
+        load_store = _gvn.transform(new GetAndAddBNode(control(), mem, adr, newval, adr_type));
+        break;
+      case LS_get_set:
+        load_store = _gvn.transform(new GetAndSetBNode(control(), mem, adr, newval, adr_type));
+        break;
+      case LS_cmp_swap_weak:
+        load_store = _gvn.transform(new WeakCompareAndSwapBNode(control(), mem, adr, newval, oldval, mo));
+        break;
+      case LS_cmp_swap:
+        load_store = _gvn.transform(new CompareAndSwapBNode(control(), mem, adr, newval, oldval, mo));
+        break;
+      case LS_cmp_exchange:
+        load_store = _gvn.transform(new CompareAndExchangeBNode(control(), mem, adr, newval, oldval, adr_type, mo));
+        break;
+      default:
+        ShouldNotReachHere();
+    }
+    break;
+  case T_SHORT:
+    switch(kind) {
+      case LS_get_add:
+        load_store = _gvn.transform(new GetAndAddSNode(control(), mem, adr, newval, adr_type));
+        break;
+      case LS_get_set:
+        load_store = _gvn.transform(new GetAndSetSNode(control(), mem, adr, newval, adr_type));
+        break;
+      case LS_cmp_swap_weak:
+        load_store = _gvn.transform(new WeakCompareAndSwapSNode(control(), mem, adr, newval, oldval, mo));
+        break;
+      case LS_cmp_swap:
+        load_store = _gvn.transform(new CompareAndSwapSNode(control(), mem, adr, newval, oldval, mo));
+        break;
+      case LS_cmp_exchange:
+        load_store = _gvn.transform(new CompareAndExchangeSNode(control(), mem, adr, newval, oldval, adr_type, mo));
+        break;
+      default:
+        ShouldNotReachHere();
+    }
+    break;
   case T_INT:
     switch(kind) {
       case LS_get_add:
--- a/hotspot/src/share/vm/opto/loopTransform.cpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp	Wed Jun 15 11:21:36 2016 +0300
@@ -2484,14 +2484,20 @@
             ((bol->in(1)->Opcode() == Op_StorePConditional ) ||
              (bol->in(1)->Opcode() == Op_StoreIConditional ) ||
              (bol->in(1)->Opcode() == Op_StoreLConditional ) ||
+             (bol->in(1)->Opcode() == Op_CompareAndExchangeB ) ||
+             (bol->in(1)->Opcode() == Op_CompareAndExchangeS ) ||
              (bol->in(1)->Opcode() == Op_CompareAndExchangeI ) ||
              (bol->in(1)->Opcode() == Op_CompareAndExchangeL ) ||
              (bol->in(1)->Opcode() == Op_CompareAndExchangeP ) ||
              (bol->in(1)->Opcode() == Op_CompareAndExchangeN ) ||
+             (bol->in(1)->Opcode() == Op_WeakCompareAndSwapB ) ||
+             (bol->in(1)->Opcode() == Op_WeakCompareAndSwapS ) ||
              (bol->in(1)->Opcode() == Op_WeakCompareAndSwapI ) ||
              (bol->in(1)->Opcode() == Op_WeakCompareAndSwapL ) ||
              (bol->in(1)->Opcode() == Op_WeakCompareAndSwapP ) ||
              (bol->in(1)->Opcode() == Op_WeakCompareAndSwapN ) ||
+             (bol->in(1)->Opcode() == Op_CompareAndSwapB ) ||
+             (bol->in(1)->Opcode() == Op_CompareAndSwapS ) ||
              (bol->in(1)->Opcode() == Op_CompareAndSwapI ) ||
              (bol->in(1)->Opcode() == Op_CompareAndSwapL ) ||
              (bol->in(1)->Opcode() == Op_CompareAndSwapP ) ||
--- a/hotspot/src/share/vm/opto/matcher.cpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/share/vm/opto/matcher.cpp	Wed Jun 15 11:21:36 2016 +0300
@@ -2228,14 +2228,20 @@
       case Op_StorePConditional:
       case Op_StoreIConditional:
       case Op_StoreLConditional:
+      case Op_CompareAndExchangeB:
+      case Op_CompareAndExchangeS:
       case Op_CompareAndExchangeI:
       case Op_CompareAndExchangeL:
       case Op_CompareAndExchangeP:
       case Op_CompareAndExchangeN:
+      case Op_WeakCompareAndSwapB:
+      case Op_WeakCompareAndSwapS:
       case Op_WeakCompareAndSwapI:
       case Op_WeakCompareAndSwapL:
       case Op_WeakCompareAndSwapP:
       case Op_WeakCompareAndSwapN:
+      case Op_CompareAndSwapB:
+      case Op_CompareAndSwapS:
       case Op_CompareAndSwapI:
       case Op_CompareAndSwapL:
       case Op_CompareAndSwapP:
@@ -2453,14 +2459,20 @@
     // that a monitor exit operation contains a serializing instruction.
 
     if (xop == Op_MemBarVolatile ||
+        xop == Op_CompareAndExchangeB ||
+        xop == Op_CompareAndExchangeS ||
         xop == Op_CompareAndExchangeI ||
         xop == Op_CompareAndExchangeL ||
         xop == Op_CompareAndExchangeP ||
         xop == Op_CompareAndExchangeN ||
+        xop == Op_WeakCompareAndSwapB ||
+        xop == Op_WeakCompareAndSwapS ||
         xop == Op_WeakCompareAndSwapL ||
         xop == Op_WeakCompareAndSwapP ||
         xop == Op_WeakCompareAndSwapN ||
         xop == Op_WeakCompareAndSwapI ||
+        xop == Op_CompareAndSwapB ||
+        xop == Op_CompareAndSwapS ||
         xop == Op_CompareAndSwapL ||
         xop == Op_CompareAndSwapP ||
         xop == Op_CompareAndSwapN ||
--- a/hotspot/src/share/vm/opto/memnode.hpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/share/vm/opto/memnode.hpp	Wed Jun 15 11:21:36 2016 +0300
@@ -885,13 +885,19 @@
   }
 };
 
-//------------------------------CompareAndSwapLNode---------------------------
-class CompareAndSwapLNode : public CompareAndSwapNode {
+//------------------------------CompareAndSwapBNode---------------------------
+class CompareAndSwapBNode : public CompareAndSwapNode {
 public:
-  CompareAndSwapLNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, MemNode::MemOrd mem_ord) : CompareAndSwapNode(c, mem, adr, val, ex, mem_ord) { }
+  CompareAndSwapBNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, MemNode::MemOrd mem_ord) : CompareAndSwapNode(c, mem, adr, val, ex, mem_ord) { }
   virtual int Opcode() const;
 };
 
+//------------------------------CompareAndSwapSNode---------------------------
+class CompareAndSwapSNode : public CompareAndSwapNode {
+public:
+  CompareAndSwapSNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, MemNode::MemOrd mem_ord) : CompareAndSwapNode(c, mem, adr, val, ex, mem_ord) { }
+  virtual int Opcode() const;
+};
 
 //------------------------------CompareAndSwapINode---------------------------
 class CompareAndSwapINode : public CompareAndSwapNode {
@@ -900,6 +906,12 @@
   virtual int Opcode() const;
 };
 
+//------------------------------CompareAndSwapLNode---------------------------
+class CompareAndSwapLNode : public CompareAndSwapNode {
+public:
+  CompareAndSwapLNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, MemNode::MemOrd mem_ord) : CompareAndSwapNode(c, mem, adr, val, ex, mem_ord) { }
+  virtual int Opcode() const;
+};
 
 //------------------------------CompareAndSwapPNode---------------------------
 class CompareAndSwapPNode : public CompareAndSwapNode {
@@ -915,14 +927,19 @@
   virtual int Opcode() const;
 };
 
-
-//------------------------------WeakCompareAndSwapLNode---------------------------
-class WeakCompareAndSwapLNode : public CompareAndSwapNode {
+//------------------------------WeakCompareAndSwapBNode---------------------------
+class WeakCompareAndSwapBNode : public CompareAndSwapNode {
 public:
-  WeakCompareAndSwapLNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, MemNode::MemOrd mem_ord) : CompareAndSwapNode(c, mem, adr, val, ex, mem_ord) { }
+  WeakCompareAndSwapBNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, MemNode::MemOrd mem_ord) : CompareAndSwapNode(c, mem, adr, val, ex, mem_ord) { }
   virtual int Opcode() const;
 };
 
+//------------------------------WeakCompareAndSwapSNode---------------------------
+class WeakCompareAndSwapSNode : public CompareAndSwapNode {
+public:
+  WeakCompareAndSwapSNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, MemNode::MemOrd mem_ord) : CompareAndSwapNode(c, mem, adr, val, ex, mem_ord) { }
+  virtual int Opcode() const;
+};
 
 //------------------------------WeakCompareAndSwapINode---------------------------
 class WeakCompareAndSwapINode : public CompareAndSwapNode {
@@ -931,6 +948,12 @@
   virtual int Opcode() const;
 };
 
+//------------------------------WeakCompareAndSwapLNode---------------------------
+class WeakCompareAndSwapLNode : public CompareAndSwapNode {
+public:
+  WeakCompareAndSwapLNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, MemNode::MemOrd mem_ord) : CompareAndSwapNode(c, mem, adr, val, ex, mem_ord) { }
+  virtual int Opcode() const;
+};
 
 //------------------------------WeakCompareAndSwapPNode---------------------------
 class WeakCompareAndSwapPNode : public CompareAndSwapNode {
@@ -946,6 +969,21 @@
   virtual int Opcode() const;
 };
 
+//------------------------------CompareAndExchangeBNode---------------------------
+class CompareAndExchangeBNode : public CompareAndExchangeNode {
+public:
+  CompareAndExchangeBNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, const TypePtr* at, MemNode::MemOrd mem_ord) : CompareAndExchangeNode(c, mem, adr, val, ex, mem_ord, at, TypeInt::BYTE) { }
+  virtual int Opcode() const;
+};
+
+
+//------------------------------CompareAndExchangeSNode---------------------------
+class CompareAndExchangeSNode : public CompareAndExchangeNode {
+public:
+  CompareAndExchangeSNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, const TypePtr* at, MemNode::MemOrd mem_ord) : CompareAndExchangeNode(c, mem, adr, val, ex, mem_ord, at, TypeInt::SHORT) { }
+  virtual int Opcode() const;
+};
+
 //------------------------------CompareAndExchangeLNode---------------------------
 class CompareAndExchangeLNode : public CompareAndExchangeNode {
 public:
@@ -976,6 +1014,20 @@
   virtual int Opcode() const;
 };
 
+//------------------------------GetAndAddBNode---------------------------
+class GetAndAddBNode : public LoadStoreNode {
+public:
+  GetAndAddBNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at ) : LoadStoreNode(c, mem, adr, val, at, TypeInt::BYTE, 4) { }
+  virtual int Opcode() const;
+};
+
+//------------------------------GetAndAddSNode---------------------------
+class GetAndAddSNode : public LoadStoreNode {
+public:
+  GetAndAddSNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at ) : LoadStoreNode(c, mem, adr, val, at, TypeInt::SHORT, 4) { }
+  virtual int Opcode() const;
+};
+
 //------------------------------GetAndAddINode---------------------------
 class GetAndAddINode : public LoadStoreNode {
 public:
@@ -990,6 +1042,19 @@
   virtual int Opcode() const;
 };
 
+//------------------------------GetAndSetBNode---------------------------
+class GetAndSetBNode : public LoadStoreNode {
+public:
+  GetAndSetBNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at ) : LoadStoreNode(c, mem, adr, val, at, TypeInt::BYTE, 4) { }
+  virtual int Opcode() const;
+};
+
+//------------------------------GetAndSetSNode---------------------------
+class GetAndSetSNode : public LoadStoreNode {
+public:
+  GetAndSetSNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at ) : LoadStoreNode(c, mem, adr, val, at, TypeInt::SHORT, 4) { }
+  virtual int Opcode() const;
+};
 
 //------------------------------GetAndSetINode---------------------------
 class GetAndSetINode : public LoadStoreNode {
@@ -998,7 +1063,7 @@
   virtual int Opcode() const;
 };
 
-//------------------------------GetAndSetINode---------------------------
+//------------------------------GetAndSetLNode---------------------------
 class GetAndSetLNode : public LoadStoreNode {
 public:
   GetAndSetLNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at ) : LoadStoreNode(c, mem, adr, val, at, TypeLong::LONG, 4) { }
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Wed Jun 15 11:21:36 2016 +0300
@@ -2024,15 +2024,21 @@
   declare_c2_type(StorePConditionalNode, LoadStoreNode)                   \
   declare_c2_type(StoreLConditionalNode, LoadStoreNode)                   \
   declare_c2_type(CompareAndSwapNode, LoadStoreConditionalNode)           \
+  declare_c2_type(CompareAndSwapBNode, CompareAndSwapNode)                \
+  declare_c2_type(CompareAndSwapSNode, CompareAndSwapNode)                \
   declare_c2_type(CompareAndSwapLNode, CompareAndSwapNode)                \
   declare_c2_type(CompareAndSwapINode, CompareAndSwapNode)                \
   declare_c2_type(CompareAndSwapPNode, CompareAndSwapNode)                \
   declare_c2_type(CompareAndSwapNNode, CompareAndSwapNode)                \
+  declare_c2_type(WeakCompareAndSwapBNode, CompareAndSwapNode)            \
+  declare_c2_type(WeakCompareAndSwapSNode, CompareAndSwapNode)            \
   declare_c2_type(WeakCompareAndSwapLNode, CompareAndSwapNode)            \
   declare_c2_type(WeakCompareAndSwapINode, CompareAndSwapNode)            \
   declare_c2_type(WeakCompareAndSwapPNode, CompareAndSwapNode)            \
   declare_c2_type(WeakCompareAndSwapNNode, CompareAndSwapNode)            \
   declare_c2_type(CompareAndExchangeNode, LoadStoreNode)                  \
+  declare_c2_type(CompareAndExchangeBNode, CompareAndExchangeNode)        \
+  declare_c2_type(CompareAndExchangeSNode, CompareAndExchangeNode)        \
   declare_c2_type(CompareAndExchangeLNode, CompareAndExchangeNode)        \
   declare_c2_type(CompareAndExchangeINode, CompareAndExchangeNode)        \
   declare_c2_type(CompareAndExchangePNode, CompareAndExchangeNode)        \
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java	Wed Jun 15 11:21:36 2016 +0300
@@ -144,6 +144,115 @@
         }
 
 
+        UNSAFE.putBoolean(base, offset, true);
+
+        // Compare
+        {
+            boolean r = UNSAFE.compareAndSwapBoolean(base, offset, true, false);
+            assertEquals(r, true, "success compareAndSwap boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, false, "success compareAndSwap boolean value");
+        }
+
+        {
+            boolean r = UNSAFE.compareAndSwapBoolean(base, offset, true, false);
+            assertEquals(r, false, "failing compareAndSwap boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, false, "failing compareAndSwap boolean value");
+        }
+
+        // Advanced compare
+        {
+            boolean r = UNSAFE.compareAndExchangeBooleanVolatile(base, offset, false, true);
+            assertEquals(r, false, "success compareAndExchangeVolatile boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, true, "success compareAndExchangeVolatile boolean value");
+        }
+
+        {
+            boolean r = UNSAFE.compareAndExchangeBooleanVolatile(base, offset, false, false);
+            assertEquals(r, true, "failing compareAndExchangeVolatile boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, true, "failing compareAndExchangeVolatile boolean value");
+        }
+
+        {
+            boolean r = UNSAFE.compareAndExchangeBooleanAcquire(base, offset, true, false);
+            assertEquals(r, true, "success compareAndExchangeAcquire boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, false, "success compareAndExchangeAcquire boolean value");
+        }
+
+        {
+            boolean r = UNSAFE.compareAndExchangeBooleanAcquire(base, offset, true, false);
+            assertEquals(r, false, "failing compareAndExchangeAcquire boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, false, "failing compareAndExchangeAcquire boolean value");
+        }
+
+        {
+            boolean r = UNSAFE.compareAndExchangeBooleanRelease(base, offset, false, true);
+            assertEquals(r, false, "success compareAndExchangeRelease boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, true, "success compareAndExchangeRelease boolean value");
+        }
+
+        {
+            boolean r = UNSAFE.compareAndExchangeBooleanRelease(base, offset, false, false);
+            assertEquals(r, true, "failing compareAndExchangeRelease boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, true, "failing compareAndExchangeRelease boolean value");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapBoolean(base, offset, true, false);
+            }
+            assertEquals(success, true, "weakCompareAndSwap boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, false, "weakCompareAndSwap boolean value");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapBooleanAcquire(base, offset, false, true);
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, true, "weakCompareAndSwapAcquire boolean");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapBooleanRelease(base, offset, true, false);
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, false, "weakCompareAndSwapRelease boolean");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapBooleanVolatile(base, offset, false, true);
+            }
+            assertEquals(success, true, "weakCompareAndSwapVolatile boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, true, "weakCompareAndSwapVolatile boolean");
+        }
+
+        UNSAFE.putBoolean(base, offset, false);
+
+        // Compare set and get
+        {
+            boolean o = UNSAFE.getAndSetBoolean(base, offset, true);
+            assertEquals(o, false, "getAndSet boolean");
+            boolean x = UNSAFE.getBoolean(base, offset);
+            assertEquals(x, true, "getAndSet boolean value");
+        }
 
     }
 
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java	Wed Jun 15 11:21:36 2016 +0300
@@ -145,43 +145,161 @@
     static void testAccess(Object base, long offset) {
         // Plain
         {
-            UNSAFE.putByte(base, offset, (byte)1);
+            UNSAFE.putByte(base, offset, (byte)0x01);
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)1, "set byte value");
+            assertEquals(x, (byte)0x01, "set byte value");
         }
 
         // Volatile
         {
-            UNSAFE.putByteVolatile(base, offset, (byte)2);
+            UNSAFE.putByteVolatile(base, offset, (byte)0x23);
             byte x = UNSAFE.getByteVolatile(base, offset);
-            assertEquals(x, (byte)2, "putVolatile byte value");
+            assertEquals(x, (byte)0x23, "putVolatile byte value");
         }
 
 
         // Lazy
         {
-            UNSAFE.putByteRelease(base, offset, (byte)1);
+            UNSAFE.putByteRelease(base, offset, (byte)0x01);
             byte x = UNSAFE.getByteAcquire(base, offset);
-            assertEquals(x, (byte)1, "putRelease byte value");
+            assertEquals(x, (byte)0x01, "putRelease byte value");
         }
 
         // Opaque
         {
-            UNSAFE.putByteOpaque(base, offset, (byte)2);
+            UNSAFE.putByteOpaque(base, offset, (byte)0x23);
             byte x = UNSAFE.getByteOpaque(base, offset);
-            assertEquals(x, (byte)2, "putOpaque byte value");
+            assertEquals(x, (byte)0x23, "putOpaque byte value");
         }
 
 
+        UNSAFE.putByte(base, offset, (byte)0x01);
 
+        // Compare
+        {
+            boolean r = UNSAFE.compareAndSwapByte(base, offset, (byte)0x01, (byte)0x23);
+            assertEquals(r, true, "success compareAndSwap byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x23, "success compareAndSwap byte value");
+        }
+
+        {
+            boolean r = UNSAFE.compareAndSwapByte(base, offset, (byte)0x01, (byte)0x45);
+            assertEquals(r, false, "failing compareAndSwap byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x23, "failing compareAndSwap byte value");
+        }
+
+        // Advanced compare
+        {
+            byte r = UNSAFE.compareAndExchangeByteVolatile(base, offset, (byte)0x23, (byte)0x01);
+            assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value");
+        }
+
+        {
+            byte r = UNSAFE.compareAndExchangeByteVolatile(base, offset, (byte)0x23, (byte)0x45);
+            assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value");
+        }
+
+        {
+            byte r = UNSAFE.compareAndExchangeByteAcquire(base, offset, (byte)0x01, (byte)0x23);
+            assertEquals(r, (byte)0x01, "success compareAndExchangeAcquire byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x23, "success compareAndExchangeAcquire byte value");
+        }
+
+        {
+            byte r = UNSAFE.compareAndExchangeByteAcquire(base, offset, (byte)0x01, (byte)0x45);
+            assertEquals(r, (byte)0x23, "failing compareAndExchangeAcquire byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x23, "failing compareAndExchangeAcquire byte value");
+        }
+
+        {
+            byte r = UNSAFE.compareAndExchangeByteRelease(base, offset, (byte)0x23, (byte)0x01);
+            assertEquals(r, (byte)0x23, "success compareAndExchangeRelease byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x01, "success compareAndExchangeRelease byte value");
+        }
+
+        {
+            byte r = UNSAFE.compareAndExchangeByteRelease(base, offset, (byte)0x23, (byte)0x45);
+            assertEquals(r, (byte)0x01, "failing compareAndExchangeRelease byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x01, "failing compareAndExchangeRelease byte value");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapByte(base, offset, (byte)0x01, (byte)0x23);
+            }
+            assertEquals(success, true, "weakCompareAndSwap byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x23, "weakCompareAndSwap byte value");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapByteAcquire(base, offset, (byte)0x23, (byte)0x01);
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x01, "weakCompareAndSwapAcquire byte");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapByteRelease(base, offset, (byte)0x01, (byte)0x23);
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x23, "weakCompareAndSwapRelease byte");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapByteVolatile(base, offset, (byte)0x23, (byte)0x01);
+            }
+            assertEquals(success, true, "weakCompareAndSwapVolatile byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x01, "weakCompareAndSwapVolatile byte");
+        }
+
+        UNSAFE.putByte(base, offset, (byte)0x23);
+
+        // Compare set and get
+        {
+            byte o = UNSAFE.getAndSetByte(base, offset, (byte)0x01);
+            assertEquals(o, (byte)0x23, "getAndSet byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)0x01, "getAndSet byte value");
+        }
+
+        UNSAFE.putByte(base, offset, (byte)0x01);
+
+        // get and add, add and get
+        {
+            byte o = UNSAFE.getAndAddByte(base, offset, (byte)0x23);
+            assertEquals(o, (byte)0x01, "getAndAdd byte");
+            byte x = UNSAFE.getByte(base, offset);
+            assertEquals(x, (byte)((byte)0x01 + (byte)0x23), "getAndAdd byte");
+        }
     }
 
     static void testAccess(long address) {
         // Plain
         {
-            UNSAFE.putByte(address, (byte)1);
+            UNSAFE.putByte(address, (byte)0x01);
             byte x = UNSAFE.getByte(address);
-            assertEquals(x, (byte)1, "set byte value");
+            assertEquals(x, (byte)0x01, "set byte value");
         }
     }
 }
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java	Wed Jun 15 11:21:36 2016 +0300
@@ -145,61 +145,179 @@
     static void testAccess(Object base, long offset) {
         // Plain
         {
-            UNSAFE.putChar(base, offset, 'a');
+            UNSAFE.putChar(base, offset, '\u0123');
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, 'a', "set char value");
+            assertEquals(x, '\u0123', "set char value");
         }
 
         // Volatile
         {
-            UNSAFE.putCharVolatile(base, offset, 'b');
+            UNSAFE.putCharVolatile(base, offset, '\u4567');
             char x = UNSAFE.getCharVolatile(base, offset);
-            assertEquals(x, 'b', "putVolatile char value");
+            assertEquals(x, '\u4567', "putVolatile char value");
         }
 
 
         // Lazy
         {
-            UNSAFE.putCharRelease(base, offset, 'a');
+            UNSAFE.putCharRelease(base, offset, '\u0123');
             char x = UNSAFE.getCharAcquire(base, offset);
-            assertEquals(x, 'a', "putRelease char value");
+            assertEquals(x, '\u0123', "putRelease char value");
         }
 
         // Opaque
         {
-            UNSAFE.putCharOpaque(base, offset, 'b');
+            UNSAFE.putCharOpaque(base, offset, '\u4567');
             char x = UNSAFE.getCharOpaque(base, offset);
-            assertEquals(x, 'b', "putOpaque char value");
+            assertEquals(x, '\u4567', "putOpaque char value");
         }
 
         // Unaligned
         {
-            UNSAFE.putCharUnaligned(base, offset, 'b');
+            UNSAFE.putCharUnaligned(base, offset, '\u4567');
             char x = UNSAFE.getCharUnaligned(base, offset);
-            assertEquals(x, 'b', "putUnaligned char value");
+            assertEquals(x, '\u4567', "putUnaligned char value");
         }
 
         {
-            UNSAFE.putCharUnaligned(base, offset, 'a', true);
+            UNSAFE.putCharUnaligned(base, offset, '\u0123', true);
             char x = UNSAFE.getCharUnaligned(base, offset, true);
-            assertEquals(x, 'a', "putUnaligned big endian char value");
+            assertEquals(x, '\u0123', "putUnaligned big endian char value");
         }
 
         {
-            UNSAFE.putCharUnaligned(base, offset, 'b', false);
+            UNSAFE.putCharUnaligned(base, offset, '\u4567', false);
             char x = UNSAFE.getCharUnaligned(base, offset, false);
-            assertEquals(x, 'b', "putUnaligned little endian char value");
+            assertEquals(x, '\u4567', "putUnaligned little endian char value");
         }
 
+        UNSAFE.putChar(base, offset, '\u0123');
 
+        // Compare
+        {
+            boolean r = UNSAFE.compareAndSwapChar(base, offset, '\u0123', '\u4567');
+            assertEquals(r, true, "success compareAndSwap char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u4567', "success compareAndSwap char value");
+        }
+
+        {
+            boolean r = UNSAFE.compareAndSwapChar(base, offset, '\u0123', '\u89AB');
+            assertEquals(r, false, "failing compareAndSwap char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u4567', "failing compareAndSwap char value");
+        }
+
+        // Advanced compare
+        {
+            char r = UNSAFE.compareAndExchangeCharVolatile(base, offset, '\u4567', '\u0123');
+            assertEquals(r, '\u4567', "success compareAndExchangeVolatile char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value");
+        }
+
+        {
+            char r = UNSAFE.compareAndExchangeCharVolatile(base, offset, '\u4567', '\u89AB');
+            assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value");
+        }
+
+        {
+            char r = UNSAFE.compareAndExchangeCharAcquire(base, offset, '\u0123', '\u4567');
+            assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
+        }
+
+        {
+            char r = UNSAFE.compareAndExchangeCharAcquire(base, offset, '\u0123', '\u89AB');
+            assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
+        }
+
+        {
+            char r = UNSAFE.compareAndExchangeCharRelease(base, offset, '\u4567', '\u0123');
+            assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
+        }
+
+        {
+            char r = UNSAFE.compareAndExchangeCharRelease(base, offset, '\u4567', '\u89AB');
+            assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapChar(base, offset, '\u0123', '\u4567');
+            }
+            assertEquals(success, true, "weakCompareAndSwap char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u4567', "weakCompareAndSwap char value");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapCharAcquire(base, offset, '\u4567', '\u0123');
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u0123', "weakCompareAndSwapAcquire char");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapCharRelease(base, offset, '\u0123', '\u4567');
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u4567', "weakCompareAndSwapRelease char");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapCharVolatile(base, offset, '\u4567', '\u0123');
+            }
+            assertEquals(success, true, "weakCompareAndSwapVolatile char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u0123', "weakCompareAndSwapVolatile char");
+        }
+
+        UNSAFE.putChar(base, offset, '\u4567');
+
+        // Compare set and get
+        {
+            char o = UNSAFE.getAndSetChar(base, offset, '\u0123');
+            assertEquals(o, '\u4567', "getAndSet char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, '\u0123', "getAndSet char value");
+        }
+
+        UNSAFE.putChar(base, offset, '\u0123');
+
+        // get and add, add and get
+        {
+            char o = UNSAFE.getAndAddChar(base, offset, '\u4567');
+            assertEquals(o, '\u0123', "getAndAdd char");
+            char x = UNSAFE.getChar(base, offset);
+            assertEquals(x, (char)('\u0123' + '\u4567'), "getAndAdd char");
+        }
     }
 
     static void testAccess(long address) {
         // Plain
         {
-            UNSAFE.putChar(address, 'a');
+            UNSAFE.putChar(address, '\u0123');
             char x = UNSAFE.getChar(address);
-            assertEquals(x, 'a', "set char value");
+            assertEquals(x, '\u0123', "set char value");
         }
     }
 }
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java	Wed Jun 15 11:21:36 2016 +0300
@@ -145,179 +145,179 @@
     static void testAccess(Object base, long offset) {
         // Plain
         {
-            UNSAFE.putInt(base, offset, 1);
+            UNSAFE.putInt(base, offset, 0x01234567);
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1, "set int value");
+            assertEquals(x, 0x01234567, "set int value");
         }
 
         // Volatile
         {
-            UNSAFE.putIntVolatile(base, offset, 2);
+            UNSAFE.putIntVolatile(base, offset, 0x89ABCDEF);
             int x = UNSAFE.getIntVolatile(base, offset);
-            assertEquals(x, 2, "putVolatile int value");
+            assertEquals(x, 0x89ABCDEF, "putVolatile int value");
         }
 
 
         // Lazy
         {
-            UNSAFE.putIntRelease(base, offset, 1);
+            UNSAFE.putIntRelease(base, offset, 0x01234567);
             int x = UNSAFE.getIntAcquire(base, offset);
-            assertEquals(x, 1, "putRelease int value");
+            assertEquals(x, 0x01234567, "putRelease int value");
         }
 
         // Opaque
         {
-            UNSAFE.putIntOpaque(base, offset, 2);
+            UNSAFE.putIntOpaque(base, offset, 0x89ABCDEF);
             int x = UNSAFE.getIntOpaque(base, offset);
-            assertEquals(x, 2, "putOpaque int value");
+            assertEquals(x, 0x89ABCDEF, "putOpaque int value");
         }
 
         // Unaligned
         {
-            UNSAFE.putIntUnaligned(base, offset, 2);
+            UNSAFE.putIntUnaligned(base, offset, 0x89ABCDEF);
             int x = UNSAFE.getIntUnaligned(base, offset);
-            assertEquals(x, 2, "putUnaligned int value");
+            assertEquals(x, 0x89ABCDEF, "putUnaligned int value");
         }
 
         {
-            UNSAFE.putIntUnaligned(base, offset, 1, true);
+            UNSAFE.putIntUnaligned(base, offset, 0x01234567, true);
             int x = UNSAFE.getIntUnaligned(base, offset, true);
-            assertEquals(x, 1, "putUnaligned big endian int value");
+            assertEquals(x, 0x01234567, "putUnaligned big endian int value");
         }
 
         {
-            UNSAFE.putIntUnaligned(base, offset, 2, false);
+            UNSAFE.putIntUnaligned(base, offset, 0x89ABCDEF, false);
             int x = UNSAFE.getIntUnaligned(base, offset, false);
-            assertEquals(x, 2, "putUnaligned little endian int value");
+            assertEquals(x, 0x89ABCDEF, "putUnaligned little endian int value");
         }
 
-        UNSAFE.putInt(base, offset, 1);
+        UNSAFE.putInt(base, offset, 0x01234567);
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapInt(base, offset, 1, 2);
+            boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF);
             assertEquals(r, true, "success compareAndSwap int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 2, "success compareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "success compareAndSwap int value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapInt(base, offset, 1, 3);
+            boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0xCAFEBABE);
             assertEquals(r, false, "failing compareAndSwap int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 2, "failing compareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "failing compareAndSwap int value");
         }
 
         // Advanced compare
         {
-            int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 2, 1);
-            assertEquals(r, 2, "success compareAndExchangeVolatile int");
+            int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 0x89ABCDEF, 0x01234567);
+            assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1, "success compareAndExchangeVolatile int value");
+            assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value");
         }
 
         {
-            int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 2, 3);
-            assertEquals(r, 1, "failing compareAndExchangeVolatile int");
+            int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 0x89ABCDEF, 0xCAFEBABE);
+            assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1, "failing compareAndExchangeVolatile int value");
+            assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value");
         }
 
         {
-            int r = UNSAFE.compareAndExchangeIntAcquire(base, offset, 1, 2);
-            assertEquals(r, 1, "success compareAndExchangeAcquire int");
+            int r = UNSAFE.compareAndExchangeIntAcquire(base, offset, 0x01234567, 0x89ABCDEF);
+            assertEquals(r, 0x01234567, "success compareAndExchangeAcquire int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 2, "success compareAndExchangeAcquire int value");
+            assertEquals(x, 0x89ABCDEF, "success compareAndExchangeAcquire int value");
         }
 
         {
-            int r = UNSAFE.compareAndExchangeIntAcquire(base, offset, 1, 3);
-            assertEquals(r, 2, "failing compareAndExchangeAcquire int");
+            int r = UNSAFE.compareAndExchangeIntAcquire(base, offset, 0x01234567, 0xCAFEBABE);
+            assertEquals(r, 0x89ABCDEF, "failing compareAndExchangeAcquire int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 2, "failing compareAndExchangeAcquire int value");
+            assertEquals(x, 0x89ABCDEF, "failing compareAndExchangeAcquire int value");
         }
 
         {
-            int r = UNSAFE.compareAndExchangeIntRelease(base, offset, 2, 1);
-            assertEquals(r, 2, "success compareAndExchangeRelease int");
+            int r = UNSAFE.compareAndExchangeIntRelease(base, offset, 0x89ABCDEF, 0x01234567);
+            assertEquals(r, 0x89ABCDEF, "success compareAndExchangeRelease int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1, "success compareAndExchangeRelease int value");
+            assertEquals(x, 0x01234567, "success compareAndExchangeRelease int value");
         }
 
         {
-            int r = UNSAFE.compareAndExchangeIntRelease(base, offset, 2, 3);
-            assertEquals(r, 1, "failing compareAndExchangeRelease int");
+            int r = UNSAFE.compareAndExchangeIntRelease(base, offset, 0x89ABCDEF, 0xCAFEBABE);
+            assertEquals(r, 0x01234567, "failing compareAndExchangeRelease int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1, "failing compareAndExchangeRelease int value");
+            assertEquals(x, 0x01234567, "failing compareAndExchangeRelease int value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapInt(base, offset, 1, 2);
+                success = UNSAFE.weakCompareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF);
             }
             assertEquals(success, true, "weakCompareAndSwap int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 2, "weakCompareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "weakCompareAndSwap int value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 2, 1);
+                success = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 0x89ABCDEF, 0x01234567);
             }
             assertEquals(success, true, "weakCompareAndSwapAcquire int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1, "weakCompareAndSwapAcquire int");
+            assertEquals(x, 0x01234567, "weakCompareAndSwapAcquire int");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 1, 2);
+                success = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 0x01234567, 0x89ABCDEF);
             }
             assertEquals(success, true, "weakCompareAndSwapRelease int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 2, "weakCompareAndSwapRelease int");
+            assertEquals(x, 0x89ABCDEF, "weakCompareAndSwapRelease int");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapIntVolatile(base, offset, 2, 1);
+                success = UNSAFE.weakCompareAndSwapIntVolatile(base, offset, 0x89ABCDEF, 0x01234567);
             }
             assertEquals(success, true, "weakCompareAndSwapVolatile int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1, "weakCompareAndSwapVolatile int");
+            assertEquals(x, 0x01234567, "weakCompareAndSwapVolatile int");
         }
 
-        UNSAFE.putInt(base, offset, 2);
+        UNSAFE.putInt(base, offset, 0x89ABCDEF);
 
         // Compare set and get
         {
-            int o = UNSAFE.getAndSetInt(base, offset, 1);
-            assertEquals(o, 2, "getAndSet int");
+            int o = UNSAFE.getAndSetInt(base, offset, 0x01234567);
+            assertEquals(o, 0x89ABCDEF, "getAndSet int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1, "getAndSet int value");
+            assertEquals(x, 0x01234567, "getAndSet int value");
         }
 
-        UNSAFE.putInt(base, offset, 1);
+        UNSAFE.putInt(base, offset, 0x01234567);
 
         // get and add, add and get
         {
-            int o = UNSAFE.getAndAddInt(base, offset, 2);
-            assertEquals(o, 1, "getAndAdd int");
+            int o = UNSAFE.getAndAddInt(base, offset, 0x89ABCDEF);
+            assertEquals(o, 0x01234567, "getAndAdd int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1 + 2, "getAndAdd int");
+            assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int");
         }
     }
 
     static void testAccess(long address) {
         // Plain
         {
-            UNSAFE.putInt(address, 1);
+            UNSAFE.putInt(address, 0x01234567);
             int x = UNSAFE.getInt(address);
-            assertEquals(x, 1, "set int value");
+            assertEquals(x, 0x01234567, "set int value");
         }
     }
 }
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java	Wed Jun 15 11:21:36 2016 +0300
@@ -145,179 +145,179 @@
     static void testAccess(Object base, long offset) {
         // Plain
         {
-            UNSAFE.putLong(base, offset, 1L);
+            UNSAFE.putLong(base, offset, 0x0123456789ABCDEFL);
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L, "set long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "set long value");
         }
 
         // Volatile
         {
-            UNSAFE.putLongVolatile(base, offset, 2L);
+            UNSAFE.putLongVolatile(base, offset, 0xCAFEBABECAFEBABEL);
             long x = UNSAFE.getLongVolatile(base, offset);
-            assertEquals(x, 2L, "putVolatile long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "putVolatile long value");
         }
 
 
         // Lazy
         {
-            UNSAFE.putLongRelease(base, offset, 1L);
+            UNSAFE.putLongRelease(base, offset, 0x0123456789ABCDEFL);
             long x = UNSAFE.getLongAcquire(base, offset);
-            assertEquals(x, 1L, "putRelease long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "putRelease long value");
         }
 
         // Opaque
         {
-            UNSAFE.putLongOpaque(base, offset, 2L);
+            UNSAFE.putLongOpaque(base, offset, 0xCAFEBABECAFEBABEL);
             long x = UNSAFE.getLongOpaque(base, offset);
-            assertEquals(x, 2L, "putOpaque long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "putOpaque long value");
         }
 
         // Unaligned
         {
-            UNSAFE.putLongUnaligned(base, offset, 2L);
+            UNSAFE.putLongUnaligned(base, offset, 0xCAFEBABECAFEBABEL);
             long x = UNSAFE.getLongUnaligned(base, offset);
-            assertEquals(x, 2L, "putUnaligned long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "putUnaligned long value");
         }
 
         {
-            UNSAFE.putLongUnaligned(base, offset, 1L, true);
+            UNSAFE.putLongUnaligned(base, offset, 0x0123456789ABCDEFL, true);
             long x = UNSAFE.getLongUnaligned(base, offset, true);
-            assertEquals(x, 1L, "putUnaligned big endian long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "putUnaligned big endian long value");
         }
 
         {
-            UNSAFE.putLongUnaligned(base, offset, 2L, false);
+            UNSAFE.putLongUnaligned(base, offset, 0xCAFEBABECAFEBABEL, false);
             long x = UNSAFE.getLongUnaligned(base, offset, false);
-            assertEquals(x, 2L, "putUnaligned little endian long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "putUnaligned little endian long value");
         }
 
-        UNSAFE.putLong(base, offset, 1L);
+        UNSAFE.putLong(base, offset, 0x0123456789ABCDEFL);
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapLong(base, offset, 1L, 2L);
+            boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
             assertEquals(r, true, "success compareAndSwap long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 2L, "success compareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSwap long value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapLong(base, offset, 1L, 3L);
+            boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
             assertEquals(r, false, "failing compareAndSwap long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 2L, "failing compareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSwap long value");
         }
 
         // Advanced compare
         {
-            long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 2L, 1L);
-            assertEquals(r, 2L, "success compareAndExchangeVolatile long");
+            long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+            assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L, "success compareAndExchangeVolatile long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value");
         }
 
         {
-            long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 2L, 3L);
-            assertEquals(r, 1L, "failing compareAndExchangeVolatile long");
+            long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+            assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L, "failing compareAndExchangeVolatile long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value");
         }
 
         {
-            long r = UNSAFE.compareAndExchangeLongAcquire(base, offset, 1L, 2L);
-            assertEquals(r, 1L, "success compareAndExchangeAcquire long");
+            long r = UNSAFE.compareAndExchangeLongAcquire(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+            assertEquals(r, 0x0123456789ABCDEFL, "success compareAndExchangeAcquire long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 2L, "success compareAndExchangeAcquire long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndExchangeAcquire long value");
         }
 
         {
-            long r = UNSAFE.compareAndExchangeLongAcquire(base, offset, 1L, 3L);
-            assertEquals(r, 2L, "failing compareAndExchangeAcquire long");
+            long r = UNSAFE.compareAndExchangeLongAcquire(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
+            assertEquals(r, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 2L, "failing compareAndExchangeAcquire long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long value");
         }
 
         {
-            long r = UNSAFE.compareAndExchangeLongRelease(base, offset, 2L, 1L);
-            assertEquals(r, 2L, "success compareAndExchangeRelease long");
+            long r = UNSAFE.compareAndExchangeLongRelease(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+            assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeRelease long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L, "success compareAndExchangeRelease long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeRelease long value");
         }
 
         {
-            long r = UNSAFE.compareAndExchangeLongRelease(base, offset, 2L, 3L);
-            assertEquals(r, 1L, "failing compareAndExchangeRelease long");
+            long r = UNSAFE.compareAndExchangeLongRelease(base, offset, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+            assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L, "failing compareAndExchangeRelease long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLong(base, offset, 1L, 2L);
+                success = UNSAFE.weakCompareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
             }
             assertEquals(success, true, "weakCompareAndSwap long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 2L, "weakCompareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSwap long value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 2L, 1L);
+                success = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
             }
             assertEquals(success, true, "weakCompareAndSwapAcquire long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L, "weakCompareAndSwapAcquire long");
+            assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSwapAcquire long");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 1L, 2L);
+                success = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
             }
             assertEquals(success, true, "weakCompareAndSwapRelease long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 2L, "weakCompareAndSwapRelease long");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSwapRelease long");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLongVolatile(base, offset, 2L, 1L);
+                success = UNSAFE.weakCompareAndSwapLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
             }
             assertEquals(success, true, "weakCompareAndSwapVolatile long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L, "weakCompareAndSwapVolatile long");
+            assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSwapVolatile long");
         }
 
-        UNSAFE.putLong(base, offset, 2L);
+        UNSAFE.putLong(base, offset, 0xCAFEBABECAFEBABEL);
 
         // Compare set and get
         {
-            long o = UNSAFE.getAndSetLong(base, offset, 1L);
-            assertEquals(o, 2L, "getAndSet long");
+            long o = UNSAFE.getAndSetLong(base, offset, 0x0123456789ABCDEFL);
+            assertEquals(o, 0xCAFEBABECAFEBABEL, "getAndSet long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L, "getAndSet long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "getAndSet long value");
         }
 
-        UNSAFE.putLong(base, offset, 1L);
+        UNSAFE.putLong(base, offset, 0x0123456789ABCDEFL);
 
         // get and add, add and get
         {
-            long o = UNSAFE.getAndAddLong(base, offset, 2L);
-            assertEquals(o, 1L, "getAndAdd long");
+            long o = UNSAFE.getAndAddLong(base, offset, 0xCAFEBABECAFEBABEL);
+            assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L + 2L, "getAndAdd long");
+            assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long");
         }
     }
 
     static void testAccess(long address) {
         // Plain
         {
-            UNSAFE.putLong(address, 1L);
+            UNSAFE.putLong(address, 0x0123456789ABCDEFL);
             long x = UNSAFE.getLong(address);
-            assertEquals(x, 1L, "set long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "set long value");
         }
     }
 }
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java	Wed Jun 15 11:21:36 2016 +0300
@@ -145,61 +145,179 @@
     static void testAccess(Object base, long offset) {
         // Plain
         {
-            UNSAFE.putShort(base, offset, (short)1);
+            UNSAFE.putShort(base, offset, (short)0x0123);
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)1, "set short value");
+            assertEquals(x, (short)0x0123, "set short value");
         }
 
         // Volatile
         {
-            UNSAFE.putShortVolatile(base, offset, (short)2);
+            UNSAFE.putShortVolatile(base, offset, (short)0x4567);
             short x = UNSAFE.getShortVolatile(base, offset);
-            assertEquals(x, (short)2, "putVolatile short value");
+            assertEquals(x, (short)0x4567, "putVolatile short value");
         }
 
 
         // Lazy
         {
-            UNSAFE.putShortRelease(base, offset, (short)1);
+            UNSAFE.putShortRelease(base, offset, (short)0x0123);
             short x = UNSAFE.getShortAcquire(base, offset);
-            assertEquals(x, (short)1, "putRelease short value");
+            assertEquals(x, (short)0x0123, "putRelease short value");
         }
 
         // Opaque
         {
-            UNSAFE.putShortOpaque(base, offset, (short)2);
+            UNSAFE.putShortOpaque(base, offset, (short)0x4567);
             short x = UNSAFE.getShortOpaque(base, offset);
-            assertEquals(x, (short)2, "putOpaque short value");
+            assertEquals(x, (short)0x4567, "putOpaque short value");
         }
 
         // Unaligned
         {
-            UNSAFE.putShortUnaligned(base, offset, (short)2);
+            UNSAFE.putShortUnaligned(base, offset, (short)0x4567);
             short x = UNSAFE.getShortUnaligned(base, offset);
-            assertEquals(x, (short)2, "putUnaligned short value");
+            assertEquals(x, (short)0x4567, "putUnaligned short value");
         }
 
         {
-            UNSAFE.putShortUnaligned(base, offset, (short)1, true);
+            UNSAFE.putShortUnaligned(base, offset, (short)0x0123, true);
             short x = UNSAFE.getShortUnaligned(base, offset, true);
-            assertEquals(x, (short)1, "putUnaligned big endian short value");
+            assertEquals(x, (short)0x0123, "putUnaligned big endian short value");
         }
 
         {
-            UNSAFE.putShortUnaligned(base, offset, (short)2, false);
+            UNSAFE.putShortUnaligned(base, offset, (short)0x4567, false);
             short x = UNSAFE.getShortUnaligned(base, offset, false);
-            assertEquals(x, (short)2, "putUnaligned little endian short value");
+            assertEquals(x, (short)0x4567, "putUnaligned little endian short value");
         }
 
+        UNSAFE.putShort(base, offset, (short)0x0123);
 
+        // Compare
+        {
+            boolean r = UNSAFE.compareAndSwapShort(base, offset, (short)0x0123, (short)0x4567);
+            assertEquals(r, true, "success compareAndSwap short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x4567, "success compareAndSwap short value");
+        }
+
+        {
+            boolean r = UNSAFE.compareAndSwapShort(base, offset, (short)0x0123, (short)0x89AB);
+            assertEquals(r, false, "failing compareAndSwap short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x4567, "failing compareAndSwap short value");
+        }
+
+        // Advanced compare
+        {
+            short r = UNSAFE.compareAndExchangeShortVolatile(base, offset, (short)0x4567, (short)0x0123);
+            assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value");
+        }
+
+        {
+            short r = UNSAFE.compareAndExchangeShortVolatile(base, offset, (short)0x4567, (short)0x89AB);
+            assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value");
+        }
+
+        {
+            short r = UNSAFE.compareAndExchangeShortAcquire(base, offset, (short)0x0123, (short)0x4567);
+            assertEquals(r, (short)0x0123, "success compareAndExchangeAcquire short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x4567, "success compareAndExchangeAcquire short value");
+        }
+
+        {
+            short r = UNSAFE.compareAndExchangeShortAcquire(base, offset, (short)0x0123, (short)0x89AB);
+            assertEquals(r, (short)0x4567, "failing compareAndExchangeAcquire short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x4567, "failing compareAndExchangeAcquire short value");
+        }
+
+        {
+            short r = UNSAFE.compareAndExchangeShortRelease(base, offset, (short)0x4567, (short)0x0123);
+            assertEquals(r, (short)0x4567, "success compareAndExchangeRelease short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x0123, "success compareAndExchangeRelease short value");
+        }
+
+        {
+            short r = UNSAFE.compareAndExchangeShortRelease(base, offset, (short)0x4567, (short)0x89AB);
+            assertEquals(r, (short)0x0123, "failing compareAndExchangeRelease short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x0123, "failing compareAndExchangeRelease short value");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapShort(base, offset, (short)0x0123, (short)0x4567);
+            }
+            assertEquals(success, true, "weakCompareAndSwap short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x4567, "weakCompareAndSwap short value");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapShortAcquire(base, offset, (short)0x4567, (short)0x0123);
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x0123, "weakCompareAndSwapAcquire short");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapShortRelease(base, offset, (short)0x0123, (short)0x4567);
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x4567, "weakCompareAndSwapRelease short");
+        }
+
+        {
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapShortVolatile(base, offset, (short)0x4567, (short)0x0123);
+            }
+            assertEquals(success, true, "weakCompareAndSwapVolatile short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x0123, "weakCompareAndSwapVolatile short");
+        }
+
+        UNSAFE.putShort(base, offset, (short)0x4567);
+
+        // Compare set and get
+        {
+            short o = UNSAFE.getAndSetShort(base, offset, (short)0x0123);
+            assertEquals(o, (short)0x4567, "getAndSet short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)0x0123, "getAndSet short value");
+        }
+
+        UNSAFE.putShort(base, offset, (short)0x0123);
+
+        // get and add, add and get
+        {
+            short o = UNSAFE.getAndAddShort(base, offset, (short)0x4567);
+            assertEquals(o, (short)0x0123, "getAndAdd short");
+            short x = UNSAFE.getShort(base, offset);
+            assertEquals(x, (short)((short)0x0123 + (short)0x4567), "getAndAdd short");
+        }
     }
 
     static void testAccess(long address) {
         // Plain
         {
-            UNSAFE.putShort(address, (short)1);
+            UNSAFE.putShort(address, (short)0x0123);
             short x = UNSAFE.getShort(address);
-            assertEquals(x, (short)1, "set short value");
+            assertEquals(x, (short)0x0123, "set short value");
         }
     }
 }
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java	Wed Jun 15 11:21:36 2016 +0300
@@ -145,16 +145,16 @@
     static void testAccess(Object base, long offset) {
         // Plain
         {
-            UNSAFE.putByte(base, offset, (byte)1);
+            UNSAFE.putByte(base, offset, (byte)0x01);
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)1, "set byte value");
+            assertEquals(x, (byte)0x01, "set byte value");
         }
 
         // Volatile
         {
-            UNSAFE.putByteVolatile(base, offset, (byte)2);
+            UNSAFE.putByteVolatile(base, offset, (byte)0x23);
             byte x = UNSAFE.getByteVolatile(base, offset);
-            assertEquals(x, (byte)2, "putVolatile byte value");
+            assertEquals(x, (byte)0x23, "putVolatile byte value");
         }
 
 
@@ -166,9 +166,9 @@
     static void testAccess(long address) {
         // Plain
         {
-            UNSAFE.putByte(address, (byte)1);
+            UNSAFE.putByte(address, (byte)0x01);
             byte x = UNSAFE.getByte(address);
-            assertEquals(x, (byte)1, "set byte value");
+            assertEquals(x, (byte)0x01, "set byte value");
         }
     }
 }
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java	Wed Jun 15 11:21:36 2016 +0300
@@ -145,16 +145,16 @@
     static void testAccess(Object base, long offset) {
         // Plain
         {
-            UNSAFE.putChar(base, offset, 'a');
+            UNSAFE.putChar(base, offset, '\u0123');
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, 'a', "set char value");
+            assertEquals(x, '\u0123', "set char value");
         }
 
         // Volatile
         {
-            UNSAFE.putCharVolatile(base, offset, 'b');
+            UNSAFE.putCharVolatile(base, offset, '\u4567');
             char x = UNSAFE.getCharVolatile(base, offset);
-            assertEquals(x, 'b', "putVolatile char value");
+            assertEquals(x, '\u4567', "putVolatile char value");
         }
 
 
@@ -166,9 +166,9 @@
     static void testAccess(long address) {
         // Plain
         {
-            UNSAFE.putChar(address, 'a');
+            UNSAFE.putChar(address, '\u0123');
             char x = UNSAFE.getChar(address);
-            assertEquals(x, 'a', "set char value");
+            assertEquals(x, '\u0123', "set char value");
         }
     }
 }
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java	Wed Jun 15 11:21:36 2016 +0300
@@ -145,71 +145,71 @@
     static void testAccess(Object base, long offset) {
         // Plain
         {
-            UNSAFE.putInt(base, offset, 1);
+            UNSAFE.putInt(base, offset, 0x01234567);
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1, "set int value");
+            assertEquals(x, 0x01234567, "set int value");
         }
 
         // Volatile
         {
-            UNSAFE.putIntVolatile(base, offset, 2);
+            UNSAFE.putIntVolatile(base, offset, 0x89ABCDEF);
             int x = UNSAFE.getIntVolatile(base, offset);
-            assertEquals(x, 2, "putVolatile int value");
+            assertEquals(x, 0x89ABCDEF, "putVolatile int value");
         }
 
         // Lazy
         {
-            UNSAFE.putOrderedInt(base, offset, 1);
+            UNSAFE.putOrderedInt(base, offset, 0x01234567);
             int x = UNSAFE.getIntVolatile(base, offset);
-            assertEquals(x, 1, "putRelease int value");
+            assertEquals(x, 0x01234567, "putRelease int value");
         }
 
 
 
-        UNSAFE.putInt(base, offset, 1);
+        UNSAFE.putInt(base, offset, 0x01234567);
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapInt(base, offset, 1, 2);
+            boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF);
             assertEquals(r, true, "success compareAndSwap int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 2, "success compareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "success compareAndSwap int value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapInt(base, offset, 1, 3);
+            boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0xCAFEBABE);
             assertEquals(r, false, "failing compareAndSwap int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 2, "failing compareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "failing compareAndSwap int value");
         }
 
-        UNSAFE.putInt(base, offset, 2);
+        UNSAFE.putInt(base, offset, 0x89ABCDEF);
 
         // Compare set and get
         {
-            int o = UNSAFE.getAndSetInt(base, offset, 1);
-            assertEquals(o, 2, "getAndSet int");
+            int o = UNSAFE.getAndSetInt(base, offset, 0x01234567);
+            assertEquals(o, 0x89ABCDEF, "getAndSet int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1, "getAndSet int value");
+            assertEquals(x, 0x01234567, "getAndSet int value");
         }
 
-        UNSAFE.putInt(base, offset, 1);
+        UNSAFE.putInt(base, offset, 0x01234567);
 
         // get and add, add and get
         {
-            int o = UNSAFE.getAndAddInt(base, offset, 2);
-            assertEquals(o, 1, "getAndAdd int");
+            int o = UNSAFE.getAndAddInt(base, offset, 0x89ABCDEF);
+            assertEquals(o, 0x01234567, "getAndAdd int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1 + 2, "getAndAdd int");
+            assertEquals(x, (int)(0x01234567 + 0x89ABCDEF), "getAndAdd int");
         }
     }
 
     static void testAccess(long address) {
         // Plain
         {
-            UNSAFE.putInt(address, 1);
+            UNSAFE.putInt(address, 0x01234567);
             int x = UNSAFE.getInt(address);
-            assertEquals(x, 1, "set int value");
+            assertEquals(x, 0x01234567, "set int value");
         }
     }
 }
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java	Wed Jun 15 11:21:36 2016 +0300
@@ -145,71 +145,71 @@
     static void testAccess(Object base, long offset) {
         // Plain
         {
-            UNSAFE.putLong(base, offset, 1L);
+            UNSAFE.putLong(base, offset, 0x0123456789ABCDEFL);
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L, "set long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "set long value");
         }
 
         // Volatile
         {
-            UNSAFE.putLongVolatile(base, offset, 2L);
+            UNSAFE.putLongVolatile(base, offset, 0xCAFEBABECAFEBABEL);
             long x = UNSAFE.getLongVolatile(base, offset);
-            assertEquals(x, 2L, "putVolatile long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "putVolatile long value");
         }
 
         // Lazy
         {
-            UNSAFE.putOrderedLong(base, offset, 1L);
+            UNSAFE.putOrderedLong(base, offset, 0x0123456789ABCDEFL);
             long x = UNSAFE.getLongVolatile(base, offset);
-            assertEquals(x, 1L, "putRelease long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "putRelease long value");
         }
 
 
 
-        UNSAFE.putLong(base, offset, 1L);
+        UNSAFE.putLong(base, offset, 0x0123456789ABCDEFL);
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapLong(base, offset, 1L, 2L);
+            boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
             assertEquals(r, true, "success compareAndSwap long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 2L, "success compareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSwap long value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapLong(base, offset, 1L, 3L);
+            boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
             assertEquals(r, false, "failing compareAndSwap long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 2L, "failing compareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSwap long value");
         }
 
-        UNSAFE.putLong(base, offset, 2L);
+        UNSAFE.putLong(base, offset, 0xCAFEBABECAFEBABEL);
 
         // Compare set and get
         {
-            long o = UNSAFE.getAndSetLong(base, offset, 1L);
-            assertEquals(o, 2L, "getAndSet long");
+            long o = UNSAFE.getAndSetLong(base, offset, 0x0123456789ABCDEFL);
+            assertEquals(o, 0xCAFEBABECAFEBABEL, "getAndSet long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L, "getAndSet long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "getAndSet long value");
         }
 
-        UNSAFE.putLong(base, offset, 1L);
+        UNSAFE.putLong(base, offset, 0x0123456789ABCDEFL);
 
         // get and add, add and get
         {
-            long o = UNSAFE.getAndAddLong(base, offset, 2L);
-            assertEquals(o, 1L, "getAndAdd long");
+            long o = UNSAFE.getAndAddLong(base, offset, 0xCAFEBABECAFEBABEL);
+            assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L + 2L, "getAndAdd long");
+            assertEquals(x, (long)(0x0123456789ABCDEFL + 0xCAFEBABECAFEBABEL), "getAndAdd long");
         }
     }
 
     static void testAccess(long address) {
         // Plain
         {
-            UNSAFE.putLong(address, 1L);
+            UNSAFE.putLong(address, 0x0123456789ABCDEFL);
             long x = UNSAFE.getLong(address);
-            assertEquals(x, 1L, "set long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "set long value");
         }
     }
 }
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java	Wed Jun 15 11:21:36 2016 +0300
@@ -145,16 +145,16 @@
     static void testAccess(Object base, long offset) {
         // Plain
         {
-            UNSAFE.putShort(base, offset, (short)1);
+            UNSAFE.putShort(base, offset, (short)0x0123);
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)1, "set short value");
+            assertEquals(x, (short)0x0123, "set short value");
         }
 
         // Volatile
         {
-            UNSAFE.putShortVolatile(base, offset, (short)2);
+            UNSAFE.putShortVolatile(base, offset, (short)0x4567);
             short x = UNSAFE.getShortVolatile(base, offset);
-            assertEquals(x, (short)2, "putVolatile short value");
+            assertEquals(x, (short)0x4567, "putVolatile short value");
         }
 
 
@@ -166,9 +166,9 @@
     static void testAccess(long address) {
         // Plain
         {
-            UNSAFE.putShort(address, (short)1);
+            UNSAFE.putShort(address, (short)0x0123);
             short x = UNSAFE.getShort(address);
-            assertEquals(x, (short)1, "set short value");
+            assertEquals(x, (short)0x0123, "set short value");
         }
     }
 }
--- a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template	Wed Jun 15 11:21:36 2016 +0300
@@ -333,7 +333,7 @@
             $type$ o = UNSAFE.getAndAdd$Type$(base, offset, $value2$);
             assertEquals(o, $value1$, "getAndAdd $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$ + $value2$, "getAndAdd $type$");
+            assertEquals(x, ($type$)($value1$ + $value2$), "getAndAdd $type$");
         }
 #end[AtomicAdd]
     }
--- a/hotspot/test/compiler/unsafe/generate-unsafe-access-tests.sh	Wed Jun 15 07:58:56 2016 +0200
+++ b/hotspot/test/compiler/unsafe/generate-unsafe-access-tests.sh	Wed Jun 15 11:21:36 2016 +0300
@@ -53,6 +53,19 @@
           ;;
       esac
 
+      if [ "$package" == "jdk.internal.misc" ]; then
+        case $type in
+          boolean|byte|char|short)
+            args="$args -KCAS"
+            ;;
+        esac
+        case $type in
+          byte|char|short)
+            args="$args -KAtomicAdd"
+            ;;
+        esac
+      fi
+
       case $type in
         short|char|int|long)
           args="$args -KUnaligned"
@@ -66,29 +79,29 @@
           value3=false
           ;;
         byte)
-          value1=(byte)1
-          value2=(byte)2
-          value3=(byte)3
+          value1=(byte)0x01
+          value2=(byte)0x23
+          value3=(byte)0x45
           ;;
         short)
-          value1=(short)1
-          value2=(short)2
-          value3=(short)3
+          value1=(short)0x0123
+          value2=(short)0x4567
+          value3=(short)0x89AB
           ;;
         char)
-          value1=\'a\'
-          value2=\'b\'
-          value3=\'c\'
+          value1=\'\\\\u0123\'
+          value2=\'\\\\u4567\'
+          value3=\'\\\\u89AB\'
           ;;
         int)
-          value1=1
-          value2=2
-          value3=3
+          value1=0x01234567
+          value2=0x89ABCDEF
+          value3=0xCAFEBABE
           ;;
         long)
-          value1=1L
-          value2=2L
-          value3=3L
+          value1=0x0123456789ABCDEFL
+          value2=0xCAFEBABECAFEBABEL
+          value3=0xDEADBEEFDEADBEEFL
           ;;
         float)
           value1=1.0f