Top


定義場所(file name)

hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp

名前(function name)

void HeapRegion::setup_heap_region_size(uintx min_heap_size) {

本体部(body)

  {- -------------------------------------------
  (1) (変数宣言など)
      (region_size, 及び region_size_log の値を計算している)
      ---------------------------------------- -}

      // region_size in bytes
      uintx region_size = G1HeapRegionSize;
      if (FLAG_IS_DEFAULT(G1HeapRegionSize)) {
        // We base the automatic calculation on the min heap size. This
        // can be problematic if the spread between min and max is quite
        // wide, imagine -Xms128m -Xmx32g. But, if we decided it based on
        // the max size, the region size might be way too large for the
        // min size. Either way, some users might have to set the region
        // size manually for some -Xms / -Xmx combos.

        region_size = MAX2(min_heap_size / TARGET_REGION_NUMBER,
                           (uintx) MIN_REGION_SIZE);
      }

      int region_size_log = log2_long((jlong) region_size);
      // Recalculate the region size to make sure it's a power of
      // 2. This means that region_size is the largest power of 2 that's
      // <= what we've calculated so far.
      region_size = ((uintx)1 << region_size_log);

      // Now make sure that we don't go over or under our limits.
      if (region_size < MIN_REGION_SIZE) {
        region_size = MIN_REGION_SIZE;
      } else if (region_size > MAX_REGION_SIZE) {
        region_size = MAX_REGION_SIZE;
      }

      // And recalculate the log.
      region_size_log = log2_long((jlong) region_size);

  {- -------------------------------------------
  (1) G1GC に関するコマンドラインオプションの値を調整する.
      ---------------------------------------- -}

      // Now, set up the globals.
      guarantee(LogOfHRGrainBytes == 0, "we should only set it once");
      LogOfHRGrainBytes = region_size_log;

      guarantee(LogOfHRGrainWords == 0, "we should only set it once");
      LogOfHRGrainWords = LogOfHRGrainBytes - LogHeapWordSize;

      guarantee(GrainBytes == 0, "we should only set it once");
      // The cast to int is safe, given that we've bounded region_size by
      // MIN_REGION_SIZE and MAX_REGION_SIZE.
      GrainBytes = (int) region_size;

      guarantee(GrainWords == 0, "we should only set it once");
      GrainWords = GrainBytes >> LogHeapWordSize;
      guarantee(1 << LogOfHRGrainWords == GrainWords, "sanity");

      guarantee(CardsPerRegion == 0, "we should only set it once");
      CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
    }

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