src/share/vm/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File
*** old/src/share/vm/runtime/arguments.cpp	Wed May 27 10:37:36 2015
--- new/src/share/vm/runtime/arguments.cpp	Wed May 27 10:37:36 2015

*** 35,44 **** --- 35,47 ---- #include "memory/universe.inline.hpp" #include "oops/oop.inline.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/arguments.hpp" #include "runtime/arguments_ext.hpp" + #include "runtime/commandLineFlagConstraintList.hpp" + #include "runtime/commandLineFlagRangeList.hpp" + #include "runtime/globals.hpp" #include "runtime/globals_extension.hpp" #include "runtime/java.hpp" #include "runtime/os.hpp" #include "runtime/vm_version.hpp" #include "services/management.hpp"
*** 185,195 **** --- 188,197 ---- } } // Initialize system properties key and value. void Arguments::init_system_properties() { PropertyList_add(&_system_properties, new SystemProperty("java.vm.specification.name", "Java Virtual Machine Specification", false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.version", VM_Version::vm_release(), false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.name", VM_Version::vm_name(), false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.info", VM_Version::vm_info_string(), true));
*** 213,224 **** --- 215,225 ---- // Set OS specific system properties values os::init_system_properties_values(); } // Update/Initialize System properties after JDK version number is known + // Update/Initialize System properties after JDK version number is known void Arguments::init_version_specific_system_properties() { enum { bufsz = 16 }; char buffer[bufsz]; const char* spec_vendor = "Sun Microsystems Inc."; uint32_t spec_version = 0;
*** 567,586 **** --- 568,591 ---- ShouldNotReachHere(); } } static bool set_bool_flag(char* name, bool value, Flag::Flags origin) { return CommandLineFlags::boolAtPut(name, &value, origin); + if (CommandLineFlags::boolAtPut(name, &value, origin) == Flag::SUCCESS) { + return true; + } else { + return false; + } } static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) { double v; if (sscanf(value, "%lf", &v) != 1) { return false; } ! if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) { return true; } return false; }
*** 588,598 **** --- 593,603 ---- julong v; intx intx_v; bool is_neg = false; // Check the sign first since atomull() parses only unsigned values. if (*value == '-') { ! if (!CommandLineFlags::intxAt(name, &intx_v)) { ! if (CommandLineFlags::intxAt(name, &intx_v) != Flag::SUCCESS) { return false; } value++; is_neg = true; }
*** 601,638 **** --- 606,643 ---- } intx_v = (intx) v; if (is_neg) { intx_v = -intx_v; } ! if (CommandLineFlags::intxAtPut(name, &intx_v, origin) == Flag::SUCCESS) { return true; } uintx uintx_v = (uintx) v; ! if (!is_neg && (CommandLineFlags::uintxAtPut(name, &uintx_v, origin) == Flag::SUCCESS)) { return true; } uint64_t uint64_t_v = (uint64_t) v; ! if (!is_neg && (CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin) == Flag::SUCCESS)) { return true; } size_t size_t_v = (size_t) v; ! if (!is_neg && (CommandLineFlags::size_tAtPut(name, &size_t_v, origin) == Flag::SUCCESS)) { return true; } return false; } static bool set_string_flag(char* name, const char* value, Flag::Flags origin) { ! if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false; ! if (CommandLineFlags::ccstrAtPut(name, &value, origin) != Flag::SUCCESS) return false; // Contract: CommandLineFlags always returns a pointer that needs freeing. FREE_C_HEAP_ARRAY(char, value); return true; } static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) { const char* old_value = ""; ! if (!CommandLineFlags::ccstrAt(name, &old_value)) return false; ! if (CommandLineFlags::ccstrAt(name, &old_value) != Flag::SUCCESS) return false; size_t old_len = old_value != NULL ? strlen(old_value) : 0; size_t new_len = strlen(new_value); const char* value; char* free_this_too = NULL; if (old_len == 0) {
*** 1395,1459 **** --- 1400,1419 ---- LogMinObjAlignment = LogMinObjAlignmentInBytes - LogHeapWordSize; // Oop encoding heap max OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes; + if (SurvivorAlignmentInBytes == 0) { + SurvivorAlignmentInBytes = ObjectAlignmentInBytes; + } + #if INCLUDE_ALL_GCS // Set CMS global values CompactibleFreeListSpace::set_cms_values(); #endif // INCLUDE_ALL_GCS } bool verify_object_alignment() { // Object alignment. if (!is_power_of_2(ObjectAlignmentInBytes)) { jio_fprintf(defaultStream::error_stream(), "error: ObjectAlignmentInBytes=%d must be power of 2\n", (int)ObjectAlignmentInBytes); return false; } if ((int)ObjectAlignmentInBytes < BytesPerLong) { jio_fprintf(defaultStream::error_stream(), "error: ObjectAlignmentInBytes=%d must be greater or equal %d\n", (int)ObjectAlignmentInBytes, BytesPerLong); return false; } // It does not make sense to have big object alignment // since a space lost due to alignment will be greater // then a saved space from compressed oops. if ((int)ObjectAlignmentInBytes > 256) { jio_fprintf(defaultStream::error_stream(), "error: ObjectAlignmentInBytes=%d must not be greater than 256\n", (int)ObjectAlignmentInBytes); return false; } // In case page size is very small. if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) { jio_fprintf(defaultStream::error_stream(), "error: ObjectAlignmentInBytes=%d must be less than page size %d\n", (int)ObjectAlignmentInBytes, os::vm_page_size()); return false; } if(SurvivorAlignmentInBytes == 0) { SurvivorAlignmentInBytes = ObjectAlignmentInBytes; } else { if (!is_power_of_2(SurvivorAlignmentInBytes)) { jio_fprintf(defaultStream::error_stream(), "error: SurvivorAlignmentInBytes=%d must be power of 2\n", (int)SurvivorAlignmentInBytes); return false; } if (SurvivorAlignmentInBytes < ObjectAlignmentInBytes) { jio_fprintf(defaultStream::error_stream(), "error: SurvivorAlignmentInBytes=%d must be greater than ObjectAlignmentInBytes=%d \n", (int)SurvivorAlignmentInBytes, (int)ObjectAlignmentInBytes); return false; } } return true; } size_t Arguments::max_heap_for_compressed_oops() { // Avoid sign flip. assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size"); // We need to fit both the NULL page and the heap into the memory budget, while // keeping alignment constraints of the heap. To guarantee the latter, as the
*** 1932,1977 **** --- 1892,1901 ---- } //=========================================================================================================== // Parsing of main arguments bool Arguments::verify_interval(uintx val, uintx min, uintx max, const char* name) { // Returns true iff value is in the inclusive interval [min..max] // false, otherwise. if (val >= min && val <= max) { return true; } jio_fprintf(defaultStream::error_stream(), "%s of " UINTX_FORMAT " is invalid; must be between " UINTX_FORMAT " and " UINTX_FORMAT "\n", name, val, min, max); return false; } bool Arguments::verify_min_value(intx val, intx min, const char* name) { // 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 at least " INTX_FORMAT "\n", name, val, min); return false; } bool Arguments::verify_percentage(uintx value, const char* name) { if (is_percentage(value)) { return true; } jio_fprintf(defaultStream::error_stream(), "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n", name, value); return false; } // check if do gclog rotation // +UseGCLogFileRotation is a must, // no gc log rotation when log file not supplied or // NumberOfGCLogFiles is 0 void check_gclog_consistency() {
*** 1984,1997 **** --- 1908,1922 ---- UseGCLogFileRotation = false; } } if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) { FLAG_SET_CMDLINE(size_t, GCLogFileSize, 8*K); + if (FLAG_SET_CMDLINE(size_t, GCLogFileSize, 8*K) == Flag::SUCCESS) { jio_fprintf(defaultStream::output_stream(), "GCLogFileSize changed to minimum 8K\n"); } + } } // This function is called for -Xloggc:<filename>, it can be used // to check if a given file name(or string) conforms to the following // specification:
*** 2035,2076 **** --- 1960,1969 ---- return false; } return count_p < 2 && count_t < 2; } bool Arguments::verify_MinHeapFreeRatio(FormatBuffer<80>& err_msg, uintx min_heap_free_ratio) { if (!is_percentage(min_heap_free_ratio)) { err_msg.print("MinHeapFreeRatio must have a value between 0 and 100"); return false; } if (min_heap_free_ratio > MaxHeapFreeRatio) { err_msg.print("MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or " "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")", min_heap_free_ratio, MaxHeapFreeRatio); return false; } // This does not set the flag itself, but stores the value in a safe place for later usage. _min_heap_free_ratio = min_heap_free_ratio; return true; } bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) { if (!is_percentage(max_heap_free_ratio)) { err_msg.print("MaxHeapFreeRatio must have a value between 0 and 100"); return false; } if (max_heap_free_ratio < MinHeapFreeRatio) { err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or " "equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio, MinHeapFreeRatio); return false; } // This does not set the flag itself, but stores the value in a safe place for later usage. _max_heap_free_ratio = max_heap_free_ratio; return true; } // Check consistency of GC selection bool Arguments::check_gc_consistency() { check_gclog_consistency(); // Ensure that the user has not selected conflicting sets // of collectors.
*** 2114,2134 **** --- 2007,2016 ---- warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. " "Use MaxRAMFraction instead."); } } // Check stack pages settings bool Arguments::check_stack_pages() { bool status = true; status = status && verify_min_value(StackYellowPages, 1, "StackYellowPages"); status = status && verify_min_value(StackRedPages, 1, "StackRedPages"); // greater stack shadow pages can't generate instruction to bang stack status = status && verify_interval(StackShadowPages, 1, 50, "StackShadowPages"); return status; } // Check the consistency of vm_init_args bool Arguments::check_vm_args_consistency() { // Method for adding checks for flag consistency. // The intent is to warn the user of all possible conflicts, // before returning an error.
*** 2141,2224 **** --- 2023,2060 ---- "not " SIZE_FORMAT "\n", TLABRefillWasteFraction); status = false; } status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100, "AdaptiveSizePolicyWeight"); status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance"); // Divide by bucket size to prevent a large size from causing rollover when // calculating amount of memory needed to be allocated for the String table. status = status && verify_interval(StringTableSize, minimumStringTableSize, (max_uintx / StringTable::bucket_size()), "StringTable size"); status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize, (max_uintx / SymbolTable::bucket_size()), "SymbolTable size"); { // Using "else if" below to avoid printing two error messages if min > max. // This will also prevent us from reporting both min>100 and max>100 at the // same time, but that is less annoying than printing two identical errors IMHO. FormatBuffer<80> err_msg("%s",""); if (!verify_MinHeapFreeRatio(err_msg, MinHeapFreeRatio)) { jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer()); status = false; } else if (!verify_MaxHeapFreeRatio(err_msg, MaxHeapFreeRatio)) { jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer()); status = false; } } // Min/MaxMetaspaceFreeRatio status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio"); status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio"); if (MinMetaspaceFreeRatio > MaxMetaspaceFreeRatio) { jio_fprintf(defaultStream::error_stream(), "MinMetaspaceFreeRatio (%s" UINTX_FORMAT ") must be less than or " "equal to MaxMetaspaceFreeRatio (%s" UINTX_FORMAT ")\n", FLAG_IS_DEFAULT(MinMetaspaceFreeRatio) ? "Default: " : "", MinMetaspaceFreeRatio, FLAG_IS_DEFAULT(MaxMetaspaceFreeRatio) ? "Default: " : "", MaxMetaspaceFreeRatio); status = false; } // Trying to keep 100% free is not practical MinMetaspaceFreeRatio = MIN2(MinMetaspaceFreeRatio, (uintx) 99); if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) { MarkSweepAlwaysCompactCount = 1; // Move objects every gc. } if (UseParallelOldGC && ParallelOldGCSplitALot) { // Settings to encourage splitting. if (!FLAG_IS_CMDLINE(NewRatio)) { FLAG_SET_CMDLINE(uintx, NewRatio, 2); + if (FLAG_SET_CMDLINE(uintx, NewRatio, 2) != Flag::SUCCESS) { + return false; + } } if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) { FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); + if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != Flag::SUCCESS) { + return false; + } } } if (!(UseParallelGC || UseParallelOldGC) && FLAG_IS_DEFAULT(ScavengeBeforeFullGC)) { FLAG_SET_DEFAULT(ScavengeBeforeFullGC, false); } status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit"); status = status && verify_percentage(GCTimeLimit, "GCTimeLimit"); if (GCTimeLimit == 100) { // Turn off gc-overhead-limit-exceeded checks FLAG_SET_DEFAULT(UseGCOverheadLimit, false); } status = status && check_gc_consistency(); status = status && check_stack_pages(); status = status && verify_percentage(CMSIncrementalSafetyFactor, "CMSIncrementalSafetyFactor"); // CMS space iteration, which FLSVerifyAllHeapreferences entails, // insists that we hold the requisite locks so that the iteration is // MT-safe. For the verification at start-up and shut-down, we don't // yet have a good way of acquiring and releasing these locks,
*** 2248,2383 **** --- 2084,2093 ---- "error: +ExplicitGCInvokesConcurrent[AndUnloadsClasses] conflicts" " with -UseAsyncConcMarkSweepGC"); status = false; } status = status && verify_min_value(ParGCArrayScanChunk, 1, "ParGCArrayScanChunk"); #if INCLUDE_ALL_GCS if (UseG1GC) { status = status && verify_percentage(G1NewSizePercent, "G1NewSizePercent"); status = status && verify_percentage(G1MaxNewSizePercent, "G1MaxNewSizePercent"); status = status && verify_interval(G1NewSizePercent, 0, G1MaxNewSizePercent, "G1NewSizePercent"); status = status && verify_percentage(G1ConfidencePercent, "G1ConfidencePercent"); status = status && verify_percentage(InitiatingHeapOccupancyPercent, "InitiatingHeapOccupancyPercent"); status = status && verify_min_value(G1RefProcDrainInterval, 1, "G1RefProcDrainInterval"); status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1, "G1ConcMarkStepDurationMillis"); status = status && verify_interval(G1ConcRSHotCardLimit, 0, max_jubyte, "G1ConcRSHotCardLimit"); status = status && verify_interval(G1ConcRSLogCacheSize, 0, 27, "G1ConcRSLogCacheSize"); status = status && verify_interval(StringDeduplicationAgeThreshold, 1, markOopDesc::max_age, "StringDeduplicationAgeThreshold"); } if (UseConcMarkSweepGC) { status = status && verify_min_value(CMSOldPLABNumRefills, 1, "CMSOldPLABNumRefills"); status = status && verify_min_value(CMSOldPLABToleranceFactor, 1, "CMSOldPLABToleranceFactor"); status = status && verify_min_value(CMSOldPLABMax, 1, "CMSOldPLABMax"); status = status && verify_interval(CMSOldPLABMin, 1, CMSOldPLABMax, "CMSOldPLABMin"); status = status && verify_min_value(CMSYoungGenPerWorker, 1, "CMSYoungGenPerWorker"); status = status && verify_min_value(CMSSamplingGrain, 1, "CMSSamplingGrain"); status = status && verify_interval(CMS_SweepWeight, 0, 100, "CMS_SweepWeight"); status = status && verify_interval(CMS_FLSWeight, 0, 100, "CMS_FLSWeight"); status = status && verify_interval(FLSCoalescePolicy, 0, 4, "FLSCoalescePolicy"); status = status && verify_min_value(CMSRescanMultiple, 1, "CMSRescanMultiple"); status = status && verify_min_value(CMSConcMarkMultiple, 1, "CMSConcMarkMultiple"); status = status && verify_interval(CMSPrecleanIter, 0, 9, "CMSPrecleanIter"); status = status && verify_min_value(CMSPrecleanDenominator, 1, "CMSPrecleanDenominator"); status = status && verify_interval(CMSPrecleanNumerator, 0, CMSPrecleanDenominator - 1, "CMSPrecleanNumerator"); status = status && verify_percentage(CMSBootstrapOccupancy, "CMSBootstrapOccupancy"); status = status && verify_min_value(CMSPrecleanThreshold, 100, "CMSPrecleanThreshold"); status = status && verify_percentage(CMSScheduleRemarkEdenPenetration, "CMSScheduleRemarkEdenPenetration"); status = status && verify_min_value(CMSScheduleRemarkSamplingRatio, 1, "CMSScheduleRemarkSamplingRatio"); status = status && verify_min_value(CMSBitMapYieldQuantum, 1, "CMSBitMapYieldQuantum"); status = status && verify_percentage(CMSTriggerRatio, "CMSTriggerRatio"); status = status && verify_percentage(CMSIsTooFullPercentage, "CMSIsTooFullPercentage"); } if (UseParallelGC || UseParallelOldGC) { status = status && verify_interval(ParallelOldDeadWoodLimiterMean, 0, 100, "ParallelOldDeadWoodLimiterMean"); status = status && verify_interval(ParallelOldDeadWoodLimiterStdDev, 0, 100, "ParallelOldDeadWoodLimiterStdDev"); status = status && verify_percentage(YoungGenerationSizeIncrement, "YoungGenerationSizeIncrement"); status = status && verify_percentage(TenuredGenerationSizeIncrement, "TenuredGenerationSizeIncrement"); status = status && verify_min_value(YoungGenerationSizeSupplementDecay, 1, "YoungGenerationSizeSupplementDecay"); status = status && verify_min_value(TenuredGenerationSizeSupplementDecay, 1, "TenuredGenerationSizeSupplementDecay"); status = status && verify_min_value(ParGCCardsPerStrideChunk, 1, "ParGCCardsPerStrideChunk"); status = status && verify_min_value(ParallelOldGCSplitInterval, 0, "ParallelOldGCSplitInterval"); } #endif // INCLUDE_ALL_GCS status = status && verify_interval(RefDiscoveryPolicy, ReferenceProcessor::DiscoveryPolicyMin, ReferenceProcessor::DiscoveryPolicyMax, "RefDiscoveryPolicy"); // Limit the lower bound of this flag to 1 as it is used in a division // expression. status = status && verify_interval(TLABWasteTargetPercent, 1, 100, "TLABWasteTargetPercent"); status = status && verify_object_alignment(); status = status && verify_interval(CompressedClassSpaceSize, 1*M, 3*G, "CompressedClassSpaceSize"); status = status && verify_interval(MarkStackSizeMax, 1, (max_jint - 1), "MarkStackSizeMax"); status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight"); status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries"); status = status && verify_min_value(HeapSizePerGCThread, (size_t) os::vm_page_size(), "HeapSizePerGCThread"); status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries"); status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct"); status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct"); status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread"); status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction"); status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction"); status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction"); status = status && verify_min_value(DefaultMaxRAMFraction, 1, "DefaultMaxRAMFraction"); status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight"); status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor"); status = status && verify_interval(TLABAllocationWeight, 0, 100, "TLABAllocationWeight"); status = status && verify_min_value(MinTLABSize, 1, "MinTLABSize"); status = status && verify_min_value(TLABRefillWasteFraction, 1, "TLABRefillWasteFraction"); status = status && verify_percentage(YoungGenerationSizeSupplement, "YoungGenerationSizeSupplement"); status = status && verify_percentage(TenuredGenerationSizeSupplement, "TenuredGenerationSizeSupplement"); status = status && verify_interval(MaxTenuringThreshold, 0, markOopDesc::max_age + 1, "MaxTenuringThreshold"); status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "InitialTenuringThreshold"); status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio"); status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio"); status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount"); #ifdef COMPILER1 status = status && verify_min_value(ValueMapInitialSize, 1, "ValueMapInitialSize"); #endif status = status && verify_min_value(HeapSearchSteps, 1, "HeapSearchSteps"); if (PrintNMTStatistics) { #if INCLUDE_NMT if (MemTracker::tracking_level() == NMT_off) { #endif // INCLUDE_NMT warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled");
*** 2385,2414 **** --- 2095,2104 ---- #if INCLUDE_NMT } #endif } // Need to limit the extent of the padding to reasonable size. // 8K is well beyond the reasonable HW cache line size, even with the // aggressive prefetching, while still leaving the room for segregating // among the distinct pages. if (ContendedPaddingWidth < 0 || ContendedPaddingWidth > 8192) { jio_fprintf(defaultStream::error_stream(), "ContendedPaddingWidth=" INTX_FORMAT " must be in between %d and %d\n", ContendedPaddingWidth, 0, 8192); status = false; } // Need to enforce the padding not to break the existing field alignments. // It is sufficient to check against the largest type size. if ((ContendedPaddingWidth % BytesPerLong) != 0) { jio_fprintf(defaultStream::error_stream(), "ContendedPaddingWidth=" INTX_FORMAT " must be a multiple of %d\n", ContendedPaddingWidth, BytesPerLong); status = false; } // Check lower bounds of the code cache // Template Interpreter code is approximately 3X larger in debug builds. uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); if (InitialCodeCacheSize < (uintx)os::vm_page_size()) { jio_fprintf(defaultStream::error_stream(),
*** 2443,2463 **** --- 2133,2145 ---- NonNMethodCodeHeapSize/K, ProfiledCodeHeapSize/K, NonProfiledCodeHeapSize/K, (NonNMethodCodeHeapSize + ProfiledCodeHeapSize + NonProfiledCodeHeapSize)/K, ReservedCodeCacheSize/K); status = false; } status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity"); status &= verify_interval(CodeCacheMinBlockLength, 1, 100, "CodeCacheMinBlockLength"); status &= verify_interval(CodeCacheSegmentSize, 1, 1024, "CodeCacheSegmentSize"); status &= verify_interval(StartAggressiveSweepingAt, 0, 100, "StartAggressiveSweepingAt"); int min_number_of_compiler_threads = get_min_number_of_compiler_threads(); // The default CICompilerCount's value is CI_COMPILER_COUNT. assert(min_number_of_compiler_threads <= CI_COMPILER_COUNT, "minimum should be less or equal default number"); // Check the minimum number of compiler threads status &=verify_min_value(CICompilerCount, min_number_of_compiler_threads, "CICompilerCount"); if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) { warning("The VM option CICompilerCountPerCPU overrides CICompilerCount."); }
*** 2646,2661 **** --- 2328,2351 ---- } // -verbose:[class/gc/jni] if (match_option(option, "-verbose", &tail)) { if (!strcmp(tail, ":class") || !strcmp(tail, "")) { FLAG_SET_CMDLINE(bool, TraceClassLoading, true); ! FLAG_SET_CMDLINE(bool, TraceClassUnloading, true); + if (FLAG_SET_CMDLINE(bool, TraceClassLoading, true) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, TraceClassUnloading, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (!strcmp(tail, ":gc")) { FLAG_SET_CMDLINE(bool, PrintGC, true); + if (FLAG_SET_CMDLINE(bool, PrintGC, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (!strcmp(tail, ":jni")) { FLAG_SET_CMDLINE(bool, PrintJNIResolving, true); + if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } } // -da / -ea / -disableassertions / -enableassertions // These accept an optional class/package name separated by a colon, e.g., // -da:java.lang.Thread. } else if (match_option(option, user_assertion_options, &tail, true)) {
*** 2738,2769 **** --- 2428,2471 ---- add_init_agent("instrument", options, false); } #endif // !INCLUDE_JVMTI // -Xnoclassgc } else if (match_option(option, "-Xnoclassgc")) { FLAG_SET_CMDLINE(bool, ClassUnloading, false); + if (FLAG_SET_CMDLINE(bool, ClassUnloading, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xconcgc } else if (match_option(option, "-Xconcgc")) { FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true); + if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xnoconcgc } else if (match_option(option, "-Xnoconcgc")) { FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false); + if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xbatch } else if (match_option(option, "-Xbatch")) { FLAG_SET_CMDLINE(bool, BackgroundCompilation, false); + if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xmn for compatibility with other JVM vendors } else if (match_option(option, "-Xmn", &tail)) { julong long_initial_young_size = 0; ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1); if (errcode != arg_in_range) { jio_fprintf(defaultStream::error_stream(), "Invalid initial young generation size: %s\n", option->optionString); describe_range_error(errcode); return JNI_EINVAL; } FLAG_SET_CMDLINE(size_t, MaxNewSize, (size_t)long_initial_young_size); ! FLAG_SET_CMDLINE(size_t, NewSize, (size_t)long_initial_young_size); + if (FLAG_SET_CMDLINE(size_t, MaxNewSize, (size_t)long_initial_young_size) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(size_t, NewSize, (size_t)long_initial_young_size) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xms } else if (match_option(option, "-Xms", &tail)) { julong long_initial_heap_size = 0; // an initial heap size of 0 means automatically determine ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 0);
*** 2774,2818 **** --- 2476,2528 ---- return JNI_EINVAL; } set_min_heap_size((size_t)long_initial_heap_size); // Currently the minimum size and the initial heap sizes are the same. // Can be overridden with -XX:InitialHeapSize. FLAG_SET_CMDLINE(size_t, InitialHeapSize, (size_t)long_initial_heap_size); + if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, (size_t)long_initial_heap_size) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xmx } else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) { julong long_max_heap_size = 0; ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1); if (errcode != arg_in_range) { jio_fprintf(defaultStream::error_stream(), "Invalid maximum heap size: %s\n", option->optionString); describe_range_error(errcode); return JNI_EINVAL; } FLAG_SET_CMDLINE(size_t, MaxHeapSize, (size_t)long_max_heap_size); + if (FLAG_SET_CMDLINE(size_t, MaxHeapSize, (size_t)long_max_heap_size) != Flag::SUCCESS) { + return JNI_EINVAL; + } // Xmaxf } else if (match_option(option, "-Xmaxf", &tail)) { char* err; int maxf = (int)(strtod(tail, &err) * 100); - if (*err != '\0' || *tail == '\0' || maxf < 0 || maxf > 100) { jio_fprintf(defaultStream::error_stream(), "Bad max heap free percentage size: %s\n", option->optionString); return JNI_EINVAL; } else { FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf); + if (FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf) != Flag::SUCCESS) { + return JNI_EINVAL; + } } // Xminf } else if (match_option(option, "-Xminf", &tail)) { char* err; int minf = (int)(strtod(tail, &err) * 100); - if (*err != '\0' || *tail == '\0' || minf < 0 || minf > 100) { jio_fprintf(defaultStream::error_stream(), "Bad min heap free percentage size: %s\n", option->optionString); return JNI_EINVAL; } else { FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf); + if (FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf) != Flag::SUCCESS) { + return JNI_EINVAL; + } } // -Xss } else if (match_option(option, "-Xss", &tail)) { julong long_ThreadStackSize = 0; ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000);
*** 2821,2832 **** --- 2531,2544 ---- "Invalid thread stack size: %s\n", option->optionString); describe_range_error(errcode); return JNI_EINVAL; } // Internally track ThreadStackSize in units of 1024 bytes. ! if (FLAG_SET_CMDLINE(intx, ThreadStackSize, round_to((int)long_ThreadStackSize, K) / K); + round_to((int)long_ThreadStackSize, K) / K) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xoss } else if (match_option(option, "-Xoss", &tail)) { // HotSpot does not have separate native and Java stacks, ignore silently for compatibility } else if (match_option(option, "-XX:CodeCacheExpansionSize=", &tail)) { julong long_CodeCacheExpansionSize = 0;
*** 2835,2899 **** --- 2547,2611 ---- jio_fprintf(defaultStream::error_stream(), "Invalid argument: %s. Must be at least %luK.\n", option->optionString, os::vm_page_size()/K); return JNI_EINVAL; } FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize); + if (FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (match_option(option, "-Xmaxjitcodesize", &tail) || match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) { julong long_ReservedCodeCacheSize = 0; ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1); if (errcode != arg_in_range) { jio_fprintf(defaultStream::error_stream(), "Invalid maximum code cache size: %s.\n", option->optionString); return JNI_EINVAL; } FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize); + if (FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -XX:NonNMethodCodeHeapSize= } else if (match_option(option, "-XX:NonNMethodCodeHeapSize=", &tail)) { julong long_NonNMethodCodeHeapSize = 0; ArgsRange errcode = parse_memory_size(tail, &long_NonNMethodCodeHeapSize, 1); if (errcode != arg_in_range) { jio_fprintf(defaultStream::error_stream(), "Invalid maximum non-nmethod code heap size: %s.\n", option->optionString); return JNI_EINVAL; } FLAG_SET_CMDLINE(uintx, NonNMethodCodeHeapSize, (uintx)long_NonNMethodCodeHeapSize); + if (FLAG_SET_CMDLINE(uintx, NonNMethodCodeHeapSize, (uintx)long_NonNMethodCodeHeapSize) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -XX:ProfiledCodeHeapSize= } else if (match_option(option, "-XX:ProfiledCodeHeapSize=", &tail)) { julong long_ProfiledCodeHeapSize = 0; ArgsRange errcode = parse_memory_size(tail, &long_ProfiledCodeHeapSize, 1); if (errcode != arg_in_range) { jio_fprintf(defaultStream::error_stream(), "Invalid maximum profiled code heap size: %s.\n", option->optionString); return JNI_EINVAL; } FLAG_SET_CMDLINE(uintx, ProfiledCodeHeapSize, (uintx)long_ProfiledCodeHeapSize); + if (FLAG_SET_CMDLINE(uintx, ProfiledCodeHeapSize, (uintx)long_ProfiledCodeHeapSize) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -XX:NonProfiledCodeHeapSizee= } else if (match_option(option, "-XX:NonProfiledCodeHeapSize=", &tail)) { julong long_NonProfiledCodeHeapSize = 0; ArgsRange errcode = parse_memory_size(tail, &long_NonProfiledCodeHeapSize, 1); if (errcode != arg_in_range) { jio_fprintf(defaultStream::error_stream(), "Invalid maximum non-profiled code heap size: %s.\n", option->optionString); return JNI_EINVAL; } FLAG_SET_CMDLINE(uintx, NonProfiledCodeHeapSize, (uintx)long_NonProfiledCodeHeapSize); //-XX:IncreaseFirstTierCompileThresholdAt= } else if (match_option(option, "-XX:IncreaseFirstTierCompileThresholdAt=", &tail)) { uintx uint_IncreaseFirstTierCompileThresholdAt = 0; if (!parse_uintx(tail, &uint_IncreaseFirstTierCompileThresholdAt, 0) || uint_IncreaseFirstTierCompileThresholdAt > 99) { jio_fprintf(defaultStream::error_stream(), "Invalid value for IncreaseFirstTierCompileThresholdAt: %s. Should be between 0 and 99.\n", option->optionString); + if (FLAG_SET_CMDLINE(uintx, NonProfiledCodeHeapSize, (uintx)long_NonProfiledCodeHeapSize) != Flag::SUCCESS) { return JNI_EINVAL; } FLAG_SET_CMDLINE(uintx, IncreaseFirstTierCompileThresholdAt, (uintx)uint_IncreaseFirstTierCompileThresholdAt); // -green } else if (match_option(option, "-green")) { jio_fprintf(defaultStream::error_stream(), "Green threads support not available\n"); return JNI_EINVAL;
*** 2904,2917 **** --- 2616,2633 ---- } else if (match_option(option, "-Xsqnopause")) { // EVM option, ignore silently for compatibility // -Xrs } else if (match_option(option, "-Xrs")) { // Classic/EVM option, new functionality FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true); + if (FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (match_option(option, "-Xusealtsigs")) { // change default internal VM signals used - lower case for back compat FLAG_SET_CMDLINE(bool, UseAltSigs, true); + if (FLAG_SET_CMDLINE(bool, UseAltSigs, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xoptimize } else if (match_option(option, "-Xoptimize")) { // EVM option, ignore silently for compatibility // -Xprof } else if (match_option(option, "-Xprof")) {
*** 2922,2936 **** --- 2638,2662 ---- "Flat profiling is not supported in this VM.\n"); return JNI_ERR; #endif // INCLUDE_FPROF // -Xconcurrentio } else if (match_option(option, "-Xconcurrentio")) { FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true); ! FLAG_SET_CMDLINE(bool, BackgroundCompilation, false); FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1); FLAG_SET_CMDLINE(bool, UseTLAB, false); FLAG_SET_CMDLINE(size_t, NewSizeThreadIncrease, 16 * K); // 20Kb per thread added to new generation + if (FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1) != Flag::SUCCESS) { + return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, UseTLAB, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(size_t, NewSizeThreadIncrease, 16 * K) != Flag::SUCCESS) { // 20Kb per thread added to new generation + return JNI_EINVAL; + } // -Xinternalversion } else if (match_option(option, "-Xinternalversion")) { jio_fprintf(defaultStream::output_stream(), "%s\n", VM_Version::internal_vm_info_string());
*** 2964,2974 **** --- 2690,2702 ---- return JNI_ENOMEM; } // Out of the box management support if (match_option(option, "-Dcom.sun.management", &tail)) { #if INCLUDE_MANAGEMENT FLAG_SET_CMDLINE(bool, ManagementServer, true); + if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } #else jio_fprintf(defaultStream::output_stream(), "-Dcom.sun.management is not supported in this VM.\n"); return JNI_ERR; #endif
*** 2983,3017 **** --- 2711,2771 ---- } else if (match_option(option, "-Xcomp")) { // for testing the compiler; turn off all flags that inhibit compilation set_mode_flags(_comp); // -Xshare:dump } else if (match_option(option, "-Xshare:dump")) { FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true); + if (FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } set_mode_flags(_int); // Prevent compilation, which creates objects // -Xshare:on } else if (match_option(option, "-Xshare:on")) { FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); ! FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true); + if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xshare:auto } else if (match_option(option, "-Xshare:auto")) { FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); ! FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false); + if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xshare:off } else if (match_option(option, "-Xshare:off")) { FLAG_SET_CMDLINE(bool, UseSharedSpaces, false); ! FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false); + if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, false) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } // -Xverify } else if (match_option(option, "-Xverify", &tail)) { if (strcmp(tail, ":all") == 0 || strcmp(tail, "") == 0) { FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true); ! FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true); + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (strcmp(tail, ":remote") == 0) { FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false); ! FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true); + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (strcmp(tail, ":none") == 0) { FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false); ! FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false); + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) { return JNI_EINVAL; } // -Xdebug } else if (match_option(option, "-Xdebug")) {
*** 3032,3044 **** --- 2786,2801 ---- "Invalid file name for use with -Xloggc: Filename can only contain the " "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n" "Note %%p or %%t can only be used once\n", _gc_log_filename); return JNI_EINVAL; } FLAG_SET_CMDLINE(bool, PrintGC, true); ! FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true); + if (FLAG_SET_CMDLINE(bool, PrintGC, true) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } // JNI hooks } else if (match_option(option, "-Xcheck", &tail)) { if (!strcmp(tail, ":jni")) { #if !INCLUDE_JNI_CHECK warning("JNI CHECKING is not supported in this VM");
*** 3086,3120 **** --- 2843,2893 ---- total_memory - (julong)160*M); initHeapSize = limit_by_allocatable_memory(initHeapSize); if (FLAG_IS_DEFAULT(MaxHeapSize)) { FLAG_SET_CMDLINE(size_t, MaxHeapSize, initHeapSize); ! FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize); + if (FLAG_SET_CMDLINE(size_t, MaxHeapSize, initHeapSize) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize) != Flag::SUCCESS) { + return JNI_EINVAL; + } // Currently the minimum size and the initial heap sizes are the same. set_min_heap_size(initHeapSize); } if (FLAG_IS_DEFAULT(NewSize)) { // Make the young generation 3/8ths of the total heap. ! if (FLAG_SET_CMDLINE(size_t, NewSize, ! ((julong)MaxHeapSize / (julong)8) * (julong)3); ! FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize); ! ((julong)MaxHeapSize / (julong)8) * (julong)3) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize) != Flag::SUCCESS) { + return JNI_EINVAL; + } } #if !defined(_ALLBSD_SOURCE) && !defined(AIX) // UseLargePages is not yet supported on BSD and AIX. FLAG_SET_DEFAULT(UseLargePages, true); #endif // Increase some data structure sizes for efficiency FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize); ! FLAG_SET_CMDLINE(bool, ResizeTLAB, false); FLAG_SET_CMDLINE(size_t, TLABSize, 256*K); + if (FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, ResizeTLAB, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(size_t, TLABSize, 256*K) != Flag::SUCCESS) { + return JNI_EINVAL; + } // See the OldPLABSize comment below, but replace 'after promotion' // with 'after copying'. YoungPLABSize is the size of the survivor // space per-gc-thread buffers. The default is 4kw. ! FLAG_SET_CMDLINE(size_t, YoungPLABSize, 256*K); // Note: this is in words ! if (FLAG_SET_CMDLINE(size_t, YoungPLABSize, 256*K) != Flag::SUCCESS) { // Note: this is in words + return JNI_EINVAL; + } // OldPLABSize is the size of the buffers in the old gen that // UseParallelGC uses to promote live data that doesn't fit in the // survivor spaces. At any given time, there's one for each gc thread. // The default size is 1kw. These buffers are rarely used, since the
*** 3125,3200 **** --- 2898,3026 ---- // is that a bigger PLAB results in retaining something like the // original allocation order after promotion, which improves mutator // locality. A minor effect may be that larger PLABs reduce the // number of PLAB allocation events during gc. The value of 8kw // was arrived at by experimenting with specjbb. ! FLAG_SET_CMDLINE(size_t, OldPLABSize, 8*K); // Note: this is in words ! if (FLAG_SET_CMDLINE(size_t, OldPLABSize, 8*K) != Flag::SUCCESS) { // Note: this is in words + return JNI_EINVAL; + } // Enable parallel GC and adaptive generation sizing FLAG_SET_CMDLINE(bool, UseParallelGC, true); + if (FLAG_SET_CMDLINE(bool, UseParallelGC, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads()); // Encourage steady state memory management FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100); + if (FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100) != Flag::SUCCESS) { + return JNI_EINVAL; + } // This appears to improve mutator locality FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); + if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } // Get around early Solaris scheduling bug // (affinity vs other jobs on system) // but disallow DR and offlining (5008695). FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true); + if (FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } // Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure; // and the last option wins. } else if (match_option(option, "-XX:+NeverTenure")) { FLAG_SET_CMDLINE(bool, NeverTenure, true); ! FLAG_SET_CMDLINE(bool, AlwaysTenure, false); FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1); + if (FLAG_SET_CMDLINE(bool, NeverTenure, true) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (match_option(option, "-XX:+AlwaysTenure")) { FLAG_SET_CMDLINE(bool, NeverTenure, false); ! FLAG_SET_CMDLINE(bool, AlwaysTenure, true); FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0); + if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (match_option(option, "-XX:MaxTenuringThreshold=", &tail)) { uintx max_tenuring_thresh = 0; ! if (!parse_uintx(tail, &max_tenuring_thresh, 0)) { jio_fprintf(defaultStream::error_stream(), ! "Improperly specified VM option 'MaxTenuringThreshold=%s'\n", tail); ! "Improperly specified VM option \'MaxTenuringThreshold=%s\'\n", tail); + return JNI_EINVAL; + } + + if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, max_tenuring_thresh) != Flag::SUCCESS) { return JNI_EINVAL; } FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, max_tenuring_thresh); if (MaxTenuringThreshold == 0) { FLAG_SET_CMDLINE(bool, NeverTenure, false); ! FLAG_SET_CMDLINE(bool, AlwaysTenure, true); + if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else { FLAG_SET_CMDLINE(bool, NeverTenure, false); ! FLAG_SET_CMDLINE(bool, AlwaysTenure, false); + if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } } } else if (match_option(option, "-XX:+DisplayVMOutputToStderr")) { FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false); ! FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true); + if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) { FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false); ! FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true); + if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) { #if defined(DTRACE_ENABLED) FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true); ! FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true); FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true); FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true); + if (FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } #else // defined(DTRACE_ENABLED) jio_fprintf(defaultStream::error_stream(), "ExtendedDTraceProbes flag is not applicable for this configuration\n"); return JNI_EINVAL; #endif // defined(DTRACE_ENABLED) #ifdef ASSERT } else if (match_option(option, "-XX:+FullGCALot")) { FLAG_SET_CMDLINE(bool, FullGCALot, true); + if (FLAG_SET_CMDLINE(bool, FullGCALot, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } // disable scavenge before parallel mark-compact FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); + if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != Flag::SUCCESS) { + return JNI_EINVAL; + } #endif } else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) || match_option(option, "-XX:G1MarkStackSize=", &tail)) { julong stack_size = 0; ArgsRange errcode = parse_memory_size(tail, &stack_size, 1);
*** 3205,3215 **** --- 3031,3043 ---- return JNI_EINVAL; } jio_fprintf(defaultStream::error_stream(), "Please use -XX:MarkStackSize in place of " "-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n"); FLAG_SET_CMDLINE(size_t, MarkStackSize, stack_size); + if (FLAG_SET_CMDLINE(size_t, MarkStackSize, stack_size) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) { julong max_stack_size = 0; ArgsRange errcode = parse_memory_size(tail, &max_stack_size, 1); if (errcode != arg_in_range) { jio_fprintf(defaultStream::error_stream(),
*** 3219,3229 **** --- 3047,3059 ---- return JNI_EINVAL; } jio_fprintf(defaultStream::error_stream(), "Please use -XX:MarkStackSizeMax in place of " "-XX:CMSMarkStackSizeMax in the future\n"); FLAG_SET_CMDLINE(size_t, MarkStackSizeMax, max_stack_size); + if (FLAG_SET_CMDLINE(size_t, MarkStackSizeMax, max_stack_size) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) || match_option(option, "-XX:ParallelCMSThreads=", &tail)) { uintx conc_threads = 0; if (!parse_uintx(tail, &conc_threads, 1)) { jio_fprintf(defaultStream::error_stream(),
*** 3231,3252 **** --- 3061,3086 ---- return JNI_EINVAL; } jio_fprintf(defaultStream::error_stream(), "Please use -XX:ConcGCThreads in place of " "-XX:ParallelMarkingThreads or -XX:ParallelCMSThreads in the future\n"); FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads); + if (FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads) != Flag::SUCCESS) { + return JNI_EINVAL; + } } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) { julong max_direct_memory_size = 0; ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0); if (errcode != arg_in_range) { jio_fprintf(defaultStream::error_stream(), "Invalid maximum direct memory size: %s\n", option->optionString); describe_range_error(errcode); return JNI_EINVAL; } FLAG_SET_CMDLINE(size_t, MaxDirectMemorySize, max_direct_memory_size); + if (FLAG_SET_CMDLINE(size_t, MaxDirectMemorySize, max_direct_memory_size) != Flag::SUCCESS) { + return JNI_EINVAL; + } #if !INCLUDE_MANAGEMENT } else if (match_option(option, "-XX:+ManagementServer")) { jio_fprintf(defaultStream::error_stream(), "ManagementServer is not supported in this VM.\n"); return JNI_ERR;
*** 3275,3287 **** --- 3109,3127 ---- // PrintSharedArchiveAndExit will turn on // -Xshare:on // -XX:+TraceClassPaths if (PrintSharedArchiveAndExit) { FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); ! FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true); FLAG_SET_CMDLINE(bool, TraceClassPaths, true); + if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) { ! return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } + if (FLAG_SET_CMDLINE(bool, TraceClassPaths, true) != Flag::SUCCESS) { + return JNI_EINVAL; + } } // Change the default value for flags which have different default values // when working with older JDKs. #ifdef LINUX
*** 3684,3693 **** --- 3524,3537 ---- // Parse entry point called from JNI_CreateJavaVM jint Arguments::parse(const JavaVMInitArgs* args) { + // Initialize ranges and constraints + CommandLineFlagRangeList::init(); + CommandLineFlagConstraintList::init(); + // Remaining part of option string const char* tail; // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. const char* hotspotrc = ".hotspotrc";
*** 4018,4027 **** --- 3862,3880 ---- } } return JNI_OK; } + // Any custom code post the final range and constraint check + // can be done here. We pass a flag that specifies whether + // the check passed successfully + void Arguments::post_final_range_and_constraint_check(bool check_passed) { + // This does not set the flag itself, but stores the value in a safe place for later usage. + _min_heap_free_ratio = MinHeapFreeRatio; + _max_heap_free_ratio = MaxHeapFreeRatio; + } + int Arguments::PropertyList_count(SystemProperty* pl) { int count = 0; while(pl != NULL) { count++; pl = pl->next();

src/share/vm/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File