Mercurial > hg > truffle
diff src/share/vm/runtime/arguments.cpp @ 2491:0654ee04b214
Merge with OpenJDK.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 22 Apr 2011 15:30:53 +0200 |
parents | 29246b1d2d3c 3449f5e02cc4 |
children | 62feb6fd69a9 |
line wrap: on
line diff
--- a/src/share/vm/runtime/arguments.cpp Fri Apr 22 15:22:45 2011 +0200 +++ b/src/share/vm/runtime/arguments.cpp Fri Apr 22 15:30:53 2011 +0200 @@ -59,7 +59,8 @@ #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp" #endif -#define DEFAULT_VENDOR_URL_BUG "http://java.sun.com/webapps/bugreport/crash.jsp" +// Note: This is a special bug reporting site for the JVM +#define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp" #define DEFAULT_JAVA_LAUNCHER "generic" char** Arguments::_jvm_flags_array = NULL; @@ -80,6 +81,7 @@ const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG; const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER; int Arguments::_sun_java_launcher_pid = -1; +bool Arguments::_created_by_gamma_launcher = false; // These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*) bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; @@ -243,6 +245,8 @@ JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) }, { "MaxLiveObjectEvacuationRatio", JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) }, + { "ForceSharedSpaces", JDK_Version::jdk_update(6,25), JDK_Version::jdk(8) }, + { "AllowTransitionalJSR292", JDK_Version::jdk(7), JDK_Version::jdk(8) }, { NULL, JDK_Version(0), JDK_Version(0) } }; @@ -966,6 +970,16 @@ UseCompiler = true; UseLoopCounter = true; +#ifndef ZERO + // Turn these off for mixed and comp. Leave them on for Zero. + if (FLAG_IS_DEFAULT(UseFastAccessorMethods)) { + UseFastAccessorMethods = mode == _int; + } + if (FLAG_IS_DEFAULT(UseFastEmptyMethods)) { + UseFastEmptyMethods = mode == _int; + } +#endif + // Default values may be platform/compiler dependent - // use the saved values ClipInlining = Arguments::_ClipInlining; @@ -1008,31 +1022,10 @@ } } -void Arguments::check_compressed_oops_compat() { -#ifdef _LP64 - assert(UseCompressedOops, "Precondition"); - // Is it on by default or set on ergonomically - bool is_on_by_default = FLAG_IS_DEFAULT(UseCompressedOops) || FLAG_IS_ERGO(UseCompressedOops); - - // If dumping an archive or forcing its use, disable compressed oops if possible - if (DumpSharedSpaces || RequireSharedSpaces) { - if (is_on_by_default) { - FLAG_SET_DEFAULT(UseCompressedOops, false); - return; - } else { - vm_exit_during_initialization( - "Class Data Sharing is not supported with compressed oops yet", NULL); - } - } else if (UseSharedSpaces) { - // UseSharedSpaces is on by default. With compressed oops, we turn it off. - FLAG_SET_DEFAULT(UseSharedSpaces, false); - } -#endif -} - void Arguments::set_tiered_flags() { + // With tiered, set default policy to AdvancedThresholdPolicy, which is 3. if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) { - FLAG_SET_DEFAULT(CompilationPolicyChoice, 2); + FLAG_SET_DEFAULT(CompilationPolicyChoice, 3); } if (CompilationPolicyChoice < 2) { vm_exit_during_initialization( @@ -1127,40 +1120,28 @@ set_parnew_gc_flags(); } + // MaxHeapSize is aligned down in collectorPolicy + size_t max_heap = align_size_down(MaxHeapSize, + CardTableRS::ct_max_alignment_constraint()); + // Now make adjustments for CMS - size_t young_gen_per_worker; - intx new_ratio; - size_t min_new_default; - intx tenuring_default; - if (CMSUseOldDefaults) { // old defaults: "old" as of 6.0 - if FLAG_IS_DEFAULT(CMSYoungGenPerWorker) { - FLAG_SET_ERGO(intx, CMSYoungGenPerWorker, 4*M); - } - young_gen_per_worker = 4*M; - new_ratio = (intx)15; - min_new_default = 4*M; - tenuring_default = (intx)0; - } else { // new defaults: "new" as of 6.0 - young_gen_per_worker = CMSYoungGenPerWorker; - new_ratio = (intx)7; - min_new_default = 16*M; - tenuring_default = (intx)4; - } - - // Preferred young gen size for "short" pauses + intx tenuring_default = (intx)6; + size_t young_gen_per_worker = CMSYoungGenPerWorker; + + // Preferred young gen size for "short" pauses: + // upper bound depends on # of threads and NewRatio. const uintx parallel_gc_threads = (ParallelGCThreads == 0 ? 1 : ParallelGCThreads); const size_t preferred_max_new_size_unaligned = - ScaleForWordSize(young_gen_per_worker * parallel_gc_threads); - const size_t preferred_max_new_size = + MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads)); + size_t preferred_max_new_size = align_size_up(preferred_max_new_size_unaligned, os::vm_page_size()); // Unless explicitly requested otherwise, size young gen - // for "short" pauses ~ 4M*ParallelGCThreads + // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads // If either MaxNewSize or NewRatio is set on the command line, // assume the user is trying to set the size of the young gen. - if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) { // Set MaxNewSize to our calculated preferred_max_new_size unless @@ -1173,49 +1154,13 @@ } if (PrintGCDetails && Verbose) { // Too early to use gclog_or_tty - tty->print_cr("Ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize); + tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize); } - // Unless explicitly requested otherwise, prefer a large - // Old to Young gen size so as to shift the collection load - // to the old generation concurrent collector - - // If this is only guarded by FLAG_IS_DEFAULT(NewRatio) - // then NewSize and OldSize may be calculated. That would - // generally lead to some differences with ParNewGC for which - // there was no obvious reason. Also limit to the case where - // MaxNewSize has not been set. - - FLAG_SET_ERGO(intx, NewRatio, MAX2(NewRatio, new_ratio)); - // Code along this path potentially sets NewSize and OldSize - // Calculate the desired minimum size of the young gen but if - // NewSize has been set on the command line, use it here since - // it should be the final value. - size_t min_new; - if (FLAG_IS_DEFAULT(NewSize)) { - min_new = align_size_up(ScaleForWordSize(min_new_default), - os::vm_page_size()); - } else { - min_new = NewSize; - } - size_t prev_initial_size = InitialHeapSize; - if (prev_initial_size != 0 && prev_initial_size < min_new + OldSize) { - FLAG_SET_ERGO(uintx, InitialHeapSize, min_new + OldSize); - // Currently minimum size and the initial heap sizes are the same. - set_min_heap_size(InitialHeapSize); - if (PrintGCDetails && Verbose) { - warning("Initial heap size increased to " SIZE_FORMAT " M from " - SIZE_FORMAT " M; use -XX:NewSize=... for finer control.", - InitialHeapSize/M, prev_initial_size/M); - } - } - - // MaxHeapSize is aligned down in collectorPolicy - size_t max_heap = - align_size_down(MaxHeapSize, - CardTableRS::ct_max_alignment_constraint()); + assert(max_heap >= InitialHeapSize, "Error"); + assert(max_heap >= NewSize, "Error"); if (PrintGCDetails && Verbose) { // Too early to use gclog_or_tty @@ -1224,7 +1169,11 @@ " max_heap: " SIZE_FORMAT, min_heap_size(), InitialHeapSize, max_heap); } - if (max_heap > min_new) { + size_t min_new = preferred_max_new_size; + if (FLAG_IS_CMDLINE(NewSize)) { + min_new = NewSize; + } + if (max_heap > min_new && min_heap_size() > min_new) { // Unless explicitly requested otherwise, make young gen // at least min_new, and at most preferred_max_new_size. if (FLAG_IS_DEFAULT(NewSize)) { @@ -1232,18 +1181,17 @@ FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize)); if (PrintGCDetails && Verbose) { // Too early to use gclog_or_tty - tty->print_cr("Ergo set NewSize: " SIZE_FORMAT, NewSize); + tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize); } } // Unless explicitly requested otherwise, size old gen - // so that it's at least 3X of NewSize to begin with; - // later NewRatio will decide how it grows; see above. + // so it's NewRatio x of NewSize. if (FLAG_IS_DEFAULT(OldSize)) { if (max_heap > NewSize) { - FLAG_SET_ERGO(uintx, OldSize, MIN2(3*NewSize, max_heap - NewSize)); + FLAG_SET_ERGO(uintx, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize)); if (PrintGCDetails && Verbose) { // Too early to use gclog_or_tty - tty->print_cr("Ergo set OldSize: " SIZE_FORMAT, OldSize); + tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize); } } } @@ -1387,7 +1335,7 @@ void Arguments::set_ergonomics_flags() { // Parallel GC is not compatible with sharing. If one specifies // that they want sharing explicitly, do not set ergonomics flags. - if (DumpSharedSpaces || ForceSharedSpaces) { + if (DumpSharedSpaces || RequireSharedSpaces) { return; } @@ -1662,6 +1610,9 @@ void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) { _sun_java_launcher = strdup(launcher); + if (strcmp("gamma", _sun_java_launcher) == 0) { + _created_by_gamma_launcher = true; + } } bool Arguments::created_by_java_launcher() { @@ -1669,6 +1620,10 @@ return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0; } +bool Arguments::created_by_gamma_launcher() { + return _created_by_gamma_launcher; +} + //=========================================================================================================== // Parsing of main arguments @@ -1687,13 +1642,13 @@ } bool Arguments::verify_min_value(intx val, intx min, const char* name) { - // Returns true if given value is greater than specified min threshold + // Returns true if given value is at least specified min threshold // false, otherwise. if (val >= min ) { return true; } jio_fprintf(defaultStream::error_stream(), - "%s of " INTX_FORMAT " is invalid; must be greater than " INTX_FORMAT "\n", + "%s of " INTX_FORMAT " is invalid; must be at least " INTX_FORMAT "\n", name, val, min); return false; } @@ -1843,33 +1798,6 @@ status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit"); - // Check whether user-specified sharing option conflicts with GC or page size. - // Both sharing and large pages are enabled by default on some platforms; - // large pages override sharing only if explicitly set on the command line. - const bool cannot_share = UseConcMarkSweepGC || CMSIncrementalMode || - UseG1GC || UseParNewGC || UseParallelGC || UseParallelOldGC || - UseLargePages && FLAG_IS_CMDLINE(UseLargePages); - if (cannot_share) { - // Either force sharing on by forcing the other options off, or - // force sharing off. - if (DumpSharedSpaces || ForceSharedSpaces) { - jio_fprintf(defaultStream::error_stream(), - "Using Serial GC and default page size because of %s\n", - ForceSharedSpaces ? "-Xshare:on" : "-Xshare:dump"); - force_serial_gc(); - FLAG_SET_DEFAULT(UseLargePages, false); - } else { - if (UseSharedSpaces && Verbose) { - jio_fprintf(defaultStream::error_stream(), - "Turning off use of shared archive because of " - "choice of garbage collector or large pages\n"); - } - no_shared_spaces(); - } - } else if (UseLargePages && (UseSharedSpaces || DumpSharedSpaces)) { - FLAG_SET_DEFAULT(UseLargePages, false); - } - status = status && check_gc_consistency(); status = status && check_stack_pages(); @@ -1947,6 +1875,8 @@ status = false; } + status = status && verify_min_value(ParGCArrayScanChunk, 1, "ParGCArrayScanChunk"); + #ifndef SERIALGC if (UseG1GC) { status = status && verify_percentage(InitiatingHeapOccupancyPercent, @@ -2410,9 +2340,6 @@ } else if (match_option(option, "-Xshare:on", &tail)) { FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true); -#ifdef TIERED - FLAG_SET_CMDLINE(bool, ForceSharedSpaces, true); -#endif // TIERED // -Xshare:auto } else if (match_option(option, "-Xshare:auto", &tail)) { FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); @@ -2832,10 +2759,6 @@ if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) { FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1); } - // Temporary disable bulk zeroing reduction with G1. See CR 6627983. - if (UseG1GC) { - FLAG_SET_DEFAULT(ReduceBulkZeroing, false); - } #endif // If we are running in a headless jre, force java.awt.headless property @@ -2949,6 +2872,52 @@ return JNI_OK; } +void Arguments::set_shared_spaces_flags() { + const bool must_share = DumpSharedSpaces || RequireSharedSpaces; + const bool might_share = must_share || UseSharedSpaces; + + // The string table is part of the shared archive so the size must match. + if (!FLAG_IS_DEFAULT(StringTableSize)) { + // Disable sharing. + if (must_share) { + warning("disabling shared archive %s because of non-default " + "StringTableSize", DumpSharedSpaces ? "creation" : "use"); + } + if (might_share) { + FLAG_SET_DEFAULT(DumpSharedSpaces, false); + FLAG_SET_DEFAULT(RequireSharedSpaces, false); + FLAG_SET_DEFAULT(UseSharedSpaces, false); + } + return; + } + + // Check whether class data sharing settings conflict with GC, compressed oops + // or page size, and fix them up. Explicit sharing options override other + // settings. + const bool cannot_share = UseConcMarkSweepGC || CMSIncrementalMode || + UseG1GC || UseParNewGC || UseParallelGC || UseParallelOldGC || + UseCompressedOops || UseLargePages && FLAG_IS_CMDLINE(UseLargePages); + if (cannot_share) { + if (must_share) { + warning("selecting serial gc and disabling large pages %s" + "because of %s", "" LP64_ONLY("and compressed oops "), + DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on"); + force_serial_gc(); + FLAG_SET_CMDLINE(bool, UseLargePages, false); + LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedOops, false)); + } else { + if (UseSharedSpaces && Verbose) { + warning("turning off use of shared archive because of " + "choice of garbage collector or large pages"); + } + no_shared_spaces(); + } + } else if (UseLargePages && might_share) { + // Disable large pages to allow shared spaces. This is sub-optimal, since + // there may not even be a shared archive to use. + FLAG_SET_DEFAULT(UseLargePages, false); + } +} // Parse entry point called from JNI_CreateJavaVM @@ -3059,21 +3028,34 @@ } #endif // PRODUCT - if (EnableInvokeDynamic && !EnableMethodHandles) { - if (!FLAG_IS_DEFAULT(EnableMethodHandles)) { - warning("forcing EnableMethodHandles true because EnableInvokeDynamic is true"); + // Transitional + if (EnableMethodHandles || AnonymousClasses) { + if (!EnableInvokeDynamic && !FLAG_IS_DEFAULT(EnableInvokeDynamic)) { + warning("EnableMethodHandles and AnonymousClasses are obsolete. Keeping EnableInvokeDynamic disabled."); + } else { + EnableInvokeDynamic = true; } - EnableMethodHandles = true; } - if (EnableMethodHandles && !AnonymousClasses) { - if (!FLAG_IS_DEFAULT(AnonymousClasses)) { - warning("forcing AnonymousClasses true because EnableMethodHandles is true"); + + // JSR 292 is not supported before 1.7 + if (!JDK_Version::is_gte_jdk17x_version()) { + if (EnableInvokeDynamic) { + if (!FLAG_IS_DEFAULT(EnableInvokeDynamic)) { + warning("JSR 292 is not supported before 1.7. Disabling support."); + } + EnableInvokeDynamic = false; } - AnonymousClasses = true; } - if ((EnableMethodHandles || AnonymousClasses) && ScavengeRootsInCode == 0) { + + if (EnableInvokeDynamic && ScavengeRootsInCode == 0) { if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) { - warning("forcing ScavengeRootsInCode non-zero because EnableMethodHandles or AnonymousClasses is true"); + warning("forcing ScavengeRootsInCode non-zero because EnableInvokeDynamic is true"); + } + ScavengeRootsInCode = 1; + } + if (!JavaObjectsInPerm && ScavengeRootsInCode == 0) { + if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) { + warning("forcing ScavengeRootsInCode non-zero because JavaObjectsInPerm is false"); } ScavengeRootsInCode = 1; } @@ -3096,9 +3078,7 @@ // Set flags based on ergonomics. set_ergonomics_flags(); - if (UseCompressedOops) { - check_compressed_oops_compat(); - } + set_shared_spaces_flags(); // Check the GC selections again. if (!check_gc_consistency()) { @@ -3116,22 +3096,17 @@ } #ifndef KERNEL - if (UseConcMarkSweepGC) { - // Set flags for CMS and ParNew. Check UseConcMarkSweep first - // to ensure that when both UseConcMarkSweepGC and UseParNewGC - // are true, we don't call set_parnew_gc_flags() as well. + // Set heap size based on available physical memory + set_heap_size(); + // Set per-collector flags + if (UseParallelGC || UseParallelOldGC) { + set_parallel_gc_flags(); + } else if (UseConcMarkSweepGC) { // should be done before ParNew check below set_cms_and_parnew_gc_flags(); - } else { - // Set heap size based on available physical memory - set_heap_size(); - // Set per-collector flags - if (UseParallelGC || UseParallelOldGC) { - set_parallel_gc_flags(); - } else if (UseParNewGC) { - set_parnew_gc_flags(); - } else if (UseG1GC) { - set_g1_gc_flags(); - } + } else if (UseParNewGC) { // skipped if CMS is set above + set_parnew_gc_flags(); + } else if (UseG1GC) { + set_g1_gc_flags(); } #endif // KERNEL @@ -3148,7 +3123,11 @@ // Turn off biased locking for locking debug mode flags, // which are subtlely different from each other but neither works with // biased locking. - if (!UseFastLocking || UseHeavyMonitors) { + if (UseHeavyMonitors +#ifdef COMPILER1 + || !UseFastLocking +#endif // COMPILER1 + ) { if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) { // flag set to true on command line; warn the user that they // can't enable biased locking here @@ -3197,6 +3176,16 @@ } } + // set PauseAtExit if the gamma launcher was used and a debugger is attached + // but only if not already set on the commandline + if (Arguments::created_by_gamma_launcher() && os::is_debugger_attached()) { + bool set = false; + CommandLineFlags::wasSetOnCmdline("PauseAtExit", &set); + if (!set) { + FLAG_SET_DEFAULT(PauseAtExit, true); + } + } + return JNI_OK; }