comparison src/share/vm/runtime/arguments.cpp @ 10418:ff3c23a329ed

Merge
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Wed, 19 Jun 2013 20:24:27 +0200
parents 1c77d0732233 36bcc10e01c0
children cdbfff4547be
comparison
equal deleted inserted replaced
10417:acc1c61ba408 10418:ff3c23a329ed
749 749
750 if (arg == NULL) { 750 if (arg == NULL) {
751 return; 751 return;
752 } 752 }
753 753
754 int index = *count; 754 int new_count = *count + 1;
755 755
756 // expand the array and add arg to the last element 756 // expand the array and add arg to the last element
757 (*count)++;
758 if (*bldarray == NULL) { 757 if (*bldarray == NULL) {
759 *bldarray = NEW_C_HEAP_ARRAY(char*, *count, mtInternal); 758 *bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal);
760 } else { 759 } else {
761 *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, *count, mtInternal); 760 *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, new_count, mtInternal);
762 } 761 }
763 (*bldarray)[index] = strdup(arg); 762 (*bldarray)[*count] = strdup(arg);
763 *count = new_count;
764 } 764 }
765 765
766 void Arguments::build_jvm_args(const char* arg) { 766 void Arguments::build_jvm_args(const char* arg) {
767 add_string(&_jvm_args_array, &_num_jvm_args, arg); 767 add_string(&_jvm_args_array, &_num_jvm_args, arg);
768 } 768 }
1096 } 1096 }
1097 // Increase the code cache size - tiered compiles a lot more. 1097 // Increase the code cache size - tiered compiles a lot more.
1098 if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) { 1098 if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
1099 FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5); 1099 FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5);
1100 } 1100 }
1101 if (!UseInterpreter) { // -Xcomp
1102 Tier3InvokeNotifyFreqLog = 0;
1103 Tier4InvocationThreshold = 0;
1104 }
1101 } 1105 }
1102 1106
1103 #if INCLUDE_ALL_GCS 1107 #if INCLUDE_ALL_GCS
1104 static void disable_adaptive_size_policy(const char* collector_name) { 1108 static void disable_adaptive_size_policy(const char* collector_name) {
1105 if (UseAdaptiveSizePolicy) { 1109 if (UseAdaptiveSizePolicy) {
1624 tty->print_cr(" Maximum heap size " SIZE_FORMAT, reasonable_max); 1628 tty->print_cr(" Maximum heap size " SIZE_FORMAT, reasonable_max);
1625 } 1629 }
1626 FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max); 1630 FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max);
1627 } 1631 }
1628 1632
1629 // If the initial_heap_size has not been set with InitialHeapSize 1633 // If the minimum or initial heap_size have not been set or requested to be set
1630 // or -Xms, then set it as fraction of the size of physical memory, 1634 // ergonomically, set them accordingly.
1631 // respecting the maximum and minimum sizes of the heap. 1635 if (InitialHeapSize == 0 || min_heap_size() == 0) {
1632 if (FLAG_IS_DEFAULT(InitialHeapSize)) {
1633 julong reasonable_minimum = (julong)(OldSize + NewSize); 1636 julong reasonable_minimum = (julong)(OldSize + NewSize);
1634 1637
1635 reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize); 1638 reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
1636 1639
1637 reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum); 1640 reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
1638 1641
1639 julong reasonable_initial = phys_mem / InitialRAMFraction; 1642 if (InitialHeapSize == 0) {
1640 1643 julong reasonable_initial = phys_mem / InitialRAMFraction;
1641 reasonable_initial = MAX2(reasonable_initial, reasonable_minimum); 1644
1642 reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); 1645 reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
1643 1646 reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
1644 reasonable_initial = limit_by_allocatable_memory(reasonable_initial); 1647
1645 1648 reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
1646 if (PrintGCDetails && Verbose) { 1649
1647 // Cannot use gclog_or_tty yet. 1650 if (PrintGCDetails && Verbose) {
1648 tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial); 1651 // Cannot use gclog_or_tty yet.
1649 tty->print_cr(" Minimum heap size " SIZE_FORMAT, (uintx)reasonable_minimum); 1652 tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial);
1650 } 1653 }
1651 FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial); 1654 FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial);
1652 set_min_heap_size((uintx)reasonable_minimum); 1655 }
1656 // If the minimum heap size has not been set (via -Xms),
1657 // synchronize with InitialHeapSize to avoid errors with the default value.
1658 if (min_heap_size() == 0) {
1659 set_min_heap_size(MIN2((uintx)reasonable_minimum, InitialHeapSize));
1660 if (PrintGCDetails && Verbose) {
1661 // Cannot use gclog_or_tty yet.
1662 tty->print_cr(" Minimum heap size " SIZE_FORMAT, min_heap_size());
1663 }
1664 }
1653 } 1665 }
1654 } 1666 }
1655 1667
1656 // This must be called after ergonomics because we want bytecode rewriting 1668 // This must be called after ergonomics because we want bytecode rewriting
1657 // if the server compiler is used, or if UseSharedSpaces is disabled. 1669 // if the server compiler is used, or if UseSharedSpaces is disabled.
1668 } 1680 }
1669 1681
1670 // Aggressive optimization flags -XX:+AggressiveOpts 1682 // Aggressive optimization flags -XX:+AggressiveOpts
1671 void Arguments::set_aggressive_opts_flags() { 1683 void Arguments::set_aggressive_opts_flags() {
1672 #ifdef COMPILER2 1684 #ifdef COMPILER2
1685 if (AggressiveUnboxing) {
1686 if (FLAG_IS_DEFAULT(EliminateAutoBox)) {
1687 FLAG_SET_DEFAULT(EliminateAutoBox, true);
1688 } else if (!EliminateAutoBox) {
1689 // warning("AggressiveUnboxing is disabled because EliminateAutoBox is disabled");
1690 AggressiveUnboxing = false;
1691 }
1692 if (FLAG_IS_DEFAULT(DoEscapeAnalysis)) {
1693 FLAG_SET_DEFAULT(DoEscapeAnalysis, true);
1694 } else if (!DoEscapeAnalysis) {
1695 // warning("AggressiveUnboxing is disabled because DoEscapeAnalysis is disabled");
1696 AggressiveUnboxing = false;
1697 }
1698 }
1673 if (AggressiveOpts || !FLAG_IS_DEFAULT(AutoBoxCacheMax)) { 1699 if (AggressiveOpts || !FLAG_IS_DEFAULT(AutoBoxCacheMax)) {
1674 if (FLAG_IS_DEFAULT(EliminateAutoBox)) { 1700 if (FLAG_IS_DEFAULT(EliminateAutoBox)) {
1675 FLAG_SET_DEFAULT(EliminateAutoBox, true); 1701 FLAG_SET_DEFAULT(EliminateAutoBox, true);
1676 } 1702 }
1677 if (FLAG_IS_DEFAULT(AutoBoxCacheMax)) { 1703 if (FLAG_IS_DEFAULT(AutoBoxCacheMax)) {
1900 "not " SIZE_FORMAT "\n", 1926 "not " SIZE_FORMAT "\n",
1901 TLABRefillWasteFraction); 1927 TLABRefillWasteFraction);
1902 status = false; 1928 status = false;
1903 } 1929 }
1904 1930
1905 status = status && verify_percentage(AdaptiveSizePolicyWeight, 1931 status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100,
1906 "AdaptiveSizePolicyWeight"); 1932 "AdaptiveSizePolicyWeight");
1907 status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance"); 1933 status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
1908 status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio"); 1934 status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio");
1909 status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio"); 1935 status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio");
1910 1936
1911 // Divide by bucket size to prevent a large size from causing rollover when 1937 // Divide by bucket size to prevent a large size from causing rollover when
1912 // calculating amount of memory needed to be allocated for the String table. 1938 // calculating amount of memory needed to be allocated for the String table.
1913 status = status && verify_interval(StringTableSize, defaultStringTableSize, 1939 status = status && verify_interval(StringTableSize, minimumStringTableSize,
1914 (max_uintx / StringTable::bucket_size()), "StringTable size"); 1940 (max_uintx / StringTable::bucket_size()), "StringTable size");
1915 1941
1916 if (MinHeapFreeRatio > MaxHeapFreeRatio) { 1942 if (MinHeapFreeRatio > MaxHeapFreeRatio) {
1917 jio_fprintf(defaultStream::error_stream(), 1943 jio_fprintf(defaultStream::error_stream(),
1918 "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or " 1944 "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
1959 status = status && verify_percentage(GCTimeLimit, "GCTimeLimit"); 1985 status = status && verify_percentage(GCTimeLimit, "GCTimeLimit");
1960 if (GCTimeLimit == 100) { 1986 if (GCTimeLimit == 100) {
1961 // Turn off gc-overhead-limit-exceeded checks 1987 // Turn off gc-overhead-limit-exceeded checks
1962 FLAG_SET_DEFAULT(UseGCOverheadLimit, false); 1988 FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
1963 } 1989 }
1964
1965 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
1966 1990
1967 status = status && check_gc_consistency(); 1991 status = status && check_gc_consistency();
1968 status = status && check_stack_pages(); 1992 status = status && check_stack_pages();
1969 1993
1970 if (_has_alloc_profile) { 1994 if (_has_alloc_profile) {
2050 "InitiatingHeapOccupancyPercent"); 2074 "InitiatingHeapOccupancyPercent");
2051 status = status && verify_min_value(G1RefProcDrainInterval, 1, 2075 status = status && verify_min_value(G1RefProcDrainInterval, 1,
2052 "G1RefProcDrainInterval"); 2076 "G1RefProcDrainInterval");
2053 status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1, 2077 status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1,
2054 "G1ConcMarkStepDurationMillis"); 2078 "G1ConcMarkStepDurationMillis");
2079 status = status && verify_interval(G1ConcRSHotCardLimit, 0, max_jubyte,
2080 "G1ConcRSHotCardLimit");
2081 status = status && verify_interval(G1ConcRSLogCacheSize, 0, 31,
2082 "G1ConcRSLogCacheSize");
2083 }
2084 if (UseConcMarkSweepGC) {
2085 status = status && verify_min_value(CMSOldPLABNumRefills, 1, "CMSOldPLABNumRefills");
2086 status = status && verify_min_value(CMSOldPLABToleranceFactor, 1, "CMSOldPLABToleranceFactor");
2087 status = status && verify_min_value(CMSOldPLABMax, 1, "CMSOldPLABMax");
2088 status = status && verify_interval(CMSOldPLABMin, 1, CMSOldPLABMax, "CMSOldPLABMin");
2089
2090 status = status && verify_min_value(CMSYoungGenPerWorker, 1, "CMSYoungGenPerWorker");
2091
2092 status = status && verify_min_value(CMSSamplingGrain, 1, "CMSSamplingGrain");
2093 status = status && verify_interval(CMS_SweepWeight, 0, 100, "CMS_SweepWeight");
2094 status = status && verify_interval(CMS_FLSWeight, 0, 100, "CMS_FLSWeight");
2095
2096 status = status && verify_interval(FLSCoalescePolicy, 0, 4, "FLSCoalescePolicy");
2097
2098 status = status && verify_min_value(CMSRescanMultiple, 1, "CMSRescanMultiple");
2099 status = status && verify_min_value(CMSConcMarkMultiple, 1, "CMSConcMarkMultiple");
2100
2101 status = status && verify_interval(CMSPrecleanIter, 0, 9, "CMSPrecleanIter");
2102 status = status && verify_min_value(CMSPrecleanDenominator, 1, "CMSPrecleanDenominator");
2103 status = status && verify_interval(CMSPrecleanNumerator, 0, CMSPrecleanDenominator - 1, "CMSPrecleanNumerator");
2104
2105 status = status && verify_percentage(CMSBootstrapOccupancy, "CMSBootstrapOccupancy");
2106
2107 status = status && verify_min_value(CMSPrecleanThreshold, 100, "CMSPrecleanThreshold");
2108
2109 status = status && verify_percentage(CMSScheduleRemarkEdenPenetration, "CMSScheduleRemarkEdenPenetration");
2110 status = status && verify_min_value(CMSScheduleRemarkSamplingRatio, 1, "CMSScheduleRemarkSamplingRatio");
2111 status = status && verify_min_value(CMSBitMapYieldQuantum, 1, "CMSBitMapYieldQuantum");
2112 status = status && verify_percentage(CMSTriggerRatio, "CMSTriggerRatio");
2113 status = status && verify_percentage(CMSIsTooFullPercentage, "CMSIsTooFullPercentage");
2114 }
2115
2116 if (UseParallelGC || UseParallelOldGC) {
2117 status = status && verify_interval(ParallelOldDeadWoodLimiterMean, 0, 100, "ParallelOldDeadWoodLimiterMean");
2118 status = status && verify_interval(ParallelOldDeadWoodLimiterStdDev, 0, 100, "ParallelOldDeadWoodLimiterStdDev");
2119
2120 status = status && verify_percentage(YoungGenerationSizeIncrement, "YoungGenerationSizeIncrement");
2121 status = status && verify_percentage(TenuredGenerationSizeIncrement, "TenuredGenerationSizeIncrement");
2122
2123 status = status && verify_min_value(YoungGenerationSizeSupplementDecay, 1, "YoungGenerationSizeSupplementDecay");
2124 status = status && verify_min_value(TenuredGenerationSizeSupplementDecay, 1, "TenuredGenerationSizeSupplementDecay");
2125
2126 status = status && verify_min_value(ParGCCardsPerStrideChunk, 1, "ParGCCardsPerStrideChunk");
2127
2128 status = status && verify_min_value(ParallelOldGCSplitInterval, 0, "ParallelOldGCSplitInterval");
2055 } 2129 }
2056 #endif // INCLUDE_ALL_GCS 2130 #endif // INCLUDE_ALL_GCS
2057 2131
2058 status = status && verify_interval(RefDiscoveryPolicy, 2132 status = status && verify_interval(RefDiscoveryPolicy,
2059 ReferenceProcessor::DiscoveryPolicyMin, 2133 ReferenceProcessor::DiscoveryPolicyMin,
2070 status = status && verify_min_value(ClassMetaspaceSize, 1*M, 2144 status = status && verify_min_value(ClassMetaspaceSize, 1*M,
2071 "ClassMetaspaceSize"); 2145 "ClassMetaspaceSize");
2072 2146
2073 status = status && verify_interval(MarkStackSizeMax, 2147 status = status && verify_interval(MarkStackSizeMax,
2074 1, (max_jint - 1), "MarkStackSizeMax"); 2148 1, (max_jint - 1), "MarkStackSizeMax");
2075 2149 status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight");
2150
2151 status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries");
2152
2153 status = status && verify_min_value(HeapSizePerGCThread, (uintx) os::vm_page_size(), "HeapSizePerGCThread");
2154
2155 status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries");
2156
2157 status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct");
2158 status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct");
2159
2160 status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread");
2161
2162 status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction");
2163 status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction");
2164 status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction");
2165 status = status && verify_min_value(DefaultMaxRAMFraction, 1, "DefaultMaxRAMFraction");
2166
2167 status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight");
2168 status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor");
2169
2170 status = status && verify_interval(TLABAllocationWeight, 0, 100, "TLABAllocationWeight");
2171 status = status && verify_min_value(MinTLABSize, 1, "MinTLABSize");
2172 status = status && verify_min_value(TLABRefillWasteFraction, 1, "TLABRefillWasteFraction");
2173
2174 status = status && verify_percentage(YoungGenerationSizeSupplement, "YoungGenerationSizeSupplement");
2175 status = status && verify_percentage(TenuredGenerationSizeSupplement, "TenuredGenerationSizeSupplement");
2176
2177 // the "age" field in the oop header is 4 bits; do not want to pull in markOop.hpp
2178 // just for that, so hardcode here.
2179 status = status && verify_interval(MaxTenuringThreshold, 0, 15, "MaxTenuringThreshold");
2180 status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "MaxTenuringThreshold");
2181 status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio");
2182 status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio");
2183
2184 status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount");
2076 #ifdef SPARC 2185 #ifdef SPARC
2077 if (UseConcMarkSweepGC || UseG1GC) { 2186 if (UseConcMarkSweepGC || UseG1GC) {
2078 // Issue a stern warning if the user has explicitly set 2187 // Issue a stern warning if the user has explicitly set
2079 // UseMemSetInBOT (it is known to cause issues), but allow 2188 // UseMemSetInBOT (it is known to cause issues), but allow
2080 // use for experimentation and debugging. 2189 // use for experimentation and debugging.
2261 if (result != JNI_OK) { 2370 if (result != JNI_OK) {
2262 return result; 2371 return result;
2263 } 2372 }
2264 2373
2265 return JNI_OK; 2374 return JNI_OK;
2375 }
2376
2377 // Checks if name in command-line argument -agent{lib,path}:name[=options]
2378 // represents a valid HPROF of JDWP agent. is_path==true denotes that we
2379 // are dealing with -agentpath (case where name is a path), otherwise with
2380 // -agentlib
2381 bool valid_hprof_or_jdwp_agent(char *name, bool is_path) {
2382 char *_name;
2383 const char *_hprof = "hprof", *_jdwp = "jdwp";
2384 size_t _len_hprof, _len_jdwp, _len_prefix;
2385
2386 if (is_path) {
2387 if ((_name = strrchr(name, (int) *os::file_separator())) == NULL) {
2388 return false;
2389 }
2390
2391 _name++; // skip past last path separator
2392 _len_prefix = strlen(JNI_LIB_PREFIX);
2393
2394 if (strncmp(_name, JNI_LIB_PREFIX, _len_prefix) != 0) {
2395 return false;
2396 }
2397
2398 _name += _len_prefix;
2399 _len_hprof = strlen(_hprof);
2400 _len_jdwp = strlen(_jdwp);
2401
2402 if (strncmp(_name, _hprof, _len_hprof) == 0) {
2403 _name += _len_hprof;
2404 }
2405 else if (strncmp(_name, _jdwp, _len_jdwp) == 0) {
2406 _name += _len_jdwp;
2407 }
2408 else {
2409 return false;
2410 }
2411
2412 if (strcmp(_name, JNI_LIB_SUFFIX) != 0) {
2413 return false;
2414 }
2415
2416 return true;
2417 }
2418
2419 if (strcmp(name, _hprof) == 0 || strcmp(name, _jdwp) == 0) {
2420 return true;
2421 }
2422
2423 return false;
2266 } 2424 }
2267 2425
2268 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, 2426 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
2269 SysClassPath* scp_p, 2427 SysClassPath* scp_p,
2270 bool* scp_assembly_required_p, 2428 bool* scp_assembly_required_p,
2361 char *options = NULL; 2519 char *options = NULL;
2362 if(pos != NULL) { 2520 if(pos != NULL) {
2363 options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1, mtInternal), pos + 1); 2521 options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1, mtInternal), pos + 1);
2364 } 2522 }
2365 #if !INCLUDE_JVMTI 2523 #if !INCLUDE_JVMTI
2366 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) { 2524 if (valid_hprof_or_jdwp_agent(name, is_absolute_path)) {
2367 jio_fprintf(defaultStream::error_stream(), 2525 jio_fprintf(defaultStream::error_stream(),
2368 "Profiling and debugging agents are not supported in this VM\n"); 2526 "Profiling and debugging agents are not supported in this VM\n");
2369 return JNI_ERR; 2527 return JNI_ERR;
2370 } 2528 }
2371 #endif // !INCLUDE_JVMTI 2529 #endif // !INCLUDE_JVMTI
2416 FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_eden_size); 2574 FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_eden_size);
2417 FLAG_SET_CMDLINE(uintx, NewSize, (uintx)long_initial_eden_size); 2575 FLAG_SET_CMDLINE(uintx, NewSize, (uintx)long_initial_eden_size);
2418 // -Xms 2576 // -Xms
2419 } else if (match_option(option, "-Xms", &tail)) { 2577 } else if (match_option(option, "-Xms", &tail)) {
2420 julong long_initial_heap_size = 0; 2578 julong long_initial_heap_size = 0;
2421 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 1); 2579 // an initial heap size of 0 means automatically determine
2580 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 0);
2422 if (errcode != arg_in_range) { 2581 if (errcode != arg_in_range) {
2423 jio_fprintf(defaultStream::error_stream(), 2582 jio_fprintf(defaultStream::error_stream(),
2424 "Invalid initial heap size: %s\n", option->optionString); 2583 "Invalid initial heap size: %s\n", option->optionString);
2425 describe_range_error(errcode); 2584 describe_range_error(errcode);
2426 return JNI_EINVAL; 2585 return JNI_EINVAL;
2427 } 2586 }
2428 FLAG_SET_CMDLINE(uintx, InitialHeapSize, (uintx)long_initial_heap_size); 2587 FLAG_SET_CMDLINE(uintx, InitialHeapSize, (uintx)long_initial_heap_size);
2429 // Currently the minimum size and the initial heap sizes are the same. 2588 // Currently the minimum size and the initial heap sizes are the same.
2430 set_min_heap_size(InitialHeapSize); 2589 set_min_heap_size(InitialHeapSize);
2431 // -Xmx 2590 // -Xmx
2432 } else if (match_option(option, "-Xmx", &tail)) { 2591 } else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) {
2433 julong long_max_heap_size = 0; 2592 julong long_max_heap_size = 0;
2434 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1); 2593 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1);
2435 if (errcode != arg_in_range) { 2594 if (errcode != arg_in_range) {
2436 jio_fprintf(defaultStream::error_stream(), 2595 jio_fprintf(defaultStream::error_stream(),
2437 "Invalid maximum heap size: %s\n", option->optionString); 2596 "Invalid maximum heap size: %s\n", option->optionString);
2479 // HotSpot does not have separate native and Java stacks, ignore silently for compatibility 2638 // HotSpot does not have separate native and Java stacks, ignore silently for compatibility
2480 // -Xmaxjitcodesize 2639 // -Xmaxjitcodesize
2481 } else if (match_option(option, "-Xmaxjitcodesize", &tail) || 2640 } else if (match_option(option, "-Xmaxjitcodesize", &tail) ||
2482 match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) { 2641 match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) {
2483 julong long_ReservedCodeCacheSize = 0; 2642 julong long_ReservedCodeCacheSize = 0;
2484 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 2643 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1);
2485 (size_t)InitialCodeCacheSize);
2486 if (errcode != arg_in_range) { 2644 if (errcode != arg_in_range) {
2487 jio_fprintf(defaultStream::error_stream(), 2645 jio_fprintf(defaultStream::error_stream(),
2488 "Invalid maximum code cache size: %s. Should be greater than InitialCodeCacheSize=%dK\n", 2646 "Invalid maximum code cache size: %s.\n", option->optionString);
2489 option->optionString, InitialCodeCacheSize/K);
2490 describe_range_error(errcode);
2491 return JNI_EINVAL; 2647 return JNI_EINVAL;
2492 } 2648 }
2493 FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize); 2649 FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize);
2650 //-XX:IncreaseFirstTierCompileThresholdAt=
2651 } else if (match_option(option, "-XX:IncreaseFirstTierCompileThresholdAt=", &tail)) {
2652 uintx uint_IncreaseFirstTierCompileThresholdAt = 0;
2653 if (!parse_uintx(tail, &uint_IncreaseFirstTierCompileThresholdAt, 0) || uint_IncreaseFirstTierCompileThresholdAt > 99) {
2654 jio_fprintf(defaultStream::error_stream(),
2655 "Invalid value for IncreaseFirstTierCompileThresholdAt: %s. Should be between 0 and 99.\n",
2656 option->optionString);
2657 return JNI_EINVAL;
2658 }
2659 FLAG_SET_CMDLINE(uintx, IncreaseFirstTierCompileThresholdAt, (uintx)uint_IncreaseFirstTierCompileThresholdAt);
2494 // -green 2660 // -green
2495 } else if (match_option(option, "-green", &tail)) { 2661 } else if (match_option(option, "-green", &tail)) {
2496 jio_fprintf(defaultStream::error_stream(), 2662 jio_fprintf(defaultStream::error_stream(),
2497 "Green threads support not available\n"); 2663 "Green threads support not available\n");
2498 return JNI_EINVAL; 2664 return JNI_EINVAL;
2953 } 3119 }
2954 if (CompileThreshold == 0) { 3120 if (CompileThreshold == 0) {
2955 set_mode_flags(_int); 3121 set_mode_flags(_int);
2956 } 3122 }
2957 3123
3124 // eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
3125 if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {
3126 FLAG_SET_ERGO(uintx, InitialTenuringThreshold, MaxTenuringThreshold);
3127 }
3128
2958 #ifndef COMPILER2 3129 #ifndef COMPILER2
2959 // Don't degrade server performance for footprint 3130 // Don't degrade server performance for footprint
2960 if (FLAG_IS_DEFAULT(UseLargePages) && 3131 if (FLAG_IS_DEFAULT(UseLargePages) &&
2961 MaxHeapSize < LargePageHeapSizeThreshold) { 3132 MaxHeapSize < LargePageHeapSizeThreshold) {
2962 // No need for large granularity pages w/small heaps. 3133 // No need for large granularity pages w/small heaps.
3085 } 3256 }
3086 return JNI_OK; 3257 return JNI_OK;
3087 } 3258 }
3088 3259
3089 void Arguments::set_shared_spaces_flags() { 3260 void Arguments::set_shared_spaces_flags() {
3090 const bool must_share = DumpSharedSpaces || RequireSharedSpaces; 3261 #ifdef _LP64
3091 const bool might_share = must_share || UseSharedSpaces; 3262 const bool must_share = DumpSharedSpaces || RequireSharedSpaces;
3092 3263
3093 // CompressedOops cannot be used with CDS. The offsets of oopmaps and 3264 // CompressedOops cannot be used with CDS. The offsets of oopmaps and
3094 // static fields are incorrect in the archive. With some more clever 3265 // static fields are incorrect in the archive. With some more clever
3095 // initialization, this restriction can probably be lifted. 3266 // initialization, this restriction can probably be lifted.
3096 // ??? UseLargePages might be okay now 3267 if (UseCompressedOops) {
3097 const bool cannot_share = UseCompressedOops || 3268 if (must_share) {
3098 (UseLargePages && FLAG_IS_CMDLINE(UseLargePages)); 3269 warning("disabling compressed oops because of %s",
3099 if (cannot_share) { 3270 DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on");
3100 if (must_share) { 3271 FLAG_SET_CMDLINE(bool, UseCompressedOops, false);
3101 warning("disabling large pages %s" 3272 FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false);
3102 "because of %s", "" LP64_ONLY("and compressed oops "), 3273 } else {
3103 DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on"); 3274 // Prefer compressed oops to class data sharing
3104 FLAG_SET_CMDLINE(bool, UseLargePages, false); 3275 if (UseSharedSpaces && Verbose) {
3105 LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedOops, false)); 3276 warning("turning off use of shared archive because of compressed oops");
3106 LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false)); 3277 }
3107 } else { 3278 no_shared_spaces();
3108 // Prefer compressed oops and large pages to class data sharing 3279 }
3109 if (UseSharedSpaces && Verbose) { 3280 }
3110 warning("turning off use of shared archive because of large pages%s", 3281 #endif
3111 "" LP64_ONLY(" and/or compressed oops"));
3112 }
3113 no_shared_spaces();
3114 }
3115 } else if (UseLargePages && might_share) {
3116 // Disable large pages to allow shared spaces. This is sub-optimal, since
3117 // there may not even be a shared archive to use.
3118 FLAG_SET_DEFAULT(UseLargePages, false);
3119 }
3120 3282
3121 if (DumpSharedSpaces) { 3283 if (DumpSharedSpaces) {
3122 if (RequireSharedSpaces) { 3284 if (RequireSharedSpaces) {
3123 warning("cannot dump shared archive while using shared archive"); 3285 warning("cannot dump shared archive while using shared archive");
3124 } 3286 }
3159 UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC); 3321 UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3160 UNSUPPORTED_GC_OPTION(UseParNewGC); 3322 UNSUPPORTED_GC_OPTION(UseParNewGC);
3161 } 3323 }
3162 #endif // INCLUDE_ALL_GCS 3324 #endif // INCLUDE_ALL_GCS
3163 3325
3326 // Sharing support
3327 // Construct the path to the archive
3328 static char* get_shared_archive_path() {
3329 char *shared_archive_path;
3330 if (SharedArchiveFile == NULL) {
3331 char jvm_path[JVM_MAXPATHLEN];
3332 os::jvm_path(jvm_path, sizeof(jvm_path));
3333 char *end = strrchr(jvm_path, *os::file_separator());
3334 if (end != NULL) *end = '\0';
3335 size_t jvm_path_len = strlen(jvm_path);
3336 size_t file_sep_len = strlen(os::file_separator());
3337 shared_archive_path = NEW_C_HEAP_ARRAY(char, jvm_path_len +
3338 file_sep_len + 20, mtInternal);
3339 if (shared_archive_path != NULL) {
3340 strncpy(shared_archive_path, jvm_path, jvm_path_len + 1);
3341 strncat(shared_archive_path, os::file_separator(), file_sep_len);
3342 strncat(shared_archive_path, "classes.jsa", 11);
3343 }
3344 } else {
3345 shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(SharedArchiveFile) + 1, mtInternal);
3346 if (shared_archive_path != NULL) {
3347 strncpy(shared_archive_path, SharedArchiveFile, strlen(SharedArchiveFile) + 1);
3348 }
3349 }
3350 return shared_archive_path;
3351 }
3352
3164 // Parse entry point called from JNI_CreateJavaVM 3353 // Parse entry point called from JNI_CreateJavaVM
3165 3354
3166 jint Arguments::parse(const JavaVMInitArgs* args) { 3355 jint Arguments::parse(const JavaVMInitArgs* args) {
3167
3168 // Sharing support
3169 // Construct the path to the archive
3170 char jvm_path[JVM_MAXPATHLEN];
3171 os::jvm_path(jvm_path, sizeof(jvm_path));
3172 char *end = strrchr(jvm_path, *os::file_separator());
3173 if (end != NULL) *end = '\0';
3174 char *shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(jvm_path) +
3175 strlen(os::file_separator()) + 20, mtInternal);
3176 if (shared_archive_path == NULL) return JNI_ENOMEM;
3177 strcpy(shared_archive_path, jvm_path);
3178 strcat(shared_archive_path, os::file_separator());
3179 strcat(shared_archive_path, "classes");
3180 strcat(shared_archive_path, ".jsa");
3181 SharedArchivePath = shared_archive_path;
3182 3356
3183 // Remaining part of option string 3357 // Remaining part of option string
3184 const char* tail; 3358 const char* tail;
3185 3359
3186 // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. 3360 // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed.
3266 3440
3267 // Parse JavaVMInitArgs structure passed in, as well as JAVA_TOOL_OPTIONS and _JAVA_OPTIONS 3441 // Parse JavaVMInitArgs structure passed in, as well as JAVA_TOOL_OPTIONS and _JAVA_OPTIONS
3268 jint result = parse_vm_init_args(args); 3442 jint result = parse_vm_init_args(args);
3269 if (result != JNI_OK) { 3443 if (result != JNI_OK) {
3270 return result; 3444 return result;
3445 }
3446
3447 // Call get_shared_archive_path() here, after possible SharedArchiveFile option got parsed.
3448 SharedArchivePath = get_shared_archive_path();
3449 if (SharedArchivePath == NULL) {
3450 return JNI_ENOMEM;
3271 } 3451 }
3272 3452
3273 // Delay warning until here so that we've had a chance to process 3453 // Delay warning until here so that we've had a chance to process
3274 // the -XX:-PrintWarnings flag 3454 // the -XX:-PrintWarnings flag
3275 if (needs_hotspotrc_warning) { 3455 if (needs_hotspotrc_warning) {