8054927: Missing MemNode::acquire ordering in some volatile Load nodes

Wed, 13 Aug 2014 13:05:04 -0700

author
kvn
date
Wed, 13 Aug 2014 13:05:04 -0700
changeset 7134
d8847542f83a
parent 7133
2219e830b668
child 7136
3153adbad1e9

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

src/share/vm/opto/library_call.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/opto/library_call.cpp	Mon Sep 08 23:01:01 2014 +0000
     1.2 +++ b/src/share/vm/opto/library_call.cpp	Wed Aug 13 13:05:04 2014 -0700
     1.3 @@ -2650,7 +2650,8 @@
     1.4    if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder);
     1.5  
     1.6    if (!is_store) {
     1.7 -    Node* p = make_load(control(), adr, value_type, type, adr_type, MemNode::unordered, is_volatile);
     1.8 +    MemNode::MemOrd mo = is_volatile ? MemNode::acquire : MemNode::unordered;
     1.9 +    Node* p = make_load(control(), adr, value_type, type, adr_type, mo, is_volatile);
    1.10      // load value
    1.11      switch (type) {
    1.12      case T_BOOLEAN:
    1.13 @@ -5912,8 +5913,19 @@
    1.14      type = Type::get_const_basic_type(bt);
    1.15    }
    1.16  
    1.17 +  if (support_IRIW_for_not_multiple_copy_atomic_cpu && is_vol) {
    1.18 +    insert_mem_bar(Op_MemBarVolatile);   // StoreLoad barrier
    1.19 +  }
    1.20    // Build the load.
    1.21 -  Node* loadedField = make_load(NULL, adr, type, bt, adr_type, MemNode::unordered, is_vol);
    1.22 +  MemNode::MemOrd mo = is_vol ? MemNode::acquire : MemNode::unordered;
    1.23 +  Node* loadedField = make_load(NULL, adr, type, bt, adr_type, mo, is_vol);
    1.24 +  // If reference is volatile, prevent following memory ops from
    1.25 +  // floating up past the volatile read.  Also prevents commoning
    1.26 +  // another volatile read.
    1.27 +  if (is_vol) {
    1.28 +    // Memory barrier includes bogus read of value to force load BEFORE membar
    1.29 +    insert_mem_bar(Op_MemBarAcquire, loadedField);
    1.30 +  }
    1.31    return loadedField;
    1.32  }
    1.33  

mercurial