8202150: [REDO] Split globals.hpp to factor out the Flag class
authorgziemski
Thu, 26 Apr 2018 11:19:05 -0500
changeset 49902 3661f31c6df4
parent 49901 794325b73468
child 49903 a2d0795ca8bb
8202150: [REDO] Split globals.hpp to factor out the Flag class Summary: Factored out Flag out go globals, renamed to JVMFlag Reviewed-by: coleenp, dholmes, kvn
src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp
src/hotspot/cpu/sparc/macroAssembler_sparc.cpp
src/hotspot/cpu/sparc/methodHandles_sparc.cpp
src/hotspot/cpu/x86/macroAssembler_x86.cpp
src/hotspot/cpu/x86/methodHandles_x86.cpp
src/hotspot/share/code/dependencies.cpp
src/hotspot/share/code/nmethod.cpp
src/hotspot/share/code/relocInfo.cpp
src/hotspot/share/gc/cms/commandLineFlagConstraintsCMS.cpp
src/hotspot/share/gc/cms/commandLineFlagConstraintsCMS.hpp
src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp
src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.cpp
src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.hpp
src/hotspot/share/gc/g1/commandLineFlagConstraintsG1.cpp
src/hotspot/share/gc/g1/commandLineFlagConstraintsG1.hpp
src/hotspot/share/gc/g1/g1CollectedHeap.cpp
src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp
src/hotspot/share/gc/g1/jvmFlagConstraintsG1.hpp
src/hotspot/share/gc/parallel/commandLineFlagConstraintsParallel.cpp
src/hotspot/share/gc/parallel/commandLineFlagConstraintsParallel.hpp
src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.cpp
src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.hpp
src/hotspot/share/gc/parallel/psMarkSweep.cpp
src/hotspot/share/gc/shared/commandLineFlagConstraintsGC.cpp
src/hotspot/share/gc/shared/commandLineFlagConstraintsGC.hpp
src/hotspot/share/gc/shared/genCollectedHeap.cpp
src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp
src/hotspot/share/gc/shared/jvmFlagConstraintsGC.hpp
src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
src/hotspot/share/jvmci/vmStructs_jvmci.cpp
src/hotspot/share/memory/universe.cpp
src/hotspot/share/oops/klassVtable.cpp
src/hotspot/share/precompiled/precompiled.hpp
src/hotspot/share/prims/whitebox.cpp
src/hotspot/share/runtime/arguments.cpp
src/hotspot/share/runtime/arguments.hpp
src/hotspot/share/runtime/commandLineFlagConstraintList.cpp
src/hotspot/share/runtime/commandLineFlagConstraintList.hpp
src/hotspot/share/runtime/commandLineFlagConstraintsCompiler.cpp
src/hotspot/share/runtime/commandLineFlagConstraintsCompiler.hpp
src/hotspot/share/runtime/commandLineFlagConstraintsRuntime.cpp
src/hotspot/share/runtime/commandLineFlagConstraintsRuntime.hpp
src/hotspot/share/runtime/commandLineFlagRangeList.cpp
src/hotspot/share/runtime/commandLineFlagRangeList.hpp
src/hotspot/share/runtime/commandLineFlagWriteableList.cpp
src/hotspot/share/runtime/commandLineFlagWriteableList.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
src/hotspot/share/runtime/globals.cpp
src/hotspot/share/runtime/globals.hpp
src/hotspot/share/runtime/globals_ext.hpp
src/hotspot/share/runtime/globals_extension.hpp
src/hotspot/share/runtime/handshake.hpp
src/hotspot/share/runtime/init.cpp
src/hotspot/share/runtime/java.cpp
src/hotspot/share/runtime/mutexLocker.hpp
src/hotspot/share/runtime/thread.cpp
src/hotspot/share/runtime/vmStructs.cpp
src/hotspot/share/services/attachListener.cpp
src/hotspot/share/services/diagnosticCommand.cpp
src/hotspot/share/services/dtraceAttacher.cpp
src/hotspot/share/services/management.cpp
src/hotspot/share/services/writeableFlags.cpp
src/hotspot/share/services/writeableFlags.hpp
src/hotspot/share/utilities/debug.cpp
src/hotspot/share/utilities/globalDefinitions.hpp
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java
test/hotspot/gtest/gc/shared/test_collectorPolicy.cpp
test/hotspot/gtest/runtime/test_globals.cpp
--- a/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -30,6 +30,7 @@
 #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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -35,6 +35,7 @@
 #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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/cpu/sparc/methodHandles_sparc.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -31,6 +31,7 @@
 #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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -37,6 +37,7 @@
 #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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/cpu/x86/methodHandles_x86.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -31,6 +31,7 @@
 #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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/code/dependencies.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -35,6 +35,7 @@
 #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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/code/nmethod.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -47,6 +47,7 @@
 #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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/code/relocInfo.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -29,6 +29,7 @@
 #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"
--- a/src/hotspot/share/gc/cms/commandLineFlagConstraintsCMS.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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/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);
-}
--- a/src/hotspot/share/gc/cms/commandLineFlagConstraintsCMS.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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
-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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -68,6 +68,7 @@
 #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"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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/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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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
+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
--- a/src/hotspot/share/gc/g1/commandLineFlagConstraintsG1.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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/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();
-}
--- a/src/hotspot/share/gc/g1/commandLineFlagConstraintsG1.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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
-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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -84,6 +84,7 @@
 #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"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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/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();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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
+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
--- a/src/hotspot/share/gc/parallel/commandLineFlagConstraintsParallel.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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/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;
-}
--- a/src/hotspot/share/gc/parallel/commandLineFlagConstraintsParallel.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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
-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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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/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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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
+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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/gc/parallel/psMarkSweep.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -51,6 +51,7 @@
 #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"
--- a/src/hotspot/share/gc/shared/commandLineFlagConstraintsGC.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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/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;
-}
--- a/src/hotspot/share/gc/shared/commandLineFlagConstraintsGC.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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/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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -53,6 +53,7 @@
 #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"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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/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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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/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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -37,6 +37,7 @@
 #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"
@@ -125,7 +126,7 @@
   }
   ResourceMark rm;
   const char* cstring = java_lang_String::as_utf8_string(name());
-  Flag* flag = Flag::find_flag(cstring, strlen(cstring), /* allow_locked */ true, /* return_flag */ true);
+  JVMFlag* flag = JVMFlag::find_flag(cstring, strlen(cstring), /* allow_locked */ true, /* return_flag */ true);
   if (flag == NULL) {
     return c2vm;
   }
--- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -29,6 +29,7 @@
 #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"
@@ -378,9 +379,9 @@
 #define COUNT_FLAG(ignore) +1
 #ifdef ASSERT
 #define CHECK_FLAG(type, name) { \
-  Flag* flag = Flag::find_flag(#name, strlen(#name), /*allow_locked*/ true, /* return_flag */ true); \
+  JVMFlag* flag = JVMFlag::find_flag(#name, strlen(#name), /*allow_locked*/ true, /* return_flag */ true); \
   assert(flag != NULL, "No such flag named " #name); \
-  assert(flag->is_##type(), "Flag " #name " is not of type " #type); \
+  assert(flag->is_##type(), "JVMFlag " #name " is not of type " #type); \
 }
 #else
 #define CHECK_FLAG(type, name)
--- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -35,6 +35,7 @@
 #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"
@@ -146,16 +147,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(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(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(InstanceKlass,               _fields,                                       Array<u2>*)                            \
   nonstatic_field(InstanceKlass,               _constants,                                    ConstantPool*)                         \
@@ -345,8 +346,8 @@
   declare_toplevel_type(BasicLock)                                        \
   declare_toplevel_type(CompilerToVM)                                     \
   declare_toplevel_type(ExceptionTableElement)                            \
-  declare_toplevel_type(Flag)                                             \
-  declare_toplevel_type(Flag*)                                            \
+  declare_toplevel_type(JVMFlag)                                          \
+  declare_toplevel_type(JVMFlag*)                                         \
   declare_toplevel_type(InvocationCounter)                                \
   declare_toplevel_type(JVMCIEnv)                                         \
   declare_toplevel_type(LocalVariableTableElement)                        \
--- a/src/hotspot/share/memory/universe.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/memory/universe.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -63,7 +63,8 @@
 #include "prims/resolvedMethodTable.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/atomic.hpp"
-#include "runtime/commandLineFlagConstraintList.hpp"
+#include "runtime/flags/flagSetting.hpp"
+#include "runtime/flags/jvmFlagConstraintList.hpp"
 #include "runtime/deoptimization.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/init.hpp"
@@ -701,7 +702,7 @@
   AOTLoader::universe_init();
 
   // Checks 'AfterMemoryInit' constraints.
-  if (!CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterMemoryInit)) {
+  if (!JVMFlagConstraintList::check_constraints(JVMFlagConstraint::AfterMemoryInit)) {
     return JNI_EINVAL;
   }
 
--- a/src/hotspot/share/oops/klassVtable.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/oops/klassVtable.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -38,6 +38,7 @@
 #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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/precompiled/precompiled.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -101,6 +101,7 @@
 # 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"
@@ -163,6 +164,13 @@
 # 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"
@@ -292,6 +300,7 @@
 # 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"
@@ -299,10 +308,12 @@
 # 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 Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/prims/whitebox.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -53,6 +53,7 @@
 #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"
@@ -971,29 +972,29 @@
 WB_END
 
 template <typename T>
-static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, Flag::Error (*TAt)(const char*, T*, bool, bool)) {
+static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::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);
-  Flag::Error result = (*TAt)(flag_name, value, true, true);
+  JVMFlag::Error result = (*TAt)(flag_name, value, true, true);
   env->ReleaseStringUTFChars(name, flag_name);
-  return (result == Flag::SUCCESS);
+  return (result == JVMFlag::SUCCESS);
 }
 
 template <typename T>
-static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, Flag::Error (*TAtPut)(const char*, T*, Flag::Flags)) {
+static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAtPut)(const char*, T*, JVMFlag::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);
-  Flag::Error result = (*TAtPut)(flag_name, value, Flag::INTERNAL);
+  JVMFlag::Error result = (*TAtPut)(flag_name, value, JVMFlag::INTERNAL);
   env->ReleaseStringUTFChars(name, flag_name);
-  return (result == Flag::SUCCESS);
+  return (result == JVMFlag::SUCCESS);
 }
 
 template <typename T>
@@ -1026,28 +1027,28 @@
   return box(thread, env, vmSymbols::java_lang_Double(), vmSymbols::Double_valueOf_signature(), value);
 }
 
-static Flag* getVMFlag(JavaThread* thread, JNIEnv* env, jstring name) {
+static JVMFlag* 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);
-  Flag* result = Flag::find_flag(flag_name, strlen(flag_name), true, true);
+  JVMFlag* result = JVMFlag::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))
-  Flag* flag = getVMFlag(thread, env, name);
+  JVMFlag* 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))
-  Flag* flag = getVMFlag(thread, env, name);
+  JVMFlag* 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, &CommandLineFlags::boolAt)) {
+  if (GetVMFlag <bool> (thread, env, name, &result, &JVMFlag::boolAt)) {
     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
     return booleanBox(thread, env, result);
   }
@@ -1056,7 +1057,7 @@
 
 WB_ENTRY(jobject, WB_GetIntVMFlag(JNIEnv* env, jobject o, jstring name))
   int result;
-  if (GetVMFlag <int> (thread, env, name, &result, &CommandLineFlags::intAt)) {
+  if (GetVMFlag <int> (thread, env, name, &result, &JVMFlag::intAt)) {
     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
     return longBox(thread, env, result);
   }
@@ -1065,7 +1066,7 @@
 
 WB_ENTRY(jobject, WB_GetUintVMFlag(JNIEnv* env, jobject o, jstring name))
   uint result;
-  if (GetVMFlag <uint> (thread, env, name, &result, &CommandLineFlags::uintAt)) {
+  if (GetVMFlag <uint> (thread, env, name, &result, &JVMFlag::uintAt)) {
     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
     return longBox(thread, env, result);
   }
@@ -1074,7 +1075,7 @@
 
 WB_ENTRY(jobject, WB_GetIntxVMFlag(JNIEnv* env, jobject o, jstring name))
   intx result;
-  if (GetVMFlag <intx> (thread, env, name, &result, &CommandLineFlags::intxAt)) {
+  if (GetVMFlag <intx> (thread, env, name, &result, &JVMFlag::intxAt)) {
     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
     return longBox(thread, env, result);
   }
@@ -1083,7 +1084,7 @@
 
 WB_ENTRY(jobject, WB_GetUintxVMFlag(JNIEnv* env, jobject o, jstring name))
   uintx result;
-  if (GetVMFlag <uintx> (thread, env, name, &result, &CommandLineFlags::uintxAt)) {
+  if (GetVMFlag <uintx> (thread, env, name, &result, &JVMFlag::uintxAt)) {
     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
     return longBox(thread, env, result);
   }
@@ -1092,7 +1093,7 @@
 
 WB_ENTRY(jobject, WB_GetUint64VMFlag(JNIEnv* env, jobject o, jstring name))
   uint64_t result;
-  if (GetVMFlag <uint64_t> (thread, env, name, &result, &CommandLineFlags::uint64_tAt)) {
+  if (GetVMFlag <uint64_t> (thread, env, name, &result, &JVMFlag::uint64_tAt)) {
     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
     return longBox(thread, env, result);
   }
@@ -1101,7 +1102,7 @@
 
 WB_ENTRY(jobject, WB_GetSizeTVMFlag(JNIEnv* env, jobject o, jstring name))
   uintx result;
-  if (GetVMFlag <size_t> (thread, env, name, &result, &CommandLineFlags::size_tAt)) {
+  if (GetVMFlag <size_t> (thread, env, name, &result, &JVMFlag::size_tAt)) {
     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
     return longBox(thread, env, result);
   }
@@ -1110,7 +1111,7 @@
 
 WB_ENTRY(jobject, WB_GetDoubleVMFlag(JNIEnv* env, jobject o, jstring name))
   double result;
-  if (GetVMFlag <double> (thread, env, name, &result, &CommandLineFlags::doubleAt)) {
+  if (GetVMFlag <double> (thread, env, name, &result, &JVMFlag::doubleAt)) {
     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
     return doubleBox(thread, env, result);
   }
@@ -1119,7 +1120,7 @@
 
 WB_ENTRY(jstring, WB_GetStringVMFlag(JNIEnv* env, jobject o, jstring name))
   ccstr ccstrResult;
-  if (GetVMFlag <ccstr> (thread, env, name, &ccstrResult, &CommandLineFlags::ccstrAt)) {
+  if (GetVMFlag <ccstr> (thread, env, name, &ccstrResult, &JVMFlag::ccstrAt)) {
     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
     jstring result = env->NewStringUTF(ccstrResult);
     CHECK_JNI_EXCEPTION_(env, NULL);
@@ -1130,42 +1131,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, &CommandLineFlags::boolAtPut);
+  SetVMFlag <bool> (thread, env, name, &result, &JVMFlag::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, &CommandLineFlags::intAtPut);
+  SetVMFlag <int> (thread, env, name, &result, &JVMFlag::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, &CommandLineFlags::uintAtPut);
+  SetVMFlag <uint> (thread, env, name, &result, &JVMFlag::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, &CommandLineFlags::intxAtPut);
+  SetVMFlag <intx> (thread, env, name, &result, &JVMFlag::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, &CommandLineFlags::uintxAtPut);
+  SetVMFlag <uintx> (thread, env, name, &result, &JVMFlag::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, &CommandLineFlags::uint64_tAtPut);
+  SetVMFlag <uint64_t> (thread, env, name, &result, &JVMFlag::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, &CommandLineFlags::size_tAtPut);
+  SetVMFlag <size_t> (thread, env, name, &result, &JVMFlag::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, &CommandLineFlags::doubleAtPut);
+  SetVMFlag <double> (thread, env, name, &result, &JVMFlag::doubleAtPut);
 WB_END
 
 WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value))
@@ -1182,7 +1183,7 @@
   bool needFree;
   {
     ThreadInVMfromNative ttvfn(thread); // back to VM
-    needFree = SetVMFlag <ccstr> (thread, env, name, &ccstrResult, &CommandLineFlags::ccstrAtPut);
+    needFree = SetVMFlag <ccstr> (thread, env, name, &ccstrResult, &JVMFlag::ccstrAtPut);
   }
   if (value != NULL) {
     env->ReleaseStringUTFChars(value, ccstrValue);
--- a/src/hotspot/share/runtime/arguments.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/arguments.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -42,10 +42,10 @@
 #include "prims/jvmtiExport.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/arguments_ext.hpp"
-#include "runtime/commandLineFlagConstraintList.hpp"
-#include "runtime/commandLineFlagWriteableList.hpp"
-#include "runtime/commandLineFlagRangeList.hpp"
-#include "runtime/globals.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 "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 (Flag::find_flag(flag.name) != NULL) {
+        if (JVMFlag::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 (Flag::find_flag(flag.name) != NULL) {
+        if (JVMFlag::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, Flag::Flags origin) {
-  if (CommandLineFlags::boolAtPut(name, &value, origin) == Flag::SUCCESS) {
+static bool set_bool_flag(const char* name, bool value, JVMFlag::Flags origin) {
+  if (JVMFlag::boolAtPut(name, &value, origin) == JVMFlag::SUCCESS) {
     return true;
   } else {
     return false;
   }
 }
 
-static bool set_fp_numeric_flag(const char* name, char* value, Flag::Flags origin) {
+static bool set_fp_numeric_flag(const char* name, char* value, JVMFlag::Flags origin) {
   char* end;
   errno = 0;
   double v = strtod(value, &end);
@@ -849,18 +849,18 @@
     return false;
   }
 
-  if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) {
+  if (JVMFlag::doubleAtPut(name, &v, origin) == JVMFlag::SUCCESS) {
     return true;
   }
   return false;
 }
 
-static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) {
+static bool set_numeric_flag(const char* name, char* value, JVMFlag::Flags origin) {
   julong v;
   int int_v;
   intx intx_v;
   bool is_neg = false;
-  Flag* result = Flag::find_flag(name, strlen(name));
+  JVMFlag* result = JVMFlag::find_flag(name, strlen(name));
 
   if (result == NULL) {
     return false;
@@ -882,43 +882,43 @@
     if (is_neg) {
       int_v = -int_v;
     }
-    return CommandLineFlags::intAtPut(result, &int_v, origin) == Flag::SUCCESS;
+    return JVMFlag::intAtPut(result, &int_v, origin) == JVMFlag::SUCCESS;
   } else if (result->is_uint()) {
     uint uint_v = (uint) v;
-    return CommandLineFlags::uintAtPut(result, &uint_v, origin) == Flag::SUCCESS;
+    return JVMFlag::uintAtPut(result, &uint_v, origin) == JVMFlag::SUCCESS;
   } else if (result->is_intx()) {
     intx_v = (intx) v;
     if (is_neg) {
       intx_v = -intx_v;
     }
-    return CommandLineFlags::intxAtPut(result, &intx_v, origin) == Flag::SUCCESS;
+    return JVMFlag::intxAtPut(result, &intx_v, origin) == JVMFlag::SUCCESS;
   } else if (result->is_uintx()) {
     uintx uintx_v = (uintx) v;
-    return CommandLineFlags::uintxAtPut(result, &uintx_v, origin) == Flag::SUCCESS;
+    return JVMFlag::uintxAtPut(result, &uintx_v, origin) == JVMFlag::SUCCESS;
   } else if (result->is_uint64_t()) {
     uint64_t uint64_t_v = (uint64_t) v;
-    return CommandLineFlags::uint64_tAtPut(result, &uint64_t_v, origin) == Flag::SUCCESS;
+    return JVMFlag::uint64_tAtPut(result, &uint64_t_v, origin) == JVMFlag::SUCCESS;
   } else if (result->is_size_t()) {
     size_t size_t_v = (size_t) v;
-    return CommandLineFlags::size_tAtPut(result, &size_t_v, origin) == Flag::SUCCESS;
+    return JVMFlag::size_tAtPut(result, &size_t_v, origin) == JVMFlag::SUCCESS;
   } else if (result->is_double()) {
     double double_v = (double) v;
-    return CommandLineFlags::doubleAtPut(result, &double_v, origin) == Flag::SUCCESS;
+    return JVMFlag::doubleAtPut(result, &double_v, origin) == JVMFlag::SUCCESS;
   } else {
     return false;
   }
 }
 
-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.
+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.
   FREE_C_HEAP_ARRAY(char, value);
   return true;
 }
 
-static bool append_to_string_flag(const char* name, const char* new_value, Flag::Flags origin) {
+static bool append_to_string_flag(const char* name, const char* new_value, JVMFlag::Flags origin) {
   const char* old_value = "";
-  if (CommandLineFlags::ccstrAt(name, &old_value) != Flag::SUCCESS) return false;
+  if (JVMFlag::ccstrAt(name, &old_value) != JVMFlag::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) CommandLineFlags::ccstrAtPut(name, &value, origin);
-  // CommandLineFlags always returns a pointer that needs freeing.
+  (void) JVMFlag::ccstrAtPut(name, &value, origin);
+  // JVMFlag always returns a pointer that needs freeing.
   FREE_C_HEAP_ARRAY(char, value);
   if (free_this_too != NULL) {
-    // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
+    // JVMFlag 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, Flag::Flags origin) {
+bool Arguments::parse_argument(const char* arg, JVMFlag::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;
-    Flag* flag;
+    JVMFlag* 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 = Flag::find_flag(real_name);
+    flag = JVMFlag::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,
-                                 Flag::Flags origin) {
+                                 JVMFlag::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.
-  Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true);
+  JVMFlag* found_flag = JVMFlag::find_flag((const char*)argname, arg_len, true, true);
   if (found_flag != NULL) {
     char locked_message_buf[BUFLEN];
-    Flag::MsgType msg_type = found_flag->get_locked_message(locked_message_buf, BUFLEN);
+    JVMFlag::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 == Flag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD) ||
-                         (msg_type == Flag::DEVELOPER_FLAG_BUT_PRODUCT_BUILD));
+      bool mismatched = ((msg_type == JVMFlag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD) ||
+                         (msg_type == JVMFlag::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);
-    Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true);
+    JVMFlag* fuzzy_matched = JVMFlag::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, Flag::CONFIG_FILE);
+        result &= process_argument(token, ignore_unrecognized, JVMFlag::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, Flag::CONFIG_FILE);
+    result &= process_argument(token, ignore_unrecognized, JVMFlag::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) != Flag::SUCCESS) {
+    if (FLAG_SET_CMDLINE(size_t, MaxHeapSize, initHeapSize) != JVMFlag::SUCCESS) {
       return JNI_EINVAL;
     }
-    if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize) != Flag::SUCCESS) {
+    if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize) != JVMFlag::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) != Flag::SUCCESS) {
+            ((julong) MaxHeapSize / (julong) 8) * (julong) 3) != JVMFlag::SUCCESS) {
       return JNI_EINVAL;
     }
-    if (FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize) != Flag::SUCCESS) {
+    if (FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize) != JVMFlag::SUCCESS) {
       return JNI_EINVAL;
     }
   }
@@ -2016,20 +2016,20 @@
 #endif
 
   // Increase some data structure sizes for efficiency
-  if (FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize) != Flag::SUCCESS) {
+  if (FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize) != JVMFlag::SUCCESS) {
     return JNI_EINVAL;
   }
-  if (FLAG_SET_CMDLINE(bool, ResizeTLAB, false) != Flag::SUCCESS) {
+  if (FLAG_SET_CMDLINE(bool, ResizeTLAB, false) != JVMFlag::SUCCESS) {
     return JNI_EINVAL;
   }
-  if (FLAG_SET_CMDLINE(size_t, TLABSize, 256 * K) != Flag::SUCCESS) {
+  if (FLAG_SET_CMDLINE(size_t, TLABSize, 256 * K) != JVMFlag::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) != Flag::SUCCESS) { // Note: this is in words
+  if (FLAG_SET_CMDLINE(size_t, YoungPLABSize, 256 * K) != JVMFlag::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) != Flag::SUCCESS) { // Note: this is in words
+  if (FLAG_SET_CMDLINE(size_t, OldPLABSize, 8 * K) != JVMFlag::SUCCESS) { // Note: this is in words
     return JNI_EINVAL;
   }
 
   // Enable parallel GC and adaptive generation sizing
-  if (FLAG_SET_CMDLINE(bool, UseParallelGC, true) != Flag::SUCCESS) {
+  if (FLAG_SET_CMDLINE(bool, UseParallelGC, true) != JVMFlag::SUCCESS) {
     return JNI_EINVAL;
   }
 
   // Encourage steady state memory management
-  if (FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100) != Flag::SUCCESS) {
+  if (FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100) != JVMFlag::SUCCESS) {
     return JNI_EINVAL;
   }
 
   // This appears to improve mutator locality
-  if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != Flag::SUCCESS) {
+  if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != JVMFlag::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) != Flag::SUCCESS) {
+  if (FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true) != JVMFlag::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, Flag::ENVIRON_VAR);
+  jint result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, JVMFlag::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, Flag::COMMAND_LINE);
+  result = parse_each_vm_init_arg(cmd_line_args, &patch_mod_javabase, JVMFlag::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, Flag::ENVIRON_VAR);
+  result = parse_each_vm_init_arg(java_options_args, &patch_mod_javabase, JVMFlag::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, Flag::Flags origin) {
+jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, JVMFlag::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) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, ClassUnloading, false) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
     // -Xconcgc
     } else if (match_option(option, "-Xconcgc")) {
-      if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(size_t, MaxNewSize, (size_t)long_initial_young_size) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(size_t, NewSize, (size_t)long_initial_young_size) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(size_t, NewSize, (size_t)long_initial_young_size) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(size_t, InitialHeapSize, (size_t)long_initial_heap_size) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(size_t, MaxHeapSize, (size_t)long_max_heap_size) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
     // Xmaxf
@@ -2812,7 +2812,7 @@
                     option->optionString);
         return JNI_EINVAL;
       } else {
-        if (FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf) != JVMFlag::SUCCESS) {
             return JNI_EINVAL;
         }
       }
@@ -2826,7 +2826,7 @@
                     option->optionString);
         return JNI_EINVAL;
       } else {
-        if (FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf) != JVMFlag::SUCCESS) {
           return JNI_EINVAL;
         }
       }
@@ -2837,7 +2837,7 @@
       if (err != JNI_OK) {
         return err;
       }
-      if (FLAG_SET_CMDLINE(intx, ThreadStackSize, value) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(intx, ThreadStackSize, value) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
       SafepointSynchronize::set_defer_thr_suspend_loop_count();
-      if (FLAG_SET_CMDLINE(bool, UseTLAB, false) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, UseTLAB, false) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(size_t, NewSizeThreadIncrease, 16 * K) != Flag::SUCCESS) {  // 20Kb per thread added to new generation
+      if (FLAG_SET_CMDLINE(size_t, NewSizeThreadIncrease, 16 * K) != JVMFlag::SUCCESS) {  // 20Kb per thread added to new generation
         return JNI_EINVAL;
       }
 
@@ -2897,7 +2897,7 @@
 #ifndef PRODUCT
     // -Xprintflags
     } else if (match_option(option, "-Xprintflags")) {
-      CommandLineFlags::printFlags(tty, false);
+      JVMFlag::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) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
     // -Xshare:auto
     } else if (match_option(option, "-Xshare:auto")) {
-      if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
     // -Xshare:off
     } else if (match_option(option, "-Xshare:off")) {
-      if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, false) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, false) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != JVMFlag::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) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true) != JVMFlag::SUCCESS) {
           return JNI_EINVAL;
         }
-        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != JVMFlag::SUCCESS) {
           return JNI_EINVAL;
         }
       } else if (strcmp(tail, ":remote") == 0) {
-        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != JVMFlag::SUCCESS) {
           return JNI_EINVAL;
         }
-        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != JVMFlag::SUCCESS) {
           return JNI_EINVAL;
         }
       } else if (strcmp(tail, ":none") == 0) {
-        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != JVMFlag::SUCCESS) {
           return JNI_EINVAL;
         }
-        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, NeverTenure, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
     } else if (match_option(option, "-XX:+AlwaysTenure")) {
-      if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, max_tenuring_thresh) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
 
       if (MaxTenuringThreshold == 0) {
-        if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != JVMFlag::SUCCESS) {
           return JNI_EINVAL;
         }
-        if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != JVMFlag::SUCCESS) {
           return JNI_EINVAL;
         }
       } else {
-        if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != JVMFlag::SUCCESS) {
           return JNI_EINVAL;
         }
-        if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) {
+        if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != JVMFlag::SUCCESS) {
           return JNI_EINVAL;
         }
       }
     } else if (match_option(option, "-XX:+DisplayVMOutputToStderr")) {
-      if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
     } else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) {
-      if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
     } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) {
 #if defined(DTRACE_ENABLED)
-      if (FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
-      if (FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true) != JVMFlag::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) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, FullGCALot, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
       // disable scavenge before parallel mark-compact
-      if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != Flag::SUCCESS) {
+      if (FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
 #endif
@@ -3178,10 +3178,10 @@
   //   -Xshare:on
   //   -Xlog:class+path=info
   if (PrintSharedArchiveAndExit) {
-    if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) {
+    if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != JVMFlag::SUCCESS) {
       return JNI_EINVAL;
     }
-    if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) {
+    if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != JVMFlag::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")) {
-      CommandLineFlags::printFlags(tty, false);
+      JVMFlag::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")) {
-      CommandLineFlags::printFlags(tty, true);
+      JVMFlag::printFlags(tty, true);
       vm_exit(0);
     }
 #endif
 
     if (match_option(option, "-XX:+UseAppCDS")) {
-      Flag* flag = Flag::find_flag("SharedArchiveFile", 17, true, true);
+      JVMFlag* flag = JVMFlag::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
-  CommandLineFlagRangeList::init();
-  CommandLineFlagConstraintList::init();
-  CommandLineFlagWriteableList::init();
+  JVMFlagRangeList::init();
+  JVMFlagConstraintList::init();
+  JVMFlagWriteableList::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) {
-    CommandLineFlags::printSetFlags(tty);
+    JVMFlag::printSetFlags(tty);
   }
 
   // Apply CPU specific policy for the BiasedLocking
--- a/src/hotspot/share/runtime/arguments.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/arguments.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -28,6 +28,7 @@
 #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"
@@ -413,8 +414,8 @@
 
   // Argument parsing
   static void do_pd_flag_adjustments();
-  static bool parse_argument(const char* arg, Flag::Flags origin);
-  static bool process_argument(const char* arg, jboolean ignore_unrecognized, Flag::Flags origin);
+  static bool parse_argument(const char* arg, JVMFlag::Flags origin);
+  static bool process_argument(const char* arg, jboolean ignore_unrecognized, JVMFlag::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);
@@ -442,7 +443,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, Flag::Flags origin);
+  static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, JVMFlag::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);
 
--- a/src/hotspot/share/runtime/commandLineFlagConstraintList.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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/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;
-}
--- a/src/hotspot/share/runtime/commandLineFlagConstraintList.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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_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 */
--- a/src/hotspot/share/runtime/commandLineFlagConstraintsCompiler.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,407 +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/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;
-}
--- a/src/hotspot/share/runtime/commandLineFlagConstraintsCompiler.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +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_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 */
--- a/src/hotspot/share/runtime/commandLineFlagConstraintsRuntime.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +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/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;
-}
--- a/src/hotspot/share/runtime/commandLineFlagConstraintsRuntime.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +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_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 */
--- a/src/hotspot/share/runtime/commandLineFlagRangeList.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,441 +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/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;
-}
--- a/src/hotspot/share/runtime/commandLineFlagRangeList.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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_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
--- a/src/hotspot/share/runtime/commandLineFlagWriteableList.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ /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.
- *
- * 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();
-  }
-}
--- a/src/hotspot/share/runtime/commandLineFlagWriteableList.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +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_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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/flagSetting.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -0,0 +1,71 @@
+/*
+ * 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlag.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -0,0 +1,1506 @@
+/*
+ * 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);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlag.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -0,0 +1,283 @@
+/*
+ * 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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/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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintList.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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_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 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -0,0 +1,408 @@
+/*
+ * 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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -0,0 +1,74 @@
+/*
+ * 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 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -0,0 +1,144 @@
+/*
+ * 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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -0,0 +1,50 @@
+/*
+ * 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 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -0,0 +1,442 @@
+/*
+ * 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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlagRangeList.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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_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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlagWriteableList.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -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/flags/jvmFlagWriteableList.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 JVMFlagWriteable::is_writeable(void) {
+  return _writeable;
+}
+
+void JVMFlagWriteable::mark_once(void) {
+  if (_type == Once) {
+    _writeable = false;
+  }
+}
+
+void JVMFlagWriteable::mark_startup(void) {
+  if (_type == JVMFlagWriteable::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 */ }
+
+// JVMFlagWriteable emitting code functions if range arguments are provided
+void emit_writeable_bool(const char* name, JVMFlagWriteable::WriteableType type) {
+  JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
+}
+void emit_writeable_int(const char* name, JVMFlagWriteable::WriteableType type) {
+  JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
+}
+void emit_writeable_intx(const char* name, JVMFlagWriteable::WriteableType type) {
+  JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
+}
+void emit_writeable_uint(const char* name, JVMFlagWriteable::WriteableType type) {
+  JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
+}
+void emit_writeable_uintx(const char* name, JVMFlagWriteable::WriteableType type) {
+  JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
+}
+void emit_writeable_uint64_t(const char* name, JVMFlagWriteable::WriteableType type) {
+  JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
+}
+void emit_writeable_size_t(const char* name, JVMFlagWriteable::WriteableType type) {
+  JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
+}
+void emit_writeable_double(const char* name, JVMFlagWriteable::WriteableType type) {
+  JVMFlagWriteableList::add(new JVMFlagWriteable(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)                                      , JVMFlagWriteable::a
+
+#define INITIAL_WRITEABLES_SIZE 2
+GrowableArray<JVMFlagWriteable*>* JVMFlagWriteableList::_controls = NULL;
+
+void JVMFlagWriteableList::init(void) {
+
+  _controls = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<JVMFlagWriteable*>(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
+}
+
+JVMFlagWriteable* JVMFlagWriteableList::find(const char* name) {
+  JVMFlagWriteable* found = NULL;
+  for (int i=0; i<length(); i++) {
+    JVMFlagWriteable* writeable = at(i);
+    if (strcmp(writeable->name(), name) == 0) {
+      found = writeable;
+      break;
+    }
+  }
+  return found;
+}
+
+void JVMFlagWriteableList::mark_startup(void) {
+  for (int i=0; i<length(); i++) {
+    JVMFlagWriteable* writeable = at(i);
+    writeable->mark_startup();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlagWriteableList.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -0,0 +1,67 @@
+/*
+ * 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_JVMFLAGWRITEABLE_HPP
+#define SHARE_VM_RUNTIME_JVMFLAGWRITEABLE_HPP
+
+#include "utilities/growableArray.hpp"
+
+class JVMFlagWriteable : 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
+  JVMFlagWriteable(const char* name, WriteableType type) { _name=name; _type=type; _writeable=true; _startup_done=false; }
+  ~JVMFlagWriteable() {}
+  const char* name() { return _name; }
+  const WriteableType type() { return _type; }
+  bool is_writeable(void);
+  void mark_once(void);
+  void mark_startup(void);
+};
+
+class JVMFlagWriteableList : public AllStatic {
+  static GrowableArray<JVMFlagWriteable*>* _controls;
+public:
+  static void init();
+  static int length() { return (_controls != NULL) ? _controls->length() : 0; }
+  static JVMFlagWriteable* at(int i) { return (_controls != NULL) ? _controls->at(i) : NULL; }
+  static JVMFlagWriteable* find(const char* name);
+  static void add(JVMFlagWriteable* range) { _controls->append(range); }
+  static void mark_startup(void);
+};
+
+#endif // SHARE_VM_RUNTIME_JVMFLAGWRITEABLE_HPP
--- a/src/hotspot/share/runtime/globals.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/globals.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -29,9 +29,9 @@
 #include "runtime/arguments.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/globals_extension.hpp"
-#include "runtime/commandLineFlagConstraintList.hpp"
-#include "runtime/commandLineFlagWriteableList.hpp"
-#include "runtime/commandLineFlagRangeList.hpp"
+#include "runtime/flags/jvmFlagConstraintList.hpp"
+#include "runtime/flags/jvmFlagWriteableList.hpp"
+#include "runtime/flags/jvmFlagRangeList.hpp"
 #include "runtime/os.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "trace/tracing.hpp"
@@ -85,1473 +85,3 @@
            IGNORE_WRITEABLE)
 
 MATERIALIZE_FLAGS_EXT
-
-#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* Flag::get_int_default_range_str() {
-  return create_range_str("[ " INT32_FORMAT_W(-25) " ... " INT32_FORMAT_W(25) " ]", INT_MIN, INT_MAX);
-}
-
-const char* Flag::get_uint_default_range_str() {
-  return create_range_str("[ " UINT32_FORMAT_W(-25) " ... " UINT32_FORMAT_W(25) " ]", 0, UINT_MAX);
-}
-
-const char* Flag::get_intx_default_range_str() {
-  return create_range_str("[ " INTX_FORMAT_W(-25) " ... " INTX_FORMAT_W(25) " ]", min_intx, max_intx);
-}
-
-const char* Flag::get_uintx_default_range_str() {
-  return create_range_str("[ " UINTX_FORMAT_W(-25) " ... " UINTX_FORMAT_W(25) " ]", 0, max_uintx);
-}
-
-const char* Flag::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* Flag::get_size_t_default_range_str() {
-  return create_range_str("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", 0, SIZE_MAX);
-}
-
-const char* Flag::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
-}
-
-Flag::Error Flag::check_writable(bool changed) {
-  if (is_constant_in_binary()) {
-    fatal("flag is constant: %s", _name);
-  }
-
-  Flag::Error error = Flag::SUCCESS;
-  if (changed) {
-    CommandLineFlagWriteable* writeable = CommandLineFlagWriteableList::find(_name);
-    if (writeable) {
-      if (writeable->is_writeable() == false) {
-        switch (writeable->type())
-        {
-          case CommandLineFlagWriteable::Once:
-            error = Flag::SET_ONLY_ONCE;
-            jio_fprintf(defaultStream::error_stream(), "Error: %s may not be set more than once\n", _name);
-            break;
-          case CommandLineFlagWriteable::CommandLineOnly:
-            error = Flag::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 Flag::is_bool() const {
-  return strcmp(_type, "bool") == 0;
-}
-
-bool Flag::get_bool() const {
-  return *((bool*) _addr);
-}
-
-Flag::Error Flag::set_bool(bool value) {
-  Flag::Error error = check_writable(value!=get_bool());
-  if (error == Flag::SUCCESS) {
-    *((bool*) _addr) = value;
-  }
-  return error;
-}
-
-bool Flag::is_int() const {
-  return strcmp(_type, "int")  == 0;
-}
-
-int Flag::get_int() const {
-  return *((int*) _addr);
-}
-
-Flag::Error Flag::set_int(int value) {
-  Flag::Error error = check_writable(value!=get_int());
-  if (error == Flag::SUCCESS) {
-    *((int*) _addr) = value;
-  }
-  return error;
-}
-
-bool Flag::is_uint() const {
-  return strcmp(_type, "uint")  == 0;
-}
-
-uint Flag::get_uint() const {
-  return *((uint*) _addr);
-}
-
-Flag::Error Flag::set_uint(uint value) {
-  Flag::Error error = check_writable(value!=get_uint());
-  if (error == Flag::SUCCESS) {
-    *((uint*) _addr) = value;
-  }
-  return error;
-}
-
-bool Flag::is_intx() const {
-  return strcmp(_type, "intx")  == 0;
-}
-
-intx Flag::get_intx() const {
-  return *((intx*) _addr);
-}
-
-Flag::Error Flag::set_intx(intx value) {
-  Flag::Error error = check_writable(value!=get_intx());
-  if (error == Flag::SUCCESS) {
-    *((intx*) _addr) = value;
-  }
-  return error;
-}
-
-bool Flag::is_uintx() const {
-  return strcmp(_type, "uintx") == 0;
-}
-
-uintx Flag::get_uintx() const {
-  return *((uintx*) _addr);
-}
-
-Flag::Error Flag::set_uintx(uintx value) {
-  Flag::Error error = check_writable(value!=get_uintx());
-  if (error == Flag::SUCCESS) {
-    *((uintx*) _addr) = value;
-  }
-  return error;
-}
-
-bool Flag::is_uint64_t() const {
-  return strcmp(_type, "uint64_t") == 0;
-}
-
-uint64_t Flag::get_uint64_t() const {
-  return *((uint64_t*) _addr);
-}
-
-Flag::Error Flag::set_uint64_t(uint64_t value) {
-  Flag::Error error = check_writable(value!=get_uint64_t());
-  if (error == Flag::SUCCESS) {
-    *((uint64_t*) _addr) = value;
-  }
-  return error;
-}
-
-bool Flag::is_size_t() const {
-  return strcmp(_type, "size_t") == 0;
-}
-
-size_t Flag::get_size_t() const {
-  return *((size_t*) _addr);
-}
-
-Flag::Error Flag::set_size_t(size_t value) {
-  Flag::Error error = check_writable(value!=get_size_t());
-  if (error == Flag::SUCCESS) {
-    *((size_t*) _addr) = value;
-  }
-  return error;
-}
-
-bool Flag::is_double() const {
-  return strcmp(_type, "double") == 0;
-}
-
-double Flag::get_double() const {
-  return *((double*) _addr);
-}
-
-Flag::Error Flag::set_double(double value) {
-  Flag::Error error = check_writable(value!=get_double());
-  if (error == Flag::SUCCESS) {
-    *((double*) _addr) = value;
-  }
-  return error;
-}
-
-bool Flag::is_ccstr() const {
-  return strcmp(_type, "ccstr") == 0 || strcmp(_type, "ccstrlist") == 0;
-}
-
-bool Flag::ccstr_accumulates() const {
-  return strcmp(_type, "ccstrlist") == 0;
-}
-
-ccstr Flag::get_ccstr() const {
-  return *((ccstr*) _addr);
-}
-
-Flag::Error Flag::set_ccstr(ccstr value) {
-  Flag::Error error = check_writable(value!=get_ccstr());
-  if (error == Flag::SUCCESS) {
-    *((ccstr*) _addr) = value;
-  }
-  return error;
-}
-
-
-Flag::Flags Flag::get_origin() {
-  return Flags(_flags & VALUE_ORIGIN_MASK);
-}
-
-void Flag::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 Flag::is_default() {
-  return (get_origin() == DEFAULT);
-}
-
-bool Flag::is_ergonomic() {
-  return (get_origin() == ERGONOMIC);
-}
-
-bool Flag::is_command_line() {
-  return (_flags & ORIG_COMMAND_LINE) != 0;
-}
-
-void Flag::set_command_line() {
-  _flags = Flags(_flags | ORIG_COMMAND_LINE);
-}
-
-bool Flag::is_product() const {
-  return (_flags & KIND_PRODUCT) != 0;
-}
-
-bool Flag::is_manageable() const {
-  return (_flags & KIND_MANAGEABLE) != 0;
-}
-
-bool Flag::is_diagnostic() const {
-  return (_flags & KIND_DIAGNOSTIC) != 0;
-}
-
-bool Flag::is_experimental() const {
-  return (_flags & KIND_EXPERIMENTAL) != 0;
-}
-
-bool Flag::is_notproduct() const {
-  return (_flags & KIND_NOT_PRODUCT) != 0;
-}
-
-bool Flag::is_develop() const {
-  return (_flags & KIND_DEVELOP) != 0;
-}
-
-bool Flag::is_read_write() const {
-  return (_flags & KIND_READ_WRITE) != 0;
-}
-
-bool Flag::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 Flag::is_constant_in_binary() const {
-#ifdef PRODUCT
-    return is_notproduct() || is_develop();
-#else
-    return false;
-#endif
-}
-
-bool Flag::is_unlocker() const {
-  return strcmp(_name, "UnlockDiagnosticVMOptions") == 0     ||
-         strcmp(_name, "UnlockExperimentalVMOptions") == 0   ||
-         is_unlocker_ext();
-}
-
-bool Flag::is_unlocked() const {
-  if (is_diagnostic()) {
-    return UnlockDiagnosticVMOptions;
-  }
-  if (is_experimental()) {
-    return UnlockExperimentalVMOptions;
-  }
-  return is_unlocked_ext();
-}
-
-void Flag::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.
-Flag::MsgType Flag::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 Flag::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 Flag::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 Flag::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 Flag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD;
-  }
-  return get_locked_message_ext(buf, buflen);
-}
-
-bool Flag::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 Flag::is_external() const {
-  return is_manageable() || is_external_ext();
-}
-
-// Helper function for Flag::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 Flag::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 = Flag::get_int_default_range_str;
-    } else if (is_uint()) {
-      func = Flag::get_uint_default_range_str;
-    } else if (is_intx()) {
-      func = Flag::get_intx_default_range_str;
-    } else if (is_uintx()) {
-      func = Flag::get_uintx_default_range_str;
-    } else if (is_uint64_t()) {
-      func = Flag::get_uint64_t_default_range_str;
-    } else if (is_size_t()) {
-      func = Flag::get_size_t_default_range_str;
-    } else if (is_double()) {
-      func = Flag::get_double_default_range_str;
-    } else {
-      st->print("unhandled  type %s", _type);
-      st->cr();
-      return;
-    }
-    CommandLineFlagRangeList::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 Flag::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 Flag::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 Flag::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* Flag::flag_error_str(Flag::Error error) {
-  switch (error) {
-    case Flag::MISSING_NAME: return "MISSING_NAME";
-    case Flag::MISSING_VALUE: return "MISSING_VALUE";
-    case Flag::NON_WRITABLE: return "NON_WRITABLE";
-    case Flag::OUT_OF_BOUNDS: return "OUT_OF_BOUNDS";
-    case Flag::VIOLATES_CONSTRAINT: return "VIOLATES_CONSTRAINT";
-    case Flag::INVALID_FLAG: return "INVALID_FLAG";
-    case Flag::ERR_OTHER: return "ERR_OTHER";
-    case Flag::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) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT) },
-#define RUNTIME_PD_PRODUCT_FLAG_STRUCT(  type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
-#define RUNTIME_DIAGNOSTIC_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DIAGNOSTIC) },
-#define RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT(type, name,       doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) },
-#define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_EXPERIMENTAL) },
-#define RUNTIME_MANAGEABLE_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_MANAGEABLE) },
-#define RUNTIME_PRODUCT_RW_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_PRODUCT | Flag::KIND_READ_WRITE) },
-#define RUNTIME_DEVELOP_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DEVELOP) },
-#define RUNTIME_PD_DEVELOP_FLAG_STRUCT(  type, name,        doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
-#define RUNTIME_NOTPRODUCT_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_NOT_PRODUCT) },
-
-#define JVMCI_PRODUCT_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_PRODUCT) },
-#define JVMCI_PD_PRODUCT_FLAG_STRUCT(    type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
-#define JVMCI_DIAGNOSTIC_FLAG_STRUCT(    type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DIAGNOSTIC) },
-#define JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT( type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) },
-#define JVMCI_EXPERIMENTAL_FLAG_STRUCT(  type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_EXPERIMENTAL) },
-#define JVMCI_DEVELOP_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DEVELOP) },
-#define JVMCI_PD_DEVELOP_FLAG_STRUCT(    type, name,        doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
-#define JVMCI_NOTPRODUCT_FLAG_STRUCT(    type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_NOT_PRODUCT) },
-
-#ifdef _LP64
-#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::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) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_PRODUCT) },
-#define C1_PD_PRODUCT_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
-#define C1_DIAGNOSTIC_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DIAGNOSTIC) },
-#define C1_PD_DIAGNOSTIC_FLAG_STRUCT(    type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) },
-#define C1_DEVELOP_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP) },
-#define C1_PD_DEVELOP_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
-#define C1_NOTPRODUCT_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_NOT_PRODUCT) },
-
-#define C2_PRODUCT_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT) },
-#define C2_PD_PRODUCT_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) },
-#define C2_DIAGNOSTIC_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DIAGNOSTIC) },
-#define C2_PD_DIAGNOSTIC_FLAG_STRUCT(    type, name,        doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DIAGNOSTIC | Flag::KIND_PLATFORM_DEPENDENT) },
-#define C2_EXPERIMENTAL_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_EXPERIMENTAL) },
-#define C2_DEVELOP_FLAG_STRUCT(          type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DEVELOP) },
-#define C2_PD_DEVELOP_FLAG_STRUCT(       type, name,        doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
-#define C2_NOTPRODUCT_FLAG_STRUCT(       type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_NOT_PRODUCT) },
-
-#define ARCH_PRODUCT_FLAG_STRUCT(        type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_PRODUCT) },
-#define ARCH_DIAGNOSTIC_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_DIAGNOSTIC) },
-#define ARCH_EXPERIMENTAL_FLAG_STRUCT(   type, name, value, doc) { #type, XSTR(name), &name,         NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_EXPERIMENTAL) },
-#define ARCH_DEVELOP_FLAG_STRUCT(        type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_DEVELOP) },
-#define ARCH_NOTPRODUCT_FLAG_STRUCT(     type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_ARCH | Flag::KIND_NOT_PRODUCT) },
-
-static Flag 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}
-};
-
-Flag* Flag::flags = flagTable;
-size_t Flag::numFlags = (sizeof(flagTable) / sizeof(Flag));
-
-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
-Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked, bool return_flag) {
-  for (Flag* 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;
-    }
-  }
-  // Flag name is not in the flag table
-  return NULL;
-}
-
-// Get or compute the flag name length
-size_t Flag::get_name_length() {
-  if (_name_len == 0) {
-    _name_len = strlen(_name);
-  }
-  return _name_len;
-}
-
-Flag* Flag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
-  float VMOptionsFuzzyMatchSimilarity = 0.7f;
-  Flag* match = NULL;
-  float score;
-  float max_score = -1;
-
-  for (Flag* 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 Flag* address_of_flag(CommandLineFlagWithType flag) {
-  assert((size_t)flag < Flag::numFlags, "bad command line flag index");
-  return &Flag::flags[flag];
-}
-
-bool CommandLineFlagsEx::is_default(CommandLineFlag flag) {
-  assert((size_t)flag < Flag::numFlags, "bad command line flag index");
-  Flag* f = &Flag::flags[flag];
-  return f->is_default();
-}
-
-bool CommandLineFlagsEx::is_ergo(CommandLineFlag flag) {
-  assert((size_t)flag < Flag::numFlags, "bad command line flag index");
-  Flag* f = &Flag::flags[flag];
-  return f->is_ergonomic();
-}
-
-bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) {
-  assert((size_t)flag < Flag::numFlags, "bad command line flag index");
-  Flag* f = &Flag::flags[flag];
-  return f->is_command_line();
-}
-
-bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) {
-  Flag* result = Flag::find_flag((char*)name, strlen(name));
-  if (result == NULL) return false;
-  *value = result->is_command_line();
-  return true;
-}
-
-void CommandLineFlagsEx::setOnCmdLine(CommandLineFlagWithType flag) {
-  Flag* 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 Flag::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 Flag::Error apply_constraint_and_check_range_bool(const char* name, bool new_value, bool verbose) {
-  Flag::Error status = Flag::SUCCESS;
-  CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
-  if (constraint != NULL) {
-    status = constraint->apply_bool(new_value, verbose);
-  }
-  return status;
-}
-
-Flag::Error CommandLineFlags::boolAt(const char* name, size_t len, bool* value, bool allow_locked, bool return_flag) {
-  Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return Flag::INVALID_FLAG;
-  if (!result->is_bool()) return Flag::WRONG_FORMAT;
-  *value = result->get_bool();
-  return Flag::SUCCESS;
-}
-
-Flag::Error CommandLineFlags::boolAtPut(Flag* flag, bool* value, Flag::Flags origin) {
-  const char* name;
-  if (flag == NULL) return Flag::INVALID_FLAG;
-  if (!flag->is_bool()) return Flag::WRONG_FORMAT;
-  name = flag->_name;
-  Flag::Error check = apply_constraint_and_check_range_bool(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
-  if (check != Flag::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;
-}
-
-Flag::Error CommandLineFlags::boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin) {
-  Flag* result = Flag::find_flag(name, len);
-  return boolAtPut(result, value, origin);
-}
-
-Flag::Error CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
-  Flag* faddr = address_of_flag(flag);
-  guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
-  return CommandLineFlags::boolAtPut(faddr, &value, origin);
-}
-
-static Flag::Error apply_constraint_and_check_range_int(const char* name, int new_value, bool verbose) {
-  Flag::Error status = Flag::SUCCESS;
-  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
-  if (range != NULL) {
-    status = range->check_int(new_value, verbose);
-  }
-  if (status == Flag::SUCCESS) {
-    CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
-    if (constraint != NULL) {
-      status = constraint->apply_int(new_value, verbose);
-    }
-  }
-  return status;
-}
-
-Flag::Error CommandLineFlags::intAt(const char* name, size_t len, int* value, bool allow_locked, bool return_flag) {
-  Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return Flag::INVALID_FLAG;
-  if (!result->is_int()) return Flag::WRONG_FORMAT;
-  *value = result->get_int();
-  return Flag::SUCCESS;
-}
-
-Flag::Error CommandLineFlags::intAtPut(Flag* flag, int* value, Flag::Flags origin) {
-  const char* name;
-  if (flag == NULL) return Flag::INVALID_FLAG;
-  if (!flag->is_int()) return Flag::WRONG_FORMAT;
-  name = flag->_name;
-  Flag::Error check = apply_constraint_and_check_range_int(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
-  if (check != Flag::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;
-}
-
-Flag::Error CommandLineFlags::intAtPut(const char* name, size_t len, int* value, Flag::Flags origin) {
-  Flag* result = Flag::find_flag(name, len);
-  return intAtPut(result, value, origin);
-}
-
-Flag::Error CommandLineFlagsEx::intAtPut(CommandLineFlagWithType flag, int value, Flag::Flags origin) {
-  Flag* faddr = address_of_flag(flag);
-  guarantee(faddr != NULL && faddr->is_int(), "wrong flag type");
-  return CommandLineFlags::intAtPut(faddr, &value, origin);
-}
-
-static Flag::Error apply_constraint_and_check_range_uint(const char* name, uint new_value, bool verbose) {
-  Flag::Error status = Flag::SUCCESS;
-  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
-  if (range != NULL) {
-    status = range->check_uint(new_value, verbose);
-  }
-  if (status == Flag::SUCCESS) {
-    CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
-    if (constraint != NULL) {
-      status = constraint->apply_uint(new_value, verbose);
-    }
-  }
-  return status;
-}
-
-Flag::Error CommandLineFlags::uintAt(const char* name, size_t len, uint* value, bool allow_locked, bool return_flag) {
-  Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return Flag::INVALID_FLAG;
-  if (!result->is_uint()) return Flag::WRONG_FORMAT;
-  *value = result->get_uint();
-  return Flag::SUCCESS;
-}
-
-Flag::Error CommandLineFlags::uintAtPut(Flag* flag, uint* value, Flag::Flags origin) {
-  const char* name;
-  if (flag == NULL) return Flag::INVALID_FLAG;
-  if (!flag->is_uint()) return Flag::WRONG_FORMAT;
-  name = flag->_name;
-  Flag::Error check = apply_constraint_and_check_range_uint(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
-  if (check != Flag::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;
-}
-
-Flag::Error CommandLineFlags::uintAtPut(const char* name, size_t len, uint* value, Flag::Flags origin) {
-  Flag* result = Flag::find_flag(name, len);
-  return uintAtPut(result, value, origin);
-}
-
-Flag::Error CommandLineFlagsEx::uintAtPut(CommandLineFlagWithType flag, uint value, Flag::Flags origin) {
-  Flag* faddr = address_of_flag(flag);
-  guarantee(faddr != NULL && faddr->is_uint(), "wrong flag type");
-  return CommandLineFlags::uintAtPut(faddr, &value, origin);
-}
-
-Flag::Error CommandLineFlags::intxAt(const char* name, size_t len, intx* value, bool allow_locked, bool return_flag) {
-  Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return Flag::INVALID_FLAG;
-  if (!result->is_intx()) return Flag::WRONG_FORMAT;
-  *value = result->get_intx();
-  return Flag::SUCCESS;
-}
-
-static Flag::Error apply_constraint_and_check_range_intx(const char* name, intx new_value, bool verbose) {
-  Flag::Error status = Flag::SUCCESS;
-  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
-  if (range != NULL) {
-    status = range->check_intx(new_value, verbose);
-  }
-  if (status == Flag::SUCCESS) {
-    CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
-    if (constraint != NULL) {
-      status = constraint->apply_intx(new_value, verbose);
-    }
-  }
-  return status;
-}
-
-Flag::Error CommandLineFlags::intxAtPut(Flag* flag, intx* value, Flag::Flags origin) {
-  const char* name;
-  if (flag == NULL) return Flag::INVALID_FLAG;
-  if (!flag->is_intx()) return Flag::WRONG_FORMAT;
-  name = flag->_name;
-  Flag::Error check = apply_constraint_and_check_range_intx(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
-  if (check != Flag::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;
-}
-
-Flag::Error CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) {
-  Flag* result = Flag::find_flag(name, len);
-  return intxAtPut(result, value, origin);
-}
-
-Flag::Error CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
-  Flag* faddr = address_of_flag(flag);
-  guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
-  return CommandLineFlags::intxAtPut(faddr, &value, origin);
-}
-
-Flag::Error CommandLineFlags::uintxAt(const char* name, size_t len, uintx* value, bool allow_locked, bool return_flag) {
-  Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return Flag::INVALID_FLAG;
-  if (!result->is_uintx()) return Flag::WRONG_FORMAT;
-  *value = result->get_uintx();
-  return Flag::SUCCESS;
-}
-
-static Flag::Error apply_constraint_and_check_range_uintx(const char* name, uintx new_value, bool verbose) {
-  Flag::Error status = Flag::SUCCESS;
-  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
-  if (range != NULL) {
-    status = range->check_uintx(new_value, verbose);
-  }
-  if (status == Flag::SUCCESS) {
-    CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
-    if (constraint != NULL) {
-      status = constraint->apply_uintx(new_value, verbose);
-    }
-  }
-  return status;
-}
-
-Flag::Error CommandLineFlags::uintxAtPut(Flag* flag, uintx* value, Flag::Flags origin) {
-  const char* name;
-  if (flag == NULL) return Flag::INVALID_FLAG;
-  if (!flag->is_uintx()) return Flag::WRONG_FORMAT;
-  name = flag->_name;
-  Flag::Error check = apply_constraint_and_check_range_uintx(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
-  if (check != Flag::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;
-}
-
-Flag::Error CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) {
-  Flag* result = Flag::find_flag(name, len);
-  return uintxAtPut(result, value, origin);
-}
-
-Flag::Error CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
-  Flag* faddr = address_of_flag(flag);
-  guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
-  return CommandLineFlags::uintxAtPut(faddr, &value, origin);
-}
-
-Flag::Error CommandLineFlags::uint64_tAt(const char* name, size_t len, uint64_t* value, bool allow_locked, bool return_flag) {
-  Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return Flag::INVALID_FLAG;
-  if (!result->is_uint64_t()) return Flag::WRONG_FORMAT;
-  *value = result->get_uint64_t();
-  return Flag::SUCCESS;
-}
-
-static Flag::Error apply_constraint_and_check_range_uint64_t(const char* name, uint64_t new_value, bool verbose) {
-  Flag::Error status = Flag::SUCCESS;
-  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
-  if (range != NULL) {
-    status = range->check_uint64_t(new_value, verbose);
-  }
-  if (status == Flag::SUCCESS) {
-    CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
-    if (constraint != NULL) {
-      status = constraint->apply_uint64_t(new_value, verbose);
-    }
-  }
-  return status;
-}
-
-Flag::Error CommandLineFlags::uint64_tAtPut(Flag* flag, uint64_t* value, Flag::Flags origin) {
-  const char* name;
-  if (flag == NULL) return Flag::INVALID_FLAG;
-  if (!flag->is_uint64_t()) return Flag::WRONG_FORMAT;
-  name = flag->_name;
-  Flag::Error check = apply_constraint_and_check_range_uint64_t(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
-  if (check != Flag::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;
-}
-
-Flag::Error CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin) {
-  Flag* result = Flag::find_flag(name, len);
-  return uint64_tAtPut(result, value, origin);
-}
-
-Flag::Error CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
-  Flag* faddr = address_of_flag(flag);
-  guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
-  return CommandLineFlags::uint64_tAtPut(faddr, &value, origin);
-}
-
-Flag::Error CommandLineFlags::size_tAt(const char* name, size_t len, size_t* value, bool allow_locked, bool return_flag) {
-  Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return Flag::INVALID_FLAG;
-  if (!result->is_size_t()) return Flag::WRONG_FORMAT;
-  *value = result->get_size_t();
-  return Flag::SUCCESS;
-}
-
-static Flag::Error apply_constraint_and_check_range_size_t(const char* name, size_t new_value, bool verbose) {
-  Flag::Error status = Flag::SUCCESS;
-  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
-  if (range != NULL) {
-    status = range->check_size_t(new_value, verbose);
-  }
-  if (status == Flag::SUCCESS) {
-    CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
-    if (constraint != NULL) {
-      status = constraint->apply_size_t(new_value, verbose);
-    }
-  }
-  return status;
-}
-
-
-Flag::Error CommandLineFlags::size_tAtPut(Flag* flag, size_t* value, Flag::Flags origin) {
-  const char* name;
-  if (flag == NULL) return Flag::INVALID_FLAG;
-  if (!flag->is_size_t()) return Flag::WRONG_FORMAT;
-  name = flag->_name;
-  Flag::Error check = apply_constraint_and_check_range_size_t(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
-  if (check != Flag::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;
-}
-
-Flag::Error CommandLineFlags::size_tAtPut(const char* name, size_t len, size_t* value, Flag::Flags origin) {
-  Flag* result = Flag::find_flag(name, len);
-  return size_tAtPut(result, value, origin);
-}
-
-Flag::Error CommandLineFlagsEx::size_tAtPut(CommandLineFlagWithType flag, size_t value, Flag::Flags origin) {
-  Flag* faddr = address_of_flag(flag);
-  guarantee(faddr != NULL && faddr->is_size_t(), "wrong flag type");
-  return CommandLineFlags::size_tAtPut(faddr, &value, origin);
-}
-
-Flag::Error CommandLineFlags::doubleAt(const char* name, size_t len, double* value, bool allow_locked, bool return_flag) {
-  Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return Flag::INVALID_FLAG;
-  if (!result->is_double()) return Flag::WRONG_FORMAT;
-  *value = result->get_double();
-  return Flag::SUCCESS;
-}
-
-static Flag::Error apply_constraint_and_check_range_double(const char* name, double new_value, bool verbose) {
-  Flag::Error status = Flag::SUCCESS;
-  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
-  if (range != NULL) {
-    status = range->check_double(new_value, verbose);
-  }
-  if (status == Flag::SUCCESS) {
-    CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
-    if (constraint != NULL) {
-      status = constraint->apply_double(new_value, verbose);
-    }
-  }
-  return status;
-}
-
-Flag::Error CommandLineFlags::doubleAtPut(Flag* flag, double* value, Flag::Flags origin) {
-  const char* name;
-  if (flag == NULL) return Flag::INVALID_FLAG;
-  if (!flag->is_double()) return Flag::WRONG_FORMAT;
-  name = flag->_name;
-  Flag::Error check = apply_constraint_and_check_range_double(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
-  if (check != Flag::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;
-}
-
-Flag::Error CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) {
-  Flag* result = Flag::find_flag(name, len);
-  return doubleAtPut(result, value, origin);
-}
-
-Flag::Error CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
-  Flag* faddr = address_of_flag(flag);
-  guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
-  return CommandLineFlags::doubleAtPut(faddr, &value, origin);
-}
-
-Flag::Error CommandLineFlags::ccstrAt(const char* name, size_t len, ccstr* value, bool allow_locked, bool return_flag) {
-  Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return Flag::INVALID_FLAG;
-  if (!result->is_ccstr()) return Flag::WRONG_FORMAT;
-  *value = result->get_ccstr();
-  return Flag::SUCCESS;
-}
-
-Flag::Error CommandLineFlags::ccstrAtPut(const char* name, size_t len, ccstr* value, Flag::Flags origin) {
-  Flag* result = Flag::find_flag(name, len);
-  if (result == NULL) return Flag::INVALID_FLAG;
-  if (!result->is_ccstr()) return Flag::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);
-  }
-  Flag::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;
-}
-
-Flag::Error CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) {
-  Flag* 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);
-  Flag::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((*((Flag**) void_a))->_name, (*((Flag**) void_b))->_name);
-  }
-}
-
-void CommandLineFlags::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 = Flag::numFlags - 1;
-
-  // Sort
-  Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtArguments);
-  for (size_t i = 0; i < length; i++) {
-    array[i] = &flagTable[i];
-  }
-  qsort(array, length, sizeof(Flag*), 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(Flag*, array);
-}
-
-#ifndef PRODUCT
-
-void CommandLineFlags::verify() {
-  assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict");
-}
-
-#endif // PRODUCT
-
-void CommandLineFlags::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 = Flag::numFlags - 1;
-
-  // Sort
-  Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtArguments);
-  for (size_t i = 0; i < length; i++) {
-    array[i] = &flagTable[i];
-  }
-  qsort(array, length, sizeof(Flag*), 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(Flag*, array);
-}
--- a/src/hotspot/share/runtime/globals.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/globals.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -108,349 +108,6 @@
 
 #endif // no compilers
 
-// string type aliases used only in this file
-typedef const char* ccstr;
-typedef const char* ccstrlist;   // represents string arguments which accumulate
-
-// function type that will construct default range string
-typedef const char* (*RangeStrFunc)(void);
-
-struct Flag {
-  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 Flag* flags;
-
-  // number of flags
-  static size_t numFlags;
-
-  static Flag* find_flag(const char* name) { return find_flag(name, strlen(name), true, true); };
-  static Flag* find_flag(const char* name, size_t length, bool allow_locked = false, bool return_flag = false);
-  static Flag* 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();
-
-  Flag::Error check_writable(bool changed);
-
-  bool is_bool() const;
-  bool get_bool() const;
-  Flag::Error set_bool(bool value);
-
-  bool is_int() const;
-  int get_int() const;
-  Flag::Error set_int(int value);
-
-  bool is_uint() const;
-  uint get_uint() const;
-  Flag::Error set_uint(uint value);
-
-  bool is_intx() const;
-  intx get_intx() const;
-  Flag::Error set_intx(intx value);
-
-  bool is_uintx() const;
-  uintx get_uintx() const;
-  Flag::Error set_uintx(uintx value);
-
-  bool is_uint64_t() const;
-  uint64_t get_uint64_t() const;
-  Flag::Error set_uint64_t(uint64_t value);
-
-  bool is_size_t() const;
-  size_t get_size_t() const;
-  Flag::Error set_size_t(size_t value);
-
-  bool is_double() const;
-  double get_double() const;
-  Flag::Error set_double(double value);
-
-  bool is_ccstr() const;
-  bool ccstr_accumulates() const;
-  ccstr get_ccstr() const;
-  Flag::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();
-
-  Flag::MsgType get_locked_message(char*, int) const;
-  Flag::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(Flag::Error error);
-};
-
-// 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 {
-  bool val;
-  bool* flag;
- public:
-  FlagSetting(bool& fl, bool newValue) { flag = &fl; val = fl; fl = newValue; }
-  ~FlagSetting()                       { *flag = val; }
-};
-
-
-class CounterSetting {
-  intx* counter;
- public:
-  CounterSetting(intx* cnt) { counter = cnt; (*counter)++; }
-  ~CounterSetting()         { (*counter)--; }
-};
-
-class IntFlagSetting {
-  int val;
-  int* flag;
- public:
-  IntFlagSetting(int& fl, int newValue) { flag = &fl; val = fl; fl = newValue; }
-  ~IntFlagSetting()                     { *flag = val; }
-};
-
-class UIntFlagSetting {
-  uint val;
-  uint* flag;
- public:
-  UIntFlagSetting(uint& fl, uint newValue) { flag = &fl; val = fl; fl = newValue; }
-  ~UIntFlagSetting()                       { *flag = val; }
-};
-
-class UIntXFlagSetting {
-  uintx val;
-  uintx* flag;
- public:
-  UIntXFlagSetting(uintx& fl, uintx newValue) { flag = &fl; val = fl; fl = newValue; }
-  ~UIntXFlagSetting()                         { *flag = val; }
-};
-
-class DoubleFlagSetting {
-  double val;
-  double* flag;
- public:
-  DoubleFlagSetting(double& fl, double newValue) { flag = &fl; val = fl; fl = newValue; }
-  ~DoubleFlagSetting()                           { *flag = val; }
-};
-
-class SizeTFlagSetting {
-  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;
-
-  // Hide operator new, this class should only be allocated on the stack.
-  // NOTE: Cannot include memory/allocation.hpp here due to circular
-  //       dependencies.
-  void* operator new(size_t size) throw();
-  void* operator new [](size_t size) throw();
-
- 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)
-
-class CommandLineFlags {
-public:
-  static Flag::Error boolAt(const char* name, size_t len, bool* value, bool allow_locked = false, bool return_flag = false);
-  static Flag::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 Flag::Error boolAtPut(Flag* flag, bool* value, Flag::Flags origin);
-  static Flag::Error boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin);
-  static Flag::Error boolAtPut(const char* name, bool* value, Flag::Flags origin)   { return boolAtPut(name, strlen(name), value, origin); }
-
-  static Flag::Error intAt(const char* name, size_t len, int* value, bool allow_locked = false, bool return_flag = false);
-  static Flag::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 Flag::Error intAtPut(Flag* flag, int* value, Flag::Flags origin);
-  static Flag::Error intAtPut(const char* name, size_t len, int* value, Flag::Flags origin);
-  static Flag::Error intAtPut(const char* name, int* value, Flag::Flags origin)   { return intAtPut(name, strlen(name), value, origin); }
-
-  static Flag::Error uintAt(const char* name, size_t len, uint* value, bool allow_locked = false, bool return_flag = false);
-  static Flag::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 Flag::Error uintAtPut(Flag* flag, uint* value, Flag::Flags origin);
-  static Flag::Error uintAtPut(const char* name, size_t len, uint* value, Flag::Flags origin);
-  static Flag::Error uintAtPut(const char* name, uint* value, Flag::Flags origin)   { return uintAtPut(name, strlen(name), value, origin); }
-
-  static Flag::Error intxAt(const char* name, size_t len, intx* value, bool allow_locked = false, bool return_flag = false);
-  static Flag::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 Flag::Error intxAtPut(Flag* flag, intx* value, Flag::Flags origin);
-  static Flag::Error intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin);
-  static Flag::Error intxAtPut(const char* name, intx* value, Flag::Flags origin)   { return intxAtPut(name, strlen(name), value, origin); }
-
-  static Flag::Error uintxAt(const char* name, size_t len, uintx* value, bool allow_locked = false, bool return_flag = false);
-  static Flag::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 Flag::Error uintxAtPut(Flag* flag, uintx* value, Flag::Flags origin);
-  static Flag::Error uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin);
-  static Flag::Error uintxAtPut(const char* name, uintx* value, Flag::Flags origin) { return uintxAtPut(name, strlen(name), value, origin); }
-
-  static Flag::Error size_tAt(const char* name, size_t len, size_t* value, bool allow_locked = false, bool return_flag = false);
-  static Flag::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 Flag::Error size_tAtPut(Flag* flag, size_t* value, Flag::Flags origin);
-  static Flag::Error size_tAtPut(const char* name, size_t len, size_t* value, Flag::Flags origin);
-  static Flag::Error size_tAtPut(const char* name, size_t* value, Flag::Flags origin) { return size_tAtPut(name, strlen(name), value, origin); }
-
-  static Flag::Error uint64_tAt(const char* name, size_t len, uint64_t* value, bool allow_locked = false, bool return_flag = false);
-  static Flag::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 Flag::Error uint64_tAtPut(Flag* flag, uint64_t* value, Flag::Flags origin);
-  static Flag::Error uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin);
-  static Flag::Error uint64_tAtPut(const char* name, uint64_t* value, Flag::Flags origin) { return uint64_tAtPut(name, strlen(name), value, origin); }
-
-  static Flag::Error doubleAt(const char* name, size_t len, double* value, bool allow_locked = false, bool return_flag = false);
-  static Flag::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 Flag::Error doubleAtPut(Flag* flag, double* value, Flag::Flags origin);
-  static Flag::Error doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin);
-  static Flag::Error doubleAtPut(const char* name, double* value, Flag::Flags origin) { return doubleAtPut(name, strlen(name), value, origin); }
-
-  static Flag::Error ccstrAt(const char* name, size_t len, ccstr* value, bool allow_locked = false, bool return_flag = false);
-  static Flag::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:  Flag will make private copy of the incoming value.
-  // Outgoing value is always malloc-ed, and caller MUST call free.
-  static Flag::Error ccstrAtPut(const char* name, size_t len, ccstr* value, Flag::Flags origin);
-  static Flag::Error ccstrAtPut(const char* name, ccstr* value, Flag::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;
-};
-
 // use this for flags that are true by default in the debug version but
 // false in the optimized version, and vice versa
 #ifdef ASSERT
@@ -536,10 +193,10 @@
 // it can be done in the same way as product_rw.
 //
 // range is a macro that will expand to min and max arguments for range
-//    checking code if provided - see commandLineFlagRangeList.hpp
+//    checking code if provided - see jvmFlagRangeList.hpp
 //
 // constraint is a macro that will expand to custom function call
-//    for constraint checking if provided - see commandLineFlagConstraintList.hpp
+//    for constraint checking if provided - see jvmFlagConstraintList.hpp
 //
 // writeable is a macro that controls if and how the value can change during the runtime
 //
--- a/src/hotspot/share/runtime/globals_ext.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/globals_ext.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -25,13 +25,15 @@
 #ifndef SHARE_VM_RUNTIME_GLOBALS_EXT_HPP
 #define SHARE_VM_RUNTIME_GLOBALS_EXT_HPP
 
+#include "runtime/flags/jvmFlag.hpp"
+
 // globals_extension.hpp extension
 
-// Additional CommandLineFlags enum values
-#define COMMANDLINEFLAG_EXT
+// Additional JVMFlags enum values
+#define JVMFLAGS_EXT
 
-// Additional CommandLineFlagsWithType enum values
-#define COMMANDLINEFLAGWITHTYPE_EXT
+// Additional JVMFlagsWithType enum values
+#define JVMFLAGSWITHTYPE_EXT
 
 
 // globals.cpp extension
@@ -45,26 +47,26 @@
 
 // Default method implementations
 
-inline bool Flag::is_unlocker_ext() const {
+inline bool JVMFlag::is_unlocker_ext() const {
   return false;
 }
 
-inline bool Flag::is_unlocked_ext() const {
+inline bool JVMFlag::is_unlocked_ext() const {
   return true;
 }
 
-inline bool Flag::is_writeable_ext() const {
+inline bool JVMFlag::is_writeable_ext() const {
   return false;
 }
 
-inline bool Flag::is_external_ext() const {
+inline bool JVMFlag::is_external_ext() const {
   return false;
 }
 
-inline Flag::MsgType Flag::get_locked_message_ext(char* buf, int buflen) const {
+inline JVMFlag::MsgType JVMFlag::get_locked_message_ext(char* buf, int buflen) const {
   assert(buf != NULL, "Buffer cannot be NULL");
   buf[0] = '\0';
-  return Flag::NONE;
+  return JVMFlag::NONE;
 }
 
 #endif // SHARE_VM_RUNTIME_GLOBALS_EXT_HPP
--- a/src/hotspot/share/runtime/globals_extension.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/globals_extension.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -27,7 +27,6 @@
 
 #include "runtime/globals.hpp"
 #include "utilities/macros.hpp"
-#include "utilities/macros.hpp"
 #if INCLUDE_JVMCI
 #include "jvmci/jvmci_globals.hpp"
 #endif
@@ -164,9 +163,9 @@
             IGNORE_RANGE, \
             IGNORE_CONSTRAINT, \
             IGNORE_WRITEABLE)
- COMMANDLINEFLAG_EXT
- NUM_CommandLineFlag
-} CommandLineFlag;
+ JVMFLAGS_EXT
+ NUM_JVMFlags
+} JVMFlags;
 
 // Construct enum of Flag_<cmdline-arg>_<type> constants.
 
@@ -293,19 +292,19 @@
           IGNORE_RANGE,
           IGNORE_CONSTRAINT,
           IGNORE_WRITEABLE)
- COMMANDLINEFLAGWITHTYPE_EXT
- NUM_CommandLineFlagWithType
-} CommandLineFlagWithType;
+  JVMFLAGSWITHTYPE_EXT
+  NUM_JVMFlagsWithType
+} JVMFlagsWithType;
 
-#define FLAG_IS_DEFAULT(name)         (CommandLineFlagsEx::is_default(FLAG_MEMBER(name)))
-#define FLAG_IS_ERGO(name)            (CommandLineFlagsEx::is_ergo(FLAG_MEMBER(name)))
-#define FLAG_IS_CMDLINE(name)         (CommandLineFlagsEx::is_cmdline(FLAG_MEMBER(name)))
+#define FLAG_IS_DEFAULT(name)         (JVMFlagEx::is_default(FLAG_MEMBER(name)))
+#define FLAG_IS_ERGO(name)            (JVMFlagEx::is_ergo(FLAG_MEMBER(name)))
+#define FLAG_IS_CMDLINE(name)         (JVMFlagEx::is_cmdline(FLAG_MEMBER(name)))
 
 #define FLAG_SET_DEFAULT(name, value) ((name) = (value))
 
-#define FLAG_SET_CMDLINE(type, name, value) (CommandLineFlagsEx::setOnCmdLine(FLAG_MEMBER_WITH_TYPE(name, type)), \
-                                             CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name, type), (type)(value), Flag::COMMAND_LINE))
-#define FLAG_SET_ERGO(type, name, value)    (CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name, type), (type)(value), Flag::ERGONOMIC))
+#define FLAG_SET_CMDLINE(type, name, value) (JVMFlagEx::setOnCmdLine(FLAG_MEMBER_WITH_TYPE(name, type)), \
+                                             JVMFlagEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name, type), (type)(value), JVMFlag::COMMAND_LINE))
+#define FLAG_SET_ERGO(type, name, value)    (JVMFlagEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name, type), (type)(value), JVMFlag::ERGONOMIC))
 #define FLAG_SET_ERGO_IF_DEFAULT(type, name, value) \
   do {                                              \
     if (FLAG_IS_DEFAULT(name)) {                    \
@@ -313,26 +312,26 @@
     }                                               \
   } while (0)
 
-// Can't put the following in CommandLineFlags because
+// Can't put the following in JVMFlags because
 // of a circular dependency on the enum definition.
-class CommandLineFlagsEx : CommandLineFlags {
+class JVMFlagEx : JVMFlag {
  public:
-  static Flag::Error boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin);
-  static Flag::Error intAtPut(CommandLineFlagWithType flag, int value, Flag::Flags origin);
-  static Flag::Error uintAtPut(CommandLineFlagWithType flag, uint value, Flag::Flags origin);
-  static Flag::Error intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin);
-  static Flag::Error uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin);
-  static Flag::Error uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin);
-  static Flag::Error size_tAtPut(CommandLineFlagWithType flag, size_t value, Flag::Flags origin);
-  static Flag::Error doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin);
+  static JVMFlag::Error boolAtPut(JVMFlagsWithType flag, bool value, JVMFlag::Flags origin);
+  static JVMFlag::Error intAtPut(JVMFlagsWithType flag, int value, JVMFlag::Flags origin);
+  static JVMFlag::Error uintAtPut(JVMFlagsWithType flag, uint value, JVMFlag::Flags origin);
+  static JVMFlag::Error intxAtPut(JVMFlagsWithType flag, intx value, JVMFlag::Flags origin);
+  static JVMFlag::Error uintxAtPut(JVMFlagsWithType flag, uintx value, JVMFlag::Flags origin);
+  static JVMFlag::Error uint64_tAtPut(JVMFlagsWithType flag, uint64_t value, JVMFlag::Flags origin);
+  static JVMFlag::Error size_tAtPut(JVMFlagsWithType flag, size_t value, JVMFlag::Flags origin);
+  static JVMFlag::Error doubleAtPut(JVMFlagsWithType flag, double value, JVMFlag::Flags origin);
   // Contract:  Flag will make private copy of the incoming value
-  static Flag::Error ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin);
+  static JVMFlag::Error ccstrAtPut(JVMFlagsWithType flag, ccstr value, JVMFlag::Flags origin);
 
-  static bool is_default(CommandLineFlag flag);
-  static bool is_ergo(CommandLineFlag flag);
-  static bool is_cmdline(CommandLineFlag flag);
+  static bool is_default(JVMFlags flag);
+  static bool is_ergo(JVMFlags flag);
+  static bool is_cmdline(JVMFlags flag);
 
-  static void setOnCmdLine(CommandLineFlagWithType flag);
+  static void setOnCmdLine(JVMFlagsWithType flag);
 };
 
 #endif // SHARE_VM_RUNTIME_GLOBALS_EXTENSION_HPP
--- a/src/hotspot/share/runtime/handshake.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/handshake.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -26,6 +26,7 @@
 #define SHARE_VM_RUNTIME_HANDSHAKE_HPP
 
 #include "memory/allocation.hpp"
+#include "runtime/flags/flagSetting.hpp"
 #include "runtime/semaphore.hpp"
 
 class ThreadClosure;
--- a/src/hotspot/share/runtime/init.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/init.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -30,7 +30,7 @@
 #include "interpreter/bytecodes.hpp"
 #include "memory/universe.hpp"
 #include "prims/methodHandles.hpp"
-#include "runtime/globals.hpp"
+#include "runtime/flags/jvmFlag.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/icache.hpp"
 #include "runtime/init.hpp"
@@ -155,7 +155,7 @@
   // All the flags that get adjusted by VM_Version_init and os::init_2
   // have been set so dump the flags now.
   if (PrintFlagsFinal || PrintFlagsRanges) {
-    CommandLineFlags::printFlags(tty, false, PrintFlagsRanges);
+    JVMFlag::printFlags(tty, false, PrintFlagsRanges);
   }
 
   return JNI_OK;
--- a/src/hotspot/share/runtime/java.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/java.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -54,6 +54,7 @@
 #include "runtime/biasedLocking.hpp"
 #include "runtime/compilationPolicy.hpp"
 #include "runtime/deoptimization.hpp"
+#include "runtime/flags/flagSetting.hpp"
 #include "runtime/init.hpp"
 #include "runtime/interfaceSupport.inline.hpp"
 #include "runtime/java.hpp"
--- a/src/hotspot/share/runtime/mutexLocker.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/mutexLocker.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -26,6 +26,7 @@
 #define SHARE_VM_RUNTIME_MUTEXLOCKER_HPP
 
 #include "memory/allocation.hpp"
+#include "runtime/flags/flagSetting.hpp"
 #include "runtime/mutex.hpp"
 
 // Mutexes used in the VM.
--- a/src/hotspot/share/runtime/thread.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/thread.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -63,12 +63,11 @@
 #include "runtime/arguments.hpp"
 #include "runtime/atomic.hpp"
 #include "runtime/biasedLocking.hpp"
-#include "runtime/commandLineFlagConstraintList.hpp"
-#include "runtime/commandLineFlagWriteableList.hpp"
-#include "runtime/commandLineFlagRangeList.hpp"
+#include "runtime/flags/jvmFlagConstraintList.hpp"
+#include "runtime/flags/jvmFlagRangeList.hpp"
+#include "runtime/flags/jvmFlagWriteableList.hpp"
 #include "runtime/deoptimization.hpp"
 #include "runtime/frame.inline.hpp"
-#include "runtime/globals.hpp"
 #include "runtime/handshake.hpp"
 #include "runtime/init.hpp"
 #include "runtime/interfaceSupport.inline.hpp"
@@ -3663,17 +3662,17 @@
   if (ergo_result != JNI_OK) return ergo_result;
 
   // Final check of all ranges after ergonomics which may change values.
-  if (!CommandLineFlagRangeList::check_ranges()) {
+  if (!JVMFlagRangeList::check_ranges()) {
     return JNI_EINVAL;
   }
 
   // Final check of all 'AfterErgo' constraints after ergonomics which may change values.
-  bool constraint_result = CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterErgo);
+  bool constraint_result = JVMFlagConstraintList::check_constraints(JVMFlagConstraint::AfterErgo);
   if (!constraint_result) {
     return JNI_EINVAL;
   }
 
-  CommandLineFlagWriteableList::mark_startup();
+  JVMFlagWriteableList::mark_startup();
 
   if (PauseAtStartup) {
     os::pause();
--- a/src/hotspot/share/runtime/vmStructs.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/runtime/vmStructs.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -83,6 +83,7 @@
 #include "prims/jvmtiAgentThread.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/deoptimization.hpp"
+#include "runtime/flags/jvmFlag.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/java.hpp"
 #include "runtime/javaCalls.hpp"
@@ -718,7 +719,7 @@
   nonstatic_field(nmethod,                     _osr_link,                                     nmethod*)                              \
   nonstatic_field(nmethod,                     _scavenge_root_link,                           nmethod*)                              \
   nonstatic_field(nmethod,                     _scavenge_root_state,                          jbyte)                                 \
-  nonstatic_field(nmethod,                     _state,                                        volatile signed char)                         \
+  nonstatic_field(nmethod,                     _state,                                        volatile signed char)                  \
   nonstatic_field(nmethod,                     _exception_offset,                             int)                                   \
   nonstatic_field(nmethod,                     _orig_pc_offset,                               int)                                   \
   nonstatic_field(nmethod,                     _stub_offset,                                  int)                                   \
@@ -1062,12 +1063,12 @@
   /* -XX flags         */                                                                                                            \
   /*********************/                                                                                                            \
                                                                                                                                      \
-  nonstatic_field(Flag,                        _type,                                         const char*)                           \
-  nonstatic_field(Flag,                        _name,                                         const char*)                           \
-  unchecked_nonstatic_field(Flag,              _addr,                                         sizeof(void*)) /* NOTE: no type */     \
-  nonstatic_field(Flag,                        _flags,                                        Flag::Flags)                           \
-     static_field(Flag,                        flags,                                         Flag*)                                 \
-     static_field(Flag,                        numFlags,                                      size_t)                                \
+  nonstatic_field(JVMFlag,                     _type,                                         const char*)                           \
+  nonstatic_field(JVMFlag,                     _name,                                         const char*)                           \
+  unchecked_nonstatic_field(JVMFlag,           _addr,                                         sizeof(void*)) /* NOTE: no type */     \
+  nonstatic_field(JVMFlag,                     _flags,                                        JVMFlag::Flags)                        \
+     static_field(JVMFlag,                     flags,                                         JVMFlag*)                              \
+     static_field(JVMFlag,                     numFlags,                                      size_t)                                \
                                                                                                                                      \
   /*************************/                                                                                                        \
   /* JDK / VM version info */                                                                                                        \
@@ -1444,14 +1445,14 @@
   declare_toplevel_type(SharedRuntime)                                    \
                                                                           \
   declare_toplevel_type(CodeBlob)                                         \
-  declare_type(RuntimeBlob,             CodeBlob)                        \
-  declare_type(BufferBlob,               RuntimeBlob)                    \
+  declare_type(RuntimeBlob,              CodeBlob)                        \
+  declare_type(BufferBlob,               RuntimeBlob)                     \
   declare_type(AdapterBlob,              BufferBlob)                      \
   declare_type(MethodHandlesAdapterBlob, BufferBlob)                      \
   declare_type(CompiledMethod,           CodeBlob)                        \
   declare_type(nmethod,                  CompiledMethod)                  \
-  declare_type(RuntimeStub,              RuntimeBlob)                    \
-  declare_type(SingletonBlob,            RuntimeBlob)                    \
+  declare_type(RuntimeStub,              RuntimeBlob)                     \
+  declare_type(SingletonBlob,            RuntimeBlob)                     \
   declare_type(SafepointBlob,            SingletonBlob)                   \
   declare_type(DeoptimizationBlob,       SingletonBlob)                   \
   declare_c2_type(ExceptionBlob,         SingletonBlob)                   \
@@ -1910,8 +1911,8 @@
   /* -XX flags        */                                                  \
   /********************/                                                  \
                                                                           \
-  declare_toplevel_type(Flag)                                             \
-  declare_toplevel_type(Flag*)                                            \
+  declare_toplevel_type(JVMFlag)                                          \
+  declare_toplevel_type(JVMFlag*)                                         \
                                                                           \
   /********************/                                                  \
   /* JVMTI            */                                                  \
@@ -1951,7 +1952,7 @@
    declare_integer_type(ThreadState)                                      \
    declare_integer_type(Location::Type)                                   \
    declare_integer_type(Location::Where)                                  \
-   declare_integer_type(Flag::Flags)                                      \
+   declare_integer_type(JVMFlag::Flags)                                   \
    COMPILER2_PRESENT(declare_integer_type(OptoReg::Name))                 \
                                                                           \
    declare_toplevel_type(CHeapObj<mtInternal>)                            \
--- a/src/hotspot/share/services/attachListener.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/services/attachListener.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -31,6 +31,7 @@
 #include "oops/typeArrayOop.inline.hpp"
 #include "prims/jvmtiExport.hpp"
 #include "runtime/arguments.hpp"
+#include "runtime/flags/jvmFlag.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/java.hpp"
@@ -275,9 +276,9 @@
 
   FormatBuffer<80> err_msg("%s", "");
 
-  int ret = WriteableFlags::set_flag(op->arg(0), op->arg(1), Flag::ATTACH_ON_DEMAND, err_msg);
-  if (ret != Flag::SUCCESS) {
-    if (ret == Flag::NON_WRITABLE) {
+  int ret = WriteableFlags::set_flag(op->arg(0), op->arg(1), JVMFlag::ATTACH_ON_DEMAND, err_msg);
+  if (ret != JVMFlag::SUCCESS) {
+    if (ret == JVMFlag::NON_WRITABLE) {
       // if the flag is not manageable try to change it through
       // the platform dependent implementation
       return AttachListener::pd_set_flag(op, out);
@@ -298,7 +299,7 @@
     out->print_cr("flag name is missing");
     return JNI_ERR;
   }
-  Flag* f = Flag::find_flag((char*)name, strlen(name));
+  JVMFlag* f = JVMFlag::find_flag((char*)name, strlen(name));
   if (f) {
     f->print_as_flag(out);
     out->cr();
--- a/src/hotspot/share/services/diagnosticCommand.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/services/diagnosticCommand.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -33,7 +33,7 @@
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/typeArrayOop.inline.hpp"
-#include "runtime/globals.hpp"
+#include "runtime/flags/jvmFlag.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/javaCalls.hpp"
 #include "runtime/os.hpp"
@@ -231,9 +231,9 @@
 
 void PrintVMFlagsDCmd::execute(DCmdSource source, TRAPS) {
   if (_all.value()) {
-    CommandLineFlags::printFlags(output(), true);
+    JVMFlag::printFlags(output(), true);
   } else {
-    CommandLineFlags::printSetFlags(output());
+    JVMFlag::printSetFlags(output());
   }
 }
 
@@ -264,9 +264,9 @@
   }
 
   FormatBuffer<80> err_msg("%s", "");
-  int ret = WriteableFlags::set_flag(_flag.value(), val, Flag::MANAGEMENT, err_msg);
+  int ret = WriteableFlags::set_flag(_flag.value(), val, JVMFlag::MANAGEMENT, err_msg);
 
-  if (ret != Flag::SUCCESS) {
+  if (ret != JVMFlag::SUCCESS) {
     output()->print_cr("%s", err_msg.buffer());
   }
 }
--- a/src/hotspot/share/services/dtraceAttacher.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/services/dtraceAttacher.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -26,6 +26,7 @@
 #include "code/codeCache.hpp"
 #include "memory/resourceArea.hpp"
 #include "runtime/deoptimization.hpp"
+#include "runtime/flags/jvmFlag.hpp"
 #include "runtime/vmThread.hpp"
 #include "runtime/vm_operations.hpp"
 #include "services/dtraceAttacher.hpp"
@@ -50,8 +51,8 @@
 };
 
 static void set_bool_flag(const char* flag, bool value) {
-  CommandLineFlags::boolAtPut((char*)flag, strlen(flag), &value,
-                              Flag::ATTACH_ON_DEMAND);
+  JVMFlag::boolAtPut((char*)flag, strlen(flag), &value,
+                              JVMFlag::ATTACH_ON_DEMAND);
 }
 
 // Enable only the "fine grained" flags. Do *not* touch
--- a/src/hotspot/share/services/management.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/services/management.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -36,6 +36,7 @@
 #include "oops/oop.inline.hpp"
 #include "oops/typeArrayOop.inline.hpp"
 #include "runtime/arguments.hpp"
+#include "runtime/flags/jvmFlag.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/interfaceSupport.inline.hpp"
@@ -866,10 +867,10 @@
 
 static jint get_num_flags() {
   // last flag entry is always NULL, so subtract 1
-  int nFlags = (int) Flag::numFlags - 1;
+  int nFlags = (int) JVMFlag::numFlags - 1;
   int count = 0;
   for (int i = 0; i < nFlags; i++) {
-    Flag* flag = &Flag::flags[i];
+    JVMFlag* flag = &JVMFlag::flags[i];
     // Exclude the locked (diagnostic, experimental) flags
     if (flag->is_unlocked() || flag->is_unlocker()) {
       count++;
@@ -1419,14 +1420,14 @@
 // Returns a String array of all VM global flag names
 JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env))
   // last flag entry is always NULL, so subtract 1
-  int nFlags = (int) Flag::numFlags - 1;
+  int nFlags = (int) JVMFlag::numFlags - 1;
   // allocate a temp array
   objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(),
                                            nFlags, CHECK_0);
   objArrayHandle flags_ah(THREAD, r);
   int num_entries = 0;
   for (int i = 0; i < nFlags; i++) {
-    Flag* flag = &Flag::flags[i];
+    JVMFlag* flag = &JVMFlag::flags[i];
     // Exclude notproduct and develop flags in product builds.
     if (flag->is_constant_in_binary()) {
       continue;
@@ -1454,7 +1455,7 @@
 // Utility function used by jmm_GetVMGlobals.  Returns false if flag type
 // can't be determined, true otherwise.  If false is returned, then *global
 // will be incomplete and invalid.
-bool add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag, TRAPS) {
+bool add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, JVMFlag *flag, TRAPS) {
   Handle flag_name;
   if (name() == NULL) {
     flag_name = java_lang_String::create_from_str(flag->_name, CHECK_false);
@@ -1499,25 +1500,25 @@
   global->writeable = flag->is_writeable();
   global->external = flag->is_external();
   switch (flag->get_origin()) {
-    case Flag::DEFAULT:
+    case JVMFlag::DEFAULT:
       global->origin = JMM_VMGLOBAL_ORIGIN_DEFAULT;
       break;
-    case Flag::COMMAND_LINE:
+    case JVMFlag::COMMAND_LINE:
       global->origin = JMM_VMGLOBAL_ORIGIN_COMMAND_LINE;
       break;
-    case Flag::ENVIRON_VAR:
+    case JVMFlag::ENVIRON_VAR:
       global->origin = JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR;
       break;
-    case Flag::CONFIG_FILE:
+    case JVMFlag::CONFIG_FILE:
       global->origin = JMM_VMGLOBAL_ORIGIN_CONFIG_FILE;
       break;
-    case Flag::MANAGEMENT:
+    case JVMFlag::MANAGEMENT:
       global->origin = JMM_VMGLOBAL_ORIGIN_MANAGEMENT;
       break;
-    case Flag::ERGONOMIC:
+    case JVMFlag::ERGONOMIC:
       global->origin = JMM_VMGLOBAL_ORIGIN_ERGONOMIC;
       break;
-    case Flag::ATTACH_ON_DEMAND:
+    case JVMFlag::ATTACH_ON_DEMAND:
       global->origin = JMM_VMGLOBAL_ORIGIN_ATTACH_ON_DEMAND;
       break;
     default:
@@ -1531,7 +1532,7 @@
 // specified by names. If names == NULL, fill globals array
 // with all Flags. Return value is number of entries
 // created in globals.
-// If a Flag with a given name in an array element does not
+// If a JVMFlag with a given name in an array element does not
 // exist, globals[i].name will be set to NULL.
 JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env,
                                  jobjectArray names,
@@ -1566,7 +1567,7 @@
 
       Handle sh(THREAD, s);
       char* str = java_lang_String::as_utf8_string(s);
-      Flag* flag = Flag::find_flag(str, strlen(str));
+      JVMFlag* flag = JVMFlag::find_flag(str, strlen(str));
       if (flag != NULL &&
           add_global_entry(env, sh, &globals[i], flag, THREAD)) {
         num_entries++;
@@ -1579,11 +1580,11 @@
     // return all globals if names == NULL
 
     // last flag entry is always NULL, so subtract 1
-    int nFlags = (int) Flag::numFlags - 1;
+    int nFlags = (int) JVMFlag::numFlags - 1;
     Handle null_h;
     int num_entries = 0;
     for (int i = 0; i < nFlags && num_entries < count;  i++) {
-      Flag* flag = &Flag::flags[i];
+      JVMFlag* flag = &JVMFlag::flags[i];
       // Exclude notproduct and develop flags in product builds.
       if (flag->is_constant_in_binary()) {
         continue;
@@ -1609,10 +1610,10 @@
   char* name = java_lang_String::as_utf8_string(fn);
 
   FormatBuffer<80> error_msg("%s", "");
-  int succeed = WriteableFlags::set_flag(name, new_value, Flag::MANAGEMENT, error_msg);
+  int succeed = WriteableFlags::set_flag(name, new_value, JVMFlag::MANAGEMENT, error_msg);
 
-  if (succeed != Flag::SUCCESS) {
-    if (succeed == Flag::MISSING_VALUE) {
+  if (succeed != JVMFlag::SUCCESS) {
+    if (succeed == JVMFlag::MISSING_VALUE) {
       // missing value causes NPE to be thrown
       THROW(vmSymbols::java_lang_NullPointerException());
     } else {
@@ -1621,7 +1622,7 @@
                 error_msg.buffer());
     }
   }
-  assert(succeed == Flag::SUCCESS, "Setting flag should succeed");
+  assert(succeed == JVMFlag::SUCCESS, "Setting flag should succeed");
 JVM_END
 
 class ThreadTimesClosure: public ThreadClosure {
--- a/src/hotspot/share/services/writeableFlags.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/services/writeableFlags.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -26,7 +26,8 @@
 #include "classfile/javaClasses.hpp"
 #include "memory/allocation.inline.hpp"
 #include "runtime/arguments.hpp"
-#include "runtime/commandLineFlagRangeList.hpp"
+#include "runtime/flags/jvmFlag.hpp"
+#include "runtime/flags/jvmFlagRangeList.hpp"
 #include "runtime/java.hpp"
 #include "runtime/jniHandles.hpp"
 #include "services/writeableFlags.hpp"
@@ -38,7 +39,7 @@
 }
 
 static void print_flag_error_message_bounds(const char* name, char* buffer) {
-  CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
+  JVMFlagRange* range = JVMFlagRangeList::find(name);
   if (range != NULL) {
     buffer_concat(buffer, "must have value in range ");
 
@@ -58,34 +59,34 @@
   }
 }
 
-static void print_flag_error_message_if_needed(Flag::Error error, const char* name, FormatBuffer<80>& err_msg) {
-  if (error == Flag::SUCCESS) {
+static void print_flag_error_message_if_needed(JVMFlag::Error error, const char* name, FormatBuffer<80>& err_msg) {
+  if (error == JVMFlag::SUCCESS) {
     return;
   }
 
   char buffer[TEMP_BUF_SIZE] = {'\0'};
-  if ((error != Flag::MISSING_NAME) && (name != NULL)) {
+  if ((error != JVMFlag::MISSING_NAME) && (name != NULL)) {
     buffer_concat(buffer, name);
     buffer_concat(buffer, " error: ");
   } else {
     buffer_concat(buffer, "Error: ");
   }
   switch (error) {
-    case Flag::MISSING_NAME:
+    case JVMFlag::MISSING_NAME:
       buffer_concat(buffer, "flag name is missing."); break;
-    case Flag::MISSING_VALUE:
+    case JVMFlag::MISSING_VALUE:
       buffer_concat(buffer, "parsing the textual form of the value."); break;
-    case Flag::NON_WRITABLE:
+    case JVMFlag::NON_WRITABLE:
       buffer_concat(buffer, "flag is not writeable."); break;
-    case Flag::OUT_OF_BOUNDS:
+    case JVMFlag::OUT_OF_BOUNDS:
       print_flag_error_message_bounds(name, buffer); break;
-    case Flag::VIOLATES_CONSTRAINT:
+    case JVMFlag::VIOLATES_CONSTRAINT:
       buffer_concat(buffer, "value violates its flag's constraint."); break;
-    case Flag::INVALID_FLAG:
+    case JVMFlag::INVALID_FLAG:
       buffer_concat(buffer, "there is no flag with the given name."); break;
-    case Flag::ERR_OTHER:
+    case JVMFlag::ERR_OTHER:
       buffer_concat(buffer, "other, unspecified error related to setting the flag."); break;
-    case Flag::SUCCESS:
+    case JVMFlag::SUCCESS:
       break;
     default:
       break;
@@ -95,127 +96,127 @@
 }
 
 // set a boolean global flag
-Flag::Error WriteableFlags::set_bool_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_bool_flag(const char* name, const char* arg, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   if ((strcasecmp(arg, "true") == 0) || (*arg == '1' && *(arg + 1) == 0)) {
     return set_bool_flag(name, true, origin, err_msg);
   } else if ((strcasecmp(arg, "false") == 0) || (*arg == '0' && *(arg + 1) == 0)) {
     return set_bool_flag(name, false, origin, err_msg);
   }
   err_msg.print("flag value must be a boolean (1/0 or true/false)");
-  return Flag::WRONG_FORMAT;
+  return JVMFlag::WRONG_FORMAT;
 }
 
-Flag::Error WriteableFlags::set_bool_flag(const char* name, bool value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
-  Flag::Error err = CommandLineFlags::boolAtPut(name, &value, origin);
+JVMFlag::Error WriteableFlags::set_bool_flag(const char* name, bool value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
+  JVMFlag::Error err = JVMFlag::boolAtPut(name, &value, origin);
   print_flag_error_message_if_needed(err, name, err_msg);
   return err;
 }
 
 // set a int global flag
-Flag::Error WriteableFlags::set_int_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_int_flag(const char* name, const char* arg, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   int value;
 
   if (sscanf(arg, "%d", &value)) {
     return set_int_flag(name, value, origin, err_msg);
   }
   err_msg.print("flag value must be an integer");
-  return Flag::WRONG_FORMAT;
+  return JVMFlag::WRONG_FORMAT;
 }
 
-Flag::Error WriteableFlags::set_int_flag(const char* name, int value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
-  Flag::Error err = CommandLineFlags::intAtPut(name, &value, origin);
+JVMFlag::Error WriteableFlags::set_int_flag(const char* name, int value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
+  JVMFlag::Error err = JVMFlag::intAtPut(name, &value, origin);
   print_flag_error_message_if_needed(err, name, err_msg);
   return err;
 }
 
 // set a uint global flag
-Flag::Error WriteableFlags::set_uint_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_uint_flag(const char* name, const char* arg, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   uint value;
 
   if (sscanf(arg, "%u", &value)) {
     return set_uint_flag(name, value, origin, err_msg);
   }
   err_msg.print("flag value must be an unsigned integer");
-  return Flag::WRONG_FORMAT;
+  return JVMFlag::WRONG_FORMAT;
 }
 
-Flag::Error WriteableFlags::set_uint_flag(const char* name, uint value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
-  Flag::Error err = CommandLineFlags::uintAtPut(name, &value, origin);
+JVMFlag::Error WriteableFlags::set_uint_flag(const char* name, uint value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
+  JVMFlag::Error err = JVMFlag::uintAtPut(name, &value, origin);
   print_flag_error_message_if_needed(err, name, err_msg);
   return err;
 }
 
 // set a intx global flag
-Flag::Error WriteableFlags::set_intx_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_intx_flag(const char* name, const char* arg, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   intx value;
 
   if (sscanf(arg, INTX_FORMAT, &value)) {
     return set_intx_flag(name, value, origin, err_msg);
   }
   err_msg.print("flag value must be an integer");
-  return Flag::WRONG_FORMAT;
+  return JVMFlag::WRONG_FORMAT;
 }
 
-Flag::Error WriteableFlags::set_intx_flag(const char* name, intx value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
-  Flag::Error err = CommandLineFlags::intxAtPut(name, &value, origin);
+JVMFlag::Error WriteableFlags::set_intx_flag(const char* name, intx value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
+  JVMFlag::Error err = JVMFlag::intxAtPut(name, &value, origin);
   print_flag_error_message_if_needed(err, name, err_msg);
   return err;
 }
 
 // set a uintx global flag
-Flag::Error WriteableFlags::set_uintx_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_uintx_flag(const char* name, const char* arg, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   uintx value;
 
   if (sscanf(arg, UINTX_FORMAT, &value)) {
     return set_uintx_flag(name, value, origin, err_msg);
   }
   err_msg.print("flag value must be an unsigned integer");
-  return Flag::WRONG_FORMAT;
+  return JVMFlag::WRONG_FORMAT;
 }
 
-Flag::Error WriteableFlags::set_uintx_flag(const char* name, uintx value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
-  Flag::Error err = CommandLineFlags::uintxAtPut(name, &value, origin);
+JVMFlag::Error WriteableFlags::set_uintx_flag(const char* name, uintx value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
+  JVMFlag::Error err = JVMFlag::uintxAtPut(name, &value, origin);
   print_flag_error_message_if_needed(err, name, err_msg);
   return err;
 }
 
 // set a uint64_t global flag
-Flag::Error WriteableFlags::set_uint64_t_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_uint64_t_flag(const char* name, const char* arg, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   uint64_t value;
 
   if (sscanf(arg, UINT64_FORMAT, &value)) {
     return set_uint64_t_flag(name, value, origin, err_msg);
   }
   err_msg.print("flag value must be an unsigned 64-bit integer");
-  return Flag::WRONG_FORMAT;
+  return JVMFlag::WRONG_FORMAT;
 }
 
-Flag::Error WriteableFlags::set_uint64_t_flag(const char* name, uint64_t value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
-  Flag::Error err = CommandLineFlags::uint64_tAtPut(name, &value, origin);
+JVMFlag::Error WriteableFlags::set_uint64_t_flag(const char* name, uint64_t value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
+  JVMFlag::Error err = JVMFlag::uint64_tAtPut(name, &value, origin);
   print_flag_error_message_if_needed(err, name, err_msg);
   return err;
 }
 
 // set a size_t global flag
-Flag::Error WriteableFlags::set_size_t_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_size_t_flag(const char* name, const char* arg, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   size_t value;
 
   if (sscanf(arg, SIZE_FORMAT, &value)) {
     return set_size_t_flag(name, value, origin, err_msg);
   }
   err_msg.print("flag value must be an unsigned integer");
-  return Flag::WRONG_FORMAT;
+  return JVMFlag::WRONG_FORMAT;
 }
 
-Flag::Error WriteableFlags::set_size_t_flag(const char* name, size_t value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
-  Flag::Error err = CommandLineFlags::size_tAtPut(name, &value, origin);
+JVMFlag::Error WriteableFlags::set_size_t_flag(const char* name, size_t value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
+  JVMFlag::Error err = JVMFlag::size_tAtPut(name, &value, origin);
   print_flag_error_message_if_needed(err, name, err_msg);
   return err;
 }
 
 // set a string global flag using value from AttachOperation
-Flag::Error WriteableFlags::set_ccstr_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
-  Flag::Error err = CommandLineFlags::ccstrAtPut((char*)name, &value, origin);
+JVMFlag::Error WriteableFlags::set_ccstr_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
+  JVMFlag::Error err = JVMFlag::ccstrAtPut((char*)name, &value, origin);
   print_flag_error_message_if_needed(err, name, err_msg);
   return err;
 }
@@ -225,7 +226,7 @@
  * - return status is one of the WriteableFlags::err enum values
  * - an eventual error message will be generated to the provided err_msg buffer
  */
-Flag::Error WriteableFlags::set_flag(const char* flag_name, const char* flag_value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_flag(const char* flag_name, const char* flag_value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   return set_flag(flag_name, &flag_value, set_flag_from_char, origin, err_msg);
 }
 
@@ -234,42 +235,42 @@
  * - return status is one of the WriteableFlags::err enum values
  * - an eventual error message will be generated to the provided err_msg buffer
  */
-Flag::Error WriteableFlags::set_flag(const char* flag_name, jvalue flag_value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_flag(const char* flag_name, jvalue flag_value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   return set_flag(flag_name, &flag_value, set_flag_from_jvalue, origin, err_msg);
 }
 
 // a writeable flag setter accepting either 'jvalue' or 'char *' values
-Flag::Error WriteableFlags::set_flag(const char* name, const void* value, Flag::Error(*setter)(Flag*,const void*,Flag::Flags,FormatBuffer<80>&), Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_flag(const char* name, const void* value, JVMFlag::Error(*setter)(JVMFlag*,const void*,JVMFlag::Flags,FormatBuffer<80>&), JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   if (name == NULL) {
     err_msg.print("flag name is missing");
-    return Flag::MISSING_NAME;
+    return JVMFlag::MISSING_NAME;
   }
   if (value == NULL) {
     err_msg.print("flag value is missing");
-    return Flag::MISSING_VALUE;
+    return JVMFlag::MISSING_VALUE;
   }
 
-  Flag* f = Flag::find_flag((char*)name, strlen(name));
+  JVMFlag* f = JVMFlag::find_flag((char*)name, strlen(name));
   if (f) {
     // only writeable flags are allowed to be set
     if (f->is_writeable()) {
       return setter(f, value, origin, err_msg);
     } else {
       err_msg.print("only 'writeable' flags can be set");
-      return Flag::NON_WRITABLE;
+      return JVMFlag::NON_WRITABLE;
     }
   }
 
   err_msg.print("flag %s does not exist", name);
-  return Flag::INVALID_FLAG;
+  return JVMFlag::INVALID_FLAG;
 }
 
 // a writeable flag setter accepting 'char *' values
-Flag::Error WriteableFlags::set_flag_from_char(Flag* f, const void* value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
+JVMFlag::Error WriteableFlags::set_flag_from_char(JVMFlag* f, const void* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
   char* flag_value = *(char**)value;
   if (flag_value == NULL) {
     err_msg.print("flag value is missing");
-    return Flag::MISSING_VALUE;
+    return JVMFlag::MISSING_VALUE;
   }
   if (f->is_bool()) {
     return set_bool_flag(f->_name, flag_value, origin, err_msg);
@@ -290,11 +291,11 @@
   } else {
     ShouldNotReachHere();
   }
-  return Flag::ERR_OTHER;
+  return JVMFlag::ERR_OTHER;
 }
 
 // a writeable flag setter accepting 'jvalue' values
-Flag::Error WriteableFlags::set_flag_from_jvalue(Flag* f, const void* value, Flag::Flags origin,
+JVMFlag::Error WriteableFlags::set_flag_from_jvalue(JVMFlag* f, const void* value, JVMFlag::Flags origin,
                                                  FormatBuffer<80>& err_msg) {
   jvalue new_value = *(jvalue*)value;
   if (f->is_bool()) {
@@ -322,16 +323,16 @@
     oop str = JNIHandles::resolve_external_guard(new_value.l);
     if (str == NULL) {
       err_msg.print("flag value is missing");
-      return Flag::MISSING_VALUE;
+      return JVMFlag::MISSING_VALUE;
     }
     ccstr svalue = java_lang_String::as_utf8_string(str);
-    Flag::Error ret = WriteableFlags::set_ccstr_flag(f->_name, svalue, origin, err_msg);
-    if (ret != Flag::SUCCESS) {
+    JVMFlag::Error ret = WriteableFlags::set_ccstr_flag(f->_name, svalue, origin, err_msg);
+    if (ret != JVMFlag::SUCCESS) {
       FREE_C_HEAP_ARRAY(char, svalue);
     }
     return ret;
   } else {
     ShouldNotReachHere();
   }
-  return Flag::ERR_OTHER;
+  return JVMFlag::ERR_OTHER;
 }
--- a/src/hotspot/share/services/writeableFlags.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/services/writeableFlags.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -25,48 +25,49 @@
 #ifndef SHARE_VM_SERVICES_WRITEABLEFLAG_HPP
 #define SHARE_VM_SERVICES_WRITEABLEFLAG_HPP
 
+#include "runtime/flags/jvmFlag.hpp"
 #include "runtime/globals.hpp"
 #include "utilities/formatBuffer.hpp"
 
 class WriteableFlags : AllStatic {
 private:
   // a writeable flag setter accepting either 'jvalue' or 'char *' values
-  static Flag::Error set_flag(const char* name, const void* value, Flag::Error(*setter)(Flag*, const void*, Flag::Flags, FormatBuffer<80>&), Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_flag(const char* name, const void* value, JVMFlag::Error(*setter)(JVMFlag*, const void*, JVMFlag::Flags, FormatBuffer<80>&), JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // a writeable flag setter accepting 'char *' values
-  static Flag::Error set_flag_from_char(Flag* f, const void* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_flag_from_char(JVMFlag* f, const void* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // a writeable flag setter accepting 'jvalue' values
-  static Flag::Error set_flag_from_jvalue(Flag* f, const void* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_flag_from_jvalue(JVMFlag* f, const void* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
 
   // set a boolean global flag
-  static Flag::Error set_bool_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_bool_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a int global flag
-  static Flag::Error set_int_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_int_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a uint global flag
-  static Flag::Error set_uint_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_uint_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a intx global flag
-  static Flag::Error set_intx_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_intx_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a uintx global flag
-  static Flag::Error set_uintx_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_uintx_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a uint64_t global flag
-  static Flag::Error set_uint64_t_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_uint64_t_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a size_t global flag using value from AttachOperation
-  static Flag::Error set_size_t_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_size_t_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a boolean global flag
-  static Flag::Error set_bool_flag(const char* name, bool value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_bool_flag(const char* name, bool value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a int global flag
-  static Flag::Error set_int_flag(const char* name, int value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_int_flag(const char* name, int value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a uint global flag
-  static Flag::Error set_uint_flag(const char* name, uint value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_uint_flag(const char* name, uint value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a intx global flag
-  static Flag::Error set_intx_flag(const char* name, intx value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_intx_flag(const char* name, intx value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a uintx global flag
-  static Flag::Error set_uintx_flag(const char* name, uintx value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_uintx_flag(const char* name, uintx value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a uint64_t global flag
-  static Flag::Error set_uint64_t_flag(const char* name, uint64_t value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_uint64_t_flag(const char* name, uint64_t value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a size_t global flag using value from AttachOperation
-  static Flag::Error set_size_t_flag(const char* name, size_t value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_size_t_flag(const char* name, size_t value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
   // set a string global flag
-  static Flag::Error set_ccstr_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_ccstr_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
 
 public:
   /* sets a writeable flag to the provided value
@@ -74,14 +75,14 @@
    * - return status is one of the WriteableFlags::err enum values
    * - an eventual error message will be generated to the provided err_msg buffer
    */
-  static Flag::Error set_flag(const char* flag_name, const char* flag_value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_flag(const char* flag_name, const char* flag_value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
 
   /* sets a writeable flag to the provided value
    *
    * - return status is one of the WriteableFlags::err enum values
    * - an eventual error message will be generated to the provided err_msg buffer
    */
-  static Flag::Error set_flag(const char* flag_name, jvalue flag_value, Flag::Flags origin, FormatBuffer<80>& err_msg);
+  static JVMFlag::Error set_flag(const char* flag_name, jvalue flag_value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg);
 };
 
 #endif /* SHARE_VM_SERVICES_WRITEABLEFLAG_HPP */
--- a/src/hotspot/share/utilities/debug.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/utilities/debug.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -40,6 +40,7 @@
 #include "prims/privilegedStack.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/atomic.hpp"
+#include "runtime/flags/flagSetting.hpp"
 #include "runtime/frame.inline.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/java.hpp"
--- a/src/hotspot/share/utilities/globalDefinitions.hpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/hotspot/share/utilities/globalDefinitions.hpp	Thu Apr 26 11:19:05 2018 -0500
@@ -1259,4 +1259,11 @@
   return *(void**)addr;
 }
 
+//----------------------------------------------------------------------------------------------------
+// String type aliases used by command line flag declarations and
+// processing utilities.
+
+typedef const char* ccstr;
+typedef const char* ccstrlist;   // represents string arguments which accumulate
+
 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java	Thu Apr 26 09:10:04 2018 -0700
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java	Thu Apr 26 11:19:05 2018 -0500
@@ -137,7 +137,7 @@
   private Boolean compressedOopsEnabled;
   private Boolean compressedKlassPointersEnabled;
 
-  // command line flags supplied to VM - see struct Flag in globals.hpp
+  // command line flags supplied to VM - see struct JVMFlag in jvmFlag.hpp
   public static final class Flag {
      private String type;
      private String name;
@@ -916,7 +916,7 @@
   private void readCommandLineFlags() {
     // get command line flags
     TypeDataBase db = getTypeDataBase();
-    Type flagType = db.lookupType("Flag");
+    Type flagType = db.lookupType("JVMFlag");
     int numFlags = (int) flagType.getCIntegerField("numFlags").getValue();
     // NOTE: last flag contains null values.
     commandLineFlags = new Flag[numFlags - 1];
--- a/test/hotspot/gtest/gc/shared/test_collectorPolicy.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/test/hotspot/gtest/gc/shared/test_collectorPolicy.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -24,6 +24,7 @@
 #include "precompiled.hpp"
 #include "gc/shared/collectorPolicy.hpp"
 #include "runtime/arguments.hpp"
+#include "runtime/flags/flagSetting.hpp"
 #include "runtime/globals_extension.hpp"
 #include "utilities/align.hpp"
 #include "utilities/globalDefinitions.hpp"
--- a/test/hotspot/gtest/runtime/test_globals.cpp	Thu Apr 26 09:10:04 2018 -0700
+++ b/test/hotspot/gtest/runtime/test_globals.cpp	Thu Apr 26 11:19:05 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -23,17 +23,18 @@
 
 #include "precompiled.hpp"
 #include "runtime/globals.hpp"
+#include "runtime/flags/flagSetting.hpp"
 #include "unittest.hpp"
 
-#define TEST_FLAG(f, type, value)                     \
-  do {                                                \
-    ASSERT_TRUE(Flag::find_flag(#f)->is_ ## type());  \
-    type original_value = f;                          \
-    {                                                 \
-      FLAG_GUARD(f);                                  \
-      f = value;                                      \
-    }                                                 \
-    ASSERT_EQ(original_value, f);                     \
+#define TEST_FLAG(f, type, value)                                \
+  do {                                                           \
+    ASSERT_TRUE(JVMFlag::find_flag(#f)->is_ ## type());          \
+    type original_value = f;                                     \
+    {                                                            \
+      FLAG_GUARD(f);                                             \
+      f = value;                                                 \
+    }                                                            \
+    ASSERT_EQ(original_value, f);                                \
   } while (0)
 
 TEST_VM(FlagGuard, bool_flag) {