aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/opto/library_call.cpp
diff options
context:
space:
mode:
authorkvn <none@none>2012-12-18 17:37:44 -0800
committerkvn <none@none>2012-12-18 17:37:44 -0800
commit595e257e4995179c04344f30c9f10b60adf9323f (patch)
tree47cddd10cb1369af2d8d693a105feb054988d52c /src/share/vm/opto/library_call.cpp
parentd95428864377ceee5f9b3b565ea62d0a62ba47c0 (diff)
8004318: JEP-171: Support Unsafe fences intrinsics
Summary: Add three memory-ordering intrinsics to the sun.misc.Unsafe class. Reviewed-by: twisti, kvn Contributed-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Diffstat (limited to 'src/share/vm/opto/library_call.cpp')
-rw-r--r--src/share/vm/opto/library_call.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/share/vm/opto/library_call.cpp b/src/share/vm/opto/library_call.cpp
index ff979d655..313339edf 100644
--- a/src/share/vm/opto/library_call.cpp
+++ b/src/share/vm/opto/library_call.cpp
@@ -282,6 +282,7 @@ class LibraryCallKit : public GraphKit {
typedef enum { LS_xadd, LS_xchg, LS_cmpxchg } LoadStoreKind;
bool inline_unsafe_load_store(BasicType type, LoadStoreKind kind);
bool inline_unsafe_ordered_store(BasicType type);
+ bool inline_unsafe_fence(vmIntrinsics::ID id);
bool inline_fp_conversions(vmIntrinsics::ID id);
bool inline_number_methods(vmIntrinsics::ID id);
bool inline_reference_get();
@@ -334,6 +335,9 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) {
case vmIntrinsics::_getAndSetInt:
case vmIntrinsics::_getAndSetLong:
case vmIntrinsics::_getAndSetObject:
+ case vmIntrinsics::_loadFence:
+ case vmIntrinsics::_storeFence:
+ case vmIntrinsics::_fullFence:
break; // InlineNatives does not control String.compareTo
case vmIntrinsics::_Reference_get:
break; // InlineNatives does not control Reference.get
@@ -732,6 +736,10 @@ bool LibraryCallKit::try_to_inline() {
case vmIntrinsics::_getAndSetLong: return inline_unsafe_load_store(T_LONG, LS_xchg);
case vmIntrinsics::_getAndSetObject: return inline_unsafe_load_store(T_OBJECT, LS_xchg);
+ case vmIntrinsics::_loadFence:
+ case vmIntrinsics::_storeFence:
+ case vmIntrinsics::_fullFence: return inline_unsafe_fence(intrinsic_id());
+
case vmIntrinsics::_currentThread: return inline_native_currentThread();
case vmIntrinsics::_isInterrupted: return inline_native_isInterrupted();
@@ -2840,6 +2848,26 @@ bool LibraryCallKit::inline_unsafe_ordered_store(BasicType type) {
return true;
}
+bool LibraryCallKit::inline_unsafe_fence(vmIntrinsics::ID id) {
+ // Regardless of form, don't allow previous ld/st to move down,
+ // then issue acquire, release, or volatile mem_bar.
+ insert_mem_bar(Op_MemBarCPUOrder);
+ switch(id) {
+ case vmIntrinsics::_loadFence:
+ insert_mem_bar(Op_MemBarAcquire);
+ return true;
+ case vmIntrinsics::_storeFence:
+ insert_mem_bar(Op_MemBarRelease);
+ return true;
+ case vmIntrinsics::_fullFence:
+ insert_mem_bar(Op_MemBarVolatile);
+ return true;
+ default:
+ fatal_unexpected_iid(id);
+ return false;
+ }
+}
+
//----------------------------inline_unsafe_allocate---------------------------
// public native Object sun.mics.Unsafe.allocateInstance(Class<?> cls);
bool LibraryCallKit::inline_unsafe_allocate() {