Top


定義場所(file name)

hotspot/src/share/vm/runtime/virtualspace.cpp

名前(function name)

bool VirtualSpace::initialize(ReservedSpace rs, size_t committed_size) {

本体部(body)

  {- -------------------------------------------
  (1) rs 引数の ReservedSpace が reserve に失敗していた場合は, ここでリターン.
      ---------------------------------------- -}

      if(!rs.is_reserved()) return false;  // allocation failed.

  {- -------------------------------------------
  (1) (assert)
      ---------------------------------------- -}

      assert(_low_boundary == NULL, "VirtualSpace already initialized");

  {- -------------------------------------------
  (1) フィールドの初期化
      ---------------------------------------- -}

      _low_boundary  = rs.base();
      _high_boundary = low_boundary() + rs.size();

      _low = low_boundary();
      _high = low();

      _special = rs.special();
      _executable = rs.executable();

      // When a VirtualSpace begins life at a large size, make all future expansion
      // and shrinking occur aligned to a granularity of large pages.  This avoids
      // fragmentation of physical addresses that inhibits the use of large pages
      // by the OS virtual memory system.  Empirically,  we see that with a 4MB
      // page size, the only spaces that get handled this way are codecache and
      // the heap itself, both of which provide a substantial performance
      // boost in many benchmarks when covered by large pages.
      //
      // No attempt is made to force large page alignment at the very top and
      // bottom of the space if they are not aligned so already.
      _lower_alignment  = os::vm_page_size();
      _middle_alignment = os::page_size_for_region(rs.size(), rs.size(), 1);
      _upper_alignment  = os::vm_page_size();

      // End of each region
      _lower_high_boundary = (char*) round_to((intptr_t) low_boundary(), middle_alignment());
      _middle_high_boundary = (char*) round_down((intptr_t) high_boundary(), middle_alignment());
      _upper_high_boundary = high_boundary();

      // High address of each region
      _lower_high = low_boundary();
      _middle_high = lower_high_boundary();
      _upper_high = middle_high_boundary();

  {- -------------------------------------------
  (1) コミットするメモリがある場合 (= committed_size 引数が 0 より大きい場合), 
      VirtualSpace::expand_by() を呼び出してメモリを commit しておく.
      ---------------------------------------- -}

      // commit to initial size
      if (committed_size > 0) {
        if (!expand_by(committed_size)) {
          return false;
        }
      }
      return true;
    }

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