src/share/vm/runtime/arguments.cpp

changeset 2652
048f98400b8e
parent 2637
799d8ccf63cf
parent 2650
dde920245681
child 2658
c7f3d0b4570f
     1.1 --- a/src/share/vm/runtime/arguments.cpp	Fri Mar 18 01:44:15 2011 -0700
     1.2 +++ b/src/share/vm/runtime/arguments.cpp	Fri Mar 18 09:03:43 2011 -0700
     1.3 @@ -242,6 +242,7 @@
     1.4                             JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
     1.5    { "MaxLiveObjectEvacuationRatio",
     1.6                             JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
     1.7 +  { "ForceSharedSpaces",   JDK_Version::jdk_update(6,25), JDK_Version::jdk(8) },
     1.8    { NULL, JDK_Version(0), JDK_Version(0) }
     1.9  };
    1.10  
    1.11 @@ -1003,28 +1004,6 @@
    1.12    }
    1.13  }
    1.14  
    1.15 -void Arguments::check_compressed_oops_compat() {
    1.16 -#ifdef _LP64
    1.17 -  assert(UseCompressedOops, "Precondition");
    1.18 -  // Is it on by default or set on ergonomically
    1.19 -  bool is_on_by_default = FLAG_IS_DEFAULT(UseCompressedOops) || FLAG_IS_ERGO(UseCompressedOops);
    1.20 -
    1.21 -  // If dumping an archive or forcing its use, disable compressed oops if possible
    1.22 -  if (DumpSharedSpaces || RequireSharedSpaces) {
    1.23 -    if (is_on_by_default) {
    1.24 -      FLAG_SET_DEFAULT(UseCompressedOops, false);
    1.25 -      return;
    1.26 -    } else {
    1.27 -      vm_exit_during_initialization(
    1.28 -        "Class Data Sharing is not supported with compressed oops yet", NULL);
    1.29 -    }
    1.30 -  } else if (UseSharedSpaces) {
    1.31 -    // UseSharedSpaces is on by default. With compressed oops, we turn it off.
    1.32 -    FLAG_SET_DEFAULT(UseSharedSpaces, false);
    1.33 -  }
    1.34 -#endif
    1.35 -}
    1.36 -
    1.37  void Arguments::set_tiered_flags() {
    1.38    // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
    1.39    if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
    1.40 @@ -1123,40 +1102,28 @@
    1.41      set_parnew_gc_flags();
    1.42    }
    1.43  
    1.44 +  // MaxHeapSize is aligned down in collectorPolicy
    1.45 +  size_t max_heap = align_size_down(MaxHeapSize,
    1.46 +                                    CardTableRS::ct_max_alignment_constraint());
    1.47 +
    1.48    // Now make adjustments for CMS
    1.49 -  size_t young_gen_per_worker;
    1.50 -  intx new_ratio;
    1.51 -  size_t min_new_default;
    1.52 -  intx tenuring_default;
    1.53 -  if (CMSUseOldDefaults) {  // old defaults: "old" as of 6.0
    1.54 -    if FLAG_IS_DEFAULT(CMSYoungGenPerWorker) {
    1.55 -      FLAG_SET_ERGO(intx, CMSYoungGenPerWorker, 4*M);
    1.56 -    }
    1.57 -    young_gen_per_worker = 4*M;
    1.58 -    new_ratio = (intx)15;
    1.59 -    min_new_default = 4*M;
    1.60 -    tenuring_default = (intx)0;
    1.61 -  } else { // new defaults: "new" as of 6.0
    1.62 -    young_gen_per_worker = CMSYoungGenPerWorker;
    1.63 -    new_ratio = (intx)7;
    1.64 -    min_new_default = 16*M;
    1.65 -    tenuring_default = (intx)4;
    1.66 -  }
    1.67 -
    1.68 -  // Preferred young gen size for "short" pauses
    1.69 +  intx   tenuring_default = (intx)6;
    1.70 +  size_t young_gen_per_worker = CMSYoungGenPerWorker;
    1.71 +
    1.72 +  // Preferred young gen size for "short" pauses:
    1.73 +  // upper bound depends on # of threads and NewRatio.
    1.74    const uintx parallel_gc_threads =
    1.75      (ParallelGCThreads == 0 ? 1 : ParallelGCThreads);
    1.76    const size_t preferred_max_new_size_unaligned =
    1.77 -    ScaleForWordSize(young_gen_per_worker * parallel_gc_threads);
    1.78 -  const size_t preferred_max_new_size =
    1.79 +    MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads));
    1.80 +  size_t preferred_max_new_size =
    1.81      align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
    1.82  
    1.83    // Unless explicitly requested otherwise, size young gen
    1.84 -  // for "short" pauses ~ 4M*ParallelGCThreads
    1.85 +  // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
    1.86  
    1.87    // If either MaxNewSize or NewRatio is set on the command line,
    1.88    // assume the user is trying to set the size of the young gen.
    1.89 -
    1.90    if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
    1.91  
    1.92      // Set MaxNewSize to our calculated preferred_max_new_size unless
    1.93 @@ -1169,49 +1136,13 @@
    1.94      }
    1.95      if (PrintGCDetails && Verbose) {
    1.96        // Too early to use gclog_or_tty
    1.97 -      tty->print_cr("Ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
    1.98 +      tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
    1.99      }
   1.100  
   1.101 -    // Unless explicitly requested otherwise, prefer a large
   1.102 -    // Old to Young gen size so as to shift the collection load
   1.103 -    // to the old generation concurrent collector
   1.104 -
   1.105 -    // If this is only guarded by FLAG_IS_DEFAULT(NewRatio)
   1.106 -    // then NewSize and OldSize may be calculated.  That would
   1.107 -    // generally lead to some differences with ParNewGC for which
   1.108 -    // there was no obvious reason.  Also limit to the case where
   1.109 -    // MaxNewSize has not been set.
   1.110 -
   1.111 -    FLAG_SET_ERGO(intx, NewRatio, MAX2(NewRatio, new_ratio));
   1.112 -
   1.113      // Code along this path potentially sets NewSize and OldSize
   1.114  
   1.115 -    // Calculate the desired minimum size of the young gen but if
   1.116 -    // NewSize has been set on the command line, use it here since
   1.117 -    // it should be the final value.
   1.118 -    size_t min_new;
   1.119 -    if (FLAG_IS_DEFAULT(NewSize)) {
   1.120 -      min_new = align_size_up(ScaleForWordSize(min_new_default),
   1.121 -                              os::vm_page_size());
   1.122 -    } else {
   1.123 -      min_new = NewSize;
   1.124 -    }
   1.125 -    size_t prev_initial_size = InitialHeapSize;
   1.126 -    if (prev_initial_size != 0 && prev_initial_size < min_new + OldSize) {
   1.127 -      FLAG_SET_ERGO(uintx, InitialHeapSize, min_new + OldSize);
   1.128 -      // Currently minimum size and the initial heap sizes are the same.
   1.129 -      set_min_heap_size(InitialHeapSize);
   1.130 -      if (PrintGCDetails && Verbose) {
   1.131 -        warning("Initial heap size increased to " SIZE_FORMAT " M from "
   1.132 -                SIZE_FORMAT " M; use -XX:NewSize=... for finer control.",
   1.133 -                InitialHeapSize/M, prev_initial_size/M);
   1.134 -      }
   1.135 -    }
   1.136 -
   1.137 -    // MaxHeapSize is aligned down in collectorPolicy
   1.138 -    size_t max_heap =
   1.139 -      align_size_down(MaxHeapSize,
   1.140 -                      CardTableRS::ct_max_alignment_constraint());
   1.141 +    assert(max_heap >= InitialHeapSize, "Error");
   1.142 +    assert(max_heap >= NewSize, "Error");
   1.143  
   1.144      if (PrintGCDetails && Verbose) {
   1.145        // Too early to use gclog_or_tty
   1.146 @@ -1220,7 +1151,11 @@
   1.147             " max_heap: " SIZE_FORMAT,
   1.148             min_heap_size(), InitialHeapSize, max_heap);
   1.149      }
   1.150 -    if (max_heap > min_new) {
   1.151 +    size_t min_new = preferred_max_new_size;
   1.152 +    if (FLAG_IS_CMDLINE(NewSize)) {
   1.153 +      min_new = NewSize;
   1.154 +    }
   1.155 +    if (max_heap > min_new && min_heap_size() > min_new) {
   1.156        // Unless explicitly requested otherwise, make young gen
   1.157        // at least min_new, and at most preferred_max_new_size.
   1.158        if (FLAG_IS_DEFAULT(NewSize)) {
   1.159 @@ -1228,18 +1163,17 @@
   1.160          FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize));
   1.161          if (PrintGCDetails && Verbose) {
   1.162            // Too early to use gclog_or_tty
   1.163 -          tty->print_cr("Ergo set NewSize: " SIZE_FORMAT, NewSize);
   1.164 +          tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
   1.165          }
   1.166        }
   1.167        // Unless explicitly requested otherwise, size old gen
   1.168 -      // so that it's at least 3X of NewSize to begin with;
   1.169 -      // later NewRatio will decide how it grows; see above.
   1.170 +      // so it's NewRatio x of NewSize.
   1.171        if (FLAG_IS_DEFAULT(OldSize)) {
   1.172          if (max_heap > NewSize) {
   1.173 -          FLAG_SET_ERGO(uintx, OldSize, MIN2(3*NewSize, max_heap - NewSize));
   1.174 +          FLAG_SET_ERGO(uintx, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
   1.175            if (PrintGCDetails && Verbose) {
   1.176              // Too early to use gclog_or_tty
   1.177 -            tty->print_cr("Ergo set OldSize: " SIZE_FORMAT, OldSize);
   1.178 +            tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
   1.179            }
   1.180          }
   1.181        }
   1.182 @@ -1383,7 +1317,7 @@
   1.183  void Arguments::set_ergonomics_flags() {
   1.184    // Parallel GC is not compatible with sharing. If one specifies
   1.185    // that they want sharing explicitly, do not set ergonomics flags.
   1.186 -  if (DumpSharedSpaces || ForceSharedSpaces) {
   1.187 +  if (DumpSharedSpaces || RequireSharedSpaces) {
   1.188      return;
   1.189    }
   1.190  
   1.191 @@ -1690,13 +1624,13 @@
   1.192  }
   1.193  
   1.194  bool Arguments::verify_min_value(intx val, intx min, const char* name) {
   1.195 -  // Returns true if given value is greater than specified min threshold
   1.196 +  // Returns true if given value is at least specified min threshold
   1.197    // false, otherwise.
   1.198    if (val >= min ) {
   1.199        return true;
   1.200    }
   1.201    jio_fprintf(defaultStream::error_stream(),
   1.202 -              "%s of " INTX_FORMAT " is invalid; must be greater than " INTX_FORMAT "\n",
   1.203 +              "%s of " INTX_FORMAT " is invalid; must be at least " INTX_FORMAT "\n",
   1.204                name, val, min);
   1.205    return false;
   1.206  }
   1.207 @@ -1846,33 +1780,6 @@
   1.208  
   1.209    status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
   1.210  
   1.211 -  // Check whether user-specified sharing option conflicts with GC or page size.
   1.212 -  // Both sharing and large pages are enabled by default on some platforms;
   1.213 -  // large pages override sharing only if explicitly set on the command line.
   1.214 -  const bool cannot_share = UseConcMarkSweepGC || CMSIncrementalMode ||
   1.215 -          UseG1GC || UseParNewGC || UseParallelGC || UseParallelOldGC ||
   1.216 -          UseLargePages && FLAG_IS_CMDLINE(UseLargePages);
   1.217 -  if (cannot_share) {
   1.218 -    // Either force sharing on by forcing the other options off, or
   1.219 -    // force sharing off.
   1.220 -    if (DumpSharedSpaces || ForceSharedSpaces) {
   1.221 -      jio_fprintf(defaultStream::error_stream(),
   1.222 -                  "Using Serial GC and default page size because of %s\n",
   1.223 -                  ForceSharedSpaces ? "-Xshare:on" : "-Xshare:dump");
   1.224 -      force_serial_gc();
   1.225 -      FLAG_SET_DEFAULT(UseLargePages, false);
   1.226 -    } else {
   1.227 -      if (UseSharedSpaces && Verbose) {
   1.228 -        jio_fprintf(defaultStream::error_stream(),
   1.229 -                    "Turning off use of shared archive because of "
   1.230 -                    "choice of garbage collector or large pages\n");
   1.231 -      }
   1.232 -      no_shared_spaces();
   1.233 -    }
   1.234 -  } else if (UseLargePages && (UseSharedSpaces || DumpSharedSpaces)) {
   1.235 -    FLAG_SET_DEFAULT(UseLargePages, false);
   1.236 -  }
   1.237 -
   1.238    status = status && check_gc_consistency();
   1.239    status = status && check_stack_pages();
   1.240  
   1.241 @@ -1950,6 +1857,8 @@
   1.242      status = false;
   1.243    }
   1.244  
   1.245 +  status = status && verify_min_value(ParGCArrayScanChunk, 1, "ParGCArrayScanChunk");
   1.246 +
   1.247  #ifndef SERIALGC
   1.248    if (UseG1GC) {
   1.249      status = status && verify_percentage(InitiatingHeapOccupancyPercent,
   1.250 @@ -2413,9 +2322,6 @@
   1.251      } else if (match_option(option, "-Xshare:on", &tail)) {
   1.252        FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
   1.253        FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
   1.254 -#ifdef TIERED
   1.255 -      FLAG_SET_CMDLINE(bool, ForceSharedSpaces, true);
   1.256 -#endif // TIERED
   1.257      // -Xshare:auto
   1.258      } else if (match_option(option, "-Xshare:auto", &tail)) {
   1.259        FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
   1.260 @@ -2912,6 +2818,36 @@
   1.261    return JNI_OK;
   1.262  }
   1.263  
   1.264 +void Arguments::set_shared_spaces_flags() {
   1.265 +  // Check whether class data sharing settings conflict with GC, compressed oops
   1.266 +  // or page size, and fix them up.  Explicit sharing options override other
   1.267 +  // settings.
   1.268 +  const bool cannot_share = UseConcMarkSweepGC || CMSIncrementalMode ||
   1.269 +    UseG1GC || UseParNewGC || UseParallelGC || UseParallelOldGC ||
   1.270 +    UseCompressedOops || UseLargePages && FLAG_IS_CMDLINE(UseLargePages);
   1.271 +  const bool must_share = DumpSharedSpaces || RequireSharedSpaces;
   1.272 +  const bool might_share = must_share || UseSharedSpaces;
   1.273 +  if (cannot_share) {
   1.274 +    if (must_share) {
   1.275 +      warning("selecting serial gc and disabling large pages %s"
   1.276 +              "because of %s", "" LP64_ONLY("and compressed oops "),
   1.277 +              DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on");
   1.278 +      force_serial_gc();
   1.279 +      FLAG_SET_CMDLINE(bool, UseLargePages, false);
   1.280 +      LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedOops, false));
   1.281 +    } else {
   1.282 +      if (UseSharedSpaces && Verbose) {
   1.283 +        warning("turning off use of shared archive because of "
   1.284 +                "choice of garbage collector or large pages");
   1.285 +      }
   1.286 +      no_shared_spaces();
   1.287 +    }
   1.288 +  } else if (UseLargePages && might_share) {
   1.289 +    // Disable large pages to allow shared spaces.  This is sub-optimal, since
   1.290 +    // there may not even be a shared archive to use.
   1.291 +    FLAG_SET_DEFAULT(UseLargePages, false);
   1.292 +  }
   1.293 +}
   1.294  
   1.295  // Parse entry point called from JNI_CreateJavaVM
   1.296  
   1.297 @@ -3059,9 +2995,7 @@
   1.298    // Set flags based on ergonomics.
   1.299    set_ergonomics_flags();
   1.300  
   1.301 -  if (UseCompressedOops) {
   1.302 -    check_compressed_oops_compat();
   1.303 -  }
   1.304 +  set_shared_spaces_flags();
   1.305  
   1.306    // Check the GC selections again.
   1.307    if (!check_gc_consistency()) {
   1.308 @@ -3079,22 +3013,17 @@
   1.309    }
   1.310  
   1.311  #ifndef KERNEL
   1.312 -  if (UseConcMarkSweepGC) {
   1.313 -    // Set flags for CMS and ParNew.  Check UseConcMarkSweep first
   1.314 -    // to ensure that when both UseConcMarkSweepGC and UseParNewGC
   1.315 -    // are true, we don't call set_parnew_gc_flags() as well.
   1.316 +  // Set heap size based on available physical memory
   1.317 +  set_heap_size();
   1.318 +  // Set per-collector flags
   1.319 +  if (UseParallelGC || UseParallelOldGC) {
   1.320 +    set_parallel_gc_flags();
   1.321 +  } else if (UseConcMarkSweepGC) { // should be done before ParNew check below
   1.322      set_cms_and_parnew_gc_flags();
   1.323 -  } else {
   1.324 -    // Set heap size based on available physical memory
   1.325 -    set_heap_size();
   1.326 -    // Set per-collector flags
   1.327 -    if (UseParallelGC || UseParallelOldGC) {
   1.328 -      set_parallel_gc_flags();
   1.329 -    } else if (UseParNewGC) {
   1.330 -      set_parnew_gc_flags();
   1.331 -    } else if (UseG1GC) {
   1.332 -      set_g1_gc_flags();
   1.333 -    }
   1.334 +  } else if (UseParNewGC) {  // skipped if CMS is set above
   1.335 +    set_parnew_gc_flags();
   1.336 +  } else if (UseG1GC) {
   1.337 +    set_g1_gc_flags();
   1.338    }
   1.339  #endif // KERNEL
   1.340  

mercurial