# HG changeset patch # User kvn # Date 1407960304 25200 # Node ID ddd28cb3f2b9db47c0027ad8f80b7bdb0ea0a439 # Parent 4645d30c2e27a24b4e99f636ccda3b704d248a03 8054927: Missing MemNode::acquire ordering in some volatile Load nodes Summary: Fixed memory ordering parameter and added missing barriers for volatile loads. Reviewed-by: roland, iveresov diff -r 4645d30c2e27 -r ddd28cb3f2b9 hotspot/src/share/vm/opto/library_call.cpp --- a/hotspot/src/share/vm/opto/library_call.cpp Wed Aug 13 09:53:18 2014 +0000 +++ b/hotspot/src/share/vm/opto/library_call.cpp Wed Aug 13 13:05:04 2014 -0700 @@ -2595,7 +2595,8 @@ if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); if (!is_store) { - Node* p = make_load(control(), adr, value_type, type, adr_type, MemNode::unordered, is_volatile); + MemNode::MemOrd mo = is_volatile ? MemNode::acquire : MemNode::unordered; + Node* p = make_load(control(), adr, value_type, type, adr_type, mo, is_volatile); // load value switch (type) { case T_BOOLEAN: @@ -5096,8 +5097,19 @@ type = Type::get_const_basic_type(bt); } + if (support_IRIW_for_not_multiple_copy_atomic_cpu && is_vol) { + insert_mem_bar(Op_MemBarVolatile); // StoreLoad barrier + } // Build the load. - Node* loadedField = make_load(NULL, adr, type, bt, adr_type, MemNode::unordered, is_vol); + MemNode::MemOrd mo = is_vol ? MemNode::acquire : MemNode::unordered; + Node* loadedField = make_load(NULL, adr, type, bt, adr_type, mo, is_vol); + // If reference is volatile, prevent following memory ops from + // floating up past the volatile read. Also prevents commoning + // another volatile read. + if (is_vol) { + // Memory barrier includes bogus read of value to force load BEFORE membar + insert_mem_bar(Op_MemBarAcquire, loadedField); + } return loadedField; }