src/hotspot/share/opto/parse1.cpp
changeset 58004 dee322336e17
parent 55635 0fb70c9118ce
child 58679 9c3209ff7550
child 58961 5d462d4b7a8b
equal deleted inserted replaced
58003:a645b2f7bece 58004:dee322336e17
   977   //    publishes the reference to the newly constructed object. Rather
   977   //    publishes the reference to the newly constructed object. Rather
   978   //    than wait for the publication, we simply block the writes here.
   978   //    than wait for the publication, we simply block the writes here.
   979   //    Rather than put a barrier on only those writes which are required
   979   //    Rather than put a barrier on only those writes which are required
   980   //    to complete, we force all writes to complete.
   980   //    to complete, we force all writes to complete.
   981   //
   981   //
   982   // 2. On PPC64, also add MemBarRelease for constructors which write
   982   // 2. Experimental VM option is used to force the barrier if any field
   983   //    volatile fields. As support_IRIW_for_not_multiple_copy_atomic_cpu
   983   //    was written out in the constructor.
   984   //    is set on PPC64, no sync instruction is issued after volatile
       
   985   //    stores. We want to guarantee the same behavior as on platforms
       
   986   //    with total store order, although this is not required by the Java
       
   987   //    memory model. So as with finals, we add a barrier here.
       
   988   //
   984   //
   989   // 3. Experimental VM option is used to force the barrier if any field
   985   // 3. On processors which are not CPU_MULTI_COPY_ATOMIC (e.g. PPC64),
   990   //    was written out in the constructor.
   986   //    support_IRIW_for_not_multiple_copy_atomic_cpu selects that
       
   987   //    MemBarVolatile is used before volatile load instead of after volatile
       
   988   //    store, so there's no barrier after the store.
       
   989   //    We want to guarantee the same behavior as on platforms with total store
       
   990   //    order, although this is not required by the Java memory model.
       
   991   //    In this case, we want to enforce visibility of volatile field
       
   992   //    initializations which are performed in constructors.
       
   993   //    So as with finals, we add a barrier here.
   991   //
   994   //
   992   // "All bets are off" unless the first publication occurs after a
   995   // "All bets are off" unless the first publication occurs after a
   993   // normal return from the constructor.  We do not attempt to detect
   996   // normal return from the constructor.  We do not attempt to detect
   994   // such unusual early publications.  But no barrier is needed on
   997   // such unusual early publications.  But no barrier is needed on
   995   // exceptional returns, since they cannot publish normally.
   998   // exceptional returns, since they cannot publish normally.
   996   //
   999   //
   997   if (method()->is_initializer() &&
  1000   if (method()->is_initializer() &&
   998         (wrote_final() ||
  1001        (wrote_final() ||
   999            PPC64_ONLY(wrote_volatile() ||)
  1002          (AlwaysSafeConstructors && wrote_fields()) ||
  1000            (AlwaysSafeConstructors && wrote_fields()))) {
  1003          (support_IRIW_for_not_multiple_copy_atomic_cpu && wrote_volatile()))) {
  1001     _exits.insert_mem_bar(Op_MemBarRelease, alloc_with_final());
  1004     _exits.insert_mem_bar(Op_MemBarRelease, alloc_with_final());
  1002 
  1005 
  1003     // If Memory barrier is created for final fields write
  1006     // If Memory barrier is created for final fields write
  1004     // and allocation node does not escape the initialize method,
  1007     // and allocation node does not escape the initialize method,
  1005     // then barrier introduced by allocation node can be removed.
  1008     // then barrier introduced by allocation node can be removed.