diff src/share/vm/c1/c1_LIRGenerator.cpp @ 14662:3c3953fb3f2a

8033380: Experimental VM flag to enforce access atomicity Summary: -XX:+AlwaysAtomicAccesses to unconditionally enforce the access atomicity. Reviewed-by: roland, kvn, iveresov
author shade
date Mon, 03 Mar 2014 15:54:45 +0400
parents 8cdf3f43f63e
children b51e29501f30
line wrap: on
line diff
--- a/src/share/vm/c1/c1_LIRGenerator.cpp	Tue Jan 28 15:05:46 2014 +0100
+++ b/src/share/vm/c1/c1_LIRGenerator.cpp	Mon Mar 03 15:54:45 2014 +0400
@@ -1734,7 +1734,8 @@
                 (info ? new CodeEmitInfo(info) : NULL));
   }
 
-  if (is_volatile && !needs_patching) {
+  bool needs_atomic_access = is_volatile || AlwaysAtomicAccesses;
+  if (needs_atomic_access && !needs_patching) {
     volatile_field_store(value.result(), address, info);
   } else {
     LIR_PatchCode patch_code = needs_patching ? lir_patch_normal : lir_patch_none;
@@ -1807,7 +1808,8 @@
     address = generate_address(object.result(), x->offset(), field_type);
   }
 
-  if (is_volatile && !needs_patching) {
+  bool needs_atomic_access = is_volatile || AlwaysAtomicAccesses;
+  if (needs_atomic_access && !needs_patching) {
     volatile_field_load(address, reg, info);
   } else {
     LIR_PatchCode patch_code = needs_patching ? lir_patch_normal : lir_patch_none;