OpenJDK / zgc / zgc
changeset 50077:14b48f47528b
Merge
author | henryjen |
---|---|
date | Mon, 23 Apr 2018 14:23:18 -0700 |
parents | 1dcd0716a178 b0c100aaede6 |
children | aa629b168667 |
files | src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.cpp src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.hpp src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp src/hotspot/share/gc/g1/jvmFlagConstraintsG1.hpp src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.cpp src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.hpp src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp src/hotspot/share/gc/shared/jvmFlagConstraintsGC.hpp src/hotspot/share/runtime/flags/flagSetting.hpp src/hotspot/share/runtime/flags/jvmFlag.cpp src/hotspot/share/runtime/flags/jvmFlag.hpp src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp src/hotspot/share/runtime/flags/jvmFlagConstraintList.hpp src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.hpp src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp src/hotspot/share/runtime/flags/jvmFlagRangeList.hpp src/hotspot/share/runtime/flags/jvmFlagWriteableList.cpp src/hotspot/share/runtime/flags/jvmFlagWriteableList.hpp |
diffstat | 85 files changed, 5270 insertions(+), 5369 deletions(-) [+] |
line wrap: on
line diff
--- a/make/launcher/Launcher-jdk.pack.gmk Thu Dec 07 12:25:09 2017 -0800 +++ b/make/launcher/Launcher-jdk.pack.gmk Mon Apr 23 14:23:18 2018 -0700 @@ -88,7 +88,6 @@ CFLAGS_solaris := -KPIC, \ CFLAGS_macosx := -fPIC, \ DISABLED_WARNINGS_gcc := unused-result implicit-fallthrough, \ - DISABLED_WARNINGS_microsoft := 4005, \ LDFLAGS := $(UNPACKEXE_ZIPOBJS) \ $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \ $(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/make/lib/Lib-jdk.pack.gmk Thu Dec 07 12:25:09 2017 -0800 +++ b/make/lib/Lib-jdk.pack.gmk Mon Apr 23 14:23:18 2018 -0700 @@ -40,7 +40,6 @@ $(LIBJAVA_HEADER_FLAGS), \ CFLAGS_release := -DPRODUCT, \ DISABLED_WARNINGS_gcc := implicit-fallthrough, \ - DISABLED_WARNINGS_microsoft := 4005, \ LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_windows := -map:$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpack.map -debug, \
--- a/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -30,7 +30,6 @@ #include "interpreter/interpreterRuntime.hpp" #include "memory/allocation.inline.hpp" #include "prims/methodHandles.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/frame.inline.hpp" #define __ _masm->
--- a/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -35,7 +35,6 @@ #include "oops/klass.inline.hpp" #include "prims/methodHandles.hpp" #include "runtime/biasedLocking.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/jniHandles.inline.hpp" #include "runtime/objectMonitor.hpp"
--- a/src/hotspot/cpu/sparc/methodHandles_sparc.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/cpu/sparc/methodHandles_sparc.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -31,7 +31,6 @@ #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" #include "prims/methodHandles.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/frame.inline.hpp" #include "utilities/preserveException.hpp"
--- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -37,7 +37,6 @@ #include "oops/klass.inline.hpp" #include "prims/methodHandles.hpp" #include "runtime/biasedLocking.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/objectMonitor.hpp" #include "runtime/os.hpp"
--- a/src/hotspot/cpu/x86/methodHandles_x86.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/cpu/x86/methodHandles_x86.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -31,7 +31,6 @@ #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" #include "prims/methodHandles.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/frame.inline.hpp" #include "utilities/preserveException.hpp"
--- a/src/hotspot/share/code/dependencies.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/code/dependencies.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -35,7 +35,6 @@ #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" #include "oops/objArrayKlass.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/handles.hpp" #include "runtime/handles.inline.hpp" #include "runtime/jniHandles.inline.hpp"
--- a/src/hotspot/share/code/nmethod.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/code/nmethod.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -47,7 +47,6 @@ #include "oops/oop.inline.hpp" #include "prims/jvmtiImpl.hpp" #include "runtime/atomic.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/frame.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/jniHandles.inline.hpp"
--- a/src/hotspot/share/code/relocInfo.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/code/relocInfo.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ #include "code/relocInfo.hpp" #include "memory/resourceArea.hpp" #include "oops/compressedOops.inline.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/stubCodeGenerator.hpp" #include "utilities/copy.hpp" #include "oops/oop.inline.hpp"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/cms/commandLineFlagConstraintsCMS.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/cms/commandLineFlagConstraintsCMS.hpp" +#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp" +#include "gc/shared/cardTableRS.hpp" +#include "gc/shared/collectedHeap.hpp" +#include "gc/shared/genCollectedHeap.hpp" +#include "gc/shared/commandLineFlagConstraintsGC.hpp" +#include "memory/universe.hpp" +#include "runtime/commandLineFlagRangeList.hpp" +#include "runtime/globals_extension.hpp" +#include "utilities/globalDefinitions.hpp" + +static Flag::Error ParallelGCThreadsAndCMSWorkQueueDrainThreshold(uint threads, uintx threshold, bool verbose) { + // CMSWorkQueueDrainThreshold is verified to be less than max_juint + if (UseConcMarkSweepGC && (threads > (uint)(max_jint / (uint)threshold))) { + CommandLineError::print(verbose, + "ParallelGCThreads (" UINT32_FORMAT ") or CMSWorkQueueDrainThreshold (" + UINTX_FORMAT ") is too large\n", + threads, threshold); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +Flag::Error ParallelGCThreadsConstraintFuncCMS(uint value, bool verbose) { + // To avoid overflow at ParScanClosure::do_oop_work. + if (UseConcMarkSweepGC && (value > (max_jint / 10))) { + CommandLineError::print(verbose, + "ParallelGCThreads (" UINT32_FORMAT ") must be " + "less than or equal to " UINT32_FORMAT " for CMS GC\n", + value, (max_jint / 10)); + return Flag::VIOLATES_CONSTRAINT; + } + return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(value, CMSWorkQueueDrainThreshold, verbose); +} +Flag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose) { + if (UseConcMarkSweepGC && (value > ((uintx)max_jint / (uintx)ParallelGCThreads))) { + CommandLineError::print(verbose, + "ParGCStridesPerThread (" UINTX_FORMAT ") must be " + "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n", + value, ((uintx)max_jint / (uintx)ParallelGCThreads)); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) { + if (UseConcMarkSweepGC) { + // ParGCCardsPerStrideChunk should be compared with card table size. + size_t heap_size = Universe::heap()->reserved_region().word_size(); + CardTableRS* ct = GenCollectedHeap::heap()->rem_set(); + size_t card_table_size = ct->cards_required(heap_size) - 1; // Valid card table size + + if ((size_t)value > card_table_size) { + CommandLineError::print(verbose, + "ParGCCardsPerStrideChunk (" INTX_FORMAT ") is too large for the heap size and " + "must be less than or equal to card table size (" SIZE_FORMAT ")\n", + value, card_table_size); + return Flag::VIOLATES_CONSTRAINT; + } + + // ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread) + // from CardTableRS::process_stride(). Note that ParGCStridesPerThread is already checked + // not to make an overflow with ParallelGCThreads from its constraint function. + uintx n_strides = ParallelGCThreads * ParGCStridesPerThread; + uintx ergo_max = max_uintx / n_strides; + if ((uintx)value > ergo_max) { + CommandLineError::print(verbose, + "ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be " + "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n", + value, ergo_max); + return Flag::VIOLATES_CONSTRAINT; + } + } + return Flag::SUCCESS; +} + +Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) { + Flag::Error status = Flag::SUCCESS; + + if (UseConcMarkSweepGC) { + if (value > CMSOldPLABMax) { + CommandLineError::print(verbose, + "CMSOldPLABMin (" SIZE_FORMAT ") must be " + "less than or equal to CMSOldPLABMax (" SIZE_FORMAT ")\n", + value, CMSOldPLABMax); + return Flag::VIOLATES_CONSTRAINT; + } + status = MaxPLABSizeBounds("CMSOldPLABMin", value, verbose); + } + return status; +} + +Flag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose) { + Flag::Error status = Flag::SUCCESS; + + if (UseConcMarkSweepGC) { + status = MaxPLABSizeBounds("CMSOldPLABMax", value, verbose); + } + return status; +} + +static Flag::Error CMSReservedAreaConstraintFunc(const char* name, size_t value, bool verbose) { + if (UseConcMarkSweepGC) { + ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*)GenCollectedHeap::heap()->old_gen(); + const size_t ergo_max = cms->cmsSpace()->max_flag_size_for_task_size(); + if (value > ergo_max) { + CommandLineError::print(verbose, + "%s (" SIZE_FORMAT ") must be " + "less than or equal to ergonomic maximum (" SIZE_FORMAT ") " + "which is based on the maximum size of the old generation of the Java heap\n", + name, value, ergo_max); + return Flag::VIOLATES_CONSTRAINT; + } + } + + return Flag::SUCCESS; +} + +Flag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose) { + Flag::Error status = CMSReservedAreaConstraintFunc("CMSRescanMultiple", value, verbose); + + if (status == Flag::SUCCESS && UseConcMarkSweepGC) { + // CMSParRemarkTask::do_dirty_card_rescan_tasks requires CompactibleFreeListSpace::rescan_task_size() + // to be aligned to CardTable::card_size * BitsPerWord. + // Note that rescan_task_size() will be aligned if CMSRescanMultiple is a multiple of 'HeapWordSize' + // because rescan_task_size() is CardTable::card_size / HeapWordSize * BitsPerWord. + if (value % HeapWordSize != 0) { + CommandLineError::print(verbose, + "CMSRescanMultiple (" SIZE_FORMAT ") must be " + "a multiple of " SIZE_FORMAT "\n", + value, HeapWordSize); + status = Flag::VIOLATES_CONSTRAINT; + } + } + + return status; +} + +Flag::Error CMSConcMarkMultipleConstraintFunc(size_t value, bool verbose) { + return CMSReservedAreaConstraintFunc("CMSConcMarkMultiple", value, verbose); +} + +Flag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose) { + if (UseConcMarkSweepGC && (value <= CMSPrecleanNumerator)) { + CommandLineError::print(verbose, + "CMSPrecleanDenominator (" UINTX_FORMAT ") must be " + "strickly greater than CMSPrecleanNumerator (" UINTX_FORMAT ")\n", + value, CMSPrecleanNumerator); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose) { + if (UseConcMarkSweepGC && (value >= CMSPrecleanDenominator)) { + CommandLineError::print(verbose, + "CMSPrecleanNumerator (" UINTX_FORMAT ") must be " + "less than CMSPrecleanDenominator (" UINTX_FORMAT ")\n", + value, CMSPrecleanDenominator); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +Flag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose) { + if (UseConcMarkSweepGC) { + size_t max_capacity = GenCollectedHeap::heap()->young_gen()->max_capacity(); + if (value > max_uintx - max_capacity) { + CommandLineError::print(verbose, + "CMSSamplingGrain (" UINTX_FORMAT ") must be " + "less than or equal to ergonomic maximum (" SIZE_FORMAT ")\n", + value, max_uintx - max_capacity); + return Flag::VIOLATES_CONSTRAINT; + } + } + return Flag::SUCCESS; +} + +Flag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose) { + if (UseConcMarkSweepGC) { + return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(ParallelGCThreads, value, verbose); + } + return Flag::SUCCESS; +} + +Flag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose) { + // Skip for current default value. + if (UseConcMarkSweepGC && FLAG_IS_CMDLINE(CMSBitMapYieldQuantum)) { + // CMSBitMapYieldQuantum should be compared with mark bitmap size. + ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*)GenCollectedHeap::heap()->old_gen(); + size_t bitmap_size = cms->collector()->markBitMap()->sizeInWords(); + + if (value > bitmap_size) { + CommandLineError::print(verbose, + "CMSBitMapYieldQuantum (" SIZE_FORMAT ") must " + "be less than or equal to bitmap size (" SIZE_FORMAT ") " + "whose size corresponds to the size of old generation of the Java heap\n", + value, bitmap_size); + return Flag::VIOLATES_CONSTRAINT; + } + } + return Flag::SUCCESS; +} + +Flag::Error OldPLABSizeConstraintFuncCMS(size_t value, bool verbose) { + if (value == 0) { + CommandLineError::print(verbose, + "OldPLABSize (" SIZE_FORMAT ") must be greater than 0", + value); + return Flag::VIOLATES_CONSTRAINT; + } + // For CMS, OldPLABSize is the number of free blocks of a given size that are used when + // replenishing the local per-worker free list caches. + // For more details, please refer to Arguments::set_cms_and_parnew_gc_flags(). + return MaxPLABSizeBounds("OldPLABSize", value, verbose); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/cms/commandLineFlagConstraintsCMS.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_CMS_COMMANDLINEFLAGCONSTRAINTSCMS_HPP +#define SHARE_GC_CMS_COMMANDLINEFLAGCONSTRAINTSCMS_HPP + +#include "runtime/globals.hpp" +#include "utilities/globalDefinitions.hpp" + +// CMS Flag Constraints +Flag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose); +Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose); +Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose); +Flag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose); +Flag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose); +Flag::Error CMSConcMarkMultipleConstraintFunc(size_t value, bool verbose); +Flag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose); +Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose); +Flag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose); +Flag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose); +Flag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose); + +// CMS Subconstraints +Flag::Error ParallelGCThreadsConstraintFuncCMS(uint value, bool verbose); +Flag::Error OldPLABSizeConstraintFuncCMS(size_t value, bool verbose); + +#endif // SHARE_GC_CMS_COMMANDLINEFLAGCONSTRAINTSCMS_HPP
--- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -68,7 +68,6 @@ #include "oops/oop.inline.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/atomic.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/globals_extension.hpp" #include "runtime/handles.inline.hpp" #include "runtime/java.hpp"
--- a/src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.cpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc/cms/jvmFlagConstraintsCMS.hpp" -#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp" -#include "gc/shared/cardTableRS.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "gc/shared/genCollectedHeap.hpp" -#include "gc/shared/jvmFlagConstraintsGC.hpp" -#include "memory/universe.hpp" -#include "runtime/flags/jvmFlagRangeList.hpp" -#include "runtime/globals_extension.hpp" -#include "utilities/globalDefinitions.hpp" - -static JVMFlag::Error ParallelGCThreadsAndCMSWorkQueueDrainThreshold(uint threads, uintx threshold, bool verbose) { - // CMSWorkQueueDrainThreshold is verified to be less than max_juint - if (UseConcMarkSweepGC && (threads > (uint)(max_jint / (uint)threshold))) { - CommandLineError::print(verbose, - "ParallelGCThreads (" UINT32_FORMAT ") or CMSWorkQueueDrainThreshold (" - UINTX_FORMAT ") is too large\n", - threads, threshold); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error ParallelGCThreadsConstraintFuncCMS(uint value, bool verbose) { - // To avoid overflow at ParScanClosure::do_oop_work. - if (UseConcMarkSweepGC && (value > (max_jint / 10))) { - CommandLineError::print(verbose, - "ParallelGCThreads (" UINT32_FORMAT ") must be " - "less than or equal to " UINT32_FORMAT " for CMS GC\n", - value, (max_jint / 10)); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(value, CMSWorkQueueDrainThreshold, verbose); -} -JVMFlag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose) { - if (UseConcMarkSweepGC && (value > ((uintx)max_jint / (uintx)ParallelGCThreads))) { - CommandLineError::print(verbose, - "ParGCStridesPerThread (" UINTX_FORMAT ") must be " - "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n", - value, ((uintx)max_jint / (uintx)ParallelGCThreads)); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) { - if (UseConcMarkSweepGC) { - // ParGCCardsPerStrideChunk should be compared with card table size. - size_t heap_size = Universe::heap()->reserved_region().word_size(); - CardTableRS* ct = GenCollectedHeap::heap()->rem_set(); - size_t card_table_size = ct->cards_required(heap_size) - 1; // Valid card table size - - if ((size_t)value > card_table_size) { - CommandLineError::print(verbose, - "ParGCCardsPerStrideChunk (" INTX_FORMAT ") is too large for the heap size and " - "must be less than or equal to card table size (" SIZE_FORMAT ")\n", - value, card_table_size); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - // ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread) - // from CardTableRS::process_stride(). Note that ParGCStridesPerThread is already checked - // not to make an overflow with ParallelGCThreads from its constraint function. - uintx n_strides = ParallelGCThreads * ParGCStridesPerThread; - uintx ergo_max = max_uintx / n_strides; - if ((uintx)value > ergo_max) { - CommandLineError::print(verbose, - "ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be " - "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n", - value, ergo_max); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - - if (UseConcMarkSweepGC) { - if (value > CMSOldPLABMax) { - CommandLineError::print(verbose, - "CMSOldPLABMin (" SIZE_FORMAT ") must be " - "less than or equal to CMSOldPLABMax (" SIZE_FORMAT ")\n", - value, CMSOldPLABMax); - return JVMFlag::VIOLATES_CONSTRAINT; - } - status = MaxPLABSizeBounds("CMSOldPLABMin", value, verbose); - } - return status; -} - -JVMFlag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - - if (UseConcMarkSweepGC) { - status = MaxPLABSizeBounds("CMSOldPLABMax", value, verbose); - } - return status; -} - -static JVMFlag::Error CMSReservedAreaConstraintFunc(const char* name, size_t value, bool verbose) { - if (UseConcMarkSweepGC) { - ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*)GenCollectedHeap::heap()->old_gen(); - const size_t ergo_max = cms->cmsSpace()->max_flag_size_for_task_size(); - if (value > ergo_max) { - CommandLineError::print(verbose, - "%s (" SIZE_FORMAT ") must be " - "less than or equal to ergonomic maximum (" SIZE_FORMAT ") " - "which is based on the maximum size of the old generation of the Java heap\n", - name, value, ergo_max); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose) { - JVMFlag::Error status = CMSReservedAreaConstraintFunc("CMSRescanMultiple", value, verbose); - - if (status == JVMFlag::SUCCESS && UseConcMarkSweepGC) { - // CMSParRemarkTask::do_dirty_card_rescan_tasks requires CompactibleFreeListSpace::rescan_task_size() - // to be aligned to CardTable::card_size * BitsPerWord. - // Note that rescan_task_size() will be aligned if CMSRescanMultiple is a multiple of 'HeapWordSize' - // because rescan_task_size() is CardTable::card_size / HeapWordSize * BitsPerWord. - if (value % HeapWordSize != 0) { - CommandLineError::print(verbose, - "CMSRescanMultiple (" SIZE_FORMAT ") must be " - "a multiple of " SIZE_FORMAT "\n", - value, HeapWordSize); - status = JVMFlag::VIOLATES_CONSTRAINT; - } - } - - return status; -} - -JVMFlag::Error CMSConcMarkMultipleConstraintFunc(size_t value, bool verbose) { - return CMSReservedAreaConstraintFunc("CMSConcMarkMultiple", value, verbose); -} - -JVMFlag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose) { - if (UseConcMarkSweepGC && (value <= CMSPrecleanNumerator)) { - CommandLineError::print(verbose, - "CMSPrecleanDenominator (" UINTX_FORMAT ") must be " - "strickly greater than CMSPrecleanNumerator (" UINTX_FORMAT ")\n", - value, CMSPrecleanNumerator); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose) { - if (UseConcMarkSweepGC && (value >= CMSPrecleanDenominator)) { - CommandLineError::print(verbose, - "CMSPrecleanNumerator (" UINTX_FORMAT ") must be " - "less than CMSPrecleanDenominator (" UINTX_FORMAT ")\n", - value, CMSPrecleanDenominator); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose) { - if (UseConcMarkSweepGC) { - size_t max_capacity = GenCollectedHeap::heap()->young_gen()->max_capacity(); - if (value > max_uintx - max_capacity) { - CommandLineError::print(verbose, - "CMSSamplingGrain (" UINTX_FORMAT ") must be " - "less than or equal to ergonomic maximum (" SIZE_FORMAT ")\n", - value, max_uintx - max_capacity); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose) { - if (UseConcMarkSweepGC) { - return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(ParallelGCThreads, value, verbose); - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose) { - // Skip for current default value. - if (UseConcMarkSweepGC && FLAG_IS_CMDLINE(CMSBitMapYieldQuantum)) { - // CMSBitMapYieldQuantum should be compared with mark bitmap size. - ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*)GenCollectedHeap::heap()->old_gen(); - size_t bitmap_size = cms->collector()->markBitMap()->sizeInWords(); - - if (value > bitmap_size) { - CommandLineError::print(verbose, - "CMSBitMapYieldQuantum (" SIZE_FORMAT ") must " - "be less than or equal to bitmap size (" SIZE_FORMAT ") " - "whose size corresponds to the size of old generation of the Java heap\n", - value, bitmap_size); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error OldPLABSizeConstraintFuncCMS(size_t value, bool verbose) { - if (value == 0) { - CommandLineError::print(verbose, - "OldPLABSize (" SIZE_FORMAT ") must be greater than 0", - value); - return JVMFlag::VIOLATES_CONSTRAINT; - } - // For CMS, OldPLABSize is the number of free blocks of a given size that are used when - // replenishing the local per-worker free list caches. - // For more details, please refer to Arguments::set_cms_and_parnew_gc_flags(). - return MaxPLABSizeBounds("OldPLABSize", value, verbose); -}
--- a/src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.hpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_GC_CMS_COMMANDLINEFLAGCONSTRAINTSCMS_HPP -#define SHARE_GC_CMS_COMMANDLINEFLAGCONSTRAINTSCMS_HPP - -#include "runtime/globals.hpp" -#include "utilities/globalDefinitions.hpp" - -// CMS Flag Constraints -JVMFlag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose); -JVMFlag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose); -JVMFlag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose); -JVMFlag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose); -JVMFlag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose); -JVMFlag::Error CMSConcMarkMultipleConstraintFunc(size_t value, bool verbose); -JVMFlag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose); -JVMFlag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose); -JVMFlag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose); -JVMFlag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose); -JVMFlag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose); - -// CMS Subconstraints -JVMFlag::Error ParallelGCThreadsConstraintFuncCMS(uint value, bool verbose); -JVMFlag::Error OldPLABSizeConstraintFuncCMS(size_t value, bool verbose); - -#endif // SHARE_GC_CMS_COMMANDLINEFLAGCONSTRAINTSCMS_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/g1/commandLineFlagConstraintsG1.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/g1/heapRegionBounds.inline.hpp" +#include "runtime/commandLineFlagRangeList.hpp" +#include "runtime/globals_extension.hpp" +#include "utilities/globalDefinitions.hpp" + +Flag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose) { + if (!UseG1GC) return Flag::SUCCESS; + + // Default value of G1RSetRegionEntries=0 means will be set ergonomically. + // Minimum value is 1. + if (FLAG_IS_CMDLINE(G1RSetRegionEntries) && (value < 1)) { + CommandLineError::print(verbose, + "G1RSetRegionEntries (" INTX_FORMAT ") must be " + "greater than or equal to 1\n", + value); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose) { + if (!UseG1GC) return Flag::SUCCESS; + + // Default value of G1RSetSparseRegionEntries=0 means will be set ergonomically. + // Minimum value is 1. + if (FLAG_IS_CMDLINE(G1RSetSparseRegionEntries) && (value < 1)) { + CommandLineError::print(verbose, + "G1RSetSparseRegionEntries (" INTX_FORMAT ") must be " + "greater than or equal to 1\n", + value); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) { + if (!UseG1GC) return Flag::SUCCESS; + + // Default value of G1HeapRegionSize=0 means will be set ergonomically. + if (FLAG_IS_CMDLINE(G1HeapRegionSize) && (value < HeapRegionBounds::min_size())) { + CommandLineError::print(verbose, + "G1HeapRegionSize (" SIZE_FORMAT ") must be " + "greater than or equal to ergonomic heap region minimum size\n", + value); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) { + if (!UseG1GC) return Flag::SUCCESS; + + if (value > G1MaxNewSizePercent) { + CommandLineError::print(verbose, + "G1NewSizePercent (" UINTX_FORMAT ") must be " + "less than or equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n", + value, G1MaxNewSizePercent); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) { + if (!UseG1GC) return Flag::SUCCESS; + + if (value < G1NewSizePercent) { + CommandLineError::print(verbose, + "G1MaxNewSizePercent (" UINTX_FORMAT ") must be " + "greater than or equal to G1NewSizePercent (" UINTX_FORMAT ")\n", + value, G1NewSizePercent); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose) { + if (UseG1GC && FLAG_IS_CMDLINE(MaxGCPauseMillis) && (value >= GCPauseIntervalMillis)) { + CommandLineError::print(verbose, + "MaxGCPauseMillis (" UINTX_FORMAT ") must be " + "less than GCPauseIntervalMillis (" UINTX_FORMAT ")\n", + value, GCPauseIntervalMillis); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +} + +Flag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose) { + if (UseG1GC) { + if (FLAG_IS_CMDLINE(GCPauseIntervalMillis)) { + if (value < 1) { + CommandLineError::print(verbose, + "GCPauseIntervalMillis (" UINTX_FORMAT ") must be " + "greater than or equal to 1\n", + value); + return Flag::VIOLATES_CONSTRAINT; + } + + if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { + CommandLineError::print(verbose, + "GCPauseIntervalMillis cannot be set " + "without setting MaxGCPauseMillis\n"); + return Flag::VIOLATES_CONSTRAINT; + } + + if (value <= MaxGCPauseMillis) { + CommandLineError::print(verbose, + "GCPauseIntervalMillis (" UINTX_FORMAT ") must be " + "greater than MaxGCPauseMillis (" UINTX_FORMAT ")\n", + value, MaxGCPauseMillis); + return Flag::VIOLATES_CONSTRAINT; + } + } + } + + return Flag::SUCCESS; +} + +Flag::Error NewSizeConstraintFuncG1(size_t value, bool verbose) { +#ifdef _LP64 + // Overflow would happen for uint type variable of YoungGenSizer::_min_desired_young_length + // when the value to be assigned exceeds uint range. + // i.e. result of '(uint)(NewSize / region size(1~32MB))' + // So maximum of NewSize should be 'max_juint * 1M' + if (UseG1GC && (value > (max_juint * 1 * M))) { + CommandLineError::print(verbose, + "NewSize (" SIZE_FORMAT ") must be less than ergonomic maximum value\n", + value); + return Flag::VIOLATES_CONSTRAINT; + } +#endif // _LP64 + return Flag::SUCCESS; +} + +size_t MaxSizeForHeapAlignmentG1() { + return HeapRegionBounds::max_size(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/g1/commandLineFlagConstraintsG1.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_G1_COMMANDLINEFLAGCONSTRAINTSG1_HPP +#define SHARE_GC_G1_COMMANDLINEFLAGCONSTRAINTSG1_HPP + +#include "runtime/globals.hpp" +#include "utilities/globalDefinitions.hpp" + +// G1 Flag Constraints +Flag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose); +Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose); +Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose); +Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose); +Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose); + +// G1 Subconstraints +Flag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose); +Flag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose); +Flag::Error MaxSizeForHeapAlignmentG1(const char* name, size_t value, bool verbose); +Flag::Error NewSizeConstraintFuncG1(size_t value, bool verbose); + +size_t MaxSizeForHeapAlignmentG1(); + +#endif // SHARE_GC_SHARED_COMMANDLINEFLAGCONSTRAINTSG1_HPP
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -84,7 +84,6 @@ #include "oops/oop.inline.hpp" #include "prims/resolvedMethodTable.hpp" #include "runtime/atomic.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/handles.inline.hpp" #include "runtime/init.hpp" #include "runtime/orderAccess.inline.hpp"
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -1695,21 +1695,18 @@ assert(!rp->discovery_enabled(), "Post condition"); } - assert(has_overflown() || _global_mark_stack.is_empty(), - "Mark stack should be empty (unless it has overflown)"); + if (has_overflown()) { + // We can not trust g1_is_alive if the marking stack overflowed + return; + } + + assert(_global_mark_stack.is_empty(), "Marking should have completed"); { GCTraceTime(Debug, gc, phases) debug("Weak Processing", _gc_timer_cm); WeakProcessor::weak_oops_do(&g1_is_alive, &do_nothing_cl); } - if (has_overflown()) { - // We can not trust g1_is_alive if the marking stack overflowed - return; - } - - assert(_global_mark_stack.is_empty(), "Marking should have completed"); - // Unload Klasses, String, Symbols, Code Cache, etc. if (ClassUnloadingWithConcurrentMark) { GCTraceTime(Debug, gc, phases) debug("Class Unloading", _gc_timer_cm);
--- a/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc/g1/heapRegionBounds.inline.hpp" -#include "runtime/flags/jvmFlagRangeList.hpp" -#include "runtime/globals_extension.hpp" -#include "utilities/globalDefinitions.hpp" - -JVMFlag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose) { - if (!UseG1GC) return JVMFlag::SUCCESS; - - // Default value of G1RSetRegionEntries=0 means will be set ergonomically. - // Minimum value is 1. - if (FLAG_IS_CMDLINE(G1RSetRegionEntries) && (value < 1)) { - CommandLineError::print(verbose, - "G1RSetRegionEntries (" INTX_FORMAT ") must be " - "greater than or equal to 1\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose) { - if (!UseG1GC) return JVMFlag::SUCCESS; - - // Default value of G1RSetSparseRegionEntries=0 means will be set ergonomically. - // Minimum value is 1. - if (FLAG_IS_CMDLINE(G1RSetSparseRegionEntries) && (value < 1)) { - CommandLineError::print(verbose, - "G1RSetSparseRegionEntries (" INTX_FORMAT ") must be " - "greater than or equal to 1\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) { - if (!UseG1GC) return JVMFlag::SUCCESS; - - // Default value of G1HeapRegionSize=0 means will be set ergonomically. - if (FLAG_IS_CMDLINE(G1HeapRegionSize) && (value < HeapRegionBounds::min_size())) { - CommandLineError::print(verbose, - "G1HeapRegionSize (" SIZE_FORMAT ") must be " - "greater than or equal to ergonomic heap region minimum size\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) { - if (!UseG1GC) return JVMFlag::SUCCESS; - - if (value > G1MaxNewSizePercent) { - CommandLineError::print(verbose, - "G1NewSizePercent (" UINTX_FORMAT ") must be " - "less than or equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n", - value, G1MaxNewSizePercent); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) { - if (!UseG1GC) return JVMFlag::SUCCESS; - - if (value < G1NewSizePercent) { - CommandLineError::print(verbose, - "G1MaxNewSizePercent (" UINTX_FORMAT ") must be " - "greater than or equal to G1NewSizePercent (" UINTX_FORMAT ")\n", - value, G1NewSizePercent); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose) { - if (UseG1GC && FLAG_IS_CMDLINE(MaxGCPauseMillis) && (value >= GCPauseIntervalMillis)) { - CommandLineError::print(verbose, - "MaxGCPauseMillis (" UINTX_FORMAT ") must be " - "less than GCPauseIntervalMillis (" UINTX_FORMAT ")\n", - value, GCPauseIntervalMillis); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose) { - if (UseG1GC) { - if (FLAG_IS_CMDLINE(GCPauseIntervalMillis)) { - if (value < 1) { - CommandLineError::print(verbose, - "GCPauseIntervalMillis (" UINTX_FORMAT ") must be " - "greater than or equal to 1\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { - CommandLineError::print(verbose, - "GCPauseIntervalMillis cannot be set " - "without setting MaxGCPauseMillis\n"); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - if (value <= MaxGCPauseMillis) { - CommandLineError::print(verbose, - "GCPauseIntervalMillis (" UINTX_FORMAT ") must be " - "greater than MaxGCPauseMillis (" UINTX_FORMAT ")\n", - value, MaxGCPauseMillis); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error NewSizeConstraintFuncG1(size_t value, bool verbose) { -#ifdef _LP64 - // Overflow would happen for uint type variable of YoungGenSizer::_min_desired_young_length - // when the value to be assigned exceeds uint range. - // i.e. result of '(uint)(NewSize / region size(1~32MB))' - // So maximum of NewSize should be 'max_juint * 1M' - if (UseG1GC && (value > (max_juint * 1 * M))) { - CommandLineError::print(verbose, - "NewSize (" SIZE_FORMAT ") must be less than ergonomic maximum value\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; - } -#endif // _LP64 - return JVMFlag::SUCCESS; -} - -size_t MaxSizeForHeapAlignmentG1() { - return HeapRegionBounds::max_size(); -}
--- a/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.hpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_GC_G1_COMMANDLINEFLAGCONSTRAINTSG1_HPP -#define SHARE_GC_G1_COMMANDLINEFLAGCONSTRAINTSG1_HPP - -#include "runtime/globals.hpp" -#include "utilities/globalDefinitions.hpp" - -// G1 Flag Constraints -JVMFlag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose); -JVMFlag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose); -JVMFlag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose); -JVMFlag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose); - -// G1 Subconstraints -JVMFlag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose); -JVMFlag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose); -JVMFlag::Error MaxSizeForHeapAlignmentG1(const char* name, size_t value, bool verbose); -JVMFlag::Error NewSizeConstraintFuncG1(size_t value, bool verbose); - -size_t MaxSizeForHeapAlignmentG1(); - -#endif // SHARE_GC_SHARED_COMMANDLINEFLAGCONSTRAINTSG1_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/parallel/commandLineFlagConstraintsParallel.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "runtime/commandLineFlagRangeList.hpp" +#include "runtime/globals.hpp" +#include "utilities/globalDefinitions.hpp" + +Flag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose) { + // Parallel GC passes ParallelGCThreads when creating GrowableArray as 'int' type parameter. + // So can't exceed with "max_jint" + + if (UseParallelGC && (value > (uint)max_jint)) { + CommandLineError::print(verbose, + "ParallelGCThreads (" UINT32_FORMAT ") must be " + "less than or equal to " UINT32_FORMAT " for Parallel GC\n", + value, max_jint); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +Flag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) { + // InitialTenuringThreshold is only used for ParallelGC. + if (UseParallelGC && (value > MaxTenuringThreshold)) { + CommandLineError::print(verbose, + "InitialTenuringThreshold (" UINTX_FORMAT ") must be " + "less than or equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n", + value, MaxTenuringThreshold); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +Flag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) { + // As only ParallelGC uses InitialTenuringThreshold, + // we don't need to compare InitialTenuringThreshold with MaxTenuringThreshold. + if (UseParallelGC && (value < InitialTenuringThreshold)) { + CommandLineError::print(verbose, + "MaxTenuringThreshold (" UINTX_FORMAT ") must be " + "greater than or equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n", + value, InitialTenuringThreshold); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/parallel/commandLineFlagConstraintsParallel.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_PARALLEL_COMMANDLINEFLAGCONSTRAINTSPARALLEL_HPP +#define SHARE_GC_PARALLEL_COMMANDLINEFLAGCONSTRAINTSPARALLEL_HPP + +#include "runtime/globals.hpp" +#include "utilities/globalDefinitions.hpp" + +// Parallel Subconstraints +Flag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose); +Flag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool verbose); +Flag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose); + +#endif // SHARE_GC_PARALLEL_COMMANDLINEFLAGCONSTRAINTSPARALLEL_HPP
--- a/src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.cpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "runtime/flags/jvmFlagRangeList.hpp" -#include "runtime/globals.hpp" -#include "utilities/globalDefinitions.hpp" - -JVMFlag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose) { - // Parallel GC passes ParallelGCThreads when creating GrowableArray as 'int' type parameter. - // So can't exceed with "max_jint" - - if (UseParallelGC && (value > (uint)max_jint)) { - CommandLineError::print(verbose, - "ParallelGCThreads (" UINT32_FORMAT ") must be " - "less than or equal to " UINT32_FORMAT " for Parallel GC\n", - value, max_jint); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) { - // InitialTenuringThreshold is only used for ParallelGC. - if (UseParallelGC && (value > MaxTenuringThreshold)) { - CommandLineError::print(verbose, - "InitialTenuringThreshold (" UINTX_FORMAT ") must be " - "less than or equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n", - value, MaxTenuringThreshold); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) { - // As only ParallelGC uses InitialTenuringThreshold, - // we don't need to compare InitialTenuringThreshold with MaxTenuringThreshold. - if (UseParallelGC && (value < InitialTenuringThreshold)) { - CommandLineError::print(verbose, - "MaxTenuringThreshold (" UINTX_FORMAT ") must be " - "greater than or equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n", - value, InitialTenuringThreshold); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -}
--- a/src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.hpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_GC_PARALLEL_COMMANDLINEFLAGCONSTRAINTSPARALLEL_HPP -#define SHARE_GC_PARALLEL_COMMANDLINEFLAGCONSTRAINTSPARALLEL_HPP - -#include "runtime/globals.hpp" -#include "utilities/globalDefinitions.hpp" - -// Parallel Subconstraints -JVMFlag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose); -JVMFlag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool verbose); -JVMFlag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose); - -#endif // SHARE_GC_PARALLEL_COMMANDLINEFLAGCONSTRAINTSPARALLEL_HPP
--- a/src/hotspot/share/gc/parallel/psMarkSweep.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/gc/parallel/psMarkSweep.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -51,7 +51,6 @@ #include "logging/log.hpp" #include "oops/oop.inline.hpp" #include "runtime/biasedLocking.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/handles.inline.hpp" #include "runtime/safepoint.hpp" #include "runtime/vmThread.hpp"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/shared/commandLineFlagConstraintsGC.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,470 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/shared/collectedHeap.hpp" +#include "gc/shared/collectorPolicy.hpp" +#include "gc/shared/commandLineFlagConstraintsGC.hpp" +#include "gc/shared/plab.hpp" +#include "gc/shared/threadLocalAllocBuffer.hpp" +#include "runtime/arguments.hpp" +#include "runtime/commandLineFlagRangeList.hpp" +#include "runtime/globals.hpp" +#include "runtime/globals_extension.hpp" +#include "runtime/thread.inline.hpp" +#include "utilities/align.hpp" +#include "utilities/defaultStream.hpp" +#include "utilities/macros.hpp" +#if INCLUDE_ALL_GCS +#include "gc/cms/commandLineFlagConstraintsCMS.hpp" +#include "gc/g1/commandLineFlagConstraintsG1.hpp" +#include "gc/parallel/commandLineFlagConstraintsParallel.hpp" +#endif +#ifdef COMPILER1 +#include "c1/c1_globals.hpp" +#endif // COMPILER1 +#ifdef COMPILER2 +#include "opto/c2_globals.hpp" +#endif // COMPILER2 + +// Some flags that have default values that indicate that the +// JVM should automatically determine an appropriate value +// for that flag. In those cases it is only appropriate for the +// constraint checking to be done if the user has specified the +// value(s) of the flag(s) on the command line. In the constraint +// checking functions, FLAG_IS_CMDLINE() is used to check if +// the flag has been set by the user and so should be checked. + +// As ParallelGCThreads differs among GC modes, we need constraint function. +Flag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) { + Flag::Error status = Flag::SUCCESS; + +#if INCLUDE_ALL_GCS + status = ParallelGCThreadsConstraintFuncParallel(value, verbose); + if (status != Flag::SUCCESS) { + return status; + } + + status = ParallelGCThreadsConstraintFuncCMS(value, verbose); + if (status != Flag::SUCCESS) { + return status; + } +#endif + + return status; +} + +// As ConcGCThreads should be smaller than ParallelGCThreads, +// we need constraint function. +Flag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) { +#if INCLUDE_ALL_GCS + // CMS and G1 GCs use ConcGCThreads. + if ((UseConcMarkSweepGC || UseG1GC) && (value > ParallelGCThreads)) { + CommandLineError::print(verbose, + "ConcGCThreads (" UINT32_FORMAT ") must be " + "less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n", + value, ParallelGCThreads); + return Flag::VIOLATES_CONSTRAINT; + } +#endif + return Flag::SUCCESS; +} + +static Flag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) { +#if INCLUDE_ALL_GCS + if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value < PLAB::min_size())) { + CommandLineError::print(verbose, + "%s (" SIZE_FORMAT ") must be " + "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n", + name, value, PLAB::min_size()); + return Flag::VIOLATES_CONSTRAINT; + } +#endif // INCLUDE_ALL_GCS + return Flag::SUCCESS; +} + +Flag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) { +#if INCLUDE_ALL_GCS + if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value > PLAB::max_size())) { + CommandLineError::print(verbose, + "%s (" SIZE_FORMAT ") must be " + "less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n", + name, value, PLAB::max_size()); + return Flag::VIOLATES_CONSTRAINT; + } +#endif // INCLUDE_ALL_GCS + return Flag::SUCCESS; +} + +static Flag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) { + Flag::Error status = MinPLABSizeBounds(name, value, verbose); + + if (status == Flag::SUCCESS) { + return MaxPLABSizeBounds(name, value, verbose); + } + return status; +} + +Flag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) { + return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose); +} + +Flag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) { + Flag::Error status = Flag::SUCCESS; + +#if INCLUDE_ALL_GCS + if (UseConcMarkSweepGC) { + return OldPLABSizeConstraintFuncCMS(value, verbose); + } else { + status = MinMaxPLABSizeBounds("OldPLABSize", value, verbose); + } +#endif + return status; +} + +Flag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) { + if (value > MaxHeapFreeRatio) { + CommandLineError::print(verbose, + "MinHeapFreeRatio (" UINTX_FORMAT ") must be " + "less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n", + value, MaxHeapFreeRatio); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) { + if (value < MinHeapFreeRatio) { + CommandLineError::print(verbose, + "MaxHeapFreeRatio (" UINTX_FORMAT ") must be " + "greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n", + value, MinHeapFreeRatio); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +static Flag::Error CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(size_t maxHeap, intx softRef, bool verbose) { + if ((softRef > 0) && ((maxHeap / M) > (max_uintx / softRef))) { + CommandLineError::print(verbose, + "Desired lifetime of SoftReferences cannot be expressed correctly. " + "MaxHeapSize (" SIZE_FORMAT ") or SoftRefLRUPolicyMSPerMB " + "(" INTX_FORMAT ") is too large\n", + maxHeap, softRef); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose) { + return CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(MaxHeapSize, value, verbose); +} + +Flag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) { + if (value > MarkStackSizeMax) { + CommandLineError::print(verbose, + "MarkStackSize (" SIZE_FORMAT ") must be " + "less than or equal to MarkStackSizeMax (" SIZE_FORMAT ")\n", + value, MarkStackSizeMax); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { + if (value > MaxMetaspaceFreeRatio) { + CommandLineError::print(verbose, + "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be " + "less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n", + value, MaxMetaspaceFreeRatio); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { + if (value < MinMetaspaceFreeRatio) { + CommandLineError::print(verbose, + "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be " + "greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n", + value, MinMetaspaceFreeRatio); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) { +#if INCLUDE_ALL_GCS + Flag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose); + if (status != Flag::SUCCESS) { + return status; + } +#endif + + return Flag::SUCCESS; +} + +Flag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) { +#if INCLUDE_ALL_GCS + Flag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose); + if (status != Flag::SUCCESS) { + return status; + } +#endif + + // MaxTenuringThreshold=0 means NeverTenure=false && AlwaysTenure=true + if ((value == 0) && (NeverTenure || !AlwaysTenure)) { + CommandLineError::print(verbose, + "MaxTenuringThreshold (0) should match to NeverTenure=false " + "&& AlwaysTenure=true. But we have NeverTenure=%s " + "AlwaysTenure=%s\n", + NeverTenure ? "true" : "false", + AlwaysTenure ? "true" : "false"); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +Flag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) { +#if INCLUDE_ALL_GCS + Flag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose); + if (status != Flag::SUCCESS) { + return status; + } +#endif + + return Flag::SUCCESS; +} + +Flag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) { +#if INCLUDE_ALL_GCS + Flag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose); + if (status != Flag::SUCCESS) { + return status; + } +#endif + + return Flag::SUCCESS; +} + +Flag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) { + size_t aligned_max = align_down(max_uintx/2, Metaspace::reserve_alignment_words()); + if (value > aligned_max) { + CommandLineError::print(verbose, + "InitialBootClassLoaderMetaspaceSize (" SIZE_FORMAT ") must be " + "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n", + value, aligned_max); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +// To avoid an overflow by 'align_up(value, alignment)'. +static Flag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) { + size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1)); + if (value > aligned_max) { + CommandLineError::print(verbose, + "%s (" SIZE_FORMAT ") must be " + "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n", + name, value, aligned_max); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +static Flag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) { + size_t heap_alignment; + +#if INCLUDE_ALL_GCS + if (UseG1GC) { + // For G1 GC, we don't know until G1CollectorPolicy is created. + heap_alignment = MaxSizeForHeapAlignmentG1(); + } else +#endif + { + heap_alignment = CollectorPolicy::compute_heap_alignment(); + } + + return MaxSizeForAlignment(name, value, heap_alignment, verbose); +} + +Flag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) { + return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose); +} + +Flag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) { + Flag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose); + + if (status == Flag::SUCCESS) { + status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose); + } + return status; +} + +Flag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) { + // If an overflow happened in Arguments::set_heap_size(), MaxHeapSize will have too large a value. + // Check for this by ensuring that MaxHeapSize plus the requested min base address still fit within max_uintx. + if (UseCompressedOops && FLAG_IS_ERGO(MaxHeapSize) && (value > (max_uintx - MaxHeapSize))) { + CommandLineError::print(verbose, + "HeapBaseMinAddress (" SIZE_FORMAT ") or MaxHeapSize (" SIZE_FORMAT ") is too large. " + "Sum of them must be less than or equal to maximum of size_t (" SIZE_FORMAT ")\n", + value, MaxHeapSize, max_uintx); + return Flag::VIOLATES_CONSTRAINT; + } + + return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose); +} + +Flag::Error NewSizeConstraintFunc(size_t value, bool verbose) { +#if INCLUDE_ALL_GCS + Flag::Error status = NewSizeConstraintFuncG1(value, verbose); + if (status != Flag::SUCCESS) { + return status; + } +#endif + + return Flag::SUCCESS; +} + +Flag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) { + // At least, alignment reserve area is needed. + if (value < ThreadLocalAllocBuffer::alignment_reserve_in_bytes()) { + CommandLineError::print(verbose, + "MinTLABSize (" SIZE_FORMAT ") must be " + "greater than or equal to reserved area in TLAB (" SIZE_FORMAT ")\n", + value, ThreadLocalAllocBuffer::alignment_reserve_in_bytes()); + return Flag::VIOLATES_CONSTRAINT; + } + if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { + CommandLineError::print(verbose, + "MinTLABSize (" SIZE_FORMAT ") must be " + "less than or equal to ergonomic TLAB maximum (" SIZE_FORMAT ")\n", + value, ThreadLocalAllocBuffer::max_size() * HeapWordSize); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +Flag::Error TLABSizeConstraintFunc(size_t value, bool verbose) { + // Skip for default value of zero which means set ergonomically. + if (FLAG_IS_CMDLINE(TLABSize)) { + if (value < MinTLABSize) { + CommandLineError::print(verbose, + "TLABSize (" SIZE_FORMAT ") must be " + "greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n", + value, MinTLABSize); + return Flag::VIOLATES_CONSTRAINT; + } + if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { + CommandLineError::print(verbose, + "TLABSize (" SIZE_FORMAT ") must be " + "less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n", + value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize)); + return Flag::VIOLATES_CONSTRAINT; + } + } + return Flag::SUCCESS; +} + +// We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(), +// so AfterMemoryInit type is enough to check. +Flag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) { + if (UseTLAB) { + size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit(); + + // Compare with 'max_uintx' as ThreadLocalAllocBuffer::_refill_waste_limit is 'size_t'. + if (refill_waste_limit > (max_uintx - value)) { + CommandLineError::print(verbose, + "TLABWasteIncrement (" UINTX_FORMAT ") must be " + "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n", + value, (max_uintx - refill_waste_limit)); + return Flag::VIOLATES_CONSTRAINT; + } + } + return Flag::SUCCESS; +} + +Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) { + if (FLAG_IS_CMDLINE(SurvivorRatio) && + (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) { + CommandLineError::print(verbose, + "SurvivorRatio (" UINTX_FORMAT ") must be " + "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n", + value, + (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment())); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) { + if (value > MaxMetaspaceSize) { + CommandLineError::print(verbose, + "MetaspaceSize (" SIZE_FORMAT ") must be " + "less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n", + value, MaxMetaspaceSize); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) { + if (value < MetaspaceSize) { + CommandLineError::print(verbose, + "MaxMetaspaceSize (" SIZE_FORMAT ") must be " + "greater than or equal to MetaspaceSize (" SIZE_FORMAT ")\n", + value, MaxMetaspaceSize); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) { + if (value != 0) { + if (!is_power_of_2(value)) { + CommandLineError::print(verbose, + "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be " + "power of 2\n", + value); + return Flag::VIOLATES_CONSTRAINT; + } + if (value < ObjectAlignmentInBytes) { + CommandLineError::print(verbose, + "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be " + "greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n", + value, ObjectAlignmentInBytes); + return Flag::VIOLATES_CONSTRAINT; + } + } + return Flag::SUCCESS; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/gc/shared/commandLineFlagConstraintsGC.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_SHARED_COMMANDLINEFLAGCONSTRAINTSGC_HPP +#define SHARE_GC_SHARED_COMMANDLINEFLAGCONSTRAINTSGC_HPP + +#include "utilities/globalDefinitions.hpp" +#include "utilities/macros.hpp" +#if INCLUDE_ALL_GCS +#include "gc/cms/commandLineFlagConstraintsCMS.hpp" +#include "gc/g1/commandLineFlagConstraintsG1.hpp" +#include "gc/parallel/commandLineFlagConstraintsParallel.hpp" +#endif + +/* + * Here we have GC arguments constraints functions, which are called automatically + * whenever flag's value changes. If the constraint fails the function should return + * an appropriate error value. + */ + +Flag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose); +Flag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose); +Flag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose); +Flag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose); +Flag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose); +Flag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose); +Flag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose); +Flag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose); +Flag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose); +Flag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose); +Flag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose); +Flag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose); + +Flag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose); +Flag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose); +Flag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose); +Flag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose); +Flag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose); +Flag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose); +Flag::Error NewSizeConstraintFunc(size_t value, bool verbose); +Flag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose); +Flag::Error TLABSizeConstraintFunc(size_t value, bool verbose); +Flag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose); +Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose); +Flag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose); +Flag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose); +Flag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose); + +// Internal +Flag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose); + +#endif // SHARE_GC_SHARED_COMMANDLINEFLAGCONSTRAINTSGC_HPP
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -53,7 +53,6 @@ #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" #include "runtime/biasedLocking.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/handles.hpp" #include "runtime/handles.inline.hpp" #include "runtime/java.hpp"
--- a/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,470 +0,0 @@ -/* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "gc/shared/collectorPolicy.hpp" -#include "gc/shared/jvmFlagConstraintsGC.hpp" -#include "gc/shared/plab.hpp" -#include "gc/shared/threadLocalAllocBuffer.hpp" -#include "runtime/arguments.hpp" -#include "runtime/flags/jvmFlagRangeList.hpp" -#include "runtime/globals.hpp" -#include "runtime/globals_extension.hpp" -#include "runtime/thread.inline.hpp" -#include "utilities/align.hpp" -#include "utilities/defaultStream.hpp" -#include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS -#include "gc/cms/jvmFlagConstraintsCMS.hpp" -#include "gc/g1/jvmFlagConstraintsG1.hpp" -#include "gc/parallel/jvmFlagConstraintsParallel.hpp" -#endif -#ifdef COMPILER1 -#include "c1/c1_globals.hpp" -#endif // COMPILER1 -#ifdef COMPILER2 -#include "opto/c2_globals.hpp" -#endif // COMPILER2 - -// Some flags that have default values that indicate that the -// JVM should automatically determine an appropriate value -// for that flag. In those cases it is only appropriate for the -// constraint checking to be done if the user has specified the -// value(s) of the flag(s) on the command line. In the constraint -// checking functions, FLAG_IS_CMDLINE() is used to check if -// the flag has been set by the user and so should be checked. - -// As ParallelGCThreads differs among GC modes, we need constraint function. -JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - -#if INCLUDE_ALL_GCS - status = ParallelGCThreadsConstraintFuncParallel(value, verbose); - if (status != JVMFlag::SUCCESS) { - return status; - } - - status = ParallelGCThreadsConstraintFuncCMS(value, verbose); - if (status != JVMFlag::SUCCESS) { - return status; - } -#endif - - return status; -} - -// As ConcGCThreads should be smaller than ParallelGCThreads, -// we need constraint function. -JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) { -#if INCLUDE_ALL_GCS - // CMS and G1 GCs use ConcGCThreads. - if ((UseConcMarkSweepGC || UseG1GC) && (value > ParallelGCThreads)) { - CommandLineError::print(verbose, - "ConcGCThreads (" UINT32_FORMAT ") must be " - "less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n", - value, ParallelGCThreads); - return JVMFlag::VIOLATES_CONSTRAINT; - } -#endif - return JVMFlag::SUCCESS; -} - -static JVMFlag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) { -#if INCLUDE_ALL_GCS - if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value < PLAB::min_size())) { - CommandLineError::print(verbose, - "%s (" SIZE_FORMAT ") must be " - "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n", - name, value, PLAB::min_size()); - return JVMFlag::VIOLATES_CONSTRAINT; - } -#endif // INCLUDE_ALL_GCS - return JVMFlag::SUCCESS; -} - -JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) { -#if INCLUDE_ALL_GCS - if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value > PLAB::max_size())) { - CommandLineError::print(verbose, - "%s (" SIZE_FORMAT ") must be " - "less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n", - name, value, PLAB::max_size()); - return JVMFlag::VIOLATES_CONSTRAINT; - } -#endif // INCLUDE_ALL_GCS - return JVMFlag::SUCCESS; -} - -static JVMFlag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) { - JVMFlag::Error status = MinPLABSizeBounds(name, value, verbose); - - if (status == JVMFlag::SUCCESS) { - return MaxPLABSizeBounds(name, value, verbose); - } - return status; -} - -JVMFlag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) { - return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose); -} - -JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - -#if INCLUDE_ALL_GCS - if (UseConcMarkSweepGC) { - return OldPLABSizeConstraintFuncCMS(value, verbose); - } else { - status = MinMaxPLABSizeBounds("OldPLABSize", value, verbose); - } -#endif - return status; -} - -JVMFlag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) { - if (value > MaxHeapFreeRatio) { - CommandLineError::print(verbose, - "MinHeapFreeRatio (" UINTX_FORMAT ") must be " - "less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n", - value, MaxHeapFreeRatio); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) { - if (value < MinHeapFreeRatio) { - CommandLineError::print(verbose, - "MaxHeapFreeRatio (" UINTX_FORMAT ") must be " - "greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n", - value, MinHeapFreeRatio); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -static JVMFlag::Error CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(size_t maxHeap, intx softRef, bool verbose) { - if ((softRef > 0) && ((maxHeap / M) > (max_uintx / softRef))) { - CommandLineError::print(verbose, - "Desired lifetime of SoftReferences cannot be expressed correctly. " - "MaxHeapSize (" SIZE_FORMAT ") or SoftRefLRUPolicyMSPerMB " - "(" INTX_FORMAT ") is too large\n", - maxHeap, softRef); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose) { - return CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(MaxHeapSize, value, verbose); -} - -JVMFlag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) { - if (value > MarkStackSizeMax) { - CommandLineError::print(verbose, - "MarkStackSize (" SIZE_FORMAT ") must be " - "less than or equal to MarkStackSizeMax (" SIZE_FORMAT ")\n", - value, MarkStackSizeMax); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { - if (value > MaxMetaspaceFreeRatio) { - CommandLineError::print(verbose, - "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be " - "less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n", - value, MaxMetaspaceFreeRatio); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { - if (value < MinMetaspaceFreeRatio) { - CommandLineError::print(verbose, - "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be " - "greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n", - value, MinMetaspaceFreeRatio); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) { -#if INCLUDE_ALL_GCS - JVMFlag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose); - if (status != JVMFlag::SUCCESS) { - return status; - } -#endif - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) { -#if INCLUDE_ALL_GCS - JVMFlag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose); - if (status != JVMFlag::SUCCESS) { - return status; - } -#endif - - // MaxTenuringThreshold=0 means NeverTenure=false && AlwaysTenure=true - if ((value == 0) && (NeverTenure || !AlwaysTenure)) { - CommandLineError::print(verbose, - "MaxTenuringThreshold (0) should match to NeverTenure=false " - "&& AlwaysTenure=true. But we have NeverTenure=%s " - "AlwaysTenure=%s\n", - NeverTenure ? "true" : "false", - AlwaysTenure ? "true" : "false"); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) { -#if INCLUDE_ALL_GCS - JVMFlag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose); - if (status != JVMFlag::SUCCESS) { - return status; - } -#endif - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) { -#if INCLUDE_ALL_GCS - JVMFlag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose); - if (status != JVMFlag::SUCCESS) { - return status; - } -#endif - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) { - size_t aligned_max = align_down(max_uintx/2, Metaspace::reserve_alignment_words()); - if (value > aligned_max) { - CommandLineError::print(verbose, - "InitialBootClassLoaderMetaspaceSize (" SIZE_FORMAT ") must be " - "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n", - value, aligned_max); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -// To avoid an overflow by 'align_up(value, alignment)'. -static JVMFlag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) { - size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1)); - if (value > aligned_max) { - CommandLineError::print(verbose, - "%s (" SIZE_FORMAT ") must be " - "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n", - name, value, aligned_max); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -static JVMFlag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) { - size_t heap_alignment; - -#if INCLUDE_ALL_GCS - if (UseG1GC) { - // For G1 GC, we don't know until G1CollectorPolicy is created. - heap_alignment = MaxSizeForHeapAlignmentG1(); - } else -#endif - { - heap_alignment = CollectorPolicy::compute_heap_alignment(); - } - - return MaxSizeForAlignment(name, value, heap_alignment, verbose); -} - -JVMFlag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) { - return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose); -} - -JVMFlag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose); - - if (status == JVMFlag::SUCCESS) { - status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose); - } - return status; -} - -JVMFlag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) { - // If an overflow happened in Arguments::set_heap_size(), MaxHeapSize will have too large a value. - // Check for this by ensuring that MaxHeapSize plus the requested min base address still fit within max_uintx. - if (UseCompressedOops && FLAG_IS_ERGO(MaxHeapSize) && (value > (max_uintx - MaxHeapSize))) { - CommandLineError::print(verbose, - "HeapBaseMinAddress (" SIZE_FORMAT ") or MaxHeapSize (" SIZE_FORMAT ") is too large. " - "Sum of them must be less than or equal to maximum of size_t (" SIZE_FORMAT ")\n", - value, MaxHeapSize, max_uintx); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose); -} - -JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) { -#if INCLUDE_ALL_GCS - JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose); - if (status != JVMFlag::SUCCESS) { - return status; - } -#endif - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) { - // At least, alignment reserve area is needed. - if (value < ThreadLocalAllocBuffer::alignment_reserve_in_bytes()) { - CommandLineError::print(verbose, - "MinTLABSize (" SIZE_FORMAT ") must be " - "greater than or equal to reserved area in TLAB (" SIZE_FORMAT ")\n", - value, ThreadLocalAllocBuffer::alignment_reserve_in_bytes()); - return JVMFlag::VIOLATES_CONSTRAINT; - } - if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { - CommandLineError::print(verbose, - "MinTLABSize (" SIZE_FORMAT ") must be " - "less than or equal to ergonomic TLAB maximum (" SIZE_FORMAT ")\n", - value, ThreadLocalAllocBuffer::max_size() * HeapWordSize); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error TLABSizeConstraintFunc(size_t value, bool verbose) { - // Skip for default value of zero which means set ergonomically. - if (FLAG_IS_CMDLINE(TLABSize)) { - if (value < MinTLABSize) { - CommandLineError::print(verbose, - "TLABSize (" SIZE_FORMAT ") must be " - "greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n", - value, MinTLABSize); - return JVMFlag::VIOLATES_CONSTRAINT; - } - if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { - CommandLineError::print(verbose, - "TLABSize (" SIZE_FORMAT ") must be " - "less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n", - value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize)); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - return JVMFlag::SUCCESS; -} - -// We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(), -// so AfterMemoryInit type is enough to check. -JVMFlag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) { - if (UseTLAB) { - size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit(); - - // Compare with 'max_uintx' as ThreadLocalAllocBuffer::_refill_waste_limit is 'size_t'. - if (refill_waste_limit > (max_uintx - value)) { - CommandLineError::print(verbose, - "TLABWasteIncrement (" UINTX_FORMAT ") must be " - "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n", - value, (max_uintx - refill_waste_limit)); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) { - if (FLAG_IS_CMDLINE(SurvivorRatio) && - (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) { - CommandLineError::print(verbose, - "SurvivorRatio (" UINTX_FORMAT ") must be " - "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n", - value, - (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment())); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) { - if (value > MaxMetaspaceSize) { - CommandLineError::print(verbose, - "MetaspaceSize (" SIZE_FORMAT ") must be " - "less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n", - value, MaxMetaspaceSize); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) { - if (value < MetaspaceSize) { - CommandLineError::print(verbose, - "MaxMetaspaceSize (" SIZE_FORMAT ") must be " - "greater than or equal to MetaspaceSize (" SIZE_FORMAT ")\n", - value, MaxMetaspaceSize); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) { - if (value != 0) { - if (!is_power_of_2(value)) { - CommandLineError::print(verbose, - "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be " - "power of 2\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; - } - if (value < ObjectAlignmentInBytes) { - CommandLineError::print(verbose, - "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be " - "greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n", - value, ObjectAlignmentInBytes); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - return JVMFlag::SUCCESS; -}
--- a/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.hpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_GC_SHARED_COMMANDLINEFLAGCONSTRAINTSGC_HPP -#define SHARE_GC_SHARED_COMMANDLINEFLAGCONSTRAINTSGC_HPP - -#include "utilities/globalDefinitions.hpp" -#include "utilities/macros.hpp" -#if INCLUDE_ALL_GCS -#include "gc/cms/jvmFlagConstraintsCMS.hpp" -#include "gc/g1/jvmFlagConstraintsG1.hpp" -#include "gc/parallel/jvmFlagConstraintsParallel.hpp" -#endif - -/* - * Here we have GC arguments constraints functions, which are called automatically - * whenever flag's value changes. If the constraint fails the function should return - * an appropriate error value. - */ - -JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose); -JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose); -JVMFlag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose); -JVMFlag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose); -JVMFlag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose); -JVMFlag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose); -JVMFlag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose); -JVMFlag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose); -JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose); - -JVMFlag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose); -JVMFlag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose); -JVMFlag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose); -JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error TLABSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose); -JVMFlag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose); -JVMFlag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose); -JVMFlag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose); - -// Internal -JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose); - -#endif // SHARE_GC_SHARED_COMMANDLINEFLAGCONSTRAINTSGC_HPP
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -37,7 +37,6 @@ #include "jvmci/jvmciCompilerToVM.hpp" #include "jvmci/jvmciCodeInstaller.hpp" #include "jvmci/jvmciRuntime.hpp" -#include "runtime/flags/jvmFlag.hpp" #include "runtime/frame.inline.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/jniHandles.inline.hpp" @@ -126,7 +125,7 @@ } ResourceMark rm; const char* cstring = java_lang_String::as_utf8_string(name()); - JVMFlag* flag = JVMFlag::find_flag(cstring, strlen(cstring), /* allow_locked */ true, /* return_flag */ true); + Flag* flag = Flag::find_flag(cstring, strlen(cstring), /* allow_locked */ true, /* return_flag */ true); if (flag == NULL) { return c2vm; }
--- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -29,7 +29,6 @@ #include "jvmci/jvmciRuntime.hpp" #include "jvmci/jvmciCompilerToVM.hpp" #include "jvmci/vmStructs_jvmci.hpp" -#include "runtime/flags/jvmFlag.hpp" #include "runtime/handles.inline.hpp" #include "runtime/sharedRuntime.hpp" #include "utilities/resourceHash.hpp" @@ -379,9 +378,9 @@ #define COUNT_FLAG(ignore) +1 #ifdef ASSERT #define CHECK_FLAG(type, name) { \ - JVMFlag* flag = JVMFlag::find_flag(#name, strlen(#name), /*allow_locked*/ true, /* return_flag */ true); \ + Flag* flag = Flag::find_flag(#name, strlen(#name), /*allow_locked*/ true, /* return_flag */ true); \ assert(flag != NULL, "No such flag named " #name); \ - assert(flag->is_##type(), "JVMFlag " #name " is not of type " #type); \ + assert(flag->is_##type(), "Flag " #name " is not of type " #type); \ } #else #define CHECK_FLAG(type, name)
--- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -35,7 +35,6 @@ #include "oops/oop.hpp" #include "oops/oopHandle.hpp" #include "oops/objArrayKlass.hpp" -#include "runtime/flags/jvmFlag.hpp" #include "runtime/globals.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/thread.hpp" @@ -147,16 +146,16 @@ nonstatic_field(Deoptimization::UnrollBlock, _initial_info, intptr_t) \ nonstatic_field(Deoptimization::UnrollBlock, _unpack_kind, int) \ \ - nonstatic_field(ExceptionTableElement, start_pc, u2) \ - nonstatic_field(ExceptionTableElement, end_pc, u2) \ - nonstatic_field(ExceptionTableElement, handler_pc, u2) \ - nonstatic_field(ExceptionTableElement, catch_type_index, u2) \ + nonstatic_field(ExceptionTableElement, start_pc, u2) \ + nonstatic_field(ExceptionTableElement, end_pc, u2) \ + nonstatic_field(ExceptionTableElement, handler_pc, u2) \ + nonstatic_field(ExceptionTableElement, catch_type_index, u2) \ \ - nonstatic_field(JVMFlag, _type, const char*) \ - nonstatic_field(JVMFlag, _name, const char*) \ - unchecked_nonstatic_field(JVMFlag, _addr, sizeof(void*)) \ - nonstatic_field(JVMFlag, _flags, JVMFlag::Flags) \ - static_field(JVMFlag, flags, JVMFlag*) \ + nonstatic_field(Flag, _type, const char*) \ + nonstatic_field(Flag, _name, const char*) \ + unchecked_nonstatic_field(Flag, _addr, sizeof(void*)) \ + nonstatic_field(Flag, _flags, Flag::Flags) \ + static_field(Flag, flags, Flag*) \ \ nonstatic_field(InstanceKlass, _fields, Array<u2>*) \ nonstatic_field(InstanceKlass, _constants, ConstantPool*) \ @@ -346,8 +345,8 @@ declare_toplevel_type(BasicLock) \ declare_toplevel_type(CompilerToVM) \ declare_toplevel_type(ExceptionTableElement) \ - declare_toplevel_type(JVMFlag) \ - declare_toplevel_type(JVMFlag*) \ + declare_toplevel_type(Flag) \ + declare_toplevel_type(Flag*) \ declare_toplevel_type(InvocationCounter) \ declare_toplevel_type(JVMCIEnv) \ declare_toplevel_type(LocalVariableTableElement) \
--- a/src/hotspot/share/memory/universe.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/memory/universe.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -63,8 +63,7 @@ #include "prims/resolvedMethodTable.hpp" #include "runtime/arguments.hpp" #include "runtime/atomic.hpp" -#include "runtime/flags/flagSetting.hpp" -#include "runtime/flags/jvmFlagConstraintList.hpp" +#include "runtime/commandLineFlagConstraintList.hpp" #include "runtime/deoptimization.hpp" #include "runtime/handles.inline.hpp" #include "runtime/init.hpp" @@ -702,7 +701,7 @@ AOTLoader::universe_init(); // Checks 'AfterMemoryInit' constraints. - if (!JVMFlagConstraintList::check_constraints(JVMFlagConstraint::AfterMemoryInit)) { + if (!CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterMemoryInit)) { return JNI_EINVAL; }
--- a/src/hotspot/share/oops/klassVtable.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/oops/klassVtable.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -38,7 +38,6 @@ #include "oops/objArrayOop.hpp" #include "oops/oop.inline.hpp" #include "runtime/arguments.hpp" -#include "runtime/flags/flagSetting.hpp" #include "runtime/handles.inline.hpp" #include "runtime/safepointVerifiers.hpp" #include "utilities/copy.hpp"
--- a/src/hotspot/share/precompiled/precompiled.hpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/precompiled/precompiled.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -101,7 +101,6 @@ # include "gc/shared/genCollectedHeap.hpp" # include "gc/shared/generation.hpp" # include "gc/shared/generationCounters.hpp" -# include "gc/shared/jvmFlagConstraintsGC.hpp" # include "gc/shared/modRefBarrierSet.hpp" # include "gc/shared/referencePolicy.hpp" # include "gc/shared/referenceProcessor.hpp" @@ -164,13 +163,6 @@ # include "runtime/extendedPC.hpp" # include "runtime/fieldDescriptor.hpp" # include "runtime/fieldType.hpp" -# include "runtime/flags/flagSetting.hpp" -# include "runtime/flags/jvmFlag.hpp" -# include "runtime/flags/jvmFlagConstraintList.hpp" -# include "runtime/flags/jvmFlagConstraintsCompiler.hpp" -# include "runtime/flags/jvmFlagConstraintsRuntime.hpp" -# include "runtime/flags/jvmFlagRangeList.hpp" -# include "runtime/flags/jvmFlagWriteableList.hpp" # include "runtime/frame.hpp" # include "runtime/frame.inline.hpp" # include "runtime/globals.hpp" @@ -300,7 +292,6 @@ # include "gc/cms/concurrentMarkSweepGeneration.hpp" # include "gc/cms/freeChunk.hpp" # include "gc/cms/gSpaceCounters.hpp" -# include "gc/cms/jvmFlagConstraintsCMS.hpp" # include "gc/cms/parOopClosures.hpp" # include "gc/cms/promotionInfo.hpp" # include "gc/cms/yieldingWorkgroup.hpp" @@ -308,12 +299,10 @@ # include "gc/g1/g1BlockOffsetTable.hpp" # include "gc/g1/g1OopClosures.hpp" # include "gc/g1/g1_globals.hpp" -# include "gc/g1/jvmFlagConstraintsG1.hpp" # include "gc/g1/ptrQueue.hpp" # include "gc/g1/satbMarkQueue.hpp" # include "gc/parallel/gcAdaptivePolicyCounters.hpp" # include "gc/parallel/immutableSpace.hpp" -# include "gc/parallel/jvmFlagConstraintsParallel.hpp" # include "gc/parallel/mutableSpace.hpp" # include "gc/parallel/objectStartArray.hpp" # include "gc/parallel/parMarkBitMap.hpp"
--- a/src/hotspot/share/prims/whitebox.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/prims/whitebox.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -53,7 +53,6 @@ #include "runtime/arguments.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/deoptimization.hpp" -#include "runtime/flags/jvmFlag.hpp" #include "runtime/frame.inline.hpp" #include "runtime/handshake.hpp" #include "runtime/interfaceSupport.inline.hpp" @@ -972,29 +971,29 @@ WB_END template <typename T> -static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAt)(const char*, T*, bool, bool)) { +static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, Flag::Error (*TAt)(const char*, T*, bool, bool)) { if (name == NULL) { return false; } ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI const char* flag_name = env->GetStringUTFChars(name, NULL); CHECK_JNI_EXCEPTION_(env, false); - JVMFlag::Error result = (*TAt)(flag_name, value, true, true); + Flag::Error result = (*TAt)(flag_name, value, true, true); env->ReleaseStringUTFChars(name, flag_name); - return (result == JVMFlag::SUCCESS); + return (result == Flag::SUCCESS); } template <typename T> -static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAtPut)(const char*, T*, JVMFlag::Flags)) { +static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, Flag::Error (*TAtPut)(const char*, T*, Flag::Flags)) { if (name == NULL) { return false; } ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI const char* flag_name = env->GetStringUTFChars(name, NULL); CHECK_JNI_EXCEPTION_(env, false); - JVMFlag::Error result = (*TAtPut)(flag_name, value, JVMFlag::INTERNAL); + Flag::Error result = (*TAtPut)(flag_name, value, Flag::INTERNAL); env->ReleaseStringUTFChars(name, flag_name); - return (result == JVMFlag::SUCCESS); + return (result == Flag::SUCCESS); } template <typename T> @@ -1027,28 +1026,28 @@ return box(thread, env, vmSymbols::java_lang_Double(), vmSymbols::Double_valueOf_signature(), value); } -static JVMFlag* getVMFlag(JavaThread* thread, JNIEnv* env, jstring name) { +static Flag* getVMFlag(JavaThread* thread, JNIEnv* env, jstring name) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI const char* flag_name = env->GetStringUTFChars(name, NULL); CHECK_JNI_EXCEPTION_(env, NULL); - JVMFlag* result = JVMFlag::find_flag(flag_name, strlen(flag_name), true, true); + Flag* result = Flag::find_flag(flag_name, strlen(flag_name), true, true); env->ReleaseStringUTFChars(name, flag_name); return result; } WB_ENTRY(jboolean, WB_IsConstantVMFlag(JNIEnv* env, jobject o, jstring name)) - JVMFlag* flag = getVMFlag(thread, env, name); + Flag* flag = getVMFlag(thread, env, name); return (flag != NULL) && flag->is_constant_in_binary(); WB_END WB_ENTRY(jboolean, WB_IsLockedVMFlag(JNIEnv* env, jobject o, jstring name)) - JVMFlag* flag = getVMFlag(thread, env, name); + Flag* flag = getVMFlag(thread, env, name); return (flag != NULL) && !(flag->is_unlocked() || flag->is_unlocker()); WB_END WB_ENTRY(jobject, WB_GetBooleanVMFlag(JNIEnv* env, jobject o, jstring name)) bool result; - if (GetVMFlag <bool> (thread, env, name, &result, &JVMFlag::boolAt)) { + if (GetVMFlag <bool> (thread, env, name, &result, &CommandLineFlags::boolAt)) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return booleanBox(thread, env, result); } @@ -1057,7 +1056,7 @@ WB_ENTRY(jobject, WB_GetIntVMFlag(JNIEnv* env, jobject o, jstring name)) int result; - if (GetVMFlag <int> (thread, env, name, &result, &JVMFlag::intAt)) { + if (GetVMFlag <int> (thread, env, name, &result, &CommandLineFlags::intAt)) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return longBox(thread, env, result); } @@ -1066,7 +1065,7 @@ WB_ENTRY(jobject, WB_GetUintVMFlag(JNIEnv* env, jobject o, jstring name)) uint result; - if (GetVMFlag <uint> (thread, env, name, &result, &JVMFlag::uintAt)) { + if (GetVMFlag <uint> (thread, env, name, &result, &CommandLineFlags::uintAt)) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return longBox(thread, env, result); } @@ -1075,7 +1074,7 @@ WB_ENTRY(jobject, WB_GetIntxVMFlag(JNIEnv* env, jobject o, jstring name)) intx result; - if (GetVMFlag <intx> (thread, env, name, &result, &JVMFlag::intxAt)) { + if (GetVMFlag <intx> (thread, env, name, &result, &CommandLineFlags::intxAt)) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return longBox(thread, env, result); } @@ -1084,7 +1083,7 @@ WB_ENTRY(jobject, WB_GetUintxVMFlag(JNIEnv* env, jobject o, jstring name)) uintx result; - if (GetVMFlag <uintx> (thread, env, name, &result, &JVMFlag::uintxAt)) { + if (GetVMFlag <uintx> (thread, env, name, &result, &CommandLineFlags::uintxAt)) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return longBox(thread, env, result); } @@ -1093,7 +1092,7 @@ WB_ENTRY(jobject, WB_GetUint64VMFlag(JNIEnv* env, jobject o, jstring name)) uint64_t result; - if (GetVMFlag <uint64_t> (thread, env, name, &result, &JVMFlag::uint64_tAt)) { + if (GetVMFlag <uint64_t> (thread, env, name, &result, &CommandLineFlags::uint64_tAt)) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return longBox(thread, env, result); } @@ -1102,7 +1101,7 @@ WB_ENTRY(jobject, WB_GetSizeTVMFlag(JNIEnv* env, jobject o, jstring name)) uintx result; - if (GetVMFlag <size_t> (thread, env, name, &result, &JVMFlag::size_tAt)) { + if (GetVMFlag <size_t> (thread, env, name, &result, &CommandLineFlags::size_tAt)) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return longBox(thread, env, result); } @@ -1111,7 +1110,7 @@ WB_ENTRY(jobject, WB_GetDoubleVMFlag(JNIEnv* env, jobject o, jstring name)) double result; - if (GetVMFlag <double> (thread, env, name, &result, &JVMFlag::doubleAt)) { + if (GetVMFlag <double> (thread, env, name, &result, &CommandLineFlags::doubleAt)) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return doubleBox(thread, env, result); } @@ -1120,7 +1119,7 @@ WB_ENTRY(jstring, WB_GetStringVMFlag(JNIEnv* env, jobject o, jstring name)) ccstr ccstrResult; - if (GetVMFlag <ccstr> (thread, env, name, &ccstrResult, &JVMFlag::ccstrAt)) { + if (GetVMFlag <ccstr> (thread, env, name, &ccstrResult, &CommandLineFlags::ccstrAt)) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI jstring result = env->NewStringUTF(ccstrResult); CHECK_JNI_EXCEPTION_(env, NULL); @@ -1131,42 +1130,42 @@ WB_ENTRY(void, WB_SetBooleanVMFlag(JNIEnv* env, jobject o, jstring name, jboolean value)) bool result = value == JNI_TRUE ? true : false; - SetVMFlag <bool> (thread, env, name, &result, &JVMFlag::boolAtPut); + SetVMFlag <bool> (thread, env, name, &result, &CommandLineFlags::boolAtPut); WB_END WB_ENTRY(void, WB_SetIntVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) int result = value; - SetVMFlag <int> (thread, env, name, &result, &JVMFlag::intAtPut); + SetVMFlag <int> (thread, env, name, &result, &CommandLineFlags::intAtPut); WB_END WB_ENTRY(void, WB_SetUintVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) uint result = value; - SetVMFlag <uint> (thread, env, name, &result, &JVMFlag::uintAtPut); + SetVMFlag <uint> (thread, env, name, &result, &CommandLineFlags::uintAtPut); WB_END WB_ENTRY(void, WB_SetIntxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) intx result = value; - SetVMFlag <intx> (thread, env, name, &result, &JVMFlag::intxAtPut); + SetVMFlag <intx> (thread, env, name, &result, &CommandLineFlags::intxAtPut); WB_END WB_ENTRY(void, WB_SetUintxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) uintx result = value; - SetVMFlag <uintx> (thread, env, name, &result, &JVMFlag::uintxAtPut); + SetVMFlag <uintx> (thread, env, name, &result, &CommandLineFlags::uintxAtPut); WB_END WB_ENTRY(void, WB_SetUint64VMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) uint64_t result = value; - SetVMFlag <uint64_t> (thread, env, name, &result, &JVMFlag::uint64_tAtPut); + SetVMFlag <uint64_t> (thread, env, name, &result, &CommandLineFlags::uint64_tAtPut); WB_END WB_ENTRY(void, WB_SetSizeTVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) size_t result = value; - SetVMFlag <size_t> (thread, env, name, &result, &JVMFlag::size_tAtPut); + SetVMFlag <size_t> (thread, env, name, &result, &CommandLineFlags::size_tAtPut); WB_END WB_ENTRY(void, WB_SetDoubleVMFlag(JNIEnv* env, jobject o, jstring name, jdouble value)) double result = value; - SetVMFlag <double> (thread, env, name, &result, &JVMFlag::doubleAtPut); + SetVMFlag <double> (thread, env, name, &result, &CommandLineFlags::doubleAtPut); WB_END WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value)) @@ -1183,7 +1182,7 @@ bool needFree; { ThreadInVMfromNative ttvfn(thread); // back to VM - needFree = SetVMFlag <ccstr> (thread, env, name, &ccstrResult, &JVMFlag::ccstrAtPut); + needFree = SetVMFlag <ccstr> (thread, env, name, &ccstrResult, &CommandLineFlags::ccstrAtPut); } if (value != NULL) { env->ReleaseStringUTFChars(value, ccstrValue);
--- a/src/hotspot/share/runtime/arguments.cpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/runtime/arguments.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -42,10 +42,10 @@ #include "prims/jvmtiExport.hpp" #include "runtime/arguments.hpp" #include "runtime/arguments_ext.hpp" -#include "runtime/flags/jvmFlag.hpp" -#include "runtime/flags/jvmFlagConstraintList.hpp" -#include "runtime/flags/jvmFlagWriteableList.hpp" -#include "runtime/flags/jvmFlagRangeList.hpp" +#include "runtime/commandLineFlagConstraintList.hpp" +#include "runtime/commandLineFlagWriteableList.hpp" +#include "runtime/commandLineFlagRangeList.hpp" +#include "runtime/globals.hpp" #include "runtime/globals_extension.hpp" #include "runtime/java.hpp" #include "runtime/os.inline.hpp" @@ -739,7 +739,7 @@ // if flag has become obsolete it should not have a "globals" flag defined anymore. if (!version_less_than(JDK_Version::current(), flag.obsolete_in)) { - if (JVMFlag::find_flag(flag.name) != NULL) { + if (Flag::find_flag(flag.name) != NULL) { // Temporarily disable the warning: 8196739 // warning("Global variable for obsolete special flag entry \"%s\" should be removed", flag.name); } @@ -749,7 +749,7 @@ if (!flag.expired_in.is_undefined()) { // if flag has become expired it should not have a "globals" flag defined anymore. if (!version_less_than(JDK_Version::current(), flag.expired_in)) { - if (JVMFlag::find_flag(flag.name) != NULL) { + if (Flag::find_flag(flag.name) != NULL) { // Temporarily disable the warning: 8196739 // warning("Global variable for expired flag entry \"%s\" should be removed", flag.name); } @@ -833,15 +833,15 @@ } } -static bool set_bool_flag(const char* name, bool value, JVMFlag::Flags origin) { - if (JVMFlag::boolAtPut(name, &value, origin) == JVMFlag::SUCCESS) { +static bool set_bool_flag(const char* name, bool value, Flag::Flags origin) { + if (CommandLineFlags::boolAtPut(name, &value, origin) == Flag::SUCCESS) { return true; } else { return false; } } -static bool set_fp_numeric_flag(const char* name, char* value, JVMFlag::Flags origin) { +static bool set_fp_numeric_flag(const char* name, char* value, Flag::Flags origin) { char* end; errno = 0; double v = strtod(value, &end); @@ -849,18 +849,18 @@ return false; } - if (JVMFlag::doubleAtPut(name, &v, origin) == JVMFlag::SUCCESS) { + if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) { return true; } return false; } -static bool set_numeric_flag(const char* name, char* value, JVMFlag::Flags origin) { +static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) { julong v; int int_v; intx intx_v; bool is_neg = false; - JVMFlag* result = JVMFlag::find_flag(name, strlen(name)); + Flag* result = Flag::find_flag(name, strlen(name)); if (result == NULL) { return false; @@ -882,43 +882,43 @@ if (is_neg) { int_v = -int_v; } - return JVMFlag::intAtPut(result, &int_v, origin) == JVMFlag::SUCCESS; + return CommandLineFlags::intAtPut(result, &int_v, origin) == Flag::SUCCESS; } else if (result->is_uint()) { uint uint_v = (uint) v; - return JVMFlag::uintAtPut(result, &uint_v, origin) == JVMFlag::SUCCESS; + return CommandLineFlags::uintAtPut(result, &uint_v, origin) == Flag::SUCCESS; } else if (result->is_intx()) { intx_v = (intx) v; if (is_neg) { intx_v = -intx_v; } - return JVMFlag::intxAtPut(result, &intx_v, origin) == JVMFlag::SUCCESS; + return CommandLineFlags::intxAtPut(result, &intx_v, origin) == Flag::SUCCESS; } else if (result->is_uintx()) { uintx uintx_v = (uintx) v; - return JVMFlag::uintxAtPut(result, &uintx_v, origin) == JVMFlag::SUCCESS; + return CommandLineFlags::uintxAtPut(result, &uintx_v, origin) == Flag::SUCCESS; } else if (result->is_uint64_t()) { uint64_t uint64_t_v = (uint64_t) v; - return JVMFlag::uint64_tAtPut(result, &uint64_t_v, origin) == JVMFlag::SUCCESS; + return CommandLineFlags::uint64_tAtPut(result, &uint64_t_v, origin) == Flag::SUCCESS; } else if (result->is_size_t()) { size_t size_t_v = (size_t) v; - return JVMFlag::size_tAtPut(result, &size_t_v, origin) == JVMFlag::SUCCESS; + return CommandLineFlags::size_tAtPut(result, &size_t_v, origin) == Flag::SUCCESS; } else if (result->is_double()) { double double_v = (double) v; - return JVMFlag::doubleAtPut(result, &double_v, origin) == JVMFlag::SUCCESS; + return CommandLineFlags::doubleAtPut(result, &double_v, origin) == Flag::SUCCESS; } else { return false; } } -static bool set_string_flag(const char* name, const char* value, JVMFlag::Flags origin) { - if (JVMFlag::ccstrAtPut(name, &value, origin) != JVMFlag::SUCCESS) return false; - // Contract: JVMFlag always returns a pointer that needs freeing. +static bool set_string_flag(const char* name, const char* value, Flag::Flags origin) { + 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(const char* name, const char* new_value, JVMFlag::Flags origin) { +static bool append_to_string_flag(const char* name, const char* new_value, Flag::Flags origin) { const char* old_value = ""; - if (JVMFlag::ccstrAt(name, &old_value) != JVMFlag::SUCCESS) 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; @@ -935,11 +935,11 @@ value = buf; free_this_too = buf; } - (void) JVMFlag::ccstrAtPut(name, &value, origin); - // JVMFlag always returns a pointer that needs freeing. + (void) CommandLineFlags::ccstrAtPut(name, &value, origin); + // CommandLineFlags always returns a pointer that needs freeing. FREE_C_HEAP_ARRAY(char, value); if (free_this_too != NULL) { - // JVMFlag made its own copy, so I must delete my own temp. buffer. + // CommandLineFlags made its own copy, so I must delete my own temp. buffer. FREE_C_HEAP_ARRAY(char, free_this_too); } return true; @@ -1010,7 +1010,7 @@ return a; } -bool Arguments::parse_argument(const char* arg, JVMFlag::Flags origin) { +bool Arguments::parse_argument(const char* arg, Flag::Flags origin) { // range of acceptable characters spelled out for portability reasons #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]" @@ -1048,7 +1048,7 @@ char punct; if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') { const char* value = strchr(arg, '=') + 1; - JVMFlag* flag; + Flag* flag; // this scanf pattern matches both strings (handled here) and numbers (handled later)) AliasedLoggingFlag alf = catch_logging_aliases(name, true); @@ -1060,7 +1060,7 @@ if (real_name == NULL) { return false; } - flag = JVMFlag::find_flag(real_name); + flag = Flag::find_flag(real_name); if (flag != NULL && flag->is_ccstr()) { if (flag->ccstr_accumulates()) { return append_to_string_flag(real_name, value, origin); @@ -1221,7 +1221,7 @@ bool Arguments::process_argument(const char* arg, jboolean ignore_unrecognized, - JVMFlag::Flags origin) { + Flag::Flags origin) { JDK_Version since = JDK_Version(); if (parse_argument(arg, origin)) { @@ -1266,10 +1266,10 @@ // For locked flags, report a custom error message if available. // Otherwise, report the standard unrecognized VM option. - JVMFlag* found_flag = JVMFlag::find_flag((const char*)argname, arg_len, true, true); + Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true); if (found_flag != NULL) { char locked_message_buf[BUFLEN]; - JVMFlag::MsgType msg_type = found_flag->get_locked_message(locked_message_buf, BUFLEN); + Flag::MsgType msg_type = found_flag->get_locked_message(locked_message_buf, BUFLEN); if (strlen(locked_message_buf) == 0) { if (found_flag->is_bool() && !has_plus_minus) { jio_fprintf(defaultStream::error_stream(), @@ -1283,8 +1283,8 @@ } } else { #ifdef PRODUCT - bool mismatched = ((msg_type == JVMFlag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD) || - (msg_type == JVMFlag::DEVELOPER_FLAG_BUT_PRODUCT_BUILD)); + bool mismatched = ((msg_type == Flag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD) || + (msg_type == Flag::DEVELOPER_FLAG_BUT_PRODUCT_BUILD)); if (ignore_unrecognized && mismatched) { return true; } @@ -1297,7 +1297,7 @@ } jio_fprintf(defaultStream::error_stream(), "Unrecognized VM option '%s'\n", argname); - JVMFlag* fuzzy_matched = JVMFlag::fuzzy_match((const char*)argname, arg_len, true); + Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true); if (fuzzy_matched != NULL) { jio_fprintf(defaultStream::error_stream(), "Did you mean '%s%s%s'? ", @@ -1350,7 +1350,7 @@ // this allows a way to include spaces in string-valued options token[pos] = '\0'; logOption(token); - result &= process_argument(token, ignore_unrecognized, JVMFlag::CONFIG_FILE); + result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE); build_jvm_flags(token); pos = 0; in_white_space = true; @@ -1368,7 +1368,7 @@ } if (pos > 0) { token[pos] = '\0'; - result &= process_argument(token, ignore_unrecognized, JVMFlag::CONFIG_FILE); + result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE); build_jvm_flags(token); } fclose(stream); @@ -1991,10 +1991,10 @@ initHeapSize = limit_by_allocatable_memory(initHeapSize); if (FLAG_IS_DEFAULT(MaxHeapSize)) { - if (FLAG_SET_CMDLINE(size_t, MaxHeapSize, initHeapSize) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(size_t, MaxHeapSize, initHeapSize) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize) != JVMFlag::SUCCESS) { + 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. @@ -2003,10 +2003,10 @@ 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) != JVMFlag::SUCCESS) { + ((julong) MaxHeapSize / (julong) 8) * (julong) 3) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize) != Flag::SUCCESS) { return JNI_EINVAL; } } @@ -2016,20 +2016,20 @@ #endif // Increase some data structure sizes for efficiency - if (FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, ResizeTLAB, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, ResizeTLAB, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(size_t, TLABSize, 256 * K) != JVMFlag::SUCCESS) { + 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. - if (FLAG_SET_CMDLINE(size_t, YoungPLABSize, 256 * K) != JVMFlag::SUCCESS) { // Note: this is in words + if (FLAG_SET_CMDLINE(size_t, YoungPLABSize, 256 * K) != Flag::SUCCESS) { // Note: this is in words return JNI_EINVAL; } @@ -2046,29 +2046,29 @@ // 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. - if (FLAG_SET_CMDLINE(size_t, OldPLABSize, 8 * K) != JVMFlag::SUCCESS) { // 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 - if (FLAG_SET_CMDLINE(bool, UseParallelGC, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, UseParallelGC, true) != Flag::SUCCESS) { return JNI_EINVAL; } // Encourage steady state memory management - if (FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100) != Flag::SUCCESS) { return JNI_EINVAL; } // This appears to improve mutator locality - if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != JVMFlag::SUCCESS) { + 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). - if (FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true) != Flag::SUCCESS) { return JNI_EINVAL; } @@ -2409,20 +2409,20 @@ // Parse args structure generated from JAVA_TOOL_OPTIONS environment // variable (if present). - jint result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, JVMFlag::ENVIRON_VAR); + jint result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR); if (result != JNI_OK) { return result; } // Parse args structure generated from the command line flags. - result = parse_each_vm_init_arg(cmd_line_args, &patch_mod_javabase, JVMFlag::COMMAND_LINE); + result = parse_each_vm_init_arg(cmd_line_args, &patch_mod_javabase, Flag::COMMAND_LINE); if (result != JNI_OK) { return result; } // Parse args structure generated from the _JAVA_OPTIONS environment // variable (if present) (mimics classic VM) - result = parse_each_vm_init_arg(java_options_args, &patch_mod_javabase, JVMFlag::ENVIRON_VAR); + result = parse_each_vm_init_arg(java_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR); if (result != JNI_OK) { return result; } @@ -2566,7 +2566,7 @@ return JNI_OK; } -jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, JVMFlag::Flags origin) { +jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin) { // For match_option to return remaining or value part of option string const char* tail; @@ -2599,7 +2599,7 @@ } else if (!strcmp(tail, ":gc")) { LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc)); } else if (!strcmp(tail, ":jni")) { - if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != Flag::SUCCESS) { return JNI_EINVAL; } } @@ -2736,24 +2736,24 @@ set_enable_preview(); // -Xnoclassgc } else if (match_option(option, "-Xnoclassgc")) { - if (FLAG_SET_CMDLINE(bool, ClassUnloading, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, ClassUnloading, false) != Flag::SUCCESS) { return JNI_EINVAL; } // -Xconcgc } else if (match_option(option, "-Xconcgc")) { - if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true) != Flag::SUCCESS) { return JNI_EINVAL; } handle_extra_cms_flags("-Xconcgc uses UseConcMarkSweepGC"); // -Xnoconcgc } else if (match_option(option, "-Xnoconcgc")) { - if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false) != Flag::SUCCESS) { return JNI_EINVAL; } handle_extra_cms_flags("-Xnoconcgc uses UseConcMarkSweepGC"); // -Xbatch } else if (match_option(option, "-Xbatch")) { - if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) { return JNI_EINVAL; } // -Xmn for compatibility with other JVM vendors @@ -2766,10 +2766,10 @@ describe_range_error(errcode); return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(size_t, MaxNewSize, (size_t)long_initial_young_size) != JVMFlag::SUCCESS) { + 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) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(size_t, NewSize, (size_t)long_initial_young_size) != Flag::SUCCESS) { return JNI_EINVAL; } // -Xms @@ -2786,7 +2786,7 @@ 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. - if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, (size_t)long_initial_heap_size) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, (size_t)long_initial_heap_size) != Flag::SUCCESS) { return JNI_EINVAL; } // -Xmx @@ -2799,7 +2799,7 @@ describe_range_error(errcode); return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(size_t, MaxHeapSize, (size_t)long_max_heap_size) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(size_t, MaxHeapSize, (size_t)long_max_heap_size) != Flag::SUCCESS) { return JNI_EINVAL; } // Xmaxf @@ -2812,7 +2812,7 @@ option->optionString); return JNI_EINVAL; } else { - if (FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf) != Flag::SUCCESS) { return JNI_EINVAL; } } @@ -2826,7 +2826,7 @@ option->optionString); return JNI_EINVAL; } else { - if (FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf) != Flag::SUCCESS) { return JNI_EINVAL; } } @@ -2837,7 +2837,7 @@ if (err != JNI_OK) { return err; } - if (FLAG_SET_CMDLINE(intx, ThreadStackSize, value) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(intx, ThreadStackSize, value) != Flag::SUCCESS) { return JNI_EINVAL; } } else if (match_option(option, "-Xmaxjitcodesize", &tail) || @@ -2850,7 +2850,7 @@ "Invalid maximum code cache size: %s.\n", option->optionString); return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize) != Flag::SUCCESS) { return JNI_EINVAL; } // -green @@ -2864,7 +2864,7 @@ // -Xrs } else if (match_option(option, "-Xrs")) { // Classic/EVM option, new functionality - if (FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true) != Flag::SUCCESS) { return JNI_EINVAL; } // -Xprof @@ -2875,17 +2875,17 @@ warning("Ignoring option %s; support was removed in %s", option->optionString, version); // -Xconcurrentio } else if (match_option(option, "-Xconcurrentio")) { - if (FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) { return JNI_EINVAL; } SafepointSynchronize::set_defer_thr_suspend_loop_count(); - if (FLAG_SET_CMDLINE(bool, UseTLAB, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, UseTLAB, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(size_t, NewSizeThreadIncrease, 16 * K) != JVMFlag::SUCCESS) { // 20Kb per thread added to new generation + if (FLAG_SET_CMDLINE(size_t, NewSizeThreadIncrease, 16 * K) != Flag::SUCCESS) { // 20Kb per thread added to new generation return JNI_EINVAL; } @@ -2897,7 +2897,7 @@ #ifndef PRODUCT // -Xprintflags } else if (match_option(option, "-Xprintflags")) { - JVMFlag::printFlags(tty, false); + CommandLineFlags::printFlags(tty, false); vm_exit(0); #endif // -D @@ -2932,7 +2932,7 @@ // Out of the box management support if (match_option(option, "-Dcom.sun.management", &tail)) { #if INCLUDE_MANAGEMENT - if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != Flag::SUCCESS) { return JNI_EINVAL; } // management agent in module jdk.management.agent @@ -2957,55 +2957,55 @@ set_mode_flags(_comp); // -Xshare:dump } else if (match_option(option, "-Xshare:dump")) { - if (FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true) != JVMFlag::SUCCESS) { + 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")) { - if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) { return JNI_EINVAL; } // -Xshare:auto } else if (match_option(option, "-Xshare:auto")) { - if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != Flag::SUCCESS) { return JNI_EINVAL; } // -Xshare:off } else if (match_option(option, "-Xshare:off")) { - if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != JVMFlag::SUCCESS) { + 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) { - if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != Flag::SUCCESS) { return JNI_EINVAL; } } else if (strcmp(tail, ":remote") == 0) { - if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != Flag::SUCCESS) { return JNI_EINVAL; } } else if (strcmp(tail, ":none") == 0) { - if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false) != Flag::SUCCESS) { return JNI_EINVAL; } } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) { @@ -3064,23 +3064,23 @@ // Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure; // and the last option wins. } else if (match_option(option, "-XX:+NeverTenure")) { - if (FLAG_SET_CMDLINE(bool, NeverTenure, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, NeverTenure, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1) != Flag::SUCCESS) { return JNI_EINVAL; } } else if (match_option(option, "-XX:+AlwaysTenure")) { - if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != Flag::SUCCESS) { return JNI_EINVAL; } } else if (match_option(option, "-XX:MaxTenuringThreshold=", &tail)) { @@ -3091,51 +3091,51 @@ return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, max_tenuring_thresh) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, max_tenuring_thresh) != Flag::SUCCESS) { return JNI_EINVAL; } if (MaxTenuringThreshold == 0) { - if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) { return JNI_EINVAL; } } else { - if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) { return JNI_EINVAL; } } } else if (match_option(option, "-XX:+DisplayVMOutputToStderr")) { - if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true) != Flag::SUCCESS) { return JNI_EINVAL; } } else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) { - if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true) != Flag::SUCCESS) { return JNI_EINVAL; } } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) { #if defined(DTRACE_ENABLED) - if (FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true) != Flag::SUCCESS) { return JNI_EINVAL; } #else // defined(DTRACE_ENABLED) @@ -3145,11 +3145,11 @@ #endif // defined(DTRACE_ENABLED) #ifdef ASSERT } else if (match_option(option, "-XX:+FullGCALot")) { - if (FLAG_SET_CMDLINE(bool, FullGCALot, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, FullGCALot, true) != Flag::SUCCESS) { return JNI_EINVAL; } // disable scavenge before parallel mark-compact - if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != Flag::SUCCESS) { return JNI_EINVAL; } #endif @@ -3178,10 +3178,10 @@ // -Xshare:on // -Xlog:class+path=info if (PrintSharedArchiveAndExit) { - if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) { return JNI_EINVAL; } - if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != JVMFlag::SUCCESS) { + if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) { return JNI_EINVAL; } LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path)); @@ -3856,7 +3856,7 @@ continue; } if (match_option(option, "-XX:+PrintFlagsInitial")) { - JVMFlag::printFlags(tty, false); + CommandLineFlags::printFlags(tty, false); vm_exit(0); } if (match_option(option, "-XX:NativeMemoryTracking", &tail)) { @@ -3885,13 +3885,13 @@ #ifndef PRODUCT if (match_option(option, "-XX:+PrintFlagsWithComments")) { - JVMFlag::printFlags(tty, true); + CommandLineFlags::printFlags(tty, true); vm_exit(0); } #endif if (match_option(option, "-XX:+UseAppCDS")) { - JVMFlag* flag = JVMFlag::find_flag("SharedArchiveFile", 17, true, true); + Flag* flag = Flag::find_flag("SharedArchiveFile", 17, true, true); if (flag->is_diagnostic()) { flag->clear_diagnostic(); } @@ -3947,9 +3947,9 @@ assert(verify_special_jvm_flags(), "deprecated and obsolete flag table inconsistent"); // Initialize ranges, constraints and writeables - JVMFlagRangeList::init(); - JVMFlagConstraintList::init(); - JVMFlagWriteableList::init(); + CommandLineFlagRangeList::init(); + CommandLineFlagConstraintList::init(); + CommandLineFlagWriteableList::init(); // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. const char* hotspotrc = ".hotspotrc"; @@ -4250,7 +4250,7 @@ #endif // PRODUCT if (PrintCommandLineFlags) { - JVMFlag::printSetFlags(tty); + CommandLineFlags::printSetFlags(tty); } // Apply CPU specific policy for the BiasedLocking
--- a/src/hotspot/share/runtime/arguments.hpp Thu Dec 07 12:25:09 2017 -0800 +++ b/src/hotspot/share/runtime/arguments.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -28,7 +28,6 @@ #include "logging/logLevel.hpp" #include "logging/logTag.hpp" #include "memory/allocation.hpp" -#include "runtime/flags/jvmFlag.hpp" #include "runtime/java.hpp" #include "runtime/os.hpp" #include "runtime/perfData.hpp" @@ -414,8 +413,8 @@ // Argument parsing static void do_pd_flag_adjustments(); - static bool parse_argument(const char* arg, JVMFlag::Flags origin); - static bool process_argument(const char* arg, jboolean ignore_unrecognized, JVMFlag::Flags origin); + static bool parse_argument(const char* arg, Flag::Flags origin); + static bool process_argument(const char* arg, jboolean ignore_unrecognized, Flag::Flags origin); static void process_java_launcher_argument(const char*, void*); static void process_java_compiler_argument(const char* arg); static jint parse_options_environment_variable(const char* name, ScopedVMInitArgs* vm_args); @@ -443,7 +442,7 @@ static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, const JavaVMInitArgs *java_options_args, const JavaVMInitArgs *cmd_line_args); - static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, JVMFlag::Flags origin); + static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin); static jint finalize_vm_init_args(bool patch_mod_javabase); static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/commandLineFlagConstraintList.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,368 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "classfile/stringTable.hpp" +#include "classfile/symbolTable.hpp" +#include "gc/shared/commandLineFlagConstraintsGC.hpp" +#include "runtime/arguments.hpp" +#include "runtime/commandLineFlagConstraintList.hpp" +#include "runtime/commandLineFlagConstraintsCompiler.hpp" +#include "runtime/commandLineFlagConstraintsRuntime.hpp" +#include "runtime/os.hpp" +#include "utilities/macros.hpp" +#ifdef COMPILER1 +#include "c1/c1_globals.hpp" +#endif +#ifdef COMPILER2 +#include "opto/c2_globals.hpp" +#endif + + +class CommandLineFlagConstraint_bool : public CommandLineFlagConstraint { + CommandLineFlagConstraintFunc_bool _constraint; + const bool* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagConstraint_bool(const char* name, const bool* ptr, + CommandLineFlagConstraintFunc_bool func, + ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} + + Flag::Error apply(bool verbose) { + bool value = *_ptr; + return _constraint(value, verbose); + } + + Flag::Error apply_bool(bool value, bool verbose) { + return _constraint(value, verbose); + } +}; + +class CommandLineFlagConstraint_int : public CommandLineFlagConstraint { + CommandLineFlagConstraintFunc_int _constraint; + const int* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagConstraint_int(const char* name, const int* ptr, + CommandLineFlagConstraintFunc_int func, + ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} + + Flag::Error apply(bool verbose) { + int value = *_ptr; + return _constraint(value, verbose); + } + + Flag::Error apply_int(int value, bool verbose) { + return _constraint(value, verbose); + } +}; + +class CommandLineFlagConstraint_intx : public CommandLineFlagConstraint { + CommandLineFlagConstraintFunc_intx _constraint; + const intx* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagConstraint_intx(const char* name, const intx* ptr, + CommandLineFlagConstraintFunc_intx func, + ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} + + Flag::Error apply(bool verbose) { + intx value = *_ptr; + return _constraint(value, verbose); + } + + Flag::Error apply_intx(intx value, bool verbose) { + return _constraint(value, verbose); + } +}; + +class CommandLineFlagConstraint_uint : public CommandLineFlagConstraint { + CommandLineFlagConstraintFunc_uint _constraint; + const uint* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagConstraint_uint(const char* name, const uint* ptr, + CommandLineFlagConstraintFunc_uint func, + ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} + + Flag::Error apply(bool verbose) { + uint value = *_ptr; + return _constraint(value, verbose); + } + + Flag::Error apply_uint(uint value, bool verbose) { + return _constraint(value, verbose); + } +}; + +class CommandLineFlagConstraint_uintx : public CommandLineFlagConstraint { + CommandLineFlagConstraintFunc_uintx _constraint; + const uintx* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagConstraint_uintx(const char* name, const uintx* ptr, + CommandLineFlagConstraintFunc_uintx func, + ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} + + Flag::Error apply(bool verbose) { + uintx value = *_ptr; + return _constraint(value, verbose); + } + + Flag::Error apply_uintx(uintx value, bool verbose) { + return _constraint(value, verbose); + } +}; + +class CommandLineFlagConstraint_uint64_t : public CommandLineFlagConstraint { + CommandLineFlagConstraintFunc_uint64_t _constraint; + const uint64_t* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagConstraint_uint64_t(const char* name, const uint64_t* ptr, + CommandLineFlagConstraintFunc_uint64_t func, + ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} + + Flag::Error apply(bool verbose) { + uint64_t value = *_ptr; + return _constraint(value, verbose); + } + + Flag::Error apply_uint64_t(uint64_t value, bool verbose) { + return _constraint(value, verbose); + } +}; + +class CommandLineFlagConstraint_size_t : public CommandLineFlagConstraint { + CommandLineFlagConstraintFunc_size_t _constraint; + const size_t* _ptr; +public: + // the "name" argument must be a string literal + CommandLineFlagConstraint_size_t(const char* name, const size_t* ptr, + CommandLineFlagConstraintFunc_size_t func, + ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} + + Flag::Error apply(bool verbose) { + size_t value = *_ptr; + return _constraint(value, verbose); + } + + Flag::Error apply_size_t(size_t value, bool verbose) { + return _constraint(value, verbose); + } +}; + +class CommandLineFlagConstraint_double : public CommandLineFlagConstraint { + CommandLineFlagConstraintFunc_double _constraint; + const double* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagConstraint_double(const char* name, const double* ptr, + CommandLineFlagConstraintFunc_double func, + ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} + + Flag::Error apply(bool verbose) { + double value = *_ptr; + return _constraint(value, verbose); + } + + Flag::Error apply_double(double value, bool verbose) { + return _constraint(value, verbose); + } +}; + +// No constraint emitting +void emit_constraint_no(...) { /* NOP */ } + +// No constraint emitting if function argument is NOT provided +void emit_constraint_bool(const char* /*name*/, const bool* /*value*/) { /* NOP */ } +void emit_constraint_ccstr(const char* /*name*/, const ccstr* /*value*/) { /* NOP */ } +void emit_constraint_ccstrlist(const char* /*name*/, const ccstrlist* /*value*/) { /* NOP */ } +void emit_constraint_int(const char* /*name*/, const int* /*value*/) { /* NOP */ } +void emit_constraint_intx(const char* /*name*/, const intx* /*value*/) { /* NOP */ } +void emit_constraint_uint(const char* /*name*/, const uint* /*value*/) { /* NOP */ } +void emit_constraint_uintx(const char* /*name*/, const uintx* /*value*/) { /* NOP */ } +void emit_constraint_uint64_t(const char* /*name*/, const uint64_t* /*value*/) { /* NOP */ } +void emit_constraint_size_t(const char* /*name*/, const size_t* /*value*/) { /* NOP */ } +void emit_constraint_double(const char* /*name*/, const double* /*value*/) { /* NOP */ } + +// CommandLineFlagConstraint emitting code functions if function argument is provided +void emit_constraint_bool(const char* name, const bool* ptr, CommandLineFlagConstraintFunc_bool func, CommandLineFlagConstraint::ConstraintType type) { + CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_bool(name, ptr, func, type)); +} +void emit_constraint_int(const char* name, const int* ptr, CommandLineFlagConstraintFunc_int func, CommandLineFlagConstraint::ConstraintType type) { + CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_int(name, ptr, func, type)); +} +void emit_constraint_intx(const char* name, const intx* ptr, CommandLineFlagConstraintFunc_intx func, CommandLineFlagConstraint::ConstraintType type) { + CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_intx(name, ptr, func, type)); +} +void emit_constraint_uint(const char* name, const uint* ptr, CommandLineFlagConstraintFunc_uint func, CommandLineFlagConstraint::ConstraintType type) { + CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uint(name, ptr, func, type)); +} +void emit_constraint_uintx(const char* name, const uintx* ptr, CommandLineFlagConstraintFunc_uintx func, CommandLineFlagConstraint::ConstraintType type) { + CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uintx(name, ptr, func, type)); +} +void emit_constraint_uint64_t(const char* name, const uint64_t* ptr, CommandLineFlagConstraintFunc_uint64_t func, CommandLineFlagConstraint::ConstraintType type) { + CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uint64_t(name, ptr, func, type)); +} +void emit_constraint_size_t(const char* name, const size_t* ptr, CommandLineFlagConstraintFunc_size_t func, CommandLineFlagConstraint::ConstraintType type) { + CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_size_t(name, ptr, func, type)); +} +void emit_constraint_double(const char* name, const double* ptr, CommandLineFlagConstraintFunc_double func, CommandLineFlagConstraint::ConstraintType type) { + CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_double(name, ptr, func, type)); +} + +// Generate code to call emit_constraint_xxx function +#define EMIT_CONSTRAINT_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name +#define EMIT_CONSTRAINT_COMMERCIAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name +#define EMIT_CONSTRAINT_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name +#define EMIT_CONSTRAINT_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name +#define EMIT_CONSTRAINT_MANAGEABLE_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name +#define EMIT_CONSTRAINT_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name +#define EMIT_CONSTRAINT_PD_PRODUCT_FLAG(type, name, doc) ); emit_constraint_##type(#name,&name +#define EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_constraint_##type(#name,&name +#ifndef PRODUCT +#define EMIT_CONSTRAINT_DEVELOPER_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name +#define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_##type(#name,&name +#define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name +#else +#define EMIT_CONSTRAINT_DEVELOPER_FLAG(type, name, value, doc) ); emit_constraint_no(#name,&name +#define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_no(#name,&name +#define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_no(#name,&name +#endif +#ifdef _LP64 +#define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name +#else +#define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_no(#name,&name +#endif + +// Generate func argument to pass into emit_constraint_xxx functions +#define EMIT_CONSTRAINT_CHECK(func, type) , func, CommandLineFlagConstraint::type + +// the "name" argument must be a string literal +#define INITIAL_CONSTRAINTS_SIZE 72 +GrowableArray<CommandLineFlagConstraint*>* CommandLineFlagConstraintList::_constraints = NULL; +CommandLineFlagConstraint::ConstraintType CommandLineFlagConstraintList::_validating_type = CommandLineFlagConstraint::AtParse; + +// Check the ranges of all flags that have them or print them out and exit if requested +void CommandLineFlagConstraintList::init(void) { + _constraints = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<CommandLineFlagConstraint*>(INITIAL_CONSTRAINTS_SIZE, true); + + emit_constraint_no(NULL VM_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG, + EMIT_CONSTRAINT_PD_DEVELOPER_FLAG, + EMIT_CONSTRAINT_PRODUCT_FLAG, + EMIT_CONSTRAINT_PD_PRODUCT_FLAG, + EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, + EMIT_CONSTRAINT_NOTPRODUCT_FLAG, + EMIT_CONSTRAINT_MANAGEABLE_FLAG, + EMIT_CONSTRAINT_PRODUCT_RW_FLAG, + EMIT_CONSTRAINT_LP64_PRODUCT_FLAG, + IGNORE_RANGE, + EMIT_CONSTRAINT_CHECK, + IGNORE_WRITEABLE)); + + EMIT_CONSTRAINTS_FOR_GLOBALS_EXT + + emit_constraint_no(NULL ARCH_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG, + EMIT_CONSTRAINT_PRODUCT_FLAG, + EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, + EMIT_CONSTRAINT_NOTPRODUCT_FLAG, + IGNORE_RANGE, + EMIT_CONSTRAINT_CHECK, + IGNORE_WRITEABLE)); + + +#ifdef COMPILER1 + emit_constraint_no(NULL C1_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG, + EMIT_CONSTRAINT_PD_DEVELOPER_FLAG, + EMIT_CONSTRAINT_PRODUCT_FLAG, + EMIT_CONSTRAINT_PD_PRODUCT_FLAG, + EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_NOTPRODUCT_FLAG, + IGNORE_RANGE, + EMIT_CONSTRAINT_CHECK, + IGNORE_WRITEABLE)); +#endif // COMPILER1 + +#ifdef COMPILER2 + emit_constraint_no(NULL C2_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG, + EMIT_CONSTRAINT_PD_DEVELOPER_FLAG, + EMIT_CONSTRAINT_PRODUCT_FLAG, + EMIT_CONSTRAINT_PD_PRODUCT_FLAG, + EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, + EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, + EMIT_CONSTRAINT_NOTPRODUCT_FLAG, + IGNORE_RANGE, + EMIT_CONSTRAINT_CHECK, + IGNORE_WRITEABLE)); +#endif // COMPILER2 +} + +CommandLineFlagConstraint* CommandLineFlagConstraintList::find(const char* name) { + CommandLineFlagConstraint* found = NULL; + for (int i=0; i<length(); i++) { + CommandLineFlagConstraint* constraint = at(i); + if (strcmp(constraint->name(), name) == 0) { + found = constraint; + break; + } + } + return found; +} + +// Find constraints by name and return only if found constraint's type is equal or lower than current validating type. +CommandLineFlagConstraint* CommandLineFlagConstraintList::find_if_needs_check(const char* name) { + CommandLineFlagConstraint* found = NULL; + CommandLineFlagConstraint* constraint = find(name); + if (constraint && (constraint->type() <= _validating_type)) { + found = constraint; + } + return found; +} + +// Check constraints for specific constraint type. +bool CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::ConstraintType type) { + guarantee(type > _validating_type, "Constraint check is out of order."); + _validating_type = type; + + bool status = true; + for (int i=0; i<length(); i++) { + CommandLineFlagConstraint* constraint = at(i); + if (type != constraint->type()) continue; + if (constraint->apply(true) != Flag::SUCCESS) status = false; + } + return status; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/commandLineFlagConstraintList.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTLIST_HPP +#define SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTLIST_HPP + +#include "runtime/globals.hpp" +#include "utilities/growableArray.hpp" + +/* + * Here we have a mechanism for extracting constraints (as custom functions) for flags, + * which otherwise can not be expressed via simple range check, specified in flag macro tables. + * + * An example of a constraint is "flag1 < flag2" where both flag1 and flag2 can change. + * + * See runtime "runtime/commandLineFlagConstraintsCompiler.hpp", + * "runtime/commandLineFlagConstraintsGC.hpp" and + * "runtime/commandLineFlagConstraintsRuntime.hpp" for the functions themselves. + */ + +typedef Flag::Error (*CommandLineFlagConstraintFunc_bool)(bool value, bool verbose); +typedef Flag::Error (*CommandLineFlagConstraintFunc_int)(int value, bool verbose); +typedef Flag::Error (*CommandLineFlagConstraintFunc_intx)(intx value, bool verbose); +typedef Flag::Error (*CommandLineFlagConstraintFunc_uint)(uint value, bool verbose); +typedef Flag::Error (*CommandLineFlagConstraintFunc_uintx)(uintx value, bool verbose); +typedef Flag::Error (*CommandLineFlagConstraintFunc_uint64_t)(uint64_t value, bool verbose); +typedef Flag::Error (*CommandLineFlagConstraintFunc_size_t)(size_t value, bool verbose); +typedef Flag::Error (*CommandLineFlagConstraintFunc_double)(double value, bool verbose); + +class CommandLineFlagConstraint : public CHeapObj<mtArguments> { +public: + // During VM initialization, constraint validation will be done order of ConstraintType. + enum ConstraintType { + // Will be validated during argument processing (Arguments::parse_argument). + AtParse = 0, + // Will be validated inside Threads::create_vm(), right after Arguments::apply_ergo(). + AfterErgo = 1, + // Will be validated inside universe_init(), right after Metaspace::global_initialize(). + AfterMemoryInit = 2 + }; + +private: + const char* _name; + ConstraintType _validate_type; + +public: + // the "name" argument must be a string literal + CommandLineFlagConstraint(const char* name, ConstraintType type) { _name=name; _validate_type=type; }; + ~CommandLineFlagConstraint() {}; + const char* name() const { return _name; } + ConstraintType type() const { return _validate_type; } + virtual Flag::Error apply(bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; + virtual Flag::Error apply_bool(bool value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; + virtual Flag::Error apply_int(int value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; + virtual Flag::Error apply_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; + virtual Flag::Error apply_uint(uint value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; + virtual Flag::Error apply_uintx(uintx value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; + virtual Flag::Error apply_uint64_t(uint64_t value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; + virtual Flag::Error apply_size_t(size_t value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; + virtual Flag::Error apply_double(double value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; +}; + +class CommandLineFlagConstraintList : public AllStatic { +private: + static GrowableArray<CommandLineFlagConstraint*>* _constraints; + // Latest constraint validation type. + static CommandLineFlagConstraint::ConstraintType _validating_type; +public: + static void init(); + static int length() { return (_constraints != NULL) ? _constraints->length() : 0; } + static CommandLineFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; } + static CommandLineFlagConstraint* find(const char* name); + static CommandLineFlagConstraint* find_if_needs_check(const char* name); + static void add(CommandLineFlagConstraint* constraint) { _constraints->append(constraint); } + // True if 'AfterErgo' or later constraint functions are validated. + static bool validated_after_ergo() { return _validating_type >= CommandLineFlagConstraint::AfterErgo; }; + static bool check_constraints(CommandLineFlagConstraint::ConstraintType type); +}; + +#endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTLIST_HPP */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/commandLineFlagConstraintsCompiler.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,407 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "code/relocInfo.hpp" +#include "compiler/compilerDefinitions.hpp" +#include "oops/metadata.hpp" +#include "runtime/os.hpp" +#include "interpreter/invocationCounter.hpp" +#include "runtime/arguments.hpp" +#include "runtime/commandLineFlagConstraintsCompiler.hpp" +#include "runtime/commandLineFlagRangeList.hpp" +#include "runtime/globals.hpp" +#include "runtime/globals_extension.hpp" +#include "utilities/defaultStream.hpp" + +Flag::Error AliasLevelConstraintFunc(intx value, bool verbose) { + if ((value <= 1) && (Arguments::mode() == Arguments::_comp || Arguments::mode() == Arguments::_mixed)) { + CommandLineError::print(verbose, + "AliasLevel (" INTX_FORMAT ") is not " + "compatible with -Xcomp or -Xmixed\n", + value); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +/** + * Validate the minimum number of compiler threads needed to run the + * JVM. The following configurations are possible. + * + * 1) The JVM is build using an interpreter only. As a result, the minimum number of + * compiler threads is 0. + * 2) The JVM is build using the compiler(s) and tiered compilation is disabled. As + * a result, either C1 or C2 is used, so the minimum number of compiler threads is 1. + * 3) The JVM is build using the compiler(s) and tiered compilation is enabled. However, + * the option "TieredStopAtLevel < CompLevel_full_optimization". As a result, only + * C1 can be used, so the minimum number of compiler threads is 1. + * 4) The JVM is build using the compilers and tiered compilation is enabled. The option + * 'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result, + * the minimum number of compiler threads is 2. + */ +Flag::Error CICompilerCountConstraintFunc(intx value, bool verbose) { + int min_number_of_compiler_threads = 0; +#if !defined(COMPILER1) && !defined(COMPILER2) && !INCLUDE_JVMCI + // case 1 +#else + if (!TieredCompilation || (TieredStopAtLevel < CompLevel_full_optimization)) { + min_number_of_compiler_threads = 1; // case 2 or case 3 + } else { + min_number_of_compiler_threads = 2; // case 4 (tiered) + } +#endif + + // The default CICompilerCount's value is CI_COMPILER_COUNT. + // With a client VM, -XX:+TieredCompilation causes TieredCompilation + // to be true here (the option is validated later) and + // min_number_of_compiler_threads to exceed CI_COMPILER_COUNT. + min_number_of_compiler_threads = MIN2(min_number_of_compiler_threads, CI_COMPILER_COUNT); + + if (value < (intx)min_number_of_compiler_threads) { + CommandLineError::print(verbose, + "CICompilerCount (" INTX_FORMAT ") must be " + "at least %d \n", + value, min_number_of_compiler_threads); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) { + if (value < 0 || value > 512) { + CommandLineError::print(verbose, + "AllocatePrefetchDistance (" INTX_FORMAT ") must be " + "between 0 and " INTX_FORMAT "\n", + AllocatePrefetchDistance, 512); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +} + +Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) { + if (AllocatePrefetchStyle == 3) { + if (value % wordSize != 0) { + CommandLineError::print(verbose, + "AllocatePrefetchStepSize (" INTX_FORMAT ") must be multiple of %d\n", + value, wordSize); + return Flag::VIOLATES_CONSTRAINT; + } + } + return Flag::SUCCESS; +} + +Flag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { + intx max_value = max_intx; +#if defined(SPARC) + max_value = 1; +#elif defined(X86) + max_value = 3; +#endif + if (value < 0 || value > max_value) { + CommandLineError::print(verbose, + "AllocatePrefetchInstr (" INTX_FORMAT ") must be " + "between 0 and " INTX_FORMAT "\n", value, max_value); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +} + +Flag::Error CompileThresholdConstraintFunc(intx value, bool verbose) { + if (value < 0 || value > INT_MAX >> InvocationCounter::count_shift) { + CommandLineError::print(verbose, + "CompileThreshold (" INTX_FORMAT ") " + "must be between 0 and %d\n", + value, + INT_MAX >> InvocationCounter::count_shift); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +} + +Flag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) { + int backward_branch_limit; + if (ProfileInterpreter) { + if (OnStackReplacePercentage < InterpreterProfilePercentage) { + CommandLineError::print(verbose, + "OnStackReplacePercentage (" INTX_FORMAT ") must be " + "larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n", + OnStackReplacePercentage, InterpreterProfilePercentage); + return Flag::VIOLATES_CONSTRAINT; + } + + backward_branch_limit = ((CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100) + << InvocationCounter::count_shift; + + if (backward_branch_limit < 0) { + CommandLineError::print(verbose, + "CompileThreshold * (InterpreterProfilePercentage - OnStackReplacePercentage) / 100 = " + INTX_FORMAT " " + "must be between 0 and " INTX_FORMAT ", try changing " + "CompileThreshold, InterpreterProfilePercentage, and/or OnStackReplacePercentage\n", + (CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100, + INT_MAX >> InvocationCounter::count_shift); + return Flag::VIOLATES_CONSTRAINT; + } + } else { + if (OnStackReplacePercentage < 0 ) { + CommandLineError::print(verbose, + "OnStackReplacePercentage (" INTX_FORMAT ") must be " + "non-negative\n", OnStackReplacePercentage); + return Flag::VIOLATES_CONSTRAINT; + } + + backward_branch_limit = ((CompileThreshold * OnStackReplacePercentage) / 100) + << InvocationCounter::count_shift; + + if (backward_branch_limit < 0) { + CommandLineError::print(verbose, + "CompileThreshold * OnStackReplacePercentage / 100 = " INTX_FORMAT " " + "must be between 0 and " INTX_FORMAT ", try changing " + "CompileThreshold and/or OnStackReplacePercentage\n", + (CompileThreshold * OnStackReplacePercentage) / 100, + INT_MAX >> InvocationCounter::count_shift); + return Flag::VIOLATES_CONSTRAINT; + } + } + return Flag::SUCCESS; +} + +Flag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose) { + if (CodeCacheSegmentSize < (uintx)CodeEntryAlignment) { + CommandLineError::print(verbose, + "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " + "larger than or equal to CodeEntryAlignment (" INTX_FORMAT ") " + "to align entry points\n", + CodeCacheSegmentSize, CodeEntryAlignment); + return Flag::VIOLATES_CONSTRAINT; + } + + if (CodeCacheSegmentSize < sizeof(jdouble)) { + CommandLineError::print(verbose, + "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " + "at least " SIZE_FORMAT " to align constants\n", + CodeCacheSegmentSize, sizeof(jdouble)); + return Flag::VIOLATES_CONSTRAINT; + } + +#ifdef COMPILER2 + if (CodeCacheSegmentSize < (uintx)OptoLoopAlignment) { + CommandLineError::print(verbose, + "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " + "larger than or equal to OptoLoopAlignment (" INTX_FORMAT ") " + "to align inner loops\n", + CodeCacheSegmentSize, OptoLoopAlignment); + return Flag::VIOLATES_CONSTRAINT; + } +#endif + + return Flag::SUCCESS; +} + +Flag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose) { +#ifdef SOLARIS + if ((value < MinimumPriority || value > MaximumPriority) && + (value != -1) && (value != -FXCriticalPriority)) { + CommandLineError::print(verbose, + "CompileThreadPriority (" INTX_FORMAT ") must be " + "between %d and %d inclusively or -1 (means no change) " + "or %d (special value for critical thread class/priority)\n", + value, MinimumPriority, MaximumPriority, -FXCriticalPriority); + return Flag::VIOLATES_CONSTRAINT; + } +#endif + + return Flag::SUCCESS; +} + +Flag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) { +#ifdef SPARC + if (CodeEntryAlignment % relocInfo::addr_unit() != 0) { + CommandLineError::print(verbose, + "CodeEntryAlignment (" INTX_FORMAT ") must be " + "multiple of NOP size\n", CodeEntryAlignment); + return Flag::VIOLATES_CONSTRAINT; + } +#endif + + if (!is_power_of_2(value)) { + CommandLineError::print(verbose, + "CodeEntryAlignment (" INTX_FORMAT ") must be " + "a power of two\n", CodeEntryAlignment); + return Flag::VIOLATES_CONSTRAINT; + } + + if (CodeEntryAlignment < 16) { + CommandLineError::print(verbose, + "CodeEntryAlignment (" INTX_FORMAT ") must be " + "greater than or equal to %d\n", + CodeEntryAlignment, 16); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +} + +Flag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose) { + if (!is_power_of_2(value)) { + CommandLineError::print(verbose, + "OptoLoopAlignment (" INTX_FORMAT ") " + "must be a power of two\n", + value); + return Flag::VIOLATES_CONSTRAINT; + } + + // Relevant on ppc, s390, sparc. Will be optimized where + // addr_unit() == 1. + if (OptoLoopAlignment % relocInfo::addr_unit() != 0) { + CommandLineError::print(verbose, + "OptoLoopAlignment (" INTX_FORMAT ") must be " + "multiple of NOP size (%d)\n", + value, relocInfo::addr_unit()); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +} + +Flag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verbose) { + if (value >= 4032) { + CommandLineError::print(verbose, + "ArraycopyDstPrefetchDistance (" UINTX_FORMAT ") must be" + "between 0 and 4031\n", value); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +} + +Flag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose) { + if (value >= 4032) { + CommandLineError::print(verbose, + "ArraycopySrcPrefetchDistance (" UINTX_FORMAT ") must be" + "between 0 and 4031\n", value); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +} + +Flag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose) { + for (int i = 0; i < 3; i++) { + if (value % 10 > 2) { + CommandLineError::print(verbose, + "Invalid value (" UINTX_FORMAT ") " + "in TypeProfileLevel at position %d\n", value, i); + return Flag::VIOLATES_CONSTRAINT; + } + value = value / 10; + } + + return Flag::SUCCESS; +} + +Flag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose) { + if (value % BytesPerLong != 0) { + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +#ifdef COMPILER2 +Flag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) { + if (InteriorEntryAlignment > CodeEntryAlignment) { + CommandLineError::print(verbose, + "InteriorEntryAlignment (" INTX_FORMAT ") must be " + "less than or equal to CodeEntryAlignment (" INTX_FORMAT ")\n", + InteriorEntryAlignment, CodeEntryAlignment); + return Flag::VIOLATES_CONSTRAINT; + } + +#ifdef SPARC + if (InteriorEntryAlignment % relocInfo::addr_unit() != 0) { + CommandLineError::print(verbose, + "InteriorEntryAlignment (" INTX_FORMAT ") must be " + "multiple of NOP size\n"); + return Flag::VIOLATES_CONSTRAINT; + } +#endif + + if (!is_power_of_2(value)) { + CommandLineError::print(verbose, + "InteriorEntryAlignment (" INTX_FORMAT ") must be " + "a power of two\n", InteriorEntryAlignment); + return Flag::VIOLATES_CONSTRAINT; + } + + int minimum_alignment = 16; +#if defined(SPARC) || (defined(X86) && !defined(AMD64)) + minimum_alignment = 4; +#elif defined(S390) + minimum_alignment = 2; +#endif + + if (InteriorEntryAlignment < minimum_alignment) { + CommandLineError::print(verbose, + "InteriorEntryAlignment (" INTX_FORMAT ") must be " + "greater than or equal to %d\n", + InteriorEntryAlignment, minimum_alignment); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +} + +Flag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose) { + if (value < MaxNodeLimit * 2 / 100 || value > MaxNodeLimit * 40 / 100) { + CommandLineError::print(verbose, + "NodeLimitFudgeFactor must be between 2%% and 40%% " + "of MaxNodeLimit (" INTX_FORMAT ")\n", + MaxNodeLimit); + return Flag::VIOLATES_CONSTRAINT; + } + + return Flag::SUCCESS; +} +#endif // COMPILER2 + +Flag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) { +#if INCLUDE_RTM_OPT + if (UseRTMLocking && !is_power_of_2(RTMTotalCountIncrRate)) { + CommandLineError::print(verbose, + "RTMTotalCountIncrRate (" INTX_FORMAT + ") must be a power of 2, resetting it to 64\n", + RTMTotalCountIncrRate); + FLAG_SET_DEFAULT(RTMTotalCountIncrRate, 64); + } +#endif + + return Flag::SUCCESS; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/commandLineFlagConstraintsCompiler.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSCOMPILER_HPP +#define SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSCOMPILER_HPP + +#include "runtime/globals.hpp" +#include "utilities/globalDefinitions.hpp" + +/* + * Here we have compiler arguments constraints functions, which are called automatically + * whenever flag's value changes. If the constraint fails the function should return + * an appropriate error value. + */ + +Flag::Error AliasLevelConstraintFunc(intx value, bool verbose); + +Flag::Error CICompilerCountConstraintFunc(intx value, bool verbose); + +Flag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose); + +Flag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose); + +Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose); + +Flag::Error CompileThresholdConstraintFunc(intx value, bool verbose); + +Flag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose); + +Flag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose); + +Flag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose); + +Flag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose); + +Flag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose); + +Flag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verbose); + +Flag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose); + +Flag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose); + +Flag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose); + +#ifdef COMPILER2 +Flag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose); + +Flag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose); +#endif + +Flag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose); + +#endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSCOMPILER_HPP */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/commandLineFlagConstraintsRuntime.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "runtime/arguments.hpp" +#include "runtime/commandLineFlagConstraintsRuntime.hpp" +#include "runtime/commandLineFlagRangeList.hpp" +#include "runtime/globals.hpp" +#include "runtime/safepointMechanism.hpp" +#include "runtime/task.hpp" +#include "utilities/defaultStream.hpp" + +Flag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) { + if (!is_power_of_2(value)) { + CommandLineError::print(verbose, + "ObjectAlignmentInBytes (" INTX_FORMAT ") must be " + "power of 2\n", + value); + return Flag::VIOLATES_CONSTRAINT; + } + // In case page size is very small. + if (value >= (intx)os::vm_page_size()) { + CommandLineError::print(verbose, + "ObjectAlignmentInBytes (" INTX_FORMAT ") must be " + "less than page size (" INTX_FORMAT ")\n", + value, (intx)os::vm_page_size()); + return Flag::VIOLATES_CONSTRAINT; + } + return Flag::SUCCESS; +} + +// Need to enforce the padding not to break the existing field alignments. +// It is sufficient to check against the largest type size. +Flag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose) { + if ((value % BytesPerLong) != 0) { + CommandLineError::print(verbose, + "ContendedPaddingWidth (" INTX_FORMAT ") must be " + "a multiple of %d\n", + value, BytesPerLong); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose) { + if (value > BiasedLockingBulkRevokeThreshold) { + CommandLineError::print(verbose, + "BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ") must be " + "less than or equal to BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")\n", + value, BiasedLockingBulkRevokeThreshold); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose) { + if ((value % PeriodicTask::interval_gran) != 0) { + CommandLineError::print(verbose, + "BiasedLockingStartupDelay (" INTX_FORMAT ") must be " + "evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n", + value, PeriodicTask::interval_gran); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose) { + if (value < BiasedLockingBulkRebiasThreshold) { + CommandLineError::print(verbose, + "BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ") must be " + "greater than or equal to BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")\n", + value, BiasedLockingBulkRebiasThreshold); + return Flag::VIOLATES_CONSTRAINT; + } else if ((double)value/(double)BiasedLockingDecayTime > 0.1) { + CommandLineError::print(verbose, + "The ratio of BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")" + " to BiasedLockingDecayTime (" INTX_FORMAT ") must be " + "less than or equal to 0.1\n", + value, BiasedLockingBulkRebiasThreshold); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose) { + if (BiasedLockingBulkRebiasThreshold/(double)value > 0.1) { + CommandLineError::print(verbose, + "The ratio of BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")" + " to BiasedLockingDecayTime (" INTX_FORMAT ") must be " + "less than or equal to 0.1\n", + BiasedLockingBulkRebiasThreshold, value); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) { + if ((value % PeriodicTask::interval_gran != 0)) { + CommandLineError::print(verbose, + "PerfDataSamplingInterval (" INTX_FORMAT ") must be " + "evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n", + value, PeriodicTask::interval_gran); + return Flag::VIOLATES_CONSTRAINT; + } else { + return Flag::SUCCESS; + } +} + +Flag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose) { + if (value) { + if (!SafepointMechanism::supports_thread_local_poll()) { + CommandLineError::print(verbose, "ThreadLocalHandshakes not yet supported on this platform\n"); + return Flag::VIOLATES_CONSTRAINT; + } + } + return Flag::SUCCESS; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/commandLineFlagConstraintsRuntime.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSRUNTIME_HPP +#define SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSRUNTIME_HPP + +#include "runtime/globals.hpp" +#include "utilities/globalDefinitions.hpp" + +/* + * Here we have runtime arguments constraints functions, which are called automatically + * whenever flag's value changes. If the constraint fails the function should return + * an appropriate error value. + */ + +Flag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose); + +Flag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose); + +Flag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose); +Flag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose); +Flag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose); +Flag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose); + +Flag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose); + +Flag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose); + + +#endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSRUNTIME_HPP */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/commandLineFlagRangeList.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,441 @@ +/* + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "jvm.h" +#include "classfile/stringTable.hpp" +#include "classfile/symbolTable.hpp" +#include "gc/shared/referenceProcessor.hpp" +#include "oops/markOop.hpp" +#include "runtime/arguments.hpp" +#include "runtime/commandLineFlagConstraintList.hpp" +#include "runtime/commandLineFlagRangeList.hpp" +#include "runtime/globals_extension.hpp" +#include "runtime/os.hpp" +#include "runtime/task.hpp" +#include "utilities/defaultStream.hpp" +#include "utilities/macros.hpp" + +void CommandLineError::print(bool verbose, const char* msg, ...) { + if (verbose) { + va_list listPointer; + va_start(listPointer, msg); + jio_vfprintf(defaultStream::error_stream(), msg, listPointer); + va_end(listPointer); + } +} + +class CommandLineFlagRange_int : public CommandLineFlagRange { + int _min; + int _max; + const int* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagRange_int(const char* name, const int* ptr, int min, int max) + : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} + + Flag::Error check(bool verbose = true) { + return check_int(*_ptr, verbose); + } + + Flag::Error check_int(int value, bool verbose = true) { + if ((value < _min) || (value > _max)) { + CommandLineError::print(verbose, + "int %s=%d is outside the allowed range " + "[ %d ... %d ]\n", + name(), value, _min, _max); + return Flag::OUT_OF_BOUNDS; + } else { + return Flag::SUCCESS; + } + } + + void print(outputStream* st) { + st->print("[ %-25d ... %25d ]", _min, _max); + } +}; + +class CommandLineFlagRange_intx : public CommandLineFlagRange { + intx _min; + intx _max; + const intx* _ptr; +public: + // the "name" argument must be a string literal + CommandLineFlagRange_intx(const char* name, const intx* ptr, intx min, intx max) + : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} + + Flag::Error check(bool verbose = true) { + return check_intx(*_ptr, verbose); + } + + Flag::Error check_intx(intx value, bool verbose = true) { + if ((value < _min) || (value > _max)) { + CommandLineError::print(verbose, + "intx %s=" INTX_FORMAT " is outside the allowed range " + "[ " INTX_FORMAT " ... " INTX_FORMAT " ]\n", + name(), value, _min, _max); + return Flag::OUT_OF_BOUNDS; + } else { + return Flag::SUCCESS; + } + } + + void print(outputStream* st) { + st->print("[ " INTX_FORMAT_W(-25) " ... " INTX_FORMAT_W(25) " ]", _min, _max); + } +}; + +class CommandLineFlagRange_uint : public CommandLineFlagRange { + uint _min; + uint _max; + const uint* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagRange_uint(const char* name, const uint* ptr, uint min, uint max) + : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} + + Flag::Error check(bool verbose = true) { + return check_uint(*_ptr, verbose); + } + + Flag::Error check_uint(uint value, bool verbose = true) { + if ((value < _min) || (value > _max)) { + CommandLineError::print(verbose, + "uint %s=%u is outside the allowed range " + "[ %u ... %u ]\n", + name(), value, _min, _max); + return Flag::OUT_OF_BOUNDS; + } else { + return Flag::SUCCESS; + } + } + + void print(outputStream* st) { + st->print("[ %-25u ... %25u ]", _min, _max); + } +}; + +class CommandLineFlagRange_uintx : public CommandLineFlagRange { + uintx _min; + uintx _max; + const uintx* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagRange_uintx(const char* name, const uintx* ptr, uintx min, uintx max) + : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} + + Flag::Error check(bool verbose = true) { + return check_uintx(*_ptr, verbose); + } + + Flag::Error check_uintx(uintx value, bool verbose = true) { + if ((value < _min) || (value > _max)) { + CommandLineError::print(verbose, + "uintx %s=" UINTX_FORMAT " is outside the allowed range " + "[ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n", + name(), value, _min, _max); + return Flag::OUT_OF_BOUNDS; + } else { + return Flag::SUCCESS; + } + } + + void print(outputStream* st) { + st->print("[ " UINTX_FORMAT_W(-25) " ... " UINTX_FORMAT_W(25) " ]", _min, _max); + } +}; + +class CommandLineFlagRange_uint64_t : public CommandLineFlagRange { + uint64_t _min; + uint64_t _max; + const uint64_t* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagRange_uint64_t(const char* name, const uint64_t* ptr, uint64_t min, uint64_t max) + : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} + + Flag::Error check(bool verbose = true) { + return check_uint64_t(*_ptr, verbose); + } + + Flag::Error check_uint64_t(uint64_t value, bool verbose = true) { + if ((value < _min) || (value > _max)) { + CommandLineError::print(verbose, + "uint64_t %s=" UINT64_FORMAT " is outside the allowed range " + "[ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n", + name(), value, _min, _max); + return Flag::OUT_OF_BOUNDS; + } else { + return Flag::SUCCESS; + } + } + + void print(outputStream* st) { + st->print("[ " UINT64_FORMAT_W(-25) " ... " UINT64_FORMAT_W(25) " ]", _min, _max); + } +}; + +class CommandLineFlagRange_size_t : public CommandLineFlagRange { + size_t _min; + size_t _max; + const size_t* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagRange_size_t(const char* name, const size_t* ptr, size_t min, size_t max) + : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} + + Flag::Error check(bool verbose = true) { + return check_size_t(*_ptr, verbose); + } + + Flag::Error check_size_t(size_t value, bool verbose = true) { + if ((value < _min) || (value > _max)) { + CommandLineError::print(verbose, + "size_t %s=" SIZE_FORMAT " is outside the allowed range " + "[ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n", + name(), value, _min, _max); + return Flag::OUT_OF_BOUNDS; + } else { + return Flag::SUCCESS; + } + } + + void print(outputStream* st) { + st->print("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", _min, _max); + } +}; + +class CommandLineFlagRange_double : public CommandLineFlagRange { + double _min; + double _max; + const double* _ptr; + +public: + // the "name" argument must be a string literal + CommandLineFlagRange_double(const char* name, const double* ptr, double min, double max) + : CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} + + Flag::Error check(bool verbose = true) { + return check_double(*_ptr, verbose); + } + + Flag::Error check_double(double value, bool verbose = true) { + if ((value < _min) || (value > _max)) { + CommandLineError::print(verbose, + "double %s=%f is outside the allowed range " + "[ %f ... %f ]\n", + name(), value, _min, _max); + return Flag::OUT_OF_BOUNDS; + } else { + return Flag::SUCCESS; + } + } + + void print(outputStream* st) { + st->print("[ %-25.3f ... %25.3f ]", _min, _max); + } +}; + +// No constraint emitting +void emit_range_no(...) { /* NOP */ } + +// No constraint emitting if function argument is NOT provided +void emit_range_bool(const char* /*name*/, const bool* /*value*/) { /* NOP */ } +void emit_range_ccstr(const char* /*name*/, const ccstr* /*value*/) { /* NOP */ } +void emit_range_ccstrlist(const char* /*name*/, const ccstrlist* /*value*/) { /* NOP */ } +void emit_range_int(const char* /*name*/, const int* /*value*/) { /* NOP */ } +void emit_range_intx(const char* /*name*/, const intx* /*value*/) { /* NOP */ } +void emit_range_uint(const char* /*name*/, const uint* /*value*/) { /* NOP */ } +void emit_range_uintx(const char* /*name*/, const uintx* /*value*/) { /* NOP */ } +void emit_range_uint64_t(const char* /*name*/, const uint64_t* /*value*/) { /* NOP */ } +void emit_range_size_t(const char* /*name*/, const size_t* /*value*/) { /* NOP */ } +void emit_range_double(const char* /*name*/, const double* /*value*/) { /* NOP */ } + +// CommandLineFlagRange emitting code functions if range arguments are provided +void emit_range_int(const char* name, const int* ptr, int min, int max) { + CommandLineFlagRangeList::add(new CommandLineFlagRange_int(name, ptr, min, max)); +} +void emit_range_intx(const char* name, const intx* ptr, intx min, intx max) { + CommandLineFlagRangeList::add(new CommandLineFlagRange_intx(name, ptr, min, max)); +} +void emit_range_uint(const char* name, const uint* ptr, uint min, uint max) { + CommandLineFlagRangeList::add(new CommandLineFlagRange_uint(name, ptr, min, max)); +} +void emit_range_uintx(const char* name, const uintx* ptr, uintx min, uintx max) { + CommandLineFlagRangeList::add(new CommandLineFlagRange_uintx(name, ptr, min, max)); +} +void emit_range_uint64_t(const char* name, const uint64_t* ptr, uint64_t min, uint64_t max) { + CommandLineFlagRangeList::add(new CommandLineFlagRange_uint64_t(name, ptr, min, max)); +} +void emit_range_size_t(const char* name, const size_t* ptr, size_t min, size_t max) { + CommandLineFlagRangeList::add(new CommandLineFlagRange_size_t(name, ptr, min, max)); +} +void emit_range_double(const char* name, const double* ptr, double min, double max) { + CommandLineFlagRangeList::add(new CommandLineFlagRange_double(name, ptr, min, max)); +} + +// Generate code to call emit_range_xxx function +#define EMIT_RANGE_PRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name +#define EMIT_RANGE_COMMERCIAL_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name +#define EMIT_RANGE_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name +#define EMIT_RANGE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name +#define EMIT_RANGE_MANAGEABLE_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name +#define EMIT_RANGE_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name +#define EMIT_RANGE_PD_PRODUCT_FLAG(type, name, doc) ); emit_range_##type(#name,&name +#define EMIT_RANGE_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_range_##type(#name,&name +#ifndef PRODUCT +#define EMIT_RANGE_DEVELOPER_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name +#define EMIT_RANGE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_range_##type(#name,&name +#define EMIT_RANGE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name +#else +#define EMIT_RANGE_DEVELOPER_FLAG(type, name, value, doc) ); emit_range_no(#name,&name +#define EMIT_RANGE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_range_no(#name,&name +#define EMIT_RANGE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_range_no(#name,&name +#endif +#ifdef _LP64 +#define EMIT_RANGE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name +#else +#define EMIT_RANGE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_range_no(#name,&name +#endif + +// Generate func argument to pass into emit_range_xxx functions +#define EMIT_RANGE_CHECK(a, b) , a, b + +#define INITIAL_RANGES_SIZE 379 +GrowableArray<CommandLineFlagRange*>* CommandLineFlagRangeList::_ranges = NULL; + +// Check the ranges of all flags that have them +void CommandLineFlagRangeList::init(void) { + + _ranges = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<CommandLineFlagRange*>(INITIAL_RANGES_SIZE, true); + + emit_range_no(NULL VM_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, + EMIT_RANGE_PD_DEVELOPER_FLAG, + EMIT_RANGE_PRODUCT_FLAG, + EMIT_RANGE_PD_PRODUCT_FLAG, + EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, + EMIT_RANGE_EXPERIMENTAL_FLAG, + EMIT_RANGE_NOTPRODUCT_FLAG, + EMIT_RANGE_MANAGEABLE_FLAG, + EMIT_RANGE_PRODUCT_RW_FLAG, + EMIT_RANGE_LP64_PRODUCT_FLAG, + EMIT_RANGE_CHECK, + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); + + EMIT_RANGES_FOR_GLOBALS_EXT + + emit_range_no(NULL ARCH_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, + EMIT_RANGE_PRODUCT_FLAG, + EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_EXPERIMENTAL_FLAG, + EMIT_RANGE_NOTPRODUCT_FLAG, + EMIT_RANGE_CHECK, + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); + +#if INCLUDE_JVMCI + emit_range_no(NULL JVMCI_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, + EMIT_RANGE_PD_DEVELOPER_FLAG, + EMIT_RANGE_PRODUCT_FLAG, + EMIT_RANGE_PD_PRODUCT_FLAG, + EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, + EMIT_RANGE_EXPERIMENTAL_FLAG, + EMIT_RANGE_NOTPRODUCT_FLAG, + EMIT_RANGE_CHECK, + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); +#endif // INCLUDE_JVMCI + +#ifdef COMPILER1 + emit_range_no(NULL C1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, + EMIT_RANGE_PD_DEVELOPER_FLAG, + EMIT_RANGE_PRODUCT_FLAG, + EMIT_RANGE_PD_PRODUCT_FLAG, + EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, + EMIT_RANGE_NOTPRODUCT_FLAG, + EMIT_RANGE_CHECK, + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); +#endif // COMPILER1 + +#ifdef COMPILER2 + emit_range_no(NULL C2_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, + EMIT_RANGE_PD_DEVELOPER_FLAG, + EMIT_RANGE_PRODUCT_FLAG, + EMIT_RANGE_PD_PRODUCT_FLAG, + EMIT_RANGE_DIAGNOSTIC_FLAG, + EMIT_RANGE_PD_DIAGNOSTIC_FLAG, + EMIT_RANGE_EXPERIMENTAL_FLAG, + EMIT_RANGE_NOTPRODUCT_FLAG, + EMIT_RANGE_CHECK, + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); +#endif // COMPILER2 +} + +CommandLineFlagRange* CommandLineFlagRangeList::find(const char* name) { + CommandLineFlagRange* found = NULL; + for (int i=0; i<length(); i++) { + CommandLineFlagRange* range = at(i); + if (strcmp(range->name(), name) == 0) { + found = range; + break; + } + } + return found; +} + +void CommandLineFlagRangeList::print(outputStream* st, const char* name, RangeStrFunc default_range_str_func) { + CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); + if (range != NULL) { + range->print(st); + } else { + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); + if (constraint != NULL) { + assert(default_range_str_func!=NULL, "default_range_str_func must be provided"); + st->print("%s", default_range_str_func()); + } else { + st->print("[ ... ]"); + } + } +} + +bool CommandLineFlagRangeList::check_ranges() { + // Check ranges. + bool status = true; + for (int i=0; i<length(); i++) { + CommandLineFlagRange* range = at(i); + if (range->check(true) != Flag::SUCCESS) status = false; + } + return status; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/commandLineFlagRangeList.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGRANGELIST_HPP +#define SHARE_VM_RUNTIME_COMMANDLINEFLAGRANGELIST_HPP + +#include "memory/metaspaceShared.hpp" +#include "runtime/globals.hpp" +#include "utilities/growableArray.hpp" + +/* + * Here we have a mechanism for extracting ranges specified in flag macro tables. + * + * The specified ranges are used to verify that flags have valid values. + * + * An example of a range is "min <= flag <= max". Both "min" and "max" must be + * constant and can not change. If either "min" or "max" can change, + * then we need to use constraint instead. + */ + +class CommandLineError : public AllStatic { +public: + static void print(bool verbose, const char* msg, ...); +}; + +class CommandLineFlagRange : public CHeapObj<mtArguments> { +private: + const char* _name; +public: + // the "name" argument must be a string literal + CommandLineFlagRange(const char* name) { _name=name; } + ~CommandLineFlagRange() {} + const char* name() { return _name; } + virtual Flag::Error check(bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } + virtual Flag::Error check_int(int value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } + virtual Flag::Error check_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } + virtual Flag::Error check_uint(uint value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } + virtual Flag::Error check_uintx(uintx value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } + virtual Flag::Error check_uint64_t(uint64_t value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } + virtual Flag::Error check_size_t(size_t value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } + virtual Flag::Error check_double(double value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } + virtual void print(outputStream* st) { ; } +}; + +class CommandLineFlagRangeList : public AllStatic { + static GrowableArray<CommandLineFlagRange*>* _ranges; +public: + static void init(); + static int length() { return (_ranges != NULL) ? _ranges->length() : 0; } + static CommandLineFlagRange* at(int i) { return (_ranges != NULL) ? _ranges->at(i) : NULL; } + static CommandLineFlagRange* find(const char* name); + static void add(CommandLineFlagRange* range) { _ranges->append(range); } + static void print(outputStream* st, const char* name, RangeStrFunc default_range_str_func); + // Check the final values of all flags for ranges. + static bool check_ranges(); +}; + +#endif // SHARE_VM_RUNTIME_COMMANDLINEFLAGRANGELIST_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/commandLineFlagWriteableList.cpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/shared/plab.hpp" +#include "runtime/commandLineFlagWriteableList.hpp" +#include "runtime/os.hpp" +#ifdef COMPILER1 +#include "c1/c1_globals.hpp" +#endif // COMPILER1 +#ifdef COMPILER2 +#include "opto/c2_globals.hpp" +#endif // COMPILER2 +#if INCLUDE_JVMCI +#include "jvmci/jvmci_globals.hpp" +#endif + +bool CommandLineFlagWriteable::is_writeable(void) { + return _writeable; +} + +void CommandLineFlagWriteable::mark_once(void) { + if (_type == Once) { + _writeable = false; + } +} + +void CommandLineFlagWriteable::mark_startup(void) { + if (_type == CommandLineFlagWriteable::CommandLineOnly) { + _writeable = false; + } +} + +// No control emitting +void emit_writeable_no(...) { /* NOP */ } + +// No control emitting if type argument is NOT provided +void emit_writeable_bool(const char* /*name*/) { /* NOP */ } +void emit_writeable_ccstr(const char* /*name*/) { /* NOP */ } +void emit_writeable_ccstrlist(const char* /*name*/) { /* NOP */ } +void emit_writeable_int(const char* /*name*/) { /* NOP */ } +void emit_writeable_intx(const char* /*name*/) { /* NOP */ } +void emit_writeable_uint(const char* /*name*/) { /* NOP */ } +void emit_writeable_uintx(const char* /*name*/) { /* NOP */ } +void emit_writeable_uint64_t(const char* /*name*/) { /* NOP */ } +void emit_writeable_size_t(const char* /*name*/) { /* NOP */ } +void emit_writeable_double(const char* /*name*/) { /* NOP */ } + +// CommandLineFlagWriteable emitting code functions if range arguments are provided +void emit_writeable_bool(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_int(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_intx(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_uint(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_uintx(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_uint64_t(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_size_t(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_double(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} + +// Generate code to call emit_writeable_xxx function +#define EMIT_WRITEABLE_PRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_COMMERCIAL_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_MANAGEABLE_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_PD_PRODUCT_FLAG(type, name, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_DEVELOPER_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name + +// Generate type argument to pass into emit_writeable_xxx functions +#define EMIT_WRITEABLE(a) , CommandLineFlagWriteable::a + +#define INITIAL_WRITEABLES_SIZE 2 +GrowableArray<CommandLineFlagWriteable*>* CommandLineFlagWriteableList::_controls = NULL; + +void CommandLineFlagWriteableList::init(void) { + + _controls = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<CommandLineFlagWriteable*>(INITIAL_WRITEABLES_SIZE, true); + + emit_writeable_no(NULL VM_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PD_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_PD_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_EXPERIMENTAL_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + EMIT_WRITEABLE_MANAGEABLE_FLAG, + EMIT_WRITEABLE_PRODUCT_RW_FLAG, + EMIT_WRITEABLE_LP64_PRODUCT_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); + + EMIT_WRITEABLES_FOR_GLOBALS_EXT + + emit_writeable_no(NULL ARCH_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_EXPERIMENTAL_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); + +#if INCLUDE_JVMCI + emit_writeable_no(NULL JVMCI_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PD_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_PD_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_EXPERIMENTAL_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); +#endif // INCLUDE_JVMCI + +#ifdef COMPILER1 + emit_writeable_no(NULL C1_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PD_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_PD_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); +#endif // COMPILER1 + +#ifdef COMPILER2 + emit_writeable_no(NULL C2_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PD_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_PD_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_PD_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_EXPERIMENTAL_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); +#endif // COMPILER2 +} + +CommandLineFlagWriteable* CommandLineFlagWriteableList::find(const char* name) { + CommandLineFlagWriteable* found = NULL; + for (int i=0; i<length(); i++) { + CommandLineFlagWriteable* writeable = at(i); + if (strcmp(writeable->name(), name) == 0) { + found = writeable; + break; + } + } + return found; +} + +void CommandLineFlagWriteableList::mark_startup(void) { + for (int i=0; i<length(); i++) { + CommandLineFlagWriteable* writeable = at(i); + writeable->mark_startup(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/commandLineFlagWriteableList.hpp Mon Apr 23 14:23:18 2018 -0700 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP +#define SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP + +#include "runtime/globals.hpp" +#include "utilities/growableArray.hpp" + +class CommandLineFlagWriteable : public CHeapObj<mtArguments> { +public: + enum WriteableType { + // can be set without any limits + Always = 0, + // can only be set once, either via command lines or during runtime + Once = 1, + // can only be set on command line (multiple times allowed) + CommandLineOnly = 2 + }; +private: + const char* _name; + WriteableType _type; + bool _writeable; + bool _startup_done; +public: + // the "name" argument must be a string literal + CommandLineFlagWriteable(const char* name, WriteableType type) { _name=name; _type=type; _writeable=true; _startup_done=false; } + ~CommandLineFlagWriteable() {} + const char* name() { return _name; } + const WriteableType type() { return _type; } + bool is_writeable(void); + void mark_once(void); + void mark_startup(void); +}; + +class CommandLineFlagWriteableList : public AllStatic { + static GrowableArray<CommandLineFlagWriteable*>* _controls; +public: + static void init(); + static int length() { return (_controls != NULL) ? _controls->length() : 0; } + static CommandLineFlagWriteable* at(int i) { return (_controls != NULL) ? _controls->at(i) : NULL; } + static CommandLineFlagWriteable* find(const char* name); + static void add(CommandLineFlagWriteable* range) { _controls->append(range); } + static void mark_startup(void); +}; + +#endif // SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP
--- a/src/hotspot/share/runtime/flags/flagSetting.hpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_RUNTIME_FLAGS_FLAGSETTING_HPP -#define SHARE_VM_RUNTIME_FLAGS_FLAGSETTING_HPP - -#include "memory/allocation.hpp" - -// debug flags control various aspects of the VM and are global accessible - -// use FlagSetting to temporarily change some debug flag -// e.g. FlagSetting fs(DebugThisAndThat, true); -// restored to previous value upon leaving scope -class FlagSetting : public StackObj { - bool val; - bool* flag; -public: - FlagSetting(bool& fl, bool newValue) { flag = &fl; val = fl; fl = newValue; } - ~FlagSetting() { *flag = val; } -}; - -class UIntFlagSetting : public StackObj { - uint val; - uint* flag; -public: - UIntFlagSetting(uint& fl, uint newValue) { flag = &fl; val = fl; fl = newValue; } - ~UIntFlagSetting() { *flag = val; } -}; - -class SizeTFlagSetting : public StackObj { - size_t val; - size_t* flag; -public: - SizeTFlagSetting(size_t& fl, size_t newValue) { flag = &fl; val = fl; fl = newValue; } - ~SizeTFlagSetting() { *flag = val; } -}; - -// Helper class for temporarily saving the value of a flag during a scope. -template <size_t SIZE> -class FlagGuard { - unsigned char _value[SIZE]; - void* const _addr; -public: - FlagGuard(void* flag_addr) : _addr(flag_addr) { memcpy(_value, _addr, SIZE); } - ~FlagGuard() { memcpy(_addr, _value, SIZE); } -}; - -#define FLAG_GUARD(f) FlagGuard<sizeof(f)> f ## _guard(&f) - -#endif // SHARE_VM_RUNTIME_FLAGS_FLAGSETTING_HPP
--- a/src/hotspot/share/runtime/flags/jvmFlag.cpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1506 +0,0 @@ -/* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "memory/allocation.inline.hpp" -#include "runtime/arguments.hpp" -#include "runtime/flags/jvmFlag.hpp" -#include "runtime/flags/jvmFlagConstraintList.hpp" -#include "runtime/flags/jvmFlagWriteableList.hpp" -#include "runtime/flags/jvmFlagRangeList.hpp" -#include "runtime/globals_extension.hpp" -#include "trace/tracing.hpp" -#include "utilities/defaultStream.hpp" -#include "utilities/stringUtils.hpp" - -#define DEFAULT_RANGE_STR_CHUNK_SIZE 64 -static char* create_range_str(const char *fmt, ...) { - static size_t string_length = DEFAULT_RANGE_STR_CHUNK_SIZE; - static char* range_string = NEW_C_HEAP_ARRAY(char, string_length, mtLogging); - - int size_needed = 0; - do { - va_list args; - va_start(args, fmt); - size_needed = jio_vsnprintf(range_string, string_length, fmt, args); - va_end(args); - - if (size_needed < 0) { - string_length += DEFAULT_RANGE_STR_CHUNK_SIZE; - range_string = REALLOC_C_HEAP_ARRAY(char, range_string, string_length, mtLogging); - guarantee(range_string != NULL, "create_range_str string should not be NULL"); - } - } while (size_needed < 0); - - return range_string; -} - -const char* JVMFlag::get_int_default_range_str() { - return create_range_str("[ " INT32_FORMAT_W(-25) " ... " INT32_FORMAT_W(25) " ]", INT_MIN, INT_MAX); -} - -const char* JVMFlag::get_uint_default_range_str() { - return create_range_str("[ " UINT32_FORMAT_W(-25) " ... " UINT32_FORMAT_W(25) " ]", 0, UINT_MAX); -} - -const char* JVMFlag::get_intx_default_range_str() { - return create_range_str("[ " INTX_FORMAT_W(-25) " ... " INTX_FORMAT_W(25) " ]", min_intx, max_intx); -} - -const char* JVMFlag::get_uintx_default_range_str() { - return create_range_str("[ " UINTX_FORMAT_W(-25) " ... " UINTX_FORMAT_W(25) " ]", 0, max_uintx); -} - -const char* JVMFlag::get_uint64_t_default_range_str() { - return create_range_str("[ " UINT64_FORMAT_W(-25) " ... " UINT64_FORMAT_W(25) " ]", 0, uint64_t(max_juint)); -} - -const char* JVMFlag::get_size_t_default_range_str() { - return create_range_str("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", 0, SIZE_MAX); -} - -const char* JVMFlag::get_double_default_range_str() { - return create_range_str("[ %-25.3f ... %25.3f ]", DBL_MIN, DBL_MAX); -} - -static bool is_product_build() { -#ifdef PRODUCT - return true; -#else - return false; -#endif -} - -JVMFlag::Error JVMFlag::check_writable(bool changed) { - if (is_constant_in_binary()) { - fatal("flag is constant: %s", _name); - } - - JVMFlag::Error error = JVMFlag::SUCCESS; - if (changed) { - JVMFlagWriteable* writeable = JVMFlagWriteableList::find(_name); - if (writeable) { - if (writeable->is_writeable() == false) { - switch (writeable->type()) - { - case JVMFlagWriteable::Once: - error = JVMFlag::SET_ONLY_ONCE; - jio_fprintf(defaultStream::error_stream(), "Error: %s may not be set more than once\n", _name); - break; - case JVMFlagWriteable::CommandLineOnly: - error = JVMFlag::COMMAND_LINE_ONLY; - jio_fprintf(defaultStream::error_stream(), "Error: %s may be modified only from commad line\n", _name); - break; - default: - ShouldNotReachHere(); - break; - } - } - writeable->mark_once(); - } - } - return error; -} - -bool JVMFlag::is_bool() const { - return strcmp(_type, "bool") == 0; -} - -bool JVMFlag::get_bool() const { - return *((bool*) _addr); -} - -JVMFlag::Error JVMFlag::set_bool(bool value) { - JVMFlag::Error error = check_writable(value!=get_bool()); - if (error == JVMFlag::SUCCESS) { - *((bool*) _addr) = value; - } - return error; -} - -bool JVMFlag::is_int() const { - return strcmp(_type, "int") == 0; -} - -int JVMFlag::get_int() const { - return *((int*) _addr); -} - -JVMFlag::Error JVMFlag::set_int(int value) { - JVMFlag::Error error = check_writable(value!=get_int()); - if (error == JVMFlag::SUCCESS) { - *((int*) _addr) = value; - } - return error; -} - -bool JVMFlag::is_uint() const { - return strcmp(_type, "uint") == 0; -} - -uint JVMFlag::get_uint() const { - return *((uint*) _addr); -} - -JVMFlag::Error JVMFlag::set_uint(uint value) { - JVMFlag::Error error = check_writable(value!=get_uint()); - if (error == JVMFlag::SUCCESS) { - *((uint*) _addr) = value; - } - return error; -} - -bool JVMFlag::is_intx() const { - return strcmp(_type, "intx") == 0; -} - -intx JVMFlag::get_intx() const { - return *((intx*) _addr); -} - -JVMFlag::Error JVMFlag::set_intx(intx value) { - JVMFlag::Error error = check_writable(value!=get_intx()); - if (error == JVMFlag::SUCCESS) { - *((intx*) _addr) = value; - } - return error; -} - -bool JVMFlag::is_uintx() const { - return strcmp(_type, "uintx") == 0; -} - -uintx JVMFlag::get_uintx() const { - return *((uintx*) _addr); -} - -JVMFlag::Error JVMFlag::set_uintx(uintx value) { - JVMFlag::Error error = check_writable(value!=get_uintx()); - if (error == JVMFlag::SUCCESS) { - *((uintx*) _addr) = value; - } - return error; -} - -bool JVMFlag::is_uint64_t() const { - return strcmp(_type, "uint64_t") == 0; -} - -uint64_t JVMFlag::get_uint64_t() const { - return *((uint64_t*) _addr); -} - -JVMFlag::Error JVMFlag::set_uint64_t(uint64_t value) { - JVMFlag::Error error = check_writable(value!=get_uint64_t()); - if (error == JVMFlag::SUCCESS) { - *((uint64_t*) _addr) = value; - } - return error; -} - -bool JVMFlag::is_size_t() const { - return strcmp(_type, "size_t") == 0; -} - -size_t JVMFlag::get_size_t() const { - return *((size_t*) _addr); -} - -JVMFlag::Error JVMFlag::set_size_t(size_t value) { - JVMFlag::Error error = check_writable(value!=get_size_t()); - if (error == JVMFlag::SUCCESS) { - *((size_t*) _addr) = value; - } - return error; -} - -bool JVMFlag::is_double() const { - return strcmp(_type, "double") == 0; -} - -double JVMFlag::get_double() const { - return *((double*) _addr); -} - -JVMFlag::Error JVMFlag::set_double(double value) { - JVMFlag::Error error = check_writable(value!=get_double()); - if (error == JVMFlag::SUCCESS) { - *((double*) _addr) = value; - } - return error; -} - -bool JVMFlag::is_ccstr() const { - return strcmp(_type, "ccstr") == 0 || strcmp(_type, "ccstrlist") == 0; -} - -bool JVMFlag::ccstr_accumulates() const { - return strcmp(_type, "ccstrlist") == 0; -} - -ccstr JVMFlag::get_ccstr() const { - return *((ccstr*) _addr); -} - -JVMFlag::Error JVMFlag::set_ccstr(ccstr value) { - JVMFlag::Error error = check_writable(value!=get_ccstr()); - if (error == JVMFlag::SUCCESS) { - *((ccstr*) _addr) = value; - } - return error; -} - - -JVMFlag::Flags JVMFlag::get_origin() { - return Flags(_flags & VALUE_ORIGIN_MASK); -} - -void JVMFlag::set_origin(Flags origin) { - assert((origin & VALUE_ORIGIN_MASK) == origin, "sanity"); - Flags new_origin = Flags((origin == COMMAND_LINE) ? Flags(origin | ORIG_COMMAND_LINE) : origin); - _flags = Flags((_flags & ~VALUE_ORIGIN_MASK) | new_origin); -} - -bool JVMFlag::is_default() { - return (get_origin() == DEFAULT); -} - -bool JVMFlag::is_ergonomic() { - return (get_origin() == ERGONOMIC); -} - -bool JVMFlag::is_command_line() { - return (_flags & ORIG_COMMAND_LINE) != 0; -} - -void JVMFlag::set_command_line() { - _flags = Flags(_flags | ORIG_COMMAND_LINE); -} - -bool JVMFlag::is_product() const { - return (_flags & KIND_PRODUCT) != 0; -} - -bool JVMFlag::is_manageable() const { - return (_flags & KIND_MANAGEABLE) != 0; -} - -bool JVMFlag::is_diagnostic() const { - return (_flags & KIND_DIAGNOSTIC) != 0; -} - -bool JVMFlag::is_experimental() const { - return (_flags & KIND_EXPERIMENTAL) != 0; -} - -bool JVMFlag::is_notproduct() const { - return (_flags & KIND_NOT_PRODUCT) != 0; -} - -bool JVMFlag::is_develop() const { - return (_flags & KIND_DEVELOP) != 0; -} - -bool JVMFlag::is_read_write() const { - return (_flags & KIND_READ_WRITE) != 0; -} - -bool JVMFlag::is_commercial() const { - return (_flags & KIND_COMMERCIAL) != 0; -} - -/** - * Returns if this flag is a constant in the binary. Right now this is - * true for notproduct and develop flags in product builds. - */ -bool JVMFlag::is_constant_in_binary() const { -#ifdef PRODUCT - return is_notproduct() || is_develop(); -#else - return false; -#endif -} - -bool JVMFlag::is_unlocker() const { - return strcmp(_name, "UnlockDiagnosticVMOptions") == 0 || - strcmp(_name, "UnlockExperimentalVMOptions") == 0 || - is_unlocker_ext(); -} - -bool JVMFlag::is_unlocked() const { - if (is_diagnostic()) { - return UnlockDiagnosticVMOptions; - } - if (is_experimental()) { - return UnlockExperimentalVMOptions; - } - return is_unlocked_ext(); -} - -void JVMFlag::clear_diagnostic() { - assert(is_diagnostic(), "sanity"); - _flags = Flags(_flags & ~KIND_DIAGNOSTIC); - assert(!is_diagnostic(), "sanity"); -} - -// Get custom message for this locked flag, or NULL if -// none is available. Returns message type produced. -JVMFlag::MsgType JVMFlag::get_locked_message(char* buf, int buflen) const { - buf[0] = '\0'; - if (is_diagnostic() && !is_unlocked()) { - jio_snprintf(buf, buflen, - "Error: VM option '%s' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.\n" - "Error: The unlock option must precede '%s'.\n", - _name, _name); - return JVMFlag::DIAGNOSTIC_FLAG_BUT_LOCKED; - } - if (is_experimental() && !is_unlocked()) { - jio_snprintf(buf, buflen, - "Error: VM option '%s' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.\n" - "Error: The unlock option must precede '%s'.\n", - _name, _name); - return JVMFlag::EXPERIMENTAL_FLAG_BUT_LOCKED; - } - if (is_develop() && is_product_build()) { - jio_snprintf(buf, buflen, "Error: VM option '%s' is develop and is available only in debug version of VM.\n", - _name); - return JVMFlag::DEVELOPER_FLAG_BUT_PRODUCT_BUILD; - } - if (is_notproduct() && is_product_build()) { - jio_snprintf(buf, buflen, "Error: VM option '%s' is notproduct and is available only in debug version of VM.\n", - _name); - return JVMFlag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD; - } - return get_locked_message_ext(buf, buflen); -} - -bool JVMFlag::is_writeable() const { - return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext(); -} - -// All flags except "manageable" are assumed to be internal flags. -// Long term, we need to define a mechanism to specify which flags -// are external/stable and change this function accordingly. -bool JVMFlag::is_external() const { - return is_manageable() || is_external_ext(); -} - -// Helper function for JVMFlag::print_on(). -// Fills current line up to requested position. -// Should the current position already be past the requested position, -// one separator blank is enforced. -void fill_to_pos(outputStream* st, unsigned int req_pos) { - if ((unsigned int)st->position() < req_pos) { - st->fill_to(req_pos); // need to fill with blanks to reach req_pos - } else { - st->print(" "); // enforce blank separation. Previous field too long. - } -} - -void JVMFlag::print_on(outputStream* st, bool withComments, bool printRanges) { - // Don't print notproduct and develop flags in a product build. - if (is_constant_in_binary()) { - return; - } - - if (!printRanges) { - // The command line options -XX:+PrintFlags* cause this function to be called - // for each existing flag to print information pertinent to this flag. The data - // is displayed in columnar form, with the following layout: - // col1 - data type, right-justified - // col2 - name, left-justified - // col3 - ' =' double-char, leading space to align with possible '+=' - // col4 - value left-justified - // col5 - kind right-justified - // col6 - origin left-justified - // col7 - comments left-justified - // - // The column widths are fixed. They are defined such that, for most cases, - // an eye-pleasing tabular output is created. - // - // Sample output: - // bool CMSScavengeBeforeRemark = false {product} {default} - // uintx CMSScheduleRemarkEdenPenetration = 50 {product} {default} - // size_t CMSScheduleRemarkEdenSizeThreshold = 2097152 {product} {default} - // uintx CMSScheduleRemarkSamplingRatio = 5 {product} {default} - // double CMSSmallCoalSurplusPercent = 1.050000 {product} {default} - // ccstr CompileCommandFile = MyFile.cmd {product} {command line} - // ccstrlist CompileOnly = Method1 - // CompileOnly += Method2 {product} {command line} - // | | | | | | | - // | | | | | | +-- col7 - // | | | | | +-- col6 - // | | | | +-- col5 - // | | | +-- col4 - // | | +-- col3 - // | +-- col2 - // +-- col1 - - const unsigned int col_spacing = 1; - const unsigned int col1_pos = 0; - const unsigned int col1_width = 9; - const unsigned int col2_pos = col1_pos + col1_width + col_spacing; - const unsigned int col2_width = 39; - const unsigned int col3_pos = col2_pos + col2_width + col_spacing; - const unsigned int col3_width = 2; - const unsigned int col4_pos = col3_pos + col3_width + col_spacing; - const unsigned int col4_width = 30; - const unsigned int col5_pos = col4_pos + col4_width + col_spacing; - const unsigned int col5_width = 20; - const unsigned int col6_pos = col5_pos + col5_width + col_spacing; - const unsigned int col6_width = 15; - const unsigned int col7_pos = col6_pos + col6_width + col_spacing; - const unsigned int col7_width = 1; - - st->fill_to(col1_pos); - st->print("%*s", col1_width, _type); // right-justified, therefore width is required. - - fill_to_pos(st, col2_pos); - st->print("%s", _name); - - fill_to_pos(st, col3_pos); - st->print(" ="); // use " =" for proper alignment with multiline ccstr output. - - fill_to_pos(st, col4_pos); - if (is_bool()) { - st->print("%s", get_bool() ? "true" : "false"); - } else if (is_int()) { - st->print("%d", get_int()); - } else if (is_uint()) { - st->print("%u", get_uint()); - } else if (is_intx()) { - st->print(INTX_FORMAT, get_intx()); - } else if (is_uintx()) { - st->print(UINTX_FORMAT, get_uintx()); - } else if (is_uint64_t()) { - st->print(UINT64_FORMAT, get_uint64_t()); - } else if (is_size_t()) { - st->print(SIZE_FORMAT, get_size_t()); - } else if (is_double()) { - st->print("%f", get_double()); - } else if (is_ccstr()) { - // Honor <newline> characters in ccstr: print multiple lines. - const char* cp = get_ccstr(); - if (cp != NULL) { - const char* eol; - while ((eol = strchr(cp, '\n')) != NULL) { - size_t llen = pointer_delta(eol, cp, sizeof(char)); - st->print("%.*s", (int)llen, cp); - st->cr(); - cp = eol+1; - fill_to_pos(st, col2_pos); - st->print("%s", _name); - fill_to_pos(st, col3_pos); - st->print("+="); - fill_to_pos(st, col4_pos); - } - st->print("%s", cp); - } - } else { - st->print("unhandled type %s", _type); - st->cr(); - return; - } - - fill_to_pos(st, col5_pos); - print_kind(st, col5_width); - - fill_to_pos(st, col6_pos); - print_origin(st, col6_width); - -#ifndef PRODUCT - if (withComments) { - fill_to_pos(st, col7_pos); - st->print("%s", _doc); - } -#endif - st->cr(); - } else if (!is_bool() && !is_ccstr()) { - // The command line options -XX:+PrintFlags* cause this function to be called - // for each existing flag to print information pertinent to this flag. The data - // is displayed in columnar form, with the following layout: - // col1 - data type, right-justified - // col2 - name, left-justified - // col4 - range [ min ... max] - // col5 - kind right-justified - // col6 - origin left-justified - // col7 - comments left-justified - // - // The column widths are fixed. They are defined such that, for most cases, - // an eye-pleasing tabular output is created. - // - // Sample output: - // intx MinPassesBeforeFlush [ 0 ... 9223372036854775807 ] {diagnostic} {default} - // uintx MinRAMFraction [ 1 ... 18446744073709551615 ] {product} {default} - // double MinRAMPercentage [ 0.000 ... 100.000 ] {product} {default} - // uintx MinSurvivorRatio [ 3 ... 18446744073709551615 ] {product} {default} - // size_t MinTLABSize [ 1 ... 9223372036854775807 ] {product} {default} - // intx MonitorBound [ 0 ... 2147483647 ] {product} {default} - // | | | | | | - // | | | | | +-- col7 - // | | | | +-- col6 - // | | | +-- col5 - // | | +-- col4 - // | +-- col2 - // +-- col1 - - const unsigned int col_spacing = 1; - const unsigned int col1_pos = 0; - const unsigned int col1_width = 9; - const unsigned int col2_pos = col1_pos + col1_width + col_spacing; - const unsigned int col2_width = 49; - const unsigned int col3_pos = col2_pos + col2_width + col_spacing; - const unsigned int col3_width = 0; - const unsigned int col4_pos = col3_pos + col3_width + col_spacing; - const unsigned int col4_width = 60; - const unsigned int col5_pos = col4_pos + col4_width + col_spacing; - const unsigned int col5_width = 35; - const unsigned int col6_pos = col5_pos + col5_width + col_spacing; - const unsigned int col6_width = 15; - const unsigned int col7_pos = col6_pos + col6_width + col_spacing; - const unsigned int col7_width = 1; - - st->fill_to(col1_pos); - st->print("%*s", col1_width, _type); // right-justified, therefore width is required. - - fill_to_pos(st, col2_pos); - st->print("%s", _name); - - fill_to_pos(st, col4_pos); - RangeStrFunc func = NULL; - if (is_int()) { - func = JVMFlag::get_int_default_range_str; - } else if (is_uint()) { - func = JVMFlag::get_uint_default_range_str; - } else if (is_intx()) { - func = JVMFlag::get_intx_default_range_str; - } else if (is_uintx()) { - func = JVMFlag::get_uintx_default_range_str; - } else if (is_uint64_t()) { - func = JVMFlag::get_uint64_t_default_range_str; - } else if (is_size_t()) { - func = JVMFlag::get_size_t_default_range_str; - } else if (is_double()) { - func = JVMFlag::get_double_default_range_str; - } else { - st->print("unhandled type %s", _type); - st->cr(); - return; - } - JVMFlagRangeList::print(st, _name, func); - - fill_to_pos(st, col5_pos); - print_kind(st, col5_width); - - fill_to_pos(st, col6_pos); - print_origin(st, col6_width); - -#ifndef PRODUCT - if (withComments) { - fill_to_pos(st, col7_pos); - st->print("%s", _doc); - } -#endif - st->cr(); - } -} - -void JVMFlag::print_kind(outputStream* st, unsigned int width) { - struct Data { - int flag; - const char* name; - }; - - Data data[] = { - { KIND_JVMCI, "JVMCI" }, - { KIND_C1, "C1" }, - { KIND_C2, "C2" }, - { KIND_ARCH, "ARCH" }, - { KIND_PLATFORM_DEPENDENT, "pd" }, - { KIND_PRODUCT, "product" }, - { KIND_MANAGEABLE, "manageable" }, - { KIND_DIAGNOSTIC, "diagnostic" }, - { KIND_EXPERIMENTAL, "experimental" }, - { KIND_COMMERCIAL, "commercial" }, - { KIND_NOT_PRODUCT, "notproduct" }, - { KIND_DEVELOP, "develop" }, - { KIND_LP64_PRODUCT, "lp64_product" }, - { KIND_READ_WRITE, "rw" }, - { -1, "" } - }; - - if ((_flags & KIND_MASK) != 0) { - bool is_first = true; - const size_t buffer_size = 64; - size_t buffer_used = 0; - char kind[buffer_size]; - - jio_snprintf(kind, buffer_size, "{"); - buffer_used++; - for (int i = 0; data[i].flag != -1; i++) { - Data d = data[i]; - if ((_flags & d.flag) != 0) { - if (is_first) { - is_first = false; - } else { - assert(buffer_used + 1 < buffer_size, "Too small buffer"); - jio_snprintf(kind + buffer_used, buffer_size - buffer_used, " "); - buffer_used++; - } - size_t length = strlen(d.name); - assert(buffer_used + length < buffer_size, "Too small buffer"); - jio_snprintf(kind + buffer_used, buffer_size - buffer_used, "%s", d.name); - buffer_used += length; - } - } - assert(buffer_used + 2 <= buffer_size, "Too small buffer"); - jio_snprintf(kind + buffer_used, buffer_size - buffer_used, "}"); - st->print("%*s", width, kind); - } -} - -void JVMFlag::print_origin(outputStream* st, unsigned int width) { - int origin = _flags & VALUE_ORIGIN_MASK; - st->print("{"); - switch(origin) { - case DEFAULT: - st->print("default"); break; - case COMMAND_LINE: - st->print("command line"); break; - case ENVIRON_VAR: - st->print("environment"); break; - case CONFIG_FILE: - st->print("config file"); break; - case MANAGEMENT: - st->print("management"); break; - case ERGONOMIC: - if (_flags & ORIG_COMMAND_LINE) { - st->print("command line, "); - } - st->print("ergonomic"); break; - case ATTACH_ON_DEMAND: - st->print("attach"); break; - case INTERNAL: - st->print("internal"); break; - } - st->print("}"); -} - -void JVMFlag::print_as_flag(outputStream* st) { - if (is_bool()) { - st->print("-XX:%s%s", get_bool() ? "+" : "-", _name); - } else if (is_int()) { - st->print("-XX:%s=%d", _name, get_int()); - } else if (is_uint()) { - st->print("-XX:%s=%u", _name, get_uint()); - } else if (is_intx()) { - st->print("-XX:%s=" INTX_FORMAT, _name, get_intx()); - } else if (is_uintx()) { - st->print("-XX:%s=" UINTX_FORMAT, _name, get_uintx()); - } else if (is_uint64_t()) { - st->print("-XX:%s=" UINT64_FORMAT, _name, get_uint64_t()); - } else if (is_size_t()) { - st->print("-XX:%s=" SIZE_FORMAT, _name, get_size_t()); - } else if (is_double()) { - st->print("-XX:%s=%f", _name, get_double()); - } else if (is_ccstr()) { - st->print("-XX:%s=", _name); - const char* cp = get_ccstr(); - if (cp != NULL) { - // Need to turn embedded '\n's back into separate arguments - // Not so efficient to print one character at a time, - // but the choice is to do the transformation to a buffer - // and print that. And this need not be efficient. - for (; *cp != '\0'; cp += 1) { - switch (*cp) { - default: - st->print("%c", *cp); - break; - case '\n': - st->print(" -XX:%s=", _name); - break; - } - } - } - } else { - ShouldNotReachHere(); - } -} - -const char* JVMFlag::flag_error_str(JVMFlag::Error error) { - switch (error) { - case JVMFlag::MISSING_NAME: return "MISSING_NAME"; - case JVMFlag::MISSING_VALUE: return "MISSING_VALUE"; - case JVMFlag::NON_WRITABLE: return "NON_WRITABLE"; - case JVMFlag::OUT_OF_BOUNDS: return "OUT_OF_BOUNDS"; - case JVMFlag::VIOLATES_CONSTRAINT: return "VIOLATES_CONSTRAINT"; - case JVMFlag::INVALID_FLAG: return "INVALID_FLAG"; - case JVMFlag::ERR_OTHER: return "ERR_OTHER"; - case JVMFlag::SUCCESS: return "SUCCESS"; - default: ShouldNotReachHere(); return "NULL"; - } -} - -// 4991491 do not "optimize out" the was_set false values: omitting them -// tickles a Microsoft compiler bug causing flagTable to be malformed - -#define RUNTIME_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_PRODUCT) }, -#define RUNTIME_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define RUNTIME_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DIAGNOSTIC) }, -#define RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_EXPERIMENTAL) }, -#define RUNTIME_MANAGEABLE_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_MANAGEABLE) }, -#define RUNTIME_PRODUCT_RW_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_READ_WRITE) }, -#define RUNTIME_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DEVELOP) }, -#define RUNTIME_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define RUNTIME_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_NOT_PRODUCT) }, - -#define JVMCI_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_PRODUCT) }, -#define JVMCI_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define JVMCI_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DIAGNOSTIC) }, -#define JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define JVMCI_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_EXPERIMENTAL) }, -#define JVMCI_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DEVELOP) }, -#define JVMCI_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define JVMCI_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_NOT_PRODUCT) }, - -#ifdef _LP64 -#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_LP64_PRODUCT) }, -#else -#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) /* flag is constant */ -#endif // _LP64 - -#define C1_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_PRODUCT) }, -#define C1_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define C1_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DIAGNOSTIC) }, -#define C1_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define C1_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DEVELOP) }, -#define C1_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define C1_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_NOT_PRODUCT) }, - -#define C2_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_PRODUCT) }, -#define C2_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define C2_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DIAGNOSTIC) }, -#define C2_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define C2_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_EXPERIMENTAL) }, -#define C2_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DEVELOP) }, -#define C2_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) }, -#define C2_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_NOT_PRODUCT) }, - -#define ARCH_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_PRODUCT) }, -#define ARCH_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_DIAGNOSTIC) }, -#define ARCH_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_EXPERIMENTAL) }, -#define ARCH_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_DEVELOP) }, -#define ARCH_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_NOT_PRODUCT) }, - -static JVMFlag flagTable[] = { - VM_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \ - RUNTIME_PD_DEVELOP_FLAG_STRUCT, \ - RUNTIME_PRODUCT_FLAG_STRUCT, \ - RUNTIME_PD_PRODUCT_FLAG_STRUCT, \ - RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \ - RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \ - RUNTIME_EXPERIMENTAL_FLAG_STRUCT, \ - RUNTIME_NOTPRODUCT_FLAG_STRUCT, \ - RUNTIME_MANAGEABLE_FLAG_STRUCT, \ - RUNTIME_PRODUCT_RW_FLAG_STRUCT, \ - RUNTIME_LP64_PRODUCT_FLAG_STRUCT, \ - IGNORE_RANGE, \ - IGNORE_CONSTRAINT, \ - IGNORE_WRITEABLE) - - RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \ - RUNTIME_PD_DEVELOP_FLAG_STRUCT, \ - RUNTIME_PRODUCT_FLAG_STRUCT, \ - RUNTIME_PD_PRODUCT_FLAG_STRUCT, \ - RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \ - RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \ - RUNTIME_NOTPRODUCT_FLAG_STRUCT, \ - IGNORE_RANGE, \ - IGNORE_CONSTRAINT, \ - IGNORE_WRITEABLE) -#if INCLUDE_JVMCI - JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_STRUCT, \ - JVMCI_PD_DEVELOP_FLAG_STRUCT, \ - JVMCI_PRODUCT_FLAG_STRUCT, \ - JVMCI_PD_PRODUCT_FLAG_STRUCT, \ - JVMCI_DIAGNOSTIC_FLAG_STRUCT, \ - JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT, \ - JVMCI_EXPERIMENTAL_FLAG_STRUCT, \ - JVMCI_NOTPRODUCT_FLAG_STRUCT, \ - IGNORE_RANGE, \ - IGNORE_CONSTRAINT, \ - IGNORE_WRITEABLE) -#endif // INCLUDE_JVMCI -#ifdef COMPILER1 - C1_FLAGS(C1_DEVELOP_FLAG_STRUCT, \ - C1_PD_DEVELOP_FLAG_STRUCT, \ - C1_PRODUCT_FLAG_STRUCT, \ - C1_PD_PRODUCT_FLAG_STRUCT, \ - C1_DIAGNOSTIC_FLAG_STRUCT, \ - C1_PD_DIAGNOSTIC_FLAG_STRUCT, \ - C1_NOTPRODUCT_FLAG_STRUCT, \ - IGNORE_RANGE, \ - IGNORE_CONSTRAINT, \ - IGNORE_WRITEABLE) -#endif // COMPILER1 -#ifdef COMPILER2 - C2_FLAGS(C2_DEVELOP_FLAG_STRUCT, \ - C2_PD_DEVELOP_FLAG_STRUCT, \ - C2_PRODUCT_FLAG_STRUCT, \ - C2_PD_PRODUCT_FLAG_STRUCT, \ - C2_DIAGNOSTIC_FLAG_STRUCT, \ - C2_PD_DIAGNOSTIC_FLAG_STRUCT, \ - C2_EXPERIMENTAL_FLAG_STRUCT, \ - C2_NOTPRODUCT_FLAG_STRUCT, \ - IGNORE_RANGE, \ - IGNORE_CONSTRAINT, \ - IGNORE_WRITEABLE) -#endif // COMPILER2 - ARCH_FLAGS(ARCH_DEVELOP_FLAG_STRUCT, \ - ARCH_PRODUCT_FLAG_STRUCT, \ - ARCH_DIAGNOSTIC_FLAG_STRUCT, \ - ARCH_EXPERIMENTAL_FLAG_STRUCT, \ - ARCH_NOTPRODUCT_FLAG_STRUCT, \ - IGNORE_RANGE, \ - IGNORE_CONSTRAINT, \ - IGNORE_WRITEABLE) - FLAGTABLE_EXT - {0, NULL, NULL} -}; - -JVMFlag* JVMFlag::flags = flagTable; -size_t JVMFlag::numFlags = (sizeof(flagTable) / sizeof(JVMFlag)); - -inline bool str_equal(const char* s, size_t s_len, const char* q, size_t q_len) { - if (s_len != q_len) return false; - return memcmp(s, q, q_len) == 0; -} - -// Search the flag table for a named flag -JVMFlag* JVMFlag::find_flag(const char* name, size_t length, bool allow_locked, bool return_flag) { - for (JVMFlag* current = &flagTable[0]; current->_name != NULL; current++) { - if (str_equal(current->_name, current->get_name_length(), name, length)) { - // Found a matching entry. - // Don't report notproduct and develop flags in product builds. - if (current->is_constant_in_binary()) { - return (return_flag ? current : NULL); - } - // Report locked flags only if allowed. - if (!(current->is_unlocked() || current->is_unlocker())) { - if (!allow_locked) { - // disable use of locked flags, e.g. diagnostic, experimental, - // commercial... until they are explicitly unlocked - return NULL; - } - } - return current; - } - } - // JVMFlag name is not in the flag table - return NULL; -} - -// Get or compute the flag name length -size_t JVMFlag::get_name_length() { - if (_name_len == 0) { - _name_len = strlen(_name); - } - return _name_len; -} - -JVMFlag* JVMFlag::fuzzy_match(const char* name, size_t length, bool allow_locked) { - float VMOptionsFuzzyMatchSimilarity = 0.7f; - JVMFlag* match = NULL; - float score; - float max_score = -1; - - for (JVMFlag* current = &flagTable[0]; current->_name != NULL; current++) { - score = StringUtils::similarity(current->_name, strlen(current->_name), name, length); - if (score > max_score) { - max_score = score; - match = current; - } - } - - if (!(match->is_unlocked() || match->is_unlocker())) { - if (!allow_locked) { - return NULL; - } - } - - if (max_score < VMOptionsFuzzyMatchSimilarity) { - return NULL; - } - - return match; -} - -// Returns the address of the index'th element -static JVMFlag* address_of_flag(JVMFlagsWithType flag) { - assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index"); - return &JVMFlag::flags[flag]; -} - -bool JVMFlagEx::is_default(JVMFlags flag) { - assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index"); - JVMFlag* f = &JVMFlag::flags[flag]; - return f->is_default(); -} - -bool JVMFlagEx::is_ergo(JVMFlags flag) { - assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index"); - JVMFlag* f = &JVMFlag::flags[flag]; - return f->is_ergonomic(); -} - -bool JVMFlagEx::is_cmdline(JVMFlags flag) { - assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index"); - JVMFlag* f = &JVMFlag::flags[flag]; - return f->is_command_line(); -} - -bool JVMFlag::wasSetOnCmdline(const char* name, bool* value) { - JVMFlag* result = JVMFlag::find_flag((char*)name, strlen(name)); - if (result == NULL) return false; - *value = result->is_command_line(); - return true; -} - -void JVMFlagEx::setOnCmdLine(JVMFlagsWithType flag) { - JVMFlag* faddr = address_of_flag(flag); - assert(faddr != NULL, "Unknown flag"); - faddr->set_command_line(); -} - -template<class E, class T> -static void trace_flag_changed(const char* name, const T old_value, const T new_value, const JVMFlag::Flags origin) { - E e; - e.set_name(name); - e.set_oldValue(old_value); - e.set_newValue(new_value); - e.set_origin(origin); - e.commit(); -} - -static JVMFlag::Error apply_constraint_and_check_range_bool(const char* name, bool new_value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - status = constraint->apply_bool(new_value, verbose); - } - return status; -} - -JVMFlag::Error JVMFlag::boolAt(const char* name, size_t len, bool* value, bool allow_locked, bool return_flag) { - JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag); - if (result == NULL) return JVMFlag::INVALID_FLAG; - if (!result->is_bool()) return JVMFlag::WRONG_FORMAT; - *value = result->get_bool(); - return JVMFlag::SUCCESS; -} - -JVMFlag::Error JVMFlag::boolAtPut(JVMFlag* flag, bool* value, JVMFlag::Flags origin) { - const char* name; - if (flag == NULL) return JVMFlag::INVALID_FLAG; - if (!flag->is_bool()) return JVMFlag::WRONG_FORMAT; - name = flag->_name; - JVMFlag::Error check = apply_constraint_and_check_range_bool(name, *value, !JVMFlagConstraintList::validated_after_ergo()); - if (check != JVMFlag::SUCCESS) return check; - bool old_value = flag->get_bool(); - trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin); - check = flag->set_bool(*value); - *value = old_value; - flag->set_origin(origin); - return check; -} - -JVMFlag::Error JVMFlag::boolAtPut(const char* name, size_t len, bool* value, JVMFlag::Flags origin) { - JVMFlag* result = JVMFlag::find_flag(name, len); - return boolAtPut(result, value, origin); -} - -JVMFlag::Error JVMFlagEx::boolAtPut(JVMFlagsWithType flag, bool value, JVMFlag::Flags origin) { - JVMFlag* faddr = address_of_flag(flag); - guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type"); - return JVMFlag::boolAtPut(faddr, &value, origin); -} - -static JVMFlag::Error apply_constraint_and_check_range_int(const char* name, int new_value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - JVMFlagRange* range = JVMFlagRangeList::find(name); - if (range != NULL) { - status = range->check_int(new_value, verbose); - } - if (status == JVMFlag::SUCCESS) { - JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - status = constraint->apply_int(new_value, verbose); - } - } - return status; -} - -JVMFlag::Error JVMFlag::intAt(const char* name, size_t len, int* value, bool allow_locked, bool return_flag) { - JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag); - if (result == NULL) return JVMFlag::INVALID_FLAG; - if (!result->is_int()) return JVMFlag::WRONG_FORMAT; - *value = result->get_int(); - return JVMFlag::SUCCESS; -} - -JVMFlag::Error JVMFlag::intAtPut(JVMFlag* flag, int* value, JVMFlag::Flags origin) { - const char* name; - if (flag == NULL) return JVMFlag::INVALID_FLAG; - if (!flag->is_int()) return JVMFlag::WRONG_FORMAT; - name = flag->_name; - JVMFlag::Error check = apply_constraint_and_check_range_int(name, *value, !JVMFlagConstraintList::validated_after_ergo()); - if (check != JVMFlag::SUCCESS) return check; - int old_value = flag->get_int(); - trace_flag_changed<EventIntFlagChanged, s4>(name, old_value, *value, origin); - check = flag->set_int(*value); - *value = old_value; - flag->set_origin(origin); - return check; -} - -JVMFlag::Error JVMFlag::intAtPut(const char* name, size_t len, int* value, JVMFlag::Flags origin) { - JVMFlag* result = JVMFlag::find_flag(name, len); - return intAtPut(result, value, origin); -} - -JVMFlag::Error JVMFlagEx::intAtPut(JVMFlagsWithType flag, int value, JVMFlag::Flags origin) { - JVMFlag* faddr = address_of_flag(flag); - guarantee(faddr != NULL && faddr->is_int(), "wrong flag type"); - return JVMFlag::intAtPut(faddr, &value, origin); -} - -static JVMFlag::Error apply_constraint_and_check_range_uint(const char* name, uint new_value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - JVMFlagRange* range = JVMFlagRangeList::find(name); - if (range != NULL) { - status = range->check_uint(new_value, verbose); - } - if (status == JVMFlag::SUCCESS) { - JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - status = constraint->apply_uint(new_value, verbose); - } - } - return status; -} - -JVMFlag::Error JVMFlag::uintAt(const char* name, size_t len, uint* value, bool allow_locked, bool return_flag) { - JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag); - if (result == NULL) return JVMFlag::INVALID_FLAG; - if (!result->is_uint()) return JVMFlag::WRONG_FORMAT; - *value = result->get_uint(); - return JVMFlag::SUCCESS; -} - -JVMFlag::Error JVMFlag::uintAtPut(JVMFlag* flag, uint* value, JVMFlag::Flags origin) { - const char* name; - if (flag == NULL) return JVMFlag::INVALID_FLAG; - if (!flag->is_uint()) return JVMFlag::WRONG_FORMAT; - name = flag->_name; - JVMFlag::Error check = apply_constraint_and_check_range_uint(name, *value, !JVMFlagConstraintList::validated_after_ergo()); - if (check != JVMFlag::SUCCESS) return check; - uint old_value = flag->get_uint(); - trace_flag_changed<EventUnsignedIntFlagChanged, u4>(name, old_value, *value, origin); - check = flag->set_uint(*value); - *value = old_value; - flag->set_origin(origin); - return check; -} - -JVMFlag::Error JVMFlag::uintAtPut(const char* name, size_t len, uint* value, JVMFlag::Flags origin) { - JVMFlag* result = JVMFlag::find_flag(name, len); - return uintAtPut(result, value, origin); -} - -JVMFlag::Error JVMFlagEx::uintAtPut(JVMFlagsWithType flag, uint value, JVMFlag::Flags origin) { - JVMFlag* faddr = address_of_flag(flag); - guarantee(faddr != NULL && faddr->is_uint(), "wrong flag type"); - return JVMFlag::uintAtPut(faddr, &value, origin); -} - -JVMFlag::Error JVMFlag::intxAt(const char* name, size_t len, intx* value, bool allow_locked, bool return_flag) { - JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag); - if (result == NULL) return JVMFlag::INVALID_FLAG; - if (!result->is_intx()) return JVMFlag::WRONG_FORMAT; - *value = result->get_intx(); - return JVMFlag::SUCCESS; -} - -static JVMFlag::Error apply_constraint_and_check_range_intx(const char* name, intx new_value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - JVMFlagRange* range = JVMFlagRangeList::find(name); - if (range != NULL) { - status = range->check_intx(new_value, verbose); - } - if (status == JVMFlag::SUCCESS) { - JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - status = constraint->apply_intx(new_value, verbose); - } - } - return status; -} - -JVMFlag::Error JVMFlag::intxAtPut(JVMFlag* flag, intx* value, JVMFlag::Flags origin) { - const char* name; - if (flag == NULL) return JVMFlag::INVALID_FLAG; - if (!flag->is_intx()) return JVMFlag::WRONG_FORMAT; - name = flag->_name; - JVMFlag::Error check = apply_constraint_and_check_range_intx(name, *value, !JVMFlagConstraintList::validated_after_ergo()); - if (check != JVMFlag::SUCCESS) return check; - intx old_value = flag->get_intx(); - trace_flag_changed<EventLongFlagChanged, intx>(name, old_value, *value, origin); - check = flag->set_intx(*value); - *value = old_value; - flag->set_origin(origin); - return check; -} - -JVMFlag::Error JVMFlag::intxAtPut(const char* name, size_t len, intx* value, JVMFlag::Flags origin) { - JVMFlag* result = JVMFlag::find_flag(name, len); - return intxAtPut(result, value, origin); -} - -JVMFlag::Error JVMFlagEx::intxAtPut(JVMFlagsWithType flag, intx value, JVMFlag::Flags origin) { - JVMFlag* faddr = address_of_flag(flag); - guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type"); - return JVMFlag::intxAtPut(faddr, &value, origin); -} - -JVMFlag::Error JVMFlag::uintxAt(const char* name, size_t len, uintx* value, bool allow_locked, bool return_flag) { - JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag); - if (result == NULL) return JVMFlag::INVALID_FLAG; - if (!result->is_uintx()) return JVMFlag::WRONG_FORMAT; - *value = result->get_uintx(); - return JVMFlag::SUCCESS; -} - -static JVMFlag::Error apply_constraint_and_check_range_uintx(const char* name, uintx new_value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - JVMFlagRange* range = JVMFlagRangeList::find(name); - if (range != NULL) { - status = range->check_uintx(new_value, verbose); - } - if (status == JVMFlag::SUCCESS) { - JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - status = constraint->apply_uintx(new_value, verbose); - } - } - return status; -} - -JVMFlag::Error JVMFlag::uintxAtPut(JVMFlag* flag, uintx* value, JVMFlag::Flags origin) { - const char* name; - if (flag == NULL) return JVMFlag::INVALID_FLAG; - if (!flag->is_uintx()) return JVMFlag::WRONG_FORMAT; - name = flag->_name; - JVMFlag::Error check = apply_constraint_and_check_range_uintx(name, *value, !JVMFlagConstraintList::validated_after_ergo()); - if (check != JVMFlag::SUCCESS) return check; - uintx old_value = flag->get_uintx(); - trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); - check = flag->set_uintx(*value); - *value = old_value; - flag->set_origin(origin); - return check; -} - -JVMFlag::Error JVMFlag::uintxAtPut(const char* name, size_t len, uintx* value, JVMFlag::Flags origin) { - JVMFlag* result = JVMFlag::find_flag(name, len); - return uintxAtPut(result, value, origin); -} - -JVMFlag::Error JVMFlagEx::uintxAtPut(JVMFlagsWithType flag, uintx value, JVMFlag::Flags origin) { - JVMFlag* faddr = address_of_flag(flag); - guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type"); - return JVMFlag::uintxAtPut(faddr, &value, origin); -} - -JVMFlag::Error JVMFlag::uint64_tAt(const char* name, size_t len, uint64_t* value, bool allow_locked, bool return_flag) { - JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag); - if (result == NULL) return JVMFlag::INVALID_FLAG; - if (!result->is_uint64_t()) return JVMFlag::WRONG_FORMAT; - *value = result->get_uint64_t(); - return JVMFlag::SUCCESS; -} - -static JVMFlag::Error apply_constraint_and_check_range_uint64_t(const char* name, uint64_t new_value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - JVMFlagRange* range = JVMFlagRangeList::find(name); - if (range != NULL) { - status = range->check_uint64_t(new_value, verbose); - } - if (status == JVMFlag::SUCCESS) { - JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - status = constraint->apply_uint64_t(new_value, verbose); - } - } - return status; -} - -JVMFlag::Error JVMFlag::uint64_tAtPut(JVMFlag* flag, uint64_t* value, JVMFlag::Flags origin) { - const char* name; - if (flag == NULL) return JVMFlag::INVALID_FLAG; - if (!flag->is_uint64_t()) return JVMFlag::WRONG_FORMAT; - name = flag->_name; - JVMFlag::Error check = apply_constraint_and_check_range_uint64_t(name, *value, !JVMFlagConstraintList::validated_after_ergo()); - if (check != JVMFlag::SUCCESS) return check; - uint64_t old_value = flag->get_uint64_t(); - trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); - check = flag->set_uint64_t(*value); - *value = old_value; - flag->set_origin(origin); - return check; -} - -JVMFlag::Error JVMFlag::uint64_tAtPut(const char* name, size_t len, uint64_t* value, JVMFlag::Flags origin) { - JVMFlag* result = JVMFlag::find_flag(name, len); - return uint64_tAtPut(result, value, origin); -} - -JVMFlag::Error JVMFlagEx::uint64_tAtPut(JVMFlagsWithType flag, uint64_t value, JVMFlag::Flags origin) { - JVMFlag* faddr = address_of_flag(flag); - guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type"); - return JVMFlag::uint64_tAtPut(faddr, &value, origin); -} - -JVMFlag::Error JVMFlag::size_tAt(const char* name, size_t len, size_t* value, bool allow_locked, bool return_flag) { - JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag); - if (result == NULL) return JVMFlag::INVALID_FLAG; - if (!result->is_size_t()) return JVMFlag::WRONG_FORMAT; - *value = result->get_size_t(); - return JVMFlag::SUCCESS; -} - -static JVMFlag::Error apply_constraint_and_check_range_size_t(const char* name, size_t new_value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - JVMFlagRange* range = JVMFlagRangeList::find(name); - if (range != NULL) { - status = range->check_size_t(new_value, verbose); - } - if (status == JVMFlag::SUCCESS) { - JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - status = constraint->apply_size_t(new_value, verbose); - } - } - return status; -} - - -JVMFlag::Error JVMFlag::size_tAtPut(JVMFlag* flag, size_t* value, JVMFlag::Flags origin) { - const char* name; - if (flag == NULL) return JVMFlag::INVALID_FLAG; - if (!flag->is_size_t()) return JVMFlag::WRONG_FORMAT; - name = flag->_name; - JVMFlag::Error check = apply_constraint_and_check_range_size_t(name, *value, !JVMFlagConstraintList::validated_after_ergo()); - if (check != JVMFlag::SUCCESS) return check; - size_t old_value = flag->get_size_t(); - trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); - check = flag->set_size_t(*value); - *value = old_value; - flag->set_origin(origin); - return check; -} - -JVMFlag::Error JVMFlag::size_tAtPut(const char* name, size_t len, size_t* value, JVMFlag::Flags origin) { - JVMFlag* result = JVMFlag::find_flag(name, len); - return size_tAtPut(result, value, origin); -} - -JVMFlag::Error JVMFlagEx::size_tAtPut(JVMFlagsWithType flag, size_t value, JVMFlag::Flags origin) { - JVMFlag* faddr = address_of_flag(flag); - guarantee(faddr != NULL && faddr->is_size_t(), "wrong flag type"); - return JVMFlag::size_tAtPut(faddr, &value, origin); -} - -JVMFlag::Error JVMFlag::doubleAt(const char* name, size_t len, double* value, bool allow_locked, bool return_flag) { - JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag); - if (result == NULL) return JVMFlag::INVALID_FLAG; - if (!result->is_double()) return JVMFlag::WRONG_FORMAT; - *value = result->get_double(); - return JVMFlag::SUCCESS; -} - -static JVMFlag::Error apply_constraint_and_check_range_double(const char* name, double new_value, bool verbose) { - JVMFlag::Error status = JVMFlag::SUCCESS; - JVMFlagRange* range = JVMFlagRangeList::find(name); - if (range != NULL) { - status = range->check_double(new_value, verbose); - } - if (status == JVMFlag::SUCCESS) { - JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - status = constraint->apply_double(new_value, verbose); - } - } - return status; -} - -JVMFlag::Error JVMFlag::doubleAtPut(JVMFlag* flag, double* value, JVMFlag::Flags origin) { - const char* name; - if (flag == NULL) return JVMFlag::INVALID_FLAG; - if (!flag->is_double()) return JVMFlag::WRONG_FORMAT; - name = flag->_name; - JVMFlag::Error check = apply_constraint_and_check_range_double(name, *value, !JVMFlagConstraintList::validated_after_ergo()); - if (check != JVMFlag::SUCCESS) return check; - double old_value = flag->get_double(); - trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin); - check = flag->set_double(*value); - *value = old_value; - flag->set_origin(origin); - return check; -} - -JVMFlag::Error JVMFlag::doubleAtPut(const char* name, size_t len, double* value, JVMFlag::Flags origin) { - JVMFlag* result = JVMFlag::find_flag(name, len); - return doubleAtPut(result, value, origin); -} - -JVMFlag::Error JVMFlagEx::doubleAtPut(JVMFlagsWithType flag, double value, JVMFlag::Flags origin) { - JVMFlag* faddr = address_of_flag(flag); - guarantee(faddr != NULL && faddr->is_double(), "wrong flag type"); - return JVMFlag::doubleAtPut(faddr, &value, origin); -} - -JVMFlag::Error JVMFlag::ccstrAt(const char* name, size_t len, ccstr* value, bool allow_locked, bool return_flag) { - JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag); - if (result == NULL) return JVMFlag::INVALID_FLAG; - if (!result->is_ccstr()) return JVMFlag::WRONG_FORMAT; - *value = result->get_ccstr(); - return JVMFlag::SUCCESS; -} - -JVMFlag::Error JVMFlag::ccstrAtPut(const char* name, size_t len, ccstr* value, JVMFlag::Flags origin) { - JVMFlag* result = JVMFlag::find_flag(name, len); - if (result == NULL) return JVMFlag::INVALID_FLAG; - if (!result->is_ccstr()) return JVMFlag::WRONG_FORMAT; - ccstr old_value = result->get_ccstr(); - trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin); - char* new_value = NULL; - if (*value != NULL) { - new_value = os::strdup_check_oom(*value); - } - JVMFlag::Error check = result->set_ccstr(new_value); - if (result->is_default() && old_value != NULL) { - // Prior value is NOT heap allocated, but was a literal constant. - old_value = os::strdup_check_oom(old_value); - } - *value = old_value; - result->set_origin(origin); - return check; -} - -JVMFlag::Error JVMFlagEx::ccstrAtPut(JVMFlagsWithType flag, ccstr value, JVMFlag::Flags origin) { - JVMFlag* faddr = address_of_flag(flag); - guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); - ccstr old_value = faddr->get_ccstr(); - trace_flag_changed<EventStringFlagChanged, const char*>(faddr->_name, old_value, value, origin); - char* new_value = os::strdup_check_oom(value); - JVMFlag::Error check = faddr->set_ccstr(new_value); - if (!faddr->is_default() && old_value != NULL) { - // Prior value is heap allocated so free it. - FREE_C_HEAP_ARRAY(char, old_value); - } - faddr->set_origin(origin); - return check; -} - -extern "C" { - static int compare_flags(const void* void_a, const void* void_b) { - return strcmp((*((JVMFlag**) void_a))->_name, (*((JVMFlag**) void_b))->_name); - } -} - -void JVMFlag::printSetFlags(outputStream* out) { - // Print which flags were set on the command line - // note: this method is called before the thread structure is in place - // which means resource allocation cannot be used. - - // The last entry is the null entry. - const size_t length = JVMFlag::numFlags - 1; - - // Sort - JVMFlag** array = NEW_C_HEAP_ARRAY(JVMFlag*, length, mtArguments); - for (size_t i = 0; i < length; i++) { - array[i] = &flagTable[i]; - } - qsort(array, length, sizeof(JVMFlag*), compare_flags); - - // Print - for (size_t i = 0; i < length; i++) { - if (array[i]->get_origin() /* naked field! */) { - array[i]->print_as_flag(out); - out->print(" "); - } - } - out->cr(); - FREE_C_HEAP_ARRAY(JVMFlag*, array); -} - -#ifndef PRODUCT - -void JVMFlag::verify() { - assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict"); -} - -#endif // PRODUCT - -void JVMFlag::printFlags(outputStream* out, bool withComments, bool printRanges) { - // Print the flags sorted by name - // note: this method is called before the thread structure is in place - // which means resource allocation cannot be used. - - // The last entry is the null entry. - const size_t length = JVMFlag::numFlags - 1; - - // Sort - JVMFlag** array = NEW_C_HEAP_ARRAY(JVMFlag*, length, mtArguments); - for (size_t i = 0; i < length; i++) { - array[i] = &flagTable[i]; - } - qsort(array, length, sizeof(JVMFlag*), compare_flags); - - // Print - if (!printRanges) { - out->print_cr("[Global flags]"); - } else { - out->print_cr("[Global flags ranges]"); - } - - for (size_t i = 0; i < length; i++) { - if (array[i]->is_unlocked()) { - array[i]->print_on(out, withComments, printRanges); - } - } - FREE_C_HEAP_ARRAY(JVMFlag*, array); -} -
--- a/src/hotspot/share/runtime/flags/jvmFlag.hpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,283 +0,0 @@ -/* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_RUNTIME_FLAGS_JVMFLAG_HPP -#define SHARE_VM_RUNTIME_FLAGS_JVMFLAG_HPP - -#include "utilities/globalDefinitions.hpp" -#include "utilities/macros.hpp" - -// function type that will construct default range string -typedef const char* (*RangeStrFunc)(void); - -struct JVMFlag { - enum Flags { - // latest value origin - DEFAULT = 0, - COMMAND_LINE = 1, - ENVIRON_VAR = 2, - CONFIG_FILE = 3, - MANAGEMENT = 4, - ERGONOMIC = 5, - ATTACH_ON_DEMAND = 6, - INTERNAL = 7, - - LAST_VALUE_ORIGIN = INTERNAL, - VALUE_ORIGIN_BITS = 4, - VALUE_ORIGIN_MASK = right_n_bits(VALUE_ORIGIN_BITS), - - // flag kind - KIND_PRODUCT = 1 << 4, - KIND_MANAGEABLE = 1 << 5, - KIND_DIAGNOSTIC = 1 << 6, - KIND_EXPERIMENTAL = 1 << 7, - KIND_NOT_PRODUCT = 1 << 8, - KIND_DEVELOP = 1 << 9, - KIND_PLATFORM_DEPENDENT = 1 << 10, - KIND_READ_WRITE = 1 << 11, - KIND_C1 = 1 << 12, - KIND_C2 = 1 << 13, - KIND_ARCH = 1 << 14, - KIND_LP64_PRODUCT = 1 << 15, - KIND_COMMERCIAL = 1 << 16, - KIND_JVMCI = 1 << 17, - - // set this bit if the flag was set on the command line - ORIG_COMMAND_LINE = 1 << 18, - - KIND_MASK = ~(VALUE_ORIGIN_MASK | ORIG_COMMAND_LINE) - }; - - enum Error { - // no error - SUCCESS = 0, - // flag name is missing - MISSING_NAME, - // flag value is missing - MISSING_VALUE, - // error parsing the textual form of the value - WRONG_FORMAT, - // flag is not writable - NON_WRITABLE, - // flag value is outside of its bounds - OUT_OF_BOUNDS, - // flag value violates its constraint - VIOLATES_CONSTRAINT, - // there is no flag with the given name - INVALID_FLAG, - // the flag can only be set only on command line during invocation of the VM - COMMAND_LINE_ONLY, - // the flag may only be set once - SET_ONLY_ONCE, - // the flag is not writable in this combination of product/debug build - CONSTANT, - // other, unspecified error related to setting the flag - ERR_OTHER - }; - - enum MsgType { - NONE = 0, - DIAGNOSTIC_FLAG_BUT_LOCKED, - EXPERIMENTAL_FLAG_BUT_LOCKED, - DEVELOPER_FLAG_BUT_PRODUCT_BUILD, - NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD, - COMMERCIAL_FLAG_BUT_DISABLED, - COMMERCIAL_FLAG_BUT_LOCKED - }; - - const char* _type; - const char* _name; - void* _addr; - NOT_PRODUCT(const char* _doc;) - Flags _flags; - size_t _name_len; - - // points to all Flags static array - static JVMFlag* flags; - - // number of flags - static size_t numFlags; - - static JVMFlag* find_flag(const char* name) { return find_flag(name, strlen(name), true, true); }; - static JVMFlag* find_flag(const char* name, size_t length, bool allow_locked = false, bool return_flag = false); - static JVMFlag* fuzzy_match(const char* name, size_t length, bool allow_locked = false); - - static const char* get_int_default_range_str(); - static const char* get_uint_default_range_str(); - static const char* get_intx_default_range_str(); - static const char* get_uintx_default_range_str(); - static const char* get_uint64_t_default_range_str(); - static const char* get_size_t_default_range_str(); - static const char* get_double_default_range_str(); - - JVMFlag::Error check_writable(bool changed); - - bool is_bool() const; - bool get_bool() const; - JVMFlag::Error set_bool(bool value); - - bool is_int() const; - int get_int() const; - JVMFlag::Error set_int(int value); - - bool is_uint() const; - uint get_uint() const; - JVMFlag::Error set_uint(uint value); - - bool is_intx() const; - intx get_intx() const; - JVMFlag::Error set_intx(intx value); - - bool is_uintx() const; - uintx get_uintx() const; - JVMFlag::Error set_uintx(uintx value); - - bool is_uint64_t() const; - uint64_t get_uint64_t() const; - JVMFlag::Error set_uint64_t(uint64_t value); - - bool is_size_t() const; - size_t get_size_t() const; - JVMFlag::Error set_size_t(size_t value); - - bool is_double() const; - double get_double() const; - JVMFlag::Error set_double(double value); - - bool is_ccstr() const; - bool ccstr_accumulates() const; - ccstr get_ccstr() const; - JVMFlag::Error set_ccstr(ccstr value); - - Flags get_origin(); - void set_origin(Flags origin); - - size_t get_name_length(); - - bool is_default(); - bool is_ergonomic(); - bool is_command_line(); - void set_command_line(); - - bool is_product() const; - bool is_manageable() const; - bool is_diagnostic() const; - bool is_experimental() const; - bool is_notproduct() const; - bool is_develop() const; - bool is_read_write() const; - bool is_commercial() const; - - bool is_constant_in_binary() const; - - bool is_unlocker() const; - bool is_unlocked() const; - bool is_writeable() const; - bool is_external() const; - - bool is_unlocker_ext() const; - bool is_unlocked_ext() const; - bool is_writeable_ext() const; - bool is_external_ext() const; - - void clear_diagnostic(); - - JVMFlag::MsgType get_locked_message(char*, int) const; - JVMFlag::MsgType get_locked_message_ext(char*, int) const; - - // printRanges will print out flags type, name and range values as expected by -XX:+PrintFlagsRanges - void print_on(outputStream* st, bool withComments = false, bool printRanges = false); - void print_kind(outputStream* st, unsigned int width); - void print_origin(outputStream* st, unsigned int width); - void print_as_flag(outputStream* st); - - static const char* flag_error_str(JVMFlag::Error error); - -public: - static JVMFlag::Error boolAt(const char* name, size_t len, bool* value, bool allow_locked = false, bool return_flag = false); - static JVMFlag::Error boolAt(const char* name, bool* value, bool allow_locked = false, bool return_flag = false) { return boolAt(name, strlen(name), value, allow_locked, return_flag); } - static JVMFlag::Error boolAtPut(JVMFlag* flag, bool* value, JVMFlag::Flags origin); - static JVMFlag::Error boolAtPut(const char* name, size_t len, bool* value, JVMFlag::Flags origin); - static JVMFlag::Error boolAtPut(const char* name, bool* value, JVMFlag::Flags origin) { return boolAtPut(name, strlen(name), value, origin); } - - static JVMFlag::Error intAt(const char* name, size_t len, int* value, bool allow_locked = false, bool return_flag = false); - static JVMFlag::Error intAt(const char* name, int* value, bool allow_locked = false, bool return_flag = false) { return intAt(name, strlen(name), value, allow_locked, return_flag); } - static JVMFlag::Error intAtPut(JVMFlag* flag, int* value, JVMFlag::Flags origin); - static JVMFlag::Error intAtPut(const char* name, size_t len, int* value, JVMFlag::Flags origin); - static JVMFlag::Error intAtPut(const char* name, int* value, JVMFlag::Flags origin) { return intAtPut(name, strlen(name), value, origin); } - - static JVMFlag::Error uintAt(const char* name, size_t len, uint* value, bool allow_locked = false, bool return_flag = false); - static JVMFlag::Error uintAt(const char* name, uint* value, bool allow_locked = false, bool return_flag = false) { return uintAt(name, strlen(name), value, allow_locked, return_flag); } - static JVMFlag::Error uintAtPut(JVMFlag* flag, uint* value, JVMFlag::Flags origin); - static JVMFlag::Error uintAtPut(const char* name, size_t len, uint* value, JVMFlag::Flags origin); - static JVMFlag::Error uintAtPut(const char* name, uint* value, JVMFlag::Flags origin) { return uintAtPut(name, strlen(name), value, origin); } - - static JVMFlag::Error intxAt(const char* name, size_t len, intx* value, bool allow_locked = false, bool return_flag = false); - static JVMFlag::Error intxAt(const char* name, intx* value, bool allow_locked = false, bool return_flag = false) { return intxAt(name, strlen(name), value, allow_locked, return_flag); } - static JVMFlag::Error intxAtPut(JVMFlag* flag, intx* value, JVMFlag::Flags origin); - static JVMFlag::Error intxAtPut(const char* name, size_t len, intx* value, JVMFlag::Flags origin); - static JVMFlag::Error intxAtPut(const char* name, intx* value, JVMFlag::Flags origin) { return intxAtPut(name, strlen(name), value, origin); } - - static JVMFlag::Error uintxAt(const char* name, size_t len, uintx* value, bool allow_locked = false, bool return_flag = false); - static JVMFlag::Error uintxAt(const char* name, uintx* value, bool allow_locked = false, bool return_flag = false) { return uintxAt(name, strlen(name), value, allow_locked, return_flag); } - static JVMFlag::Error uintxAtPut(JVMFlag* flag, uintx* value, JVMFlag::Flags origin); - static JVMFlag::Error uintxAtPut(const char* name, size_t len, uintx* value, JVMFlag::Flags origin); - static JVMFlag::Error uintxAtPut(const char* name, uintx* value, JVMFlag::Flags origin) { return uintxAtPut(name, strlen(name), value, origin); } - - static JVMFlag::Error size_tAt(const char* name, size_t len, size_t* value, bool allow_locked = false, bool return_flag = false); - static JVMFlag::Error size_tAt(const char* name, size_t* value, bool allow_locked = false, bool return_flag = false) { return size_tAt(name, strlen(name), value, allow_locked, return_flag); } - static JVMFlag::Error size_tAtPut(JVMFlag* flag, size_t* value, JVMFlag::Flags origin); - static JVMFlag::Error size_tAtPut(const char* name, size_t len, size_t* value, JVMFlag::Flags origin); - static JVMFlag::Error size_tAtPut(const char* name, size_t* value, JVMFlag::Flags origin) { return size_tAtPut(name, strlen(name), value, origin); } - - static JVMFlag::Error uint64_tAt(const char* name, size_t len, uint64_t* value, bool allow_locked = false, bool return_flag = false); - static JVMFlag::Error uint64_tAt(const char* name, uint64_t* value, bool allow_locked = false, bool return_flag = false) { return uint64_tAt(name, strlen(name), value, allow_locked, return_flag); } - static JVMFlag::Error uint64_tAtPut(JVMFlag* flag, uint64_t* value, JVMFlag::Flags origin); - static JVMFlag::Error uint64_tAtPut(const char* name, size_t len, uint64_t* value, JVMFlag::Flags origin); - static JVMFlag::Error uint64_tAtPut(const char* name, uint64_t* value, JVMFlag::Flags origin) { return uint64_tAtPut(name, strlen(name), value, origin); } - - static JVMFlag::Error doubleAt(const char* name, size_t len, double* value, bool allow_locked = false, bool return_flag = false); - static JVMFlag::Error doubleAt(const char* name, double* value, bool allow_locked = false, bool return_flag = false) { return doubleAt(name, strlen(name), value, allow_locked, return_flag); } - static JVMFlag::Error doubleAtPut(JVMFlag* flag, double* value, JVMFlag::Flags origin); - static JVMFlag::Error doubleAtPut(const char* name, size_t len, double* value, JVMFlag::Flags origin); - static JVMFlag::Error doubleAtPut(const char* name, double* value, JVMFlag::Flags origin) { return doubleAtPut(name, strlen(name), value, origin); } - - static JVMFlag::Error ccstrAt(const char* name, size_t len, ccstr* value, bool allow_locked = false, bool return_flag = false); - static JVMFlag::Error ccstrAt(const char* name, ccstr* value, bool allow_locked = false, bool return_flag = false) { return ccstrAt(name, strlen(name), value, allow_locked, return_flag); } - // Contract: JVMFlag will make private copy of the incoming value. - // Outgoing value is always malloc-ed, and caller MUST call free. - static JVMFlag::Error ccstrAtPut(const char* name, size_t len, ccstr* value, JVMFlag::Flags origin); - static JVMFlag::Error ccstrAtPut(const char* name, ccstr* value, JVMFlag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); } - - // Returns false if name is not a command line flag. - static bool wasSetOnCmdline(const char* name, bool* value); - static void printSetFlags(outputStream* out); - - // printRanges will print out flags type, name and range values as expected by -XX:+PrintFlagsRanges - static void printFlags(outputStream* out, bool withComments, bool printRanges = false); - - static void verify() PRODUCT_RETURN; -}; - -#endif // SHARE_VM_RUNTIME_FLAGS_JVMFLAG_HPP
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,368 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "classfile/stringTable.hpp" -#include "classfile/symbolTable.hpp" -#include "gc/shared/jvmFlagConstraintsGC.hpp" -#include "runtime/arguments.hpp" -#include "runtime/flags/jvmFlag.hpp" -#include "runtime/flags/jvmFlagConstraintList.hpp" -#include "runtime/flags/jvmFlagConstraintsCompiler.hpp" -#include "runtime/flags/jvmFlagConstraintsRuntime.hpp" -#include "runtime/os.hpp" -#include "utilities/macros.hpp" -#ifdef COMPILER1 -#include "c1/c1_globals.hpp" -#endif -#ifdef COMPILER2 -#include "opto/c2_globals.hpp" -#endif - -class JVMFlagConstraint_bool : public JVMFlagConstraint { - JVMFlagConstraintFunc_bool _constraint; - const bool* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagConstraint_bool(const char* name, const bool* ptr, - JVMFlagConstraintFunc_bool func, - ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} - - JVMFlag::Error apply(bool verbose) { - bool value = *_ptr; - return _constraint(value, verbose); - } - - JVMFlag::Error apply_bool(bool value, bool verbose) { - return _constraint(value, verbose); - } -}; - -class JVMFlagConstraint_int : public JVMFlagConstraint { - JVMFlagConstraintFunc_int _constraint; - const int* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagConstraint_int(const char* name, const int* ptr, - JVMFlagConstraintFunc_int func, - ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} - - JVMFlag::Error apply(bool verbose) { - int value = *_ptr; - return _constraint(value, verbose); - } - - JVMFlag::Error apply_int(int value, bool verbose) { - return _constraint(value, verbose); - } -}; - -class JVMFlagConstraint_intx : public JVMFlagConstraint { - JVMFlagConstraintFunc_intx _constraint; - const intx* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagConstraint_intx(const char* name, const intx* ptr, - JVMFlagConstraintFunc_intx func, - ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} - - JVMFlag::Error apply(bool verbose) { - intx value = *_ptr; - return _constraint(value, verbose); - } - - JVMFlag::Error apply_intx(intx value, bool verbose) { - return _constraint(value, verbose); - } -}; - -class JVMFlagConstraint_uint : public JVMFlagConstraint { - JVMFlagConstraintFunc_uint _constraint; - const uint* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagConstraint_uint(const char* name, const uint* ptr, - JVMFlagConstraintFunc_uint func, - ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} - - JVMFlag::Error apply(bool verbose) { - uint value = *_ptr; - return _constraint(value, verbose); - } - - JVMFlag::Error apply_uint(uint value, bool verbose) { - return _constraint(value, verbose); - } -}; - -class JVMFlagConstraint_uintx : public JVMFlagConstraint { - JVMFlagConstraintFunc_uintx _constraint; - const uintx* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagConstraint_uintx(const char* name, const uintx* ptr, - JVMFlagConstraintFunc_uintx func, - ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} - - JVMFlag::Error apply(bool verbose) { - uintx value = *_ptr; - return _constraint(value, verbose); - } - - JVMFlag::Error apply_uintx(uintx value, bool verbose) { - return _constraint(value, verbose); - } -}; - -class JVMFlagConstraint_uint64_t : public JVMFlagConstraint { - JVMFlagConstraintFunc_uint64_t _constraint; - const uint64_t* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagConstraint_uint64_t(const char* name, const uint64_t* ptr, - JVMFlagConstraintFunc_uint64_t func, - ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} - - JVMFlag::Error apply(bool verbose) { - uint64_t value = *_ptr; - return _constraint(value, verbose); - } - - JVMFlag::Error apply_uint64_t(uint64_t value, bool verbose) { - return _constraint(value, verbose); - } -}; - -class JVMFlagConstraint_size_t : public JVMFlagConstraint { - JVMFlagConstraintFunc_size_t _constraint; - const size_t* _ptr; -public: - // the "name" argument must be a string literal - JVMFlagConstraint_size_t(const char* name, const size_t* ptr, - JVMFlagConstraintFunc_size_t func, - ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} - - JVMFlag::Error apply(bool verbose) { - size_t value = *_ptr; - return _constraint(value, verbose); - } - - JVMFlag::Error apply_size_t(size_t value, bool verbose) { - return _constraint(value, verbose); - } -}; - -class JVMFlagConstraint_double : public JVMFlagConstraint { - JVMFlagConstraintFunc_double _constraint; - const double* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagConstraint_double(const char* name, const double* ptr, - JVMFlagConstraintFunc_double func, - ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} - - JVMFlag::Error apply(bool verbose) { - double value = *_ptr; - return _constraint(value, verbose); - } - - JVMFlag::Error apply_double(double value, bool verbose) { - return _constraint(value, verbose); - } -}; - -// No constraint emitting -void emit_constraint_no(...) { /* NOP */ } - -// No constraint emitting if function argument is NOT provided -void emit_constraint_bool(const char* /*name*/, const bool* /*value*/) { /* NOP */ } -void emit_constraint_ccstr(const char* /*name*/, const ccstr* /*value*/) { /* NOP */ } -void emit_constraint_ccstrlist(const char* /*name*/, const ccstrlist* /*value*/) { /* NOP */ } -void emit_constraint_int(const char* /*name*/, const int* /*value*/) { /* NOP */ } -void emit_constraint_intx(const char* /*name*/, const intx* /*value*/) { /* NOP */ } -void emit_constraint_uint(const char* /*name*/, const uint* /*value*/) { /* NOP */ } -void emit_constraint_uintx(const char* /*name*/, const uintx* /*value*/) { /* NOP */ } -void emit_constraint_uint64_t(const char* /*name*/, const uint64_t* /*value*/) { /* NOP */ } -void emit_constraint_size_t(const char* /*name*/, const size_t* /*value*/) { /* NOP */ } -void emit_constraint_double(const char* /*name*/, const double* /*value*/) { /* NOP */ } - -// JVMFlagConstraint emitting code functions if function argument is provided -void emit_constraint_bool(const char* name, const bool* ptr, JVMFlagConstraintFunc_bool func, JVMFlagConstraint::ConstraintType type) { - JVMFlagConstraintList::add(new JVMFlagConstraint_bool(name, ptr, func, type)); -} -void emit_constraint_int(const char* name, const int* ptr, JVMFlagConstraintFunc_int func, JVMFlagConstraint::ConstraintType type) { - JVMFlagConstraintList::add(new JVMFlagConstraint_int(name, ptr, func, type)); -} -void emit_constraint_intx(const char* name, const intx* ptr, JVMFlagConstraintFunc_intx func, JVMFlagConstraint::ConstraintType type) { - JVMFlagConstraintList::add(new JVMFlagConstraint_intx(name, ptr, func, type)); -} -void emit_constraint_uint(const char* name, const uint* ptr, JVMFlagConstraintFunc_uint func, JVMFlagConstraint::ConstraintType type) { - JVMFlagConstraintList::add(new JVMFlagConstraint_uint(name, ptr, func, type)); -} -void emit_constraint_uintx(const char* name, const uintx* ptr, JVMFlagConstraintFunc_uintx func, JVMFlagConstraint::ConstraintType type) { - JVMFlagConstraintList::add(new JVMFlagConstraint_uintx(name, ptr, func, type)); -} -void emit_constraint_uint64_t(const char* name, const uint64_t* ptr, JVMFlagConstraintFunc_uint64_t func, JVMFlagConstraint::ConstraintType type) { - JVMFlagConstraintList::add(new JVMFlagConstraint_uint64_t(name, ptr, func, type)); -} -void emit_constraint_size_t(const char* name, const size_t* ptr, JVMFlagConstraintFunc_size_t func, JVMFlagConstraint::ConstraintType type) { - JVMFlagConstraintList::add(new JVMFlagConstraint_size_t(name, ptr, func, type)); -} -void emit_constraint_double(const char* name, const double* ptr, JVMFlagConstraintFunc_double func, JVMFlagConstraint::ConstraintType type) { - JVMFlagConstraintList::add(new JVMFlagConstraint_double(name, ptr, func, type)); -} - -// Generate code to call emit_constraint_xxx function -#define EMIT_CONSTRAINT_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name -#define EMIT_CONSTRAINT_COMMERCIAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name -#define EMIT_CONSTRAINT_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name -#define EMIT_CONSTRAINT_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name -#define EMIT_CONSTRAINT_MANAGEABLE_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name -#define EMIT_CONSTRAINT_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name -#define EMIT_CONSTRAINT_PD_PRODUCT_FLAG(type, name, doc) ); emit_constraint_##type(#name,&name -#define EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_constraint_##type(#name,&name -#ifndef PRODUCT -#define EMIT_CONSTRAINT_DEVELOPER_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name -#define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_##type(#name,&name -#define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name -#else -#define EMIT_CONSTRAINT_DEVELOPER_FLAG(type, name, value, doc) ); emit_constraint_no(#name,&name -#define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_no(#name,&name -#define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_no(#name,&name -#endif -#ifdef _LP64 -#define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name,&name -#else -#define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_no(#name,&name -#endif - -// Generate func argument to pass into emit_constraint_xxx functions -#define EMIT_CONSTRAINT_CHECK(func, type) , func, JVMFlagConstraint::type - -// the "name" argument must be a string literal -#define INITIAL_CONSTRAINTS_SIZE 72 -GrowableArray<JVMFlagConstraint*>* JVMFlagConstraintList::_constraints = NULL; -JVMFlagConstraint::ConstraintType JVMFlagConstraintList::_validating_type = JVMFlagConstraint::AtParse; - -// Check the ranges of all flags that have them or print them out and exit if requested -void JVMFlagConstraintList::init(void) { - _constraints = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<JVMFlagConstraint*>(INITIAL_CONSTRAINTS_SIZE, true); - - emit_constraint_no(NULL VM_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG, - EMIT_CONSTRAINT_PD_DEVELOPER_FLAG, - EMIT_CONSTRAINT_PRODUCT_FLAG, - EMIT_CONSTRAINT_PD_PRODUCT_FLAG, - EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, - EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, - EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, - EMIT_CONSTRAINT_NOTPRODUCT_FLAG, - EMIT_CONSTRAINT_MANAGEABLE_FLAG, - EMIT_CONSTRAINT_PRODUCT_RW_FLAG, - EMIT_CONSTRAINT_LP64_PRODUCT_FLAG, - IGNORE_RANGE, - EMIT_CONSTRAINT_CHECK, - IGNORE_WRITEABLE)); - - EMIT_CONSTRAINTS_FOR_GLOBALS_EXT - - emit_constraint_no(NULL ARCH_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG, - EMIT_CONSTRAINT_PRODUCT_FLAG, - EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, - EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, - EMIT_CONSTRAINT_NOTPRODUCT_FLAG, - IGNORE_RANGE, - EMIT_CONSTRAINT_CHECK, - IGNORE_WRITEABLE)); - - -#ifdef COMPILER1 - emit_constraint_no(NULL C1_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG, - EMIT_CONSTRAINT_PD_DEVELOPER_FLAG, - EMIT_CONSTRAINT_PRODUCT_FLAG, - EMIT_CONSTRAINT_PD_PRODUCT_FLAG, - EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, - EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, - EMIT_CONSTRAINT_NOTPRODUCT_FLAG, - IGNORE_RANGE, - EMIT_CONSTRAINT_CHECK, - IGNORE_WRITEABLE)); -#endif // COMPILER1 - -#ifdef COMPILER2 - emit_constraint_no(NULL C2_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG, - EMIT_CONSTRAINT_PD_DEVELOPER_FLAG, - EMIT_CONSTRAINT_PRODUCT_FLAG, - EMIT_CONSTRAINT_PD_PRODUCT_FLAG, - EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, - EMIT_CONSTRAINT_PD_DIAGNOSTIC_FLAG, - EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, - EMIT_CONSTRAINT_NOTPRODUCT_FLAG, - IGNORE_RANGE, - EMIT_CONSTRAINT_CHECK, - IGNORE_WRITEABLE)); -#endif // COMPILER2 -} - -JVMFlagConstraint* JVMFlagConstraintList::find(const char* name) { - JVMFlagConstraint* found = NULL; - for (int i=0; i<length(); i++) { - JVMFlagConstraint* constraint = at(i); - if (strcmp(constraint->name(), name) == 0) { - found = constraint; - break; - } - } - return found; -} - -// Find constraints by name and return only if found constraint's type is equal or lower than current validating type. -JVMFlagConstraint* JVMFlagConstraintList::find_if_needs_check(const char* name) { - JVMFlagConstraint* found = NULL; - JVMFlagConstraint* constraint = find(name); - if (constraint && (constraint->type() <= _validating_type)) { - found = constraint; - } - return found; -} - -// Check constraints for specific constraint type. -bool JVMFlagConstraintList::check_constraints(JVMFlagConstraint::ConstraintType type) { - guarantee(type > _validating_type, "Constraint check is out of order."); - _validating_type = type; - - bool status = true; - for (int i=0; i<length(); i++) { - JVMFlagConstraint* constraint = at(i); - if (type != constraint->type()) continue; - if (constraint->apply(true) != JVMFlag::SUCCESS) status = false; - } - return status; -}
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintList.hpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTLIST_HPP -#define SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTLIST_HPP - -#include "runtime/flags/jvmFlag.hpp" -#include "utilities/growableArray.hpp" - -/* - * Here we have a mechanism for extracting constraints (as custom functions) for flags, - * which otherwise can not be expressed via simple range check, specified in flag macro tables. - * - * An example of a constraint is "flag1 < flag2" where both flag1 and flag2 can change. - * - * See runtime "runtime/flags/jvmFlagConstraintsCompiler.hpp", - * "runtime/flags/jvmFlagConstraintsGC.hpp" and - * "runtime/flags/jvmFlagConstraintsRuntime.hpp" for the functions themselves. - */ - -typedef JVMFlag::Error (*JVMFlagConstraintFunc_bool)(bool value, bool verbose); -typedef JVMFlag::Error (*JVMFlagConstraintFunc_int)(int value, bool verbose); -typedef JVMFlag::Error (*JVMFlagConstraintFunc_intx)(intx value, bool verbose); -typedef JVMFlag::Error (*JVMFlagConstraintFunc_uint)(uint value, bool verbose); -typedef JVMFlag::Error (*JVMFlagConstraintFunc_uintx)(uintx value, bool verbose); -typedef JVMFlag::Error (*JVMFlagConstraintFunc_uint64_t)(uint64_t value, bool verbose); -typedef JVMFlag::Error (*JVMFlagConstraintFunc_size_t)(size_t value, bool verbose); -typedef JVMFlag::Error (*JVMFlagConstraintFunc_double)(double value, bool verbose); - -class JVMFlagConstraint : public CHeapObj<mtArguments> { -public: - // During VM initialization, constraint validation will be done order of ConstraintType. - enum ConstraintType { - // Will be validated during argument processing (Arguments::parse_argument). - AtParse = 0, - // Will be validated inside Threads::create_vm(), right after Arguments::apply_ergo(). - AfterErgo = 1, - // Will be validated inside universe_init(), right after Metaspace::global_initialize(). - AfterMemoryInit = 2 - }; - -private: - const char* _name; - ConstraintType _validate_type; - -public: - // the "name" argument must be a string literal - JVMFlagConstraint(const char* name, ConstraintType type) { _name=name; _validate_type=type; }; - ~JVMFlagConstraint() {}; - const char* name() const { return _name; } - ConstraintType type() const { return _validate_type; } - virtual JVMFlag::Error apply(bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }; - virtual JVMFlag::Error apply_bool(bool value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }; - virtual JVMFlag::Error apply_int(int value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }; - virtual JVMFlag::Error apply_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }; - virtual JVMFlag::Error apply_uint(uint value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }; - virtual JVMFlag::Error apply_uintx(uintx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }; - virtual JVMFlag::Error apply_uint64_t(uint64_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }; - virtual JVMFlag::Error apply_size_t(size_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }; - virtual JVMFlag::Error apply_double(double value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }; -}; - -class JVMFlagConstraintList : public AllStatic { -private: - static GrowableArray<JVMFlagConstraint*>* _constraints; - // Latest constraint validation type. - static JVMFlagConstraint::ConstraintType _validating_type; -public: - static void init(); - static int length() { return (_constraints != NULL) ? _constraints->length() : 0; } - static JVMFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; } - static JVMFlagConstraint* find(const char* name); - static JVMFlagConstraint* find_if_needs_check(const char* name); - static void add(JVMFlagConstraint* constraint) { _constraints->append(constraint); } - // True if 'AfterErgo' or later constraint functions are validated. - static bool validated_after_ergo() { return _validating_type >= JVMFlagConstraint::AfterErgo; }; - static bool check_constraints(JVMFlagConstraint::ConstraintType type); -}; - -#endif /* SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTLIST_HPP */
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,408 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "code/relocInfo.hpp" -#include "compiler/compilerDefinitions.hpp" -#include "oops/metadata.hpp" -#include "runtime/os.hpp" -#include "interpreter/invocationCounter.hpp" -#include "runtime/arguments.hpp" -#include "runtime/flags/jvmFlag.hpp" -#include "runtime/flags/jvmFlagConstraintsCompiler.hpp" -#include "runtime/flags/jvmFlagRangeList.hpp" -#include "runtime/globals.hpp" -#include "runtime/globals_extension.hpp" -#include "utilities/defaultStream.hpp" - -JVMFlag::Error AliasLevelConstraintFunc(intx value, bool verbose) { - if ((value <= 1) && (Arguments::mode() == Arguments::_comp || Arguments::mode() == Arguments::_mixed)) { - CommandLineError::print(verbose, - "AliasLevel (" INTX_FORMAT ") is not " - "compatible with -Xcomp or -Xmixed\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -/** - * Validate the minimum number of compiler threads needed to run the - * JVM. The following configurations are possible. - * - * 1) The JVM is build using an interpreter only. As a result, the minimum number of - * compiler threads is 0. - * 2) The JVM is build using the compiler(s) and tiered compilation is disabled. As - * a result, either C1 or C2 is used, so the minimum number of compiler threads is 1. - * 3) The JVM is build using the compiler(s) and tiered compilation is enabled. However, - * the option "TieredStopAtLevel < CompLevel_full_optimization". As a result, only - * C1 can be used, so the minimum number of compiler threads is 1. - * 4) The JVM is build using the compilers and tiered compilation is enabled. The option - * 'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result, - * the minimum number of compiler threads is 2. - */ -JVMFlag::Error CICompilerCountConstraintFunc(intx value, bool verbose) { - int min_number_of_compiler_threads = 0; -#if !defined(COMPILER1) && !defined(COMPILER2) && !INCLUDE_JVMCI - // case 1 -#else - if (!TieredCompilation || (TieredStopAtLevel < CompLevel_full_optimization)) { - min_number_of_compiler_threads = 1; // case 2 or case 3 - } else { - min_number_of_compiler_threads = 2; // case 4 (tiered) - } -#endif - - // The default CICompilerCount's value is CI_COMPILER_COUNT. - // With a client VM, -XX:+TieredCompilation causes TieredCompilation - // to be true here (the option is validated later) and - // min_number_of_compiler_threads to exceed CI_COMPILER_COUNT. - min_number_of_compiler_threads = MIN2(min_number_of_compiler_threads, CI_COMPILER_COUNT); - - if (value < (intx)min_number_of_compiler_threads) { - CommandLineError::print(verbose, - "CICompilerCount (" INTX_FORMAT ") must be " - "at least %d \n", - value, min_number_of_compiler_threads); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) { - if (value < 0 || value > 512) { - CommandLineError::print(verbose, - "AllocatePrefetchDistance (" INTX_FORMAT ") must be " - "between 0 and " INTX_FORMAT "\n", - AllocatePrefetchDistance, 512); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) { - if (AllocatePrefetchStyle == 3) { - if (value % wordSize != 0) { - CommandLineError::print(verbose, - "AllocatePrefetchStepSize (" INTX_FORMAT ") must be multiple of %d\n", - value, wordSize); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { - intx max_value = max_intx; -#if defined(SPARC) - max_value = 1; -#elif defined(X86) - max_value = 3; -#endif - if (value < 0 || value > max_value) { - CommandLineError::print(verbose, - "AllocatePrefetchInstr (" INTX_FORMAT ") must be " - "between 0 and " INTX_FORMAT "\n", value, max_value); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error CompileThresholdConstraintFunc(intx value, bool verbose) { - if (value < 0 || value > INT_MAX >> InvocationCounter::count_shift) { - CommandLineError::print(verbose, - "CompileThreshold (" INTX_FORMAT ") " - "must be between 0 and %d\n", - value, - INT_MAX >> InvocationCounter::count_shift); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) { - int backward_branch_limit; - if (ProfileInterpreter) { - if (OnStackReplacePercentage < InterpreterProfilePercentage) { - CommandLineError::print(verbose, - "OnStackReplacePercentage (" INTX_FORMAT ") must be " - "larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n", - OnStackReplacePercentage, InterpreterProfilePercentage); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - backward_branch_limit = ((CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100) - << InvocationCounter::count_shift; - - if (backward_branch_limit < 0) { - CommandLineError::print(verbose, - "CompileThreshold * (InterpreterProfilePercentage - OnStackReplacePercentage) / 100 = " - INTX_FORMAT " " - "must be between 0 and " INTX_FORMAT ", try changing " - "CompileThreshold, InterpreterProfilePercentage, and/or OnStackReplacePercentage\n", - (CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100, - INT_MAX >> InvocationCounter::count_shift); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } else { - if (OnStackReplacePercentage < 0 ) { - CommandLineError::print(verbose, - "OnStackReplacePercentage (" INTX_FORMAT ") must be " - "non-negative\n", OnStackReplacePercentage); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - backward_branch_limit = ((CompileThreshold * OnStackReplacePercentage) / 100) - << InvocationCounter::count_shift; - - if (backward_branch_limit < 0) { - CommandLineError::print(verbose, - "CompileThreshold * OnStackReplacePercentage / 100 = " INTX_FORMAT " " - "must be between 0 and " INTX_FORMAT ", try changing " - "CompileThreshold and/or OnStackReplacePercentage\n", - (CompileThreshold * OnStackReplacePercentage) / 100, - INT_MAX >> InvocationCounter::count_shift); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - return JVMFlag::SUCCESS; -} - -JVMFlag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose) { - if (CodeCacheSegmentSize < (uintx)CodeEntryAlignment) { - CommandLineError::print(verbose, - "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " - "larger than or equal to CodeEntryAlignment (" INTX_FORMAT ") " - "to align entry points\n", - CodeCacheSegmentSize, CodeEntryAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - if (CodeCacheSegmentSize < sizeof(jdouble)) { - CommandLineError::print(verbose, - "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " - "at least " SIZE_FORMAT " to align constants\n", - CodeCacheSegmentSize, sizeof(jdouble)); - return JVMFlag::VIOLATES_CONSTRAINT; - } - -#ifdef COMPILER2 - if (CodeCacheSegmentSize < (uintx)OptoLoopAlignment) { - CommandLineError::print(verbose, - "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " - "larger than or equal to OptoLoopAlignment (" INTX_FORMAT ") " - "to align inner loops\n", - CodeCacheSegmentSize, OptoLoopAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; - } -#endif - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose) { -#ifdef SOLARIS - if ((value < MinimumPriority || value > MaximumPriority) && - (value != -1) && (value != -FXCriticalPriority)) { - CommandLineError::print(verbose, - "CompileThreadPriority (" INTX_FORMAT ") must be " - "between %d and %d inclusively or -1 (means no change) " - "or %d (special value for critical thread class/priority)\n", - value, MinimumPriority, MaximumPriority, -FXCriticalPriority); - return JVMFlag::VIOLATES_CONSTRAINT; - } -#endif - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) { -#ifdef SPARC - if (CodeEntryAlignment % relocInfo::addr_unit() != 0) { - CommandLineError::print(verbose, - "CodeEntryAlignment (" INTX_FORMAT ") must be " - "multiple of NOP size\n", CodeEntryAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; - } -#endif - - if (!is_power_of_2(value)) { - CommandLineError::print(verbose, - "CodeEntryAlignment (" INTX_FORMAT ") must be " - "a power of two\n", CodeEntryAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - if (CodeEntryAlignment < 16) { - CommandLineError::print(verbose, - "CodeEntryAlignment (" INTX_FORMAT ") must be " - "greater than or equal to %d\n", - CodeEntryAlignment, 16); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose) { - if (!is_power_of_2(value)) { - CommandLineError::print(verbose, - "OptoLoopAlignment (" INTX_FORMAT ") " - "must be a power of two\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - // Relevant on ppc, s390, sparc. Will be optimized where - // addr_unit() == 1. - if (OptoLoopAlignment % relocInfo::addr_unit() != 0) { - CommandLineError::print(verbose, - "OptoLoopAlignment (" INTX_FORMAT ") must be " - "multiple of NOP size (%d)\n", - value, relocInfo::addr_unit()); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verbose) { - if (value >= 4032) { - CommandLineError::print(verbose, - "ArraycopyDstPrefetchDistance (" UINTX_FORMAT ") must be" - "between 0 and 4031\n", value); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose) { - if (value >= 4032) { - CommandLineError::print(verbose, - "ArraycopySrcPrefetchDistance (" UINTX_FORMAT ") must be" - "between 0 and 4031\n", value); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose) { - for (int i = 0; i < 3; i++) { - if (value % 10 > 2) { - CommandLineError::print(verbose, - "Invalid value (" UINTX_FORMAT ") " - "in TypeProfileLevel at position %d\n", value, i); - return JVMFlag::VIOLATES_CONSTRAINT; - } - value = value / 10; - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose) { - if (value % BytesPerLong != 0) { - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -#ifdef COMPILER2 -JVMFlag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) { - if (InteriorEntryAlignment > CodeEntryAlignment) { - CommandLineError::print(verbose, - "InteriorEntryAlignment (" INTX_FORMAT ") must be " - "less than or equal to CodeEntryAlignment (" INTX_FORMAT ")\n", - InteriorEntryAlignment, CodeEntryAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; - } - -#ifdef SPARC - if (InteriorEntryAlignment % relocInfo::addr_unit() != 0) { - CommandLineError::print(verbose, - "InteriorEntryAlignment (" INTX_FORMAT ") must be " - "multiple of NOP size\n"); - return JVMFlag::VIOLATES_CONSTRAINT; - } -#endif - - if (!is_power_of_2(value)) { - CommandLineError::print(verbose, - "InteriorEntryAlignment (" INTX_FORMAT ") must be " - "a power of two\n", InteriorEntryAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - int minimum_alignment = 16; -#if defined(SPARC) || (defined(X86) && !defined(AMD64)) - minimum_alignment = 4; -#elif defined(S390) - minimum_alignment = 2; -#endif - - if (InteriorEntryAlignment < minimum_alignment) { - CommandLineError::print(verbose, - "InteriorEntryAlignment (" INTX_FORMAT ") must be " - "greater than or equal to %d\n", - InteriorEntryAlignment, minimum_alignment); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -} - -JVMFlag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose) { - if (value < MaxNodeLimit * 2 / 100 || value > MaxNodeLimit * 40 / 100) { - CommandLineError::print(verbose, - "NodeLimitFudgeFactor must be between 2%% and 40%% " - "of MaxNodeLimit (" INTX_FORMAT ")\n", - MaxNodeLimit); - return JVMFlag::VIOLATES_CONSTRAINT; - } - - return JVMFlag::SUCCESS; -} -#endif // COMPILER2 - -JVMFlag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) { -#if INCLUDE_RTM_OPT - if (UseRTMLocking && !is_power_of_2(RTMTotalCountIncrRate)) { - CommandLineError::print(verbose, - "RTMTotalCountIncrRate (" INTX_FORMAT - ") must be a power of 2, resetting it to 64\n", - RTMTotalCountIncrRate); - FLAG_SET_DEFAULT(RTMTotalCountIncrRate, 64); - } -#endif - - return JVMFlag::SUCCESS; -}
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.hpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTSCOMPILER_HPP -#define SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTSCOMPILER_HPP - -#include "runtime/flags/jvmFlag.hpp" - -/* - * Here we have compiler arguments constraints functions, which are called automatically - * whenever flag's value changes. If the constraint fails the function should return - * an appropriate error value. - */ - -JVMFlag::Error AliasLevelConstraintFunc(intx value, bool verbose); - -JVMFlag::Error CICompilerCountConstraintFunc(intx value, bool verbose); - -JVMFlag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose); - -JVMFlag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose); - -JVMFlag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose); - -JVMFlag::Error CompileThresholdConstraintFunc(intx value, bool verbose); - -JVMFlag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose); - -JVMFlag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose); - -JVMFlag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose); - -JVMFlag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose); - -JVMFlag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose); - -JVMFlag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verbose); - -JVMFlag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose); - -JVMFlag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose); - -JVMFlag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose); - -#ifdef COMPILER2 -JVMFlag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose); - -JVMFlag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose); -#endif - -JVMFlag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose); - -#endif /* SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTSCOMPILER_HPP */
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "runtime/arguments.hpp" -#include "runtime/flags/jvmFlag.hpp" -#include "runtime/flags/jvmFlagConstraintsRuntime.hpp" -#include "runtime/flags/jvmFlagRangeList.hpp" -#include "runtime/globals.hpp" -#include "runtime/safepointMechanism.hpp" -#include "runtime/task.hpp" -#include "utilities/defaultStream.hpp" - -JVMFlag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) { - if (!is_power_of_2(value)) { - CommandLineError::print(verbose, - "ObjectAlignmentInBytes (" INTX_FORMAT ") must be " - "power of 2\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; - } - // In case page size is very small. - if (value >= (intx)os::vm_page_size()) { - CommandLineError::print(verbose, - "ObjectAlignmentInBytes (" INTX_FORMAT ") must be " - "less than page size (" INTX_FORMAT ")\n", - value, (intx)os::vm_page_size()); - return JVMFlag::VIOLATES_CONSTRAINT; - } - return JVMFlag::SUCCESS; -} - -// Need to enforce the padding not to break the existing field alignments. -// It is sufficient to check against the largest type size. -JVMFlag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose) { - if ((value % BytesPerLong) != 0) { - CommandLineError::print(verbose, - "ContendedPaddingWidth (" INTX_FORMAT ") must be " - "a multiple of %d\n", - value, BytesPerLong); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose) { - if (value > BiasedLockingBulkRevokeThreshold) { - CommandLineError::print(verbose, - "BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ") must be " - "less than or equal to BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")\n", - value, BiasedLockingBulkRevokeThreshold); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose) { - if ((value % PeriodicTask::interval_gran) != 0) { - CommandLineError::print(verbose, - "BiasedLockingStartupDelay (" INTX_FORMAT ") must be " - "evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n", - value, PeriodicTask::interval_gran); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose) { - if (value < BiasedLockingBulkRebiasThreshold) { - CommandLineError::print(verbose, - "BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ") must be " - "greater than or equal to BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")\n", - value, BiasedLockingBulkRebiasThreshold); - return JVMFlag::VIOLATES_CONSTRAINT; - } else if ((double)value/(double)BiasedLockingDecayTime > 0.1) { - CommandLineError::print(verbose, - "The ratio of BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")" - " to BiasedLockingDecayTime (" INTX_FORMAT ") must be " - "less than or equal to 0.1\n", - value, BiasedLockingBulkRebiasThreshold); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose) { - if (BiasedLockingBulkRebiasThreshold/(double)value > 0.1) { - CommandLineError::print(verbose, - "The ratio of BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")" - " to BiasedLockingDecayTime (" INTX_FORMAT ") must be " - "less than or equal to 0.1\n", - BiasedLockingBulkRebiasThreshold, value); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) { - if ((value % PeriodicTask::interval_gran != 0)) { - CommandLineError::print(verbose, - "PerfDataSamplingInterval (" INTX_FORMAT ") must be " - "evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n", - value, PeriodicTask::interval_gran); - return JVMFlag::VIOLATES_CONSTRAINT; - } else { - return JVMFlag::SUCCESS; - } -} - -JVMFlag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose) { - if (value) { - if (!SafepointMechanism::supports_thread_local_poll()) { - CommandLineError::print(verbose, "ThreadLocalHandshakes not yet supported on this platform\n"); - return JVMFlag::VIOLATES_CONSTRAINT; - } - } - return JVMFlag::SUCCESS; -}
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTSRUNTIME_HPP -#define SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTSRUNTIME_HPP - -#include "runtime/flags/jvmFlag.hpp" - -/* - * Here we have runtime arguments constraints functions, which are called automatically - * whenever flag's value changes. If the constraint fails the function should return - * an appropriate error value. - */ - -JVMFlag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose); - -JVMFlag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose); - -JVMFlag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose); -JVMFlag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose); -JVMFlag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose); -JVMFlag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose); - -JVMFlag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose); - -JVMFlag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose); - - -#endif /* SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTSRUNTIME_HPP */
--- a/src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,442 +0,0 @@ -/* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "jvm.h" -#include "classfile/stringTable.hpp" -#include "classfile/symbolTable.hpp" -#include "gc/shared/referenceProcessor.hpp" -#include "oops/markOop.hpp" -#include "runtime/arguments.hpp" -#include "runtime/flags/jvmFlag.hpp" -#include "runtime/flags/jvmFlagConstraintList.hpp" -#include "runtime/flags/jvmFlagRangeList.hpp" -#include "runtime/globals_extension.hpp" -#include "runtime/os.hpp" -#include "runtime/task.hpp" -#include "utilities/defaultStream.hpp" -#include "utilities/macros.hpp" - -void CommandLineError::print(bool verbose, const char* msg, ...) { - if (verbose) { - va_list listPointer; - va_start(listPointer, msg); - jio_vfprintf(defaultStream::error_stream(), msg, listPointer); - va_end(listPointer); - } -} - -class JVMFlagRange_int : public JVMFlagRange { - int _min; - int _max; - const int* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagRange_int(const char* name, const int* ptr, int min, int max) - : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {} - - JVMFlag::Error check(bool verbose = true) { - return check_int(*_ptr, verbose); - } - - JVMFlag::Error check_int(int value, bool verbose = true) { - if ((value < _min) || (value > _max)) { - CommandLineError::print(verbose, - "int %s=%d is outside the allowed range " - "[ %d ... %d ]\n", - name(), value, _min, _max); - return JVMFlag::OUT_OF_BOUNDS; - } else { - return JVMFlag::SUCCESS; - } - } - - void print(outputStream* st) { - st->print("[ %-25d ... %25d ]", _min, _max); - } -}; - -class JVMFlagRange_intx : public JVMFlagRange { - intx _min; - intx _max; - const intx* _ptr; -public: - // the "name" argument must be a string literal - JVMFlagRange_intx(const char* name, const intx* ptr, intx min, intx max) - : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {} - - JVMFlag::Error check(bool verbose = true) { - return check_intx(*_ptr, verbose); - } - - JVMFlag::Error check_intx(intx value, bool verbose = true) { - if ((value < _min) || (value > _max)) { - CommandLineError::print(verbose, - "intx %s=" INTX_FORMAT " is outside the allowed range " - "[ " INTX_FORMAT " ... " INTX_FORMAT " ]\n", - name(), value, _min, _max); - return JVMFlag::OUT_OF_BOUNDS; - } else { - return JVMFlag::SUCCESS; - } - } - - void print(outputStream* st) { - st->print("[ " INTX_FORMAT_W(-25) " ... " INTX_FORMAT_W(25) " ]", _min, _max); - } -}; - -class JVMFlagRange_uint : public JVMFlagRange { - uint _min; - uint _max; - const uint* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagRange_uint(const char* name, const uint* ptr, uint min, uint max) - : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {} - - JVMFlag::Error check(bool verbose = true) { - return check_uint(*_ptr, verbose); - } - - JVMFlag::Error check_uint(uint value, bool verbose = true) { - if ((value < _min) || (value > _max)) { - CommandLineError::print(verbose, - "uint %s=%u is outside the allowed range " - "[ %u ... %u ]\n", - name(), value, _min, _max); - return JVMFlag::OUT_OF_BOUNDS; - } else { - return JVMFlag::SUCCESS; - } - } - - void print(outputStream* st) { - st->print("[ %-25u ... %25u ]", _min, _max); - } -}; - -class JVMFlagRange_uintx : public JVMFlagRange { - uintx _min; - uintx _max; - const uintx* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagRange_uintx(const char* name, const uintx* ptr, uintx min, uintx max) - : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {} - - JVMFlag::Error check(bool verbose = true) { - return check_uintx(*_ptr, verbose); - } - - JVMFlag::Error check_uintx(uintx value, bool verbose = true) { - if ((value < _min) || (value > _max)) { - CommandLineError::print(verbose, - "uintx %s=" UINTX_FORMAT " is outside the allowed range " - "[ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n", - name(), value, _min, _max); - return JVMFlag::OUT_OF_BOUNDS; - } else { - return JVMFlag::SUCCESS; - } - } - - void print(outputStream* st) { - st->print("[ " UINTX_FORMAT_W(-25) " ... " UINTX_FORMAT_W(25) " ]", _min, _max); - } -}; - -class JVMFlagRange_uint64_t : public JVMFlagRange { - uint64_t _min; - uint64_t _max; - const uint64_t* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagRange_uint64_t(const char* name, const uint64_t* ptr, uint64_t min, uint64_t max) - : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {} - - JVMFlag::Error check(bool verbose = true) { - return check_uint64_t(*_ptr, verbose); - } - - JVMFlag::Error check_uint64_t(uint64_t value, bool verbose = true) { - if ((value < _min) || (value > _max)) { - CommandLineError::print(verbose, - "uint64_t %s=" UINT64_FORMAT " is outside the allowed range " - "[ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n", - name(), value, _min, _max); - return JVMFlag::OUT_OF_BOUNDS; - } else { - return JVMFlag::SUCCESS; - } - } - - void print(outputStream* st) { - st->print("[ " UINT64_FORMAT_W(-25) " ... " UINT64_FORMAT_W(25) " ]", _min, _max); - } -}; - -class JVMFlagRange_size_t : public JVMFlagRange { - size_t _min; - size_t _max; - const size_t* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagRange_size_t(const char* name, const size_t* ptr, size_t min, size_t max) - : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {} - - JVMFlag::Error check(bool verbose = true) { - return check_size_t(*_ptr, verbose); - } - - JVMFlag::Error check_size_t(size_t value, bool verbose = true) { - if ((value < _min) || (value > _max)) { - CommandLineError::print(verbose, - "size_t %s=" SIZE_FORMAT " is outside the allowed range " - "[ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n", - name(), value, _min, _max); - return JVMFlag::OUT_OF_BOUNDS; - } else { - return JVMFlag::SUCCESS; - } - } - - void print(outputStream* st) { - st->print("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", _min, _max); - } -}; - -class JVMFlagRange_double : public JVMFlagRange { - double _min; - double _max; - const double* _ptr; - -public: - // the "name" argument must be a string literal - JVMFlagRange_double(const char* name, const double* ptr, double min, double max) - : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {} - - JVMFlag::Error check(bool verbose = true) { - return check_double(*_ptr, verbose); - } - - JVMFlag::Error check_double(double value, bool verbose = true) { - if ((value < _min) || (value > _max)) { - CommandLineError::print(verbose, - "double %s=%f is outside the allowed range " - "[ %f ... %f ]\n", - name(), value, _min, _max); - return JVMFlag::OUT_OF_BOUNDS; - } else { - return JVMFlag::SUCCESS; - } - } - - void print(outputStream* st) { - st->print("[ %-25.3f ... %25.3f ]", _min, _max); - } -}; - -// No constraint emitting -void emit_range_no(...) { /* NOP */ } - -// No constraint emitting if function argument is NOT provided -void emit_range_bool(const char* /*name*/, const bool* /*value*/) { /* NOP */ } -void emit_range_ccstr(const char* /*name*/, const ccstr* /*value*/) { /* NOP */ } -void emit_range_ccstrlist(const char* /*name*/, const ccstrlist* /*value*/) { /* NOP */ } -void emit_range_int(const char* /*name*/, const int* /*value*/) { /* NOP */ } -void emit_range_intx(const char* /*name*/, const intx* /*value*/) { /* NOP */ } -void emit_range_uint(const char* /*name*/, const uint* /*value*/) { /* NOP */ } -void emit_range_uintx(const char* /*name*/, const uintx* /*value*/) { /* NOP */ } -void emit_range_uint64_t(const char* /*name*/, const uint64_t* /*value*/) { /* NOP */ } -void emit_range_size_t(const char* /*name*/, const size_t* /*value*/) { /* NOP */ } -void emit_range_double(const char* /*name*/, const double* /*value*/) { /* NOP */ } - -// JVMFlagRange emitting code functions if range arguments are provided -void emit_range_int(const char* name, const int* ptr, int min, int max) { - JVMFlagRangeList::add(new JVMFlagRange_int(name, ptr, min, max)); -} -void emit_range_intx(const char* name, const intx* ptr, intx min, intx max) { - JVMFlagRangeList::add(new JVMFlagRange_intx(name, ptr, min, max)); -} -void emit_range_uint(const char* name, const uint* ptr, uint min, uint max) { - JVMFlagRangeList::add(new JVMFlagRange_uint(name, ptr, min, max)); -} -void emit_range_uintx(const char* name, const uintx* ptr, uintx min, uintx max) { - JVMFlagRangeList::add(new JVMFlagRange_uintx(name, ptr, min, max)); -} -void emit_range_uint64_t(const char* name, const uint64_t* ptr, uint64_t min, uint64_t max) { - JVMFlagRangeList::add(new JVMFlagRange_uint64_t(name, ptr, min, max)); -} -void emit_range_size_t(const char* name, const size_t* ptr, size_t min, size_t max) { - JVMFlagRangeList::add(new JVMFlagRange_size_t(name, ptr, min, max)); -} -void emit_range_double(const char* name, const double* ptr, double min, double max) { - JVMFlagRangeList::add(new JVMFlagRange_double(name, ptr, min, max)); -} - -// Generate code to call emit_range_xxx function -#define EMIT_RANGE_PRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name -#define EMIT_RANGE_COMMERCIAL_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name -#define EMIT_RANGE_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name -#define EMIT_RANGE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name -#define EMIT_RANGE_MANAGEABLE_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name -#define EMIT_RANGE_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name -#define EMIT_RANGE_PD_PRODUCT_FLAG(type, name, doc) ); emit_range_##type(#name,&name -#define EMIT_RANGE_PD_DIAGNOSTIC_FLAG(type, name, doc) ); emit_range_##type(#name,&name -#ifndef PRODUCT -#define EMIT_RANGE_DEVELOPER_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name -#define EMIT_RANGE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_range_##type(#name,&name -#define EMIT_RANGE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name -#else -#define EMIT_RANGE_DEVELOPER_FLAG(type, name, value, doc) ); emit_range_no(#name,&name -#define EMIT_RANGE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_range_no(#name,&name -#define EMIT_RANGE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_range_no(#name,&name -#endif -#ifdef _LP64 -#define EMIT_RANGE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_range_##type(#name,&name -#else -#define EMIT_RANGE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_range_no(#name,&name -#endif - -// Generate func argument to pass into emit_range_xxx functions -#define EMIT_RANGE_CHECK(a, b) , a, b - -#define INITIAL_RANGES_SIZE 379 -GrowableArray<JVMFlagRange*>* JVMFlagRangeList::_ranges = NULL; - -// Check the ranges of all flags that have them -void JVMFlagRangeList::init(void) { - - _ranges = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<JVMFlagRange*>(INITIAL_RANGES_SIZE, true); - - emit_range_no(NULL VM_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, - EMIT_RANGE_PD_DEVELOPER_FLAG, - EMIT_RANGE_PRODUCT_FLAG, - EMIT_RANGE_PD_PRODUCT_FLAG, - EMIT_RANGE_DIAGNOSTIC_FLAG, - EMIT_RANGE_PD_DIAGNOSTIC_FLAG, - EMIT_RANGE_EXPERIMENTAL_FLAG, - EMIT_RANGE_NOTPRODUCT_FLAG, - EMIT_RANGE_MANAGEABLE_FLAG, - EMIT_RANGE_PRODUCT_RW_FLAG, - EMIT_RANGE_LP64_PRODUCT_FLAG, - EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT, - IGNORE_WRITEABLE)); - - EMIT_RANGES_FOR_GLOBALS_EXT - - emit_range_no(NULL ARCH_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, - EMIT_RANGE_PRODUCT_FLAG, - EMIT_RANGE_DIAGNOSTIC_FLAG, - EMIT_RANGE_EXPERIMENTAL_FLAG, - EMIT_RANGE_NOTPRODUCT_FLAG, - EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT, - IGNORE_WRITEABLE)); - -#if INCLUDE_JVMCI - emit_range_no(NULL JVMCI_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, - EMIT_RANGE_PD_DEVELOPER_FLAG, - EMIT_RANGE_PRODUCT_FLAG, - EMIT_RANGE_PD_PRODUCT_FLAG, - EMIT_RANGE_DIAGNOSTIC_FLAG, - EMIT_RANGE_PD_DIAGNOSTIC_FLAG, - EMIT_RANGE_EXPERIMENTAL_FLAG, - EMIT_RANGE_NOTPRODUCT_FLAG, - EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT, - IGNORE_WRITEABLE)); -#endif // INCLUDE_JVMCI - -#ifdef COMPILER1 - emit_range_no(NULL C1_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, - EMIT_RANGE_PD_DEVELOPER_FLAG, - EMIT_RANGE_PRODUCT_FLAG, - EMIT_RANGE_PD_PRODUCT_FLAG, - EMIT_RANGE_DIAGNOSTIC_FLAG, - EMIT_RANGE_PD_DIAGNOSTIC_FLAG, - EMIT_RANGE_NOTPRODUCT_FLAG, - EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT, - IGNORE_WRITEABLE)); -#endif // COMPILER1 - -#ifdef COMPILER2 - emit_range_no(NULL C2_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, - EMIT_RANGE_PD_DEVELOPER_FLAG, - EMIT_RANGE_PRODUCT_FLAG, - EMIT_RANGE_PD_PRODUCT_FLAG, - EMIT_RANGE_DIAGNOSTIC_FLAG, - EMIT_RANGE_PD_DIAGNOSTIC_FLAG, - EMIT_RANGE_EXPERIMENTAL_FLAG, - EMIT_RANGE_NOTPRODUCT_FLAG, - EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT, - IGNORE_WRITEABLE)); -#endif // COMPILER2 -} - -JVMFlagRange* JVMFlagRangeList::find(const char* name) { - JVMFlagRange* found = NULL; - for (int i=0; i<length(); i++) { - JVMFlagRange* range = at(i); - if (strcmp(range->name(), name) == 0) { - found = range; - break; - } - } - return found; -} - -void JVMFlagRangeList::print(outputStream* st, const char* name, RangeStrFunc default_range_str_func) { - JVMFlagRange* range = JVMFlagRangeList::find(name); - if (range != NULL) { - range->print(st); - } else { - JVMFlagConstraint* constraint = JVMFlagConstraintList::find(name); - if (constraint != NULL) { - assert(default_range_str_func!=NULL, "default_range_str_func must be provided"); - st->print("%s", default_range_str_func()); - } else { - st->print("[ ... ]"); - } - } -} - -bool JVMFlagRangeList::check_ranges() { - // Check ranges. - bool status = true; - for (int i=0; i<length(); i++) { - JVMFlagRange* range = at(i); - if (range->check(true) != JVMFlag::SUCCESS) status = false; - } - return status; -}
--- a/src/hotspot/share/runtime/flags/jvmFlagRangeList.hpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_RUNTIME_JVMFLAGRANGELIST_HPP -#define SHARE_VM_RUNTIME_JVMFLAGRANGELIST_HPP - -#include "memory/metaspaceShared.hpp" -#include "runtime/flags/jvmFlag.hpp" -#include "utilities/growableArray.hpp" - -/* - * Here we have a mechanism for extracting ranges specified in flag macro tables. - * - * The specified ranges are used to verify that flags have valid values. - * - * An example of a range is "min <= flag <= max". Both "min" and "max" must be - * constant and can not change. If either "min" or "max" can change, - * then we need to use constraint instead. - */ - -class CommandLineError : public AllStatic { -public: - static void print(bool verbose, const char* msg, ...); -}; - -class JVMFlagRange : public CHeapObj<mtArguments> { -private: - const char* _name; -public: - // the "name" argument must be a string literal - JVMFlagRange(const char* name) { _name=name; } - ~JVMFlagRange() {} - const char* name() { return _name; } - virtual JVMFlag::Error check(bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; } - virtual JVMFlag::Error check_int(int value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; } - virtual JVMFlag::Error check_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; } - virtual JVMFlag::Error check_uint(uint value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; } - virtual JVMFlag::Error check_uintx(uintx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; } - virtual JVMFlag::Error check_uint64_t(uint64_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; } - virtual JVMFlag::Error check_size_t(size_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; } - virtual JVMFlag::Error check_double(double value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; } - virtual void print(outputStream* st) { ; } -}; - -class JVMFlagRangeList : public AllStatic { - static GrowableArray<JVMFlagRange*>* _ranges; -public: - static void init(); - static int length() { return (_ranges != NULL) ? _ranges->length() : 0; } - static JVMFlagRange* at(int i) { return (_ranges != NULL) ? _ranges->at(i) : NULL; } - static JVMFlagRange* find(const char* name); - static void add(JVMFlagRange* range) { _ranges->append(range); } - static void print(outputStream* st, const char* name, RangeStrFunc default_range_str_func); - // Check the final values of all flags for ranges. - static bool check_ranges(); -}; - -#endif // SHARE_VM_RUNTIME_JVMFLAGRANGELIST_HPP
--- a/src/hotspot/share/runtime/flags/jvmFlagWriteableList.cpp Thu Dec 07 12:25:09 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.