Top


定義場所(file name)

hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp

名前(function name)

inline void MacroAssembler::membar( Membar_mask_bits const7a ) {

本体部(body)

  {- -------------------------------------------
  (1) MP 環境でなければ, (メモリバリアは必要ないので) 何もしない. ここでリターン.
      ---------------------------------------- -}

      // Uniprocessors do not need memory barriers
      if (!os::is_MP()) return;

  {- -------------------------------------------
  (1) V9 では LoadLoad, LoadStore, StoreStore では出す必要はない. (StoreLoad の場合のみ必要)
      要求されているのが StoreLoad の場合のみ, Assembler::membar() でメモリバリアコードを生成.
      ---------------------------------------- -}

      // Weakened for current Sparcs and TSO.  See the v9 manual, sections 8.4.3,
      // 8.4.4.3, a.31 and a.50.
      if( VM_Version::v9_instructions_work() ) {
        // Under TSO, setting bit 3, 2, or 0 is redundant, so the only value
        // of the mmask subfield of const7a that does anything that isn't done
        // implicitly is StoreLoad.
        const Membar_mask_bits effective_mask =
            Membar_mask_bits(const7a & ~(LoadLoad | LoadStore | StoreStore));
        if ( effective_mask != 0 ) {
          Assembler::membar( effective_mask );
        }

  {- -------------------------------------------
  (1) V9 でない場合は, とりあえず ldstub を生成.

      (コメントによると, 
         V8 では stbar が membar(StoreStore) として働くが, 
         そもそも知っている範囲では全て TSO なので, 普通に store を発行すれば stbar 効果も付いてくる.
         membar(StoreLoad) に相当するものは V8 にはない.
         なお, David Dice によると ldstub が write buffer をフラッシュするとのこと.
         念のために ldstub をここに置いておくことにする.
       とのこと.
      ---------------------------------------- -}

      } else {
        // stbar is the closest there is on v8.  Equivalent to membar(StoreStore).  We
        // do not issue the stbar because to my knowledge all v8 machines implement TSO,
        // which guarantees that all stores behave as if an stbar were issued just after
        // each one of them.  On these machines, stbar ought to be a nop.  There doesn't
        // appear to be an equivalent of membar(StoreLoad) on v8: TSO doesn't require it,
        // it can't be specified by stbar, nor have I come up with a way to simulate it.
        //
        // Addendum.  Dave says that ldstub guarantees a write buffer flush to coherent
        // space.  Put one here to be on the safe side.
        Assembler::ldstub(SP, 0, G0);
      }
    }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.