8081519: Split globals.hpp to factor out the Flag class

Factored out Flag out go globals, renamed to JVMFlag

Reviewed-by: coleenp, dholmes, kvn
This commit is contained in:
Gerard Ziemski 2018-04-23 10:59:39 -05:00
parent ac44a19694
commit 60723b7e3d
66 changed files with 3060 additions and 2966 deletions

View File

@ -30,6 +30,7 @@
#include "interpreter/interpreterRuntime.hpp" #include "interpreter/interpreterRuntime.hpp"
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "prims/methodHandles.hpp" #include "prims/methodHandles.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/frame.inline.hpp" #include "runtime/frame.inline.hpp"
#define __ _masm-> #define __ _masm->

View File

@ -35,6 +35,7 @@
#include "oops/klass.inline.hpp" #include "oops/klass.inline.hpp"
#include "prims/methodHandles.hpp" #include "prims/methodHandles.hpp"
#include "runtime/biasedLocking.hpp" #include "runtime/biasedLocking.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/interfaceSupport.inline.hpp" #include "runtime/interfaceSupport.inline.hpp"
#include "runtime/jniHandles.inline.hpp" #include "runtime/jniHandles.inline.hpp"
#include "runtime/objectMonitor.hpp" #include "runtime/objectMonitor.hpp"

View File

@ -31,6 +31,7 @@
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "prims/methodHandles.hpp" #include "prims/methodHandles.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/frame.inline.hpp" #include "runtime/frame.inline.hpp"
#include "utilities/preserveException.hpp" #include "utilities/preserveException.hpp"

View File

@ -37,6 +37,7 @@
#include "oops/klass.inline.hpp" #include "oops/klass.inline.hpp"
#include "prims/methodHandles.hpp" #include "prims/methodHandles.hpp"
#include "runtime/biasedLocking.hpp" #include "runtime/biasedLocking.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/interfaceSupport.inline.hpp" #include "runtime/interfaceSupport.inline.hpp"
#include "runtime/objectMonitor.hpp" #include "runtime/objectMonitor.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"

View File

@ -31,6 +31,7 @@
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "prims/methodHandles.hpp" #include "prims/methodHandles.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/frame.inline.hpp" #include "runtime/frame.inline.hpp"
#include "utilities/preserveException.hpp" #include "utilities/preserveException.hpp"

View File

@ -35,6 +35,7 @@
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "oops/objArrayKlass.hpp" #include "oops/objArrayKlass.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/handles.hpp" #include "runtime/handles.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/jniHandles.inline.hpp" #include "runtime/jniHandles.inline.hpp"

View File

@ -47,6 +47,7 @@
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "prims/jvmtiImpl.hpp" #include "prims/jvmtiImpl.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/frame.inline.hpp" #include "runtime/frame.inline.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/jniHandles.inline.hpp" #include "runtime/jniHandles.inline.hpp"

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,7 @@
#include "code/relocInfo.hpp" #include "code/relocInfo.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "oops/compressedOops.inline.hpp" #include "oops/compressedOops.inline.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/stubCodeGenerator.hpp" #include "runtime/stubCodeGenerator.hpp"
#include "utilities/copy.hpp" #include "utilities/copy.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"

View File

@ -68,6 +68,7 @@
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "prims/jvmtiExport.hpp" #include "prims/jvmtiExport.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/globals_extension.hpp" #include "runtime/globals_extension.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"

View File

@ -23,52 +23,52 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "gc/cms/commandLineFlagConstraintsCMS.hpp" #include "gc/cms/jvmFlagConstraintsCMS.hpp"
#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp" #include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
#include "gc/shared/cardTableRS.hpp" #include "gc/shared/cardTableRS.hpp"
#include "gc/shared/collectedHeap.hpp" #include "gc/shared/collectedHeap.hpp"
#include "gc/shared/genCollectedHeap.hpp" #include "gc/shared/genCollectedHeap.hpp"
#include "gc/shared/commandLineFlagConstraintsGC.hpp" #include "gc/shared/jvmFlagConstraintsGC.hpp"
#include "memory/universe.hpp" #include "memory/universe.hpp"
#include "runtime/commandLineFlagRangeList.hpp" #include "runtime/flags/jvmFlagRangeList.hpp"
#include "runtime/globals_extension.hpp" #include "runtime/globals_extension.hpp"
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"
static Flag::Error ParallelGCThreadsAndCMSWorkQueueDrainThreshold(uint threads, uintx threshold, bool verbose) { static JVMFlag::Error ParallelGCThreadsAndCMSWorkQueueDrainThreshold(uint threads, uintx threshold, bool verbose) {
// CMSWorkQueueDrainThreshold is verified to be less than max_juint // CMSWorkQueueDrainThreshold is verified to be less than max_juint
if (UseConcMarkSweepGC && (threads > (uint)(max_jint / (uint)threshold))) { if (UseConcMarkSweepGC && (threads > (uint)(max_jint / (uint)threshold))) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"ParallelGCThreads (" UINT32_FORMAT ") or CMSWorkQueueDrainThreshold (" "ParallelGCThreads (" UINT32_FORMAT ") or CMSWorkQueueDrainThreshold ("
UINTX_FORMAT ") is too large\n", UINTX_FORMAT ") is too large\n",
threads, threshold); threads, threshold);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error ParallelGCThreadsConstraintFuncCMS(uint value, bool verbose) { JVMFlag::Error ParallelGCThreadsConstraintFuncCMS(uint value, bool verbose) {
// To avoid overflow at ParScanClosure::do_oop_work. // To avoid overflow at ParScanClosure::do_oop_work.
if (UseConcMarkSweepGC && (value > (max_jint / 10))) { if (UseConcMarkSweepGC && (value > (max_jint / 10))) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"ParallelGCThreads (" UINT32_FORMAT ") must be " "ParallelGCThreads (" UINT32_FORMAT ") must be "
"less than or equal to " UINT32_FORMAT " for CMS GC\n", "less than or equal to " UINT32_FORMAT " for CMS GC\n",
value, (max_jint / 10)); value, (max_jint / 10));
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(value, CMSWorkQueueDrainThreshold, verbose); return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(value, CMSWorkQueueDrainThreshold, verbose);
} }
Flag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose) { JVMFlag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose) {
if (UseConcMarkSweepGC && (value > ((uintx)max_jint / (uintx)ParallelGCThreads))) { if (UseConcMarkSweepGC && (value > ((uintx)max_jint / (uintx)ParallelGCThreads))) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"ParGCStridesPerThread (" UINTX_FORMAT ") must be " "ParGCStridesPerThread (" UINTX_FORMAT ") must be "
"less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n", "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
value, ((uintx)max_jint / (uintx)ParallelGCThreads)); value, ((uintx)max_jint / (uintx)ParallelGCThreads));
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) { JVMFlag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) {
if (UseConcMarkSweepGC) { if (UseConcMarkSweepGC) {
// ParGCCardsPerStrideChunk should be compared with card table size. // ParGCCardsPerStrideChunk should be compared with card table size.
size_t heap_size = Universe::heap()->reserved_region().word_size(); size_t heap_size = Universe::heap()->reserved_region().word_size();
@ -80,7 +80,7 @@ Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) {
"ParGCCardsPerStrideChunk (" INTX_FORMAT ") is too large for the heap size and " "ParGCCardsPerStrideChunk (" INTX_FORMAT ") is too large for the heap size and "
"must be less than or equal to card table size (" SIZE_FORMAT ")\n", "must be less than or equal to card table size (" SIZE_FORMAT ")\n",
value, card_table_size); value, card_table_size);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
// ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread) // ParGCCardsPerStrideChunk is used with n_strides(ParallelGCThreads*ParGCStridesPerThread)
@ -93,14 +93,14 @@ Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose) {
"ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be " "ParGCCardsPerStrideChunk (" INTX_FORMAT ") must be "
"less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n", "less than or equal to ergonomic maximum (" UINTX_FORMAT ")\n",
value, ergo_max); value, ergo_max);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) { JVMFlag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) {
Flag::Error status = Flag::SUCCESS; JVMFlag::Error status = JVMFlag::SUCCESS;
if (UseConcMarkSweepGC) { if (UseConcMarkSweepGC) {
if (value > CMSOldPLABMax) { if (value > CMSOldPLABMax) {
@ -108,15 +108,15 @@ Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) {
"CMSOldPLABMin (" SIZE_FORMAT ") must be " "CMSOldPLABMin (" SIZE_FORMAT ") must be "
"less than or equal to CMSOldPLABMax (" SIZE_FORMAT ")\n", "less than or equal to CMSOldPLABMax (" SIZE_FORMAT ")\n",
value, CMSOldPLABMax); value, CMSOldPLABMax);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
status = MaxPLABSizeBounds("CMSOldPLABMin", value, verbose); status = MaxPLABSizeBounds("CMSOldPLABMin", value, verbose);
} }
return status; return status;
} }
Flag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose) { JVMFlag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose) {
Flag::Error status = Flag::SUCCESS; JVMFlag::Error status = JVMFlag::SUCCESS;
if (UseConcMarkSweepGC) { if (UseConcMarkSweepGC) {
status = MaxPLABSizeBounds("CMSOldPLABMax", value, verbose); status = MaxPLABSizeBounds("CMSOldPLABMax", value, verbose);
@ -124,7 +124,7 @@ Flag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose) {
return status; return status;
} }
static Flag::Error CMSReservedAreaConstraintFunc(const char* name, size_t value, bool verbose) { static JVMFlag::Error CMSReservedAreaConstraintFunc(const char* name, size_t value, bool verbose) {
if (UseConcMarkSweepGC) { if (UseConcMarkSweepGC) {
ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*)GenCollectedHeap::heap()->old_gen(); ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*)GenCollectedHeap::heap()->old_gen();
const size_t ergo_max = cms->cmsSpace()->max_flag_size_for_task_size(); const size_t ergo_max = cms->cmsSpace()->max_flag_size_for_task_size();
@ -134,17 +134,17 @@ static Flag::Error CMSReservedAreaConstraintFunc(const char* name, size_t value,
"less than or equal to ergonomic maximum (" SIZE_FORMAT ") " "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", "which is based on the maximum size of the old generation of the Java heap\n",
name, value, ergo_max); name, value, ergo_max);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose) { JVMFlag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose) {
Flag::Error status = CMSReservedAreaConstraintFunc("CMSRescanMultiple", value, verbose); JVMFlag::Error status = CMSReservedAreaConstraintFunc("CMSRescanMultiple", value, verbose);
if (status == Flag::SUCCESS && UseConcMarkSweepGC) { if (status == JVMFlag::SUCCESS && UseConcMarkSweepGC) {
// CMSParRemarkTask::do_dirty_card_rescan_tasks requires CompactibleFreeListSpace::rescan_task_size() // CMSParRemarkTask::do_dirty_card_rescan_tasks requires CompactibleFreeListSpace::rescan_task_size()
// to be aligned to CardTable::card_size * BitsPerWord. // to be aligned to CardTable::card_size * BitsPerWord.
// Note that rescan_task_size() will be aligned if CMSRescanMultiple is a multiple of 'HeapWordSize' // Note that rescan_task_size() will be aligned if CMSRescanMultiple is a multiple of 'HeapWordSize'
@ -154,40 +154,40 @@ Flag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose) {
"CMSRescanMultiple (" SIZE_FORMAT ") must be " "CMSRescanMultiple (" SIZE_FORMAT ") must be "
"a multiple of " SIZE_FORMAT "\n", "a multiple of " SIZE_FORMAT "\n",
value, HeapWordSize); value, HeapWordSize);
status = Flag::VIOLATES_CONSTRAINT; status = JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return status; return status;
} }
Flag::Error CMSConcMarkMultipleConstraintFunc(size_t value, bool verbose) { JVMFlag::Error CMSConcMarkMultipleConstraintFunc(size_t value, bool verbose) {
return CMSReservedAreaConstraintFunc("CMSConcMarkMultiple", value, verbose); return CMSReservedAreaConstraintFunc("CMSConcMarkMultiple", value, verbose);
} }
Flag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose) { JVMFlag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose) {
if (UseConcMarkSweepGC && (value <= CMSPrecleanNumerator)) { if (UseConcMarkSweepGC && (value <= CMSPrecleanNumerator)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"CMSPrecleanDenominator (" UINTX_FORMAT ") must be " "CMSPrecleanDenominator (" UINTX_FORMAT ") must be "
"strickly greater than CMSPrecleanNumerator (" UINTX_FORMAT ")\n", "strickly greater than CMSPrecleanNumerator (" UINTX_FORMAT ")\n",
value, CMSPrecleanNumerator); value, CMSPrecleanNumerator);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose) { JVMFlag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose) {
if (UseConcMarkSweepGC && (value >= CMSPrecleanDenominator)) { if (UseConcMarkSweepGC && (value >= CMSPrecleanDenominator)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"CMSPrecleanNumerator (" UINTX_FORMAT ") must be " "CMSPrecleanNumerator (" UINTX_FORMAT ") must be "
"less than CMSPrecleanDenominator (" UINTX_FORMAT ")\n", "less than CMSPrecleanDenominator (" UINTX_FORMAT ")\n",
value, CMSPrecleanDenominator); value, CMSPrecleanDenominator);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose) { JVMFlag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose) {
if (UseConcMarkSweepGC) { if (UseConcMarkSweepGC) {
size_t max_capacity = GenCollectedHeap::heap()->young_gen()->max_capacity(); size_t max_capacity = GenCollectedHeap::heap()->young_gen()->max_capacity();
if (value > max_uintx - max_capacity) { if (value > max_uintx - max_capacity) {
@ -195,20 +195,20 @@ Flag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose) {
"CMSSamplingGrain (" UINTX_FORMAT ") must be " "CMSSamplingGrain (" UINTX_FORMAT ") must be "
"less than or equal to ergonomic maximum (" SIZE_FORMAT ")\n", "less than or equal to ergonomic maximum (" SIZE_FORMAT ")\n",
value, max_uintx - max_capacity); value, max_uintx - max_capacity);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose) { JVMFlag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose) {
if (UseConcMarkSweepGC) { if (UseConcMarkSweepGC) {
return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(ParallelGCThreads, value, verbose); return ParallelGCThreadsAndCMSWorkQueueDrainThreshold(ParallelGCThreads, value, verbose);
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose) { JVMFlag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose) {
// Skip for current default value. // Skip for current default value.
if (UseConcMarkSweepGC && FLAG_IS_CMDLINE(CMSBitMapYieldQuantum)) { if (UseConcMarkSweepGC && FLAG_IS_CMDLINE(CMSBitMapYieldQuantum)) {
// CMSBitMapYieldQuantum should be compared with mark bitmap size. // CMSBitMapYieldQuantum should be compared with mark bitmap size.
@ -221,18 +221,18 @@ Flag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose) {
"be less than or equal to bitmap size (" SIZE_FORMAT ") " "be less than or equal to bitmap size (" SIZE_FORMAT ") "
"whose size corresponds to the size of old generation of the Java heap\n", "whose size corresponds to the size of old generation of the Java heap\n",
value, bitmap_size); value, bitmap_size);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error OldPLABSizeConstraintFuncCMS(size_t value, bool verbose) { JVMFlag::Error OldPLABSizeConstraintFuncCMS(size_t value, bool verbose) {
if (value == 0) { if (value == 0) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"OldPLABSize (" SIZE_FORMAT ") must be greater than 0", "OldPLABSize (" SIZE_FORMAT ") must be greater than 0",
value); value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
// For CMS, OldPLABSize is the number of free blocks of a given size that are used when // 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. // replenishing the local per-worker free list caches.

View File

@ -29,20 +29,20 @@
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"
// CMS Flag Constraints // CMS Flag Constraints
Flag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose); JVMFlag::Error ParGCStridesPerThreadConstraintFunc(uintx value, bool verbose);
Flag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose); JVMFlag::Error ParGCCardsPerStrideChunkConstraintFunc(intx value, bool verbose);
Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose); JVMFlag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose);
Flag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose); JVMFlag::Error CMSOldPLABMaxConstraintFunc(size_t value, bool verbose);
Flag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose); JVMFlag::Error CMSRescanMultipleConstraintFunc(size_t value, bool verbose);
Flag::Error CMSConcMarkMultipleConstraintFunc(size_t value, bool verbose); JVMFlag::Error CMSConcMarkMultipleConstraintFunc(size_t value, bool verbose);
Flag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose); JVMFlag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose);
Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose); JVMFlag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose);
Flag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose); JVMFlag::Error CMSSamplingGrainConstraintFunc(uintx value, bool verbose);
Flag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose); JVMFlag::Error CMSWorkQueueDrainThresholdConstraintFunc(uintx value, bool verbose);
Flag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose); JVMFlag::Error CMSBitMapYieldQuantumConstraintFunc(size_t value, bool verbose);
// CMS Subconstraints // CMS Subconstraints
Flag::Error ParallelGCThreadsConstraintFuncCMS(uint value, bool verbose); JVMFlag::Error ParallelGCThreadsConstraintFuncCMS(uint value, bool verbose);
Flag::Error OldPLABSizeConstraintFuncCMS(size_t value, bool verbose); JVMFlag::Error OldPLABSizeConstraintFuncCMS(size_t value, bool verbose);
#endif // SHARE_GC_CMS_COMMANDLINEFLAGCONSTRAINTSCMS_HPP #endif // SHARE_GC_CMS_COMMANDLINEFLAGCONSTRAINTSCMS_HPP

View File

@ -84,6 +84,7 @@
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "prims/resolvedMethodTable.hpp" #include "prims/resolvedMethodTable.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/init.hpp" #include "runtime/init.hpp"
#include "runtime/orderAccess.inline.hpp" #include "runtime/orderAccess.inline.hpp"

View File

@ -24,12 +24,12 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "gc/g1/heapRegionBounds.inline.hpp" #include "gc/g1/heapRegionBounds.inline.hpp"
#include "runtime/commandLineFlagRangeList.hpp" #include "runtime/flags/jvmFlagRangeList.hpp"
#include "runtime/globals_extension.hpp" #include "runtime/globals_extension.hpp"
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"
Flag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose) { JVMFlag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose) {
if (!UseG1GC) return Flag::SUCCESS; if (!UseG1GC) return JVMFlag::SUCCESS;
// Default value of G1RSetRegionEntries=0 means will be set ergonomically. // Default value of G1RSetRegionEntries=0 means will be set ergonomically.
// Minimum value is 1. // Minimum value is 1.
@ -38,14 +38,14 @@ Flag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose) {
"G1RSetRegionEntries (" INTX_FORMAT ") must be " "G1RSetRegionEntries (" INTX_FORMAT ") must be "
"greater than or equal to 1\n", "greater than or equal to 1\n",
value); value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose) { JVMFlag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose) {
if (!UseG1GC) return Flag::SUCCESS; if (!UseG1GC) return JVMFlag::SUCCESS;
// Default value of G1RSetSparseRegionEntries=0 means will be set ergonomically. // Default value of G1RSetSparseRegionEntries=0 means will be set ergonomically.
// Minimum value is 1. // Minimum value is 1.
@ -54,14 +54,14 @@ Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose) {
"G1RSetSparseRegionEntries (" INTX_FORMAT ") must be " "G1RSetSparseRegionEntries (" INTX_FORMAT ") must be "
"greater than or equal to 1\n", "greater than or equal to 1\n",
value); value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) {
if (!UseG1GC) return Flag::SUCCESS; if (!UseG1GC) return JVMFlag::SUCCESS;
// Default value of G1HeapRegionSize=0 means will be set ergonomically. // Default value of G1HeapRegionSize=0 means will be set ergonomically.
if (FLAG_IS_CMDLINE(G1HeapRegionSize) && (value < HeapRegionBounds::min_size())) { if (FLAG_IS_CMDLINE(G1HeapRegionSize) && (value < HeapRegionBounds::min_size())) {
@ -69,53 +69,53 @@ Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) {
"G1HeapRegionSize (" SIZE_FORMAT ") must be " "G1HeapRegionSize (" SIZE_FORMAT ") must be "
"greater than or equal to ergonomic heap region minimum size\n", "greater than or equal to ergonomic heap region minimum size\n",
value); value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) { JVMFlag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) {
if (!UseG1GC) return Flag::SUCCESS; if (!UseG1GC) return JVMFlag::SUCCESS;
if (value > G1MaxNewSizePercent) { if (value > G1MaxNewSizePercent) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"G1NewSizePercent (" UINTX_FORMAT ") must be " "G1NewSizePercent (" UINTX_FORMAT ") must be "
"less than or equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n", "less than or equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n",
value, G1MaxNewSizePercent); value, G1MaxNewSizePercent);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) { JVMFlag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) {
if (!UseG1GC) return Flag::SUCCESS; if (!UseG1GC) return JVMFlag::SUCCESS;
if (value < G1NewSizePercent) { if (value < G1NewSizePercent) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"G1MaxNewSizePercent (" UINTX_FORMAT ") must be " "G1MaxNewSizePercent (" UINTX_FORMAT ") must be "
"greater than or equal to G1NewSizePercent (" UINTX_FORMAT ")\n", "greater than or equal to G1NewSizePercent (" UINTX_FORMAT ")\n",
value, G1NewSizePercent); value, G1NewSizePercent);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose) { JVMFlag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose) {
if (UseG1GC && FLAG_IS_CMDLINE(MaxGCPauseMillis) && (value >= GCPauseIntervalMillis)) { if (UseG1GC && FLAG_IS_CMDLINE(MaxGCPauseMillis) && (value >= GCPauseIntervalMillis)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"MaxGCPauseMillis (" UINTX_FORMAT ") must be " "MaxGCPauseMillis (" UINTX_FORMAT ") must be "
"less than GCPauseIntervalMillis (" UINTX_FORMAT ")\n", "less than GCPauseIntervalMillis (" UINTX_FORMAT ")\n",
value, GCPauseIntervalMillis); value, GCPauseIntervalMillis);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose) { JVMFlag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose) {
if (UseG1GC) { if (UseG1GC) {
if (FLAG_IS_CMDLINE(GCPauseIntervalMillis)) { if (FLAG_IS_CMDLINE(GCPauseIntervalMillis)) {
if (value < 1) { if (value < 1) {
@ -123,14 +123,14 @@ Flag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose) {
"GCPauseIntervalMillis (" UINTX_FORMAT ") must be " "GCPauseIntervalMillis (" UINTX_FORMAT ") must be "
"greater than or equal to 1\n", "greater than or equal to 1\n",
value); value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"GCPauseIntervalMillis cannot be set " "GCPauseIntervalMillis cannot be set "
"without setting MaxGCPauseMillis\n"); "without setting MaxGCPauseMillis\n");
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
if (value <= MaxGCPauseMillis) { if (value <= MaxGCPauseMillis) {
@ -138,15 +138,15 @@ Flag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose) {
"GCPauseIntervalMillis (" UINTX_FORMAT ") must be " "GCPauseIntervalMillis (" UINTX_FORMAT ") must be "
"greater than MaxGCPauseMillis (" UINTX_FORMAT ")\n", "greater than MaxGCPauseMillis (" UINTX_FORMAT ")\n",
value, MaxGCPauseMillis); value, MaxGCPauseMillis);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error NewSizeConstraintFuncG1(size_t value, bool verbose) { JVMFlag::Error NewSizeConstraintFuncG1(size_t value, bool verbose) {
#ifdef _LP64 #ifdef _LP64
// Overflow would happen for uint type variable of YoungGenSizer::_min_desired_young_length // Overflow would happen for uint type variable of YoungGenSizer::_min_desired_young_length
// when the value to be assigned exceeds uint range. // when the value to be assigned exceeds uint range.
@ -156,10 +156,10 @@ Flag::Error NewSizeConstraintFuncG1(size_t value, bool verbose) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"NewSize (" SIZE_FORMAT ") must be less than ergonomic maximum value\n", "NewSize (" SIZE_FORMAT ") must be less than ergonomic maximum value\n",
value); value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
#endif // _LP64 #endif // _LP64
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
size_t MaxSizeForHeapAlignmentG1() { size_t MaxSizeForHeapAlignmentG1() {

View File

@ -29,17 +29,17 @@
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"
// G1 Flag Constraints // G1 Flag Constraints
Flag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose); JVMFlag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose);
Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose); JVMFlag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose);
Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose); JVMFlag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose);
Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose); JVMFlag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose);
Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose); JVMFlag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose);
// G1 Subconstraints // G1 Subconstraints
Flag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose); JVMFlag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose);
Flag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose); JVMFlag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose);
Flag::Error MaxSizeForHeapAlignmentG1(const char* name, size_t value, bool verbose); JVMFlag::Error MaxSizeForHeapAlignmentG1(const char* name, size_t value, bool verbose);
Flag::Error NewSizeConstraintFuncG1(size_t value, bool verbose); JVMFlag::Error NewSizeConstraintFuncG1(size_t value, bool verbose);
size_t MaxSizeForHeapAlignmentG1(); size_t MaxSizeForHeapAlignmentG1();

View File

@ -23,11 +23,11 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "runtime/commandLineFlagRangeList.hpp" #include "runtime/flags/jvmFlagRangeList.hpp"
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"
Flag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose) { JVMFlag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose) {
// Parallel GC passes ParallelGCThreads when creating GrowableArray as 'int' type parameter. // Parallel GC passes ParallelGCThreads when creating GrowableArray as 'int' type parameter.
// So can't exceed with "max_jint" // So can't exceed with "max_jint"
@ -36,24 +36,24 @@ Flag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose) {
"ParallelGCThreads (" UINT32_FORMAT ") must be " "ParallelGCThreads (" UINT32_FORMAT ") must be "
"less than or equal to " UINT32_FORMAT " for Parallel GC\n", "less than or equal to " UINT32_FORMAT " for Parallel GC\n",
value, max_jint); value, max_jint);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) { JVMFlag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) {
// InitialTenuringThreshold is only used for ParallelGC. // InitialTenuringThreshold is only used for ParallelGC.
if (UseParallelGC && (value > MaxTenuringThreshold)) { if (UseParallelGC && (value > MaxTenuringThreshold)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"InitialTenuringThreshold (" UINTX_FORMAT ") must be " "InitialTenuringThreshold (" UINTX_FORMAT ") must be "
"less than or equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n", "less than or equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n",
value, MaxTenuringThreshold); value, MaxTenuringThreshold);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) { JVMFlag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) {
// As only ParallelGC uses InitialTenuringThreshold, // As only ParallelGC uses InitialTenuringThreshold,
// we don't need to compare InitialTenuringThreshold with MaxTenuringThreshold. // we don't need to compare InitialTenuringThreshold with MaxTenuringThreshold.
if (UseParallelGC && (value < InitialTenuringThreshold)) { if (UseParallelGC && (value < InitialTenuringThreshold)) {
@ -61,8 +61,8 @@ Flag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose
"MaxTenuringThreshold (" UINTX_FORMAT ") must be " "MaxTenuringThreshold (" UINTX_FORMAT ") must be "
"greater than or equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n", "greater than or equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n",
value, InitialTenuringThreshold); value, InitialTenuringThreshold);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }

View File

@ -29,8 +29,8 @@
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"
// Parallel Subconstraints // Parallel Subconstraints
Flag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose); JVMFlag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose);
Flag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool verbose); JVMFlag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool verbose);
Flag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose); JVMFlag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose);
#endif // SHARE_GC_PARALLEL_COMMANDLINEFLAGCONSTRAINTSPARALLEL_HPP #endif // SHARE_GC_PARALLEL_COMMANDLINEFLAGCONSTRAINTSPARALLEL_HPP

View File

@ -51,6 +51,7 @@
#include "logging/log.hpp" #include "logging/log.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "runtime/biasedLocking.hpp" #include "runtime/biasedLocking.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/safepoint.hpp" #include "runtime/safepoint.hpp"
#include "runtime/vmThread.hpp" #include "runtime/vmThread.hpp"

View File

@ -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

View File

@ -53,6 +53,7 @@
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "runtime/biasedLocking.hpp" #include "runtime/biasedLocking.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/handles.hpp" #include "runtime/handles.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"

View File

@ -25,11 +25,11 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "gc/shared/collectedHeap.hpp" #include "gc/shared/collectedHeap.hpp"
#include "gc/shared/collectorPolicy.hpp" #include "gc/shared/collectorPolicy.hpp"
#include "gc/shared/commandLineFlagConstraintsGC.hpp" #include "gc/shared/jvmFlagConstraintsGC.hpp"
#include "gc/shared/plab.hpp" #include "gc/shared/plab.hpp"
#include "gc/shared/threadLocalAllocBuffer.hpp" #include "gc/shared/threadLocalAllocBuffer.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/commandLineFlagRangeList.hpp" #include "runtime/flags/jvmFlagRangeList.hpp"
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "runtime/globals_extension.hpp" #include "runtime/globals_extension.hpp"
#include "runtime/thread.inline.hpp" #include "runtime/thread.inline.hpp"
@ -37,9 +37,9 @@
#include "utilities/defaultStream.hpp" #include "utilities/defaultStream.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
#include "gc/cms/commandLineFlagConstraintsCMS.hpp" #include "gc/cms/jvmFlagConstraintsCMS.hpp"
#include "gc/g1/commandLineFlagConstraintsG1.hpp" #include "gc/g1/jvmFlagConstraintsG1.hpp"
#include "gc/parallel/commandLineFlagConstraintsParallel.hpp" #include "gc/parallel/jvmFlagConstraintsParallel.hpp"
#endif #endif
#ifdef COMPILER1 #ifdef COMPILER1
#include "c1/c1_globals.hpp" #include "c1/c1_globals.hpp"
@ -57,17 +57,17 @@
// the flag has been set by the user and so should be checked. // the flag has been set by the user and so should be checked.
// As ParallelGCThreads differs among GC modes, we need constraint function. // As ParallelGCThreads differs among GC modes, we need constraint function.
Flag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) { JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) {
Flag::Error status = Flag::SUCCESS; JVMFlag::Error status = JVMFlag::SUCCESS;
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
status = ParallelGCThreadsConstraintFuncParallel(value, verbose); status = ParallelGCThreadsConstraintFuncParallel(value, verbose);
if (status != Flag::SUCCESS) { if (status != JVMFlag::SUCCESS) {
return status; return status;
} }
status = ParallelGCThreadsConstraintFuncCMS(value, verbose); status = ParallelGCThreadsConstraintFuncCMS(value, verbose);
if (status != Flag::SUCCESS) { if (status != JVMFlag::SUCCESS) {
return status; return status;
} }
#endif #endif
@ -77,7 +77,7 @@ Flag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) {
// As ConcGCThreads should be smaller than ParallelGCThreads, // As ConcGCThreads should be smaller than ParallelGCThreads,
// we need constraint function. // we need constraint function.
Flag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) { JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) {
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
// CMS and G1 GCs use ConcGCThreads. // CMS and G1 GCs use ConcGCThreads.
if ((UseConcMarkSweepGC || UseG1GC) && (value > ParallelGCThreads)) { if ((UseConcMarkSweepGC || UseG1GC) && (value > ParallelGCThreads)) {
@ -85,53 +85,53 @@ Flag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) {
"ConcGCThreads (" UINT32_FORMAT ") must be " "ConcGCThreads (" UINT32_FORMAT ") must be "
"less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n", "less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n",
value, ParallelGCThreads); value, ParallelGCThreads);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
#endif #endif
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
static Flag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) { static JVMFlag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) {
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value < PLAB::min_size())) { if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value < PLAB::min_size())) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"%s (" SIZE_FORMAT ") must be " "%s (" SIZE_FORMAT ") must be "
"greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n", "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n",
name, value, PLAB::min_size()); name, value, PLAB::min_size());
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
#endif // INCLUDE_ALL_GCS #endif // INCLUDE_ALL_GCS
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) { JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value > PLAB::max_size())) { if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value > PLAB::max_size())) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"%s (" SIZE_FORMAT ") must be " "%s (" SIZE_FORMAT ") must be "
"less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n", "less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
name, value, PLAB::max_size()); name, value, PLAB::max_size());
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
#endif // INCLUDE_ALL_GCS #endif // INCLUDE_ALL_GCS
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
static Flag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) { static JVMFlag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
Flag::Error status = MinPLABSizeBounds(name, value, verbose); JVMFlag::Error status = MinPLABSizeBounds(name, value, verbose);
if (status == Flag::SUCCESS) { if (status == JVMFlag::SUCCESS) {
return MaxPLABSizeBounds(name, value, verbose); return MaxPLABSizeBounds(name, value, verbose);
} }
return status; return status;
} }
Flag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) {
return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose); return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose);
} }
Flag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) {
Flag::Error status = Flag::SUCCESS; JVMFlag::Error status = JVMFlag::SUCCESS;
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
if (UseConcMarkSweepGC) { if (UseConcMarkSweepGC) {
@ -143,98 +143,98 @@ Flag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) {
return status; return status;
} }
Flag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) { JVMFlag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
if (value > MaxHeapFreeRatio) { if (value > MaxHeapFreeRatio) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"MinHeapFreeRatio (" UINTX_FORMAT ") must be " "MinHeapFreeRatio (" UINTX_FORMAT ") must be "
"less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n", "less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
value, MaxHeapFreeRatio); value, MaxHeapFreeRatio);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) { JVMFlag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
if (value < MinHeapFreeRatio) { if (value < MinHeapFreeRatio) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"MaxHeapFreeRatio (" UINTX_FORMAT ") must be " "MaxHeapFreeRatio (" UINTX_FORMAT ") must be "
"greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n", "greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
value, MinHeapFreeRatio); value, MinHeapFreeRatio);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
static Flag::Error CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(size_t maxHeap, intx softRef, bool verbose) { static JVMFlag::Error CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(size_t maxHeap, intx softRef, bool verbose) {
if ((softRef > 0) && ((maxHeap / M) > (max_uintx / softRef))) { if ((softRef > 0) && ((maxHeap / M) > (max_uintx / softRef))) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"Desired lifetime of SoftReferences cannot be expressed correctly. " "Desired lifetime of SoftReferences cannot be expressed correctly. "
"MaxHeapSize (" SIZE_FORMAT ") or SoftRefLRUPolicyMSPerMB " "MaxHeapSize (" SIZE_FORMAT ") or SoftRefLRUPolicyMSPerMB "
"(" INTX_FORMAT ") is too large\n", "(" INTX_FORMAT ") is too large\n",
maxHeap, softRef); maxHeap, softRef);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose) { JVMFlag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose) {
return CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(MaxHeapSize, value, verbose); return CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(MaxHeapSize, value, verbose);
} }
Flag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) {
if (value > MarkStackSizeMax) { if (value > MarkStackSizeMax) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"MarkStackSize (" SIZE_FORMAT ") must be " "MarkStackSize (" SIZE_FORMAT ") must be "
"less than or equal to MarkStackSizeMax (" SIZE_FORMAT ")\n", "less than or equal to MarkStackSizeMax (" SIZE_FORMAT ")\n",
value, MarkStackSizeMax); value, MarkStackSizeMax);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { JVMFlag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
if (value > MaxMetaspaceFreeRatio) { if (value > MaxMetaspaceFreeRatio) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be " "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
"less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n", "less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
value, MaxMetaspaceFreeRatio); value, MaxMetaspaceFreeRatio);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { JVMFlag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
if (value < MinMetaspaceFreeRatio) { if (value < MinMetaspaceFreeRatio) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be " "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
"greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n", "greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
value, MinMetaspaceFreeRatio); value, MinMetaspaceFreeRatio);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) { JVMFlag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) {
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
Flag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose); JVMFlag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose);
if (status != Flag::SUCCESS) { if (status != JVMFlag::SUCCESS) {
return status; return status;
} }
#endif #endif
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) { JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) {
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
Flag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose); JVMFlag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose);
if (status != Flag::SUCCESS) { if (status != JVMFlag::SUCCESS) {
return status; return status;
} }
#endif #endif
@ -247,59 +247,59 @@ Flag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) {
"AlwaysTenure=%s\n", "AlwaysTenure=%s\n",
NeverTenure ? "true" : "false", NeverTenure ? "true" : "false",
AlwaysTenure ? "true" : "false"); AlwaysTenure ? "true" : "false");
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) { JVMFlag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) {
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
Flag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose); JVMFlag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose);
if (status != Flag::SUCCESS) { if (status != JVMFlag::SUCCESS) {
return status; return status;
} }
#endif #endif
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) { JVMFlag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) {
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
Flag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose); JVMFlag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose);
if (status != Flag::SUCCESS) { if (status != JVMFlag::SUCCESS) {
return status; return status;
} }
#endif #endif
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
size_t aligned_max = align_down(max_uintx/2, Metaspace::reserve_alignment_words()); size_t aligned_max = align_down(max_uintx/2, Metaspace::reserve_alignment_words());
if (value > aligned_max) { if (value > aligned_max) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"InitialBootClassLoaderMetaspaceSize (" SIZE_FORMAT ") must be " "InitialBootClassLoaderMetaspaceSize (" SIZE_FORMAT ") must be "
"less than or equal to aligned maximum value (" SIZE_FORMAT ")\n", "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
value, aligned_max); value, aligned_max);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
// To avoid an overflow by 'align_up(value, alignment)'. // To avoid an overflow by 'align_up(value, alignment)'.
static Flag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) { static JVMFlag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) {
size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1)); size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
if (value > aligned_max) { if (value > aligned_max) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"%s (" SIZE_FORMAT ") must be " "%s (" SIZE_FORMAT ") must be "
"less than or equal to aligned maximum value (" SIZE_FORMAT ")\n", "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
name, value, aligned_max); name, value, aligned_max);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
static Flag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) { static JVMFlag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
size_t heap_alignment; size_t heap_alignment;
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
@ -315,20 +315,20 @@ static Flag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool
return MaxSizeForAlignment(name, value, heap_alignment, verbose); return MaxSizeForAlignment(name, value, heap_alignment, verbose);
} }
Flag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) {
return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose); return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose);
} }
Flag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) {
Flag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose); JVMFlag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose);
if (status == Flag::SUCCESS) { if (status == JVMFlag::SUCCESS) {
status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose); status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose);
} }
return status; return status;
} }
Flag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) { JVMFlag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
// If an overflow happened in Arguments::set_heap_size(), MaxHeapSize will have too large a value. // 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. // 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))) { if (UseCompressedOops && FLAG_IS_ERGO(MaxHeapSize) && (value > (max_uintx - MaxHeapSize))) {
@ -336,43 +336,43 @@ Flag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
"HeapBaseMinAddress (" SIZE_FORMAT ") or MaxHeapSize (" SIZE_FORMAT ") is too large. " "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", "Sum of them must be less than or equal to maximum of size_t (" SIZE_FORMAT ")\n",
value, MaxHeapSize, max_uintx); value, MaxHeapSize, max_uintx);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose); return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
} }
Flag::Error NewSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
#if INCLUDE_ALL_GCS #if INCLUDE_ALL_GCS
Flag::Error status = NewSizeConstraintFuncG1(value, verbose); JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose);
if (status != Flag::SUCCESS) { if (status != JVMFlag::SUCCESS) {
return status; return status;
} }
#endif #endif
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) {
// At least, alignment reserve area is needed. // At least, alignment reserve area is needed.
if (value < ThreadLocalAllocBuffer::alignment_reserve_in_bytes()) { if (value < ThreadLocalAllocBuffer::alignment_reserve_in_bytes()) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"MinTLABSize (" SIZE_FORMAT ") must be " "MinTLABSize (" SIZE_FORMAT ") must be "
"greater than or equal to reserved area in TLAB (" SIZE_FORMAT ")\n", "greater than or equal to reserved area in TLAB (" SIZE_FORMAT ")\n",
value, ThreadLocalAllocBuffer::alignment_reserve_in_bytes()); value, ThreadLocalAllocBuffer::alignment_reserve_in_bytes());
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"MinTLABSize (" SIZE_FORMAT ") must be " "MinTLABSize (" SIZE_FORMAT ") must be "
"less than or equal to ergonomic TLAB maximum (" SIZE_FORMAT ")\n", "less than or equal to ergonomic TLAB maximum (" SIZE_FORMAT ")\n",
value, ThreadLocalAllocBuffer::max_size() * HeapWordSize); value, ThreadLocalAllocBuffer::max_size() * HeapWordSize);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error TLABSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error TLABSizeConstraintFunc(size_t value, bool verbose) {
// Skip for default value of zero which means set ergonomically. // Skip for default value of zero which means set ergonomically.
if (FLAG_IS_CMDLINE(TLABSize)) { if (FLAG_IS_CMDLINE(TLABSize)) {
if (value < MinTLABSize) { if (value < MinTLABSize) {
@ -380,22 +380,22 @@ Flag::Error TLABSizeConstraintFunc(size_t value, bool verbose) {
"TLABSize (" SIZE_FORMAT ") must be " "TLABSize (" SIZE_FORMAT ") must be "
"greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n", "greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n",
value, MinTLABSize); value, MinTLABSize);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"TLABSize (" SIZE_FORMAT ") must be " "TLABSize (" SIZE_FORMAT ") must be "
"less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n", "less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n",
value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize)); value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize));
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
// We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(), // We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(),
// so AfterMemoryInit type is enough to check. // so AfterMemoryInit type is enough to check.
Flag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) { JVMFlag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
if (UseTLAB) { if (UseTLAB) {
size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit(); size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit();
@ -405,13 +405,13 @@ Flag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
"TLABWasteIncrement (" UINTX_FORMAT ") must be " "TLABWasteIncrement (" UINTX_FORMAT ") must be "
"less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n", "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n",
value, (max_uintx - refill_waste_limit)); value, (max_uintx - refill_waste_limit));
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) { JVMFlag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) {
if (FLAG_IS_CMDLINE(SurvivorRatio) && if (FLAG_IS_CMDLINE(SurvivorRatio) &&
(value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) { (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
@ -419,52 +419,52 @@ Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) {
"less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n", "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n",
value, value,
(MaxHeapSize / Universe::heap()->collector_policy()->space_alignment())); (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()));
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) {
if (value > MaxMetaspaceSize) { if (value > MaxMetaspaceSize) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"MetaspaceSize (" SIZE_FORMAT ") must be " "MetaspaceSize (" SIZE_FORMAT ") must be "
"less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n", "less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n",
value, MaxMetaspaceSize); value, MaxMetaspaceSize);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) { JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
if (value < MetaspaceSize) { if (value < MetaspaceSize) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"MaxMetaspaceSize (" SIZE_FORMAT ") must be " "MaxMetaspaceSize (" SIZE_FORMAT ") must be "
"greater than or equal to MetaspaceSize (" SIZE_FORMAT ")\n", "greater than or equal to MetaspaceSize (" SIZE_FORMAT ")\n",
value, MaxMetaspaceSize); value, MaxMetaspaceSize);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) { JVMFlag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
if (value != 0) { if (value != 0) {
if (!is_power_of_2(value)) { if (!is_power_of_2(value)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be " "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
"power of 2\n", "power of 2\n",
value); value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
if (value < ObjectAlignmentInBytes) { if (value < ObjectAlignmentInBytes) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be " "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
"greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n", "greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
value, ObjectAlignmentInBytes); value, ObjectAlignmentInBytes);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }

View File

@ -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

View File

@ -37,6 +37,7 @@
#include "jvmci/jvmciCompilerToVM.hpp" #include "jvmci/jvmciCompilerToVM.hpp"
#include "jvmci/jvmciCodeInstaller.hpp" #include "jvmci/jvmciCodeInstaller.hpp"
#include "jvmci/jvmciRuntime.hpp" #include "jvmci/jvmciRuntime.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/frame.inline.hpp" #include "runtime/frame.inline.hpp"
#include "runtime/interfaceSupport.inline.hpp" #include "runtime/interfaceSupport.inline.hpp"
#include "runtime/jniHandles.inline.hpp" #include "runtime/jniHandles.inline.hpp"
@ -125,7 +126,7 @@ C2V_VMENTRY(jobject, getFlagValue, (JNIEnv *, jobject c2vm, jobject name_handle)
} }
ResourceMark rm; ResourceMark rm;
const char* cstring = java_lang_String::as_utf8_string(name()); 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) { if (flag == NULL) {
return c2vm; return c2vm;
} }

View File

@ -29,6 +29,7 @@
#include "jvmci/jvmciRuntime.hpp" #include "jvmci/jvmciRuntime.hpp"
#include "jvmci/jvmciCompilerToVM.hpp" #include "jvmci/jvmciCompilerToVM.hpp"
#include "jvmci/vmStructs_jvmci.hpp" #include "jvmci/vmStructs_jvmci.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/sharedRuntime.hpp" #include "runtime/sharedRuntime.hpp"
#include "utilities/resourceHash.hpp" #include "utilities/resourceHash.hpp"
@ -378,9 +379,9 @@ jobjectArray readConfiguration0(JNIEnv *env, TRAPS) {
#define COUNT_FLAG(ignore) +1 #define COUNT_FLAG(ignore) +1
#ifdef ASSERT #ifdef ASSERT
#define CHECK_FLAG(type, name) { \ #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 != 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 #else
#define CHECK_FLAG(type, name) #define CHECK_FLAG(type, name)

View File

@ -35,6 +35,7 @@
#include "oops/oop.hpp" #include "oops/oop.hpp"
#include "oops/oopHandle.hpp" #include "oops/oopHandle.hpp"
#include "oops/objArrayKlass.hpp" #include "oops/objArrayKlass.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "runtime/sharedRuntime.hpp" #include "runtime/sharedRuntime.hpp"
#include "runtime/thread.hpp" #include "runtime/thread.hpp"
@ -151,11 +152,11 @@
nonstatic_field(ExceptionTableElement, handler_pc, u2) \ nonstatic_field(ExceptionTableElement, handler_pc, u2) \
nonstatic_field(ExceptionTableElement, catch_type_index, u2) \ nonstatic_field(ExceptionTableElement, catch_type_index, u2) \
\ \
nonstatic_field(Flag, _type, const char*) \ nonstatic_field(JVMFlag, _type, const char*) \
nonstatic_field(Flag, _name, const char*) \ nonstatic_field(JVMFlag, _name, const char*) \
unchecked_nonstatic_field(Flag, _addr, sizeof(void*)) \ unchecked_nonstatic_field(JVMFlag, _addr, sizeof(void*)) \
nonstatic_field(Flag, _flags, Flag::Flags) \ nonstatic_field(JVMFlag, _flags, JVMFlag::Flags) \
static_field(Flag, flags, Flag*) \ static_field(JVMFlag, flags, JVMFlag*) \
\ \
nonstatic_field(InstanceKlass, _fields, Array<u2>*) \ nonstatic_field(InstanceKlass, _fields, Array<u2>*) \
nonstatic_field(InstanceKlass, _constants, ConstantPool*) \ nonstatic_field(InstanceKlass, _constants, ConstantPool*) \
@ -345,8 +346,8 @@
declare_toplevel_type(BasicLock) \ declare_toplevel_type(BasicLock) \
declare_toplevel_type(CompilerToVM) \ declare_toplevel_type(CompilerToVM) \
declare_toplevel_type(ExceptionTableElement) \ declare_toplevel_type(ExceptionTableElement) \
declare_toplevel_type(Flag) \ declare_toplevel_type(JVMFlag) \
declare_toplevel_type(Flag*) \ declare_toplevel_type(JVMFlag*) \
declare_toplevel_type(InvocationCounter) \ declare_toplevel_type(InvocationCounter) \
declare_toplevel_type(JVMCIEnv) \ declare_toplevel_type(JVMCIEnv) \
declare_toplevel_type(LocalVariableTableElement) \ declare_toplevel_type(LocalVariableTableElement) \

View File

@ -63,7 +63,8 @@
#include "prims/resolvedMethodTable.hpp" #include "prims/resolvedMethodTable.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/atomic.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/deoptimization.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/init.hpp" #include "runtime/init.hpp"
@ -701,7 +702,7 @@ jint universe_init() {
AOTLoader::universe_init(); AOTLoader::universe_init();
// Checks 'AfterMemoryInit' constraints. // Checks 'AfterMemoryInit' constraints.
if (!CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterMemoryInit)) { if (!JVMFlagConstraintList::check_constraints(JVMFlagConstraint::AfterMemoryInit)) {
return JNI_EINVAL; return JNI_EINVAL;
} }

View File

@ -38,6 +38,7 @@
#include "oops/objArrayOop.hpp" #include "oops/objArrayOop.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/safepointVerifiers.hpp" #include "runtime/safepointVerifiers.hpp"
#include "utilities/copy.hpp" #include "utilities/copy.hpp"

View File

@ -101,6 +101,7 @@
# include "gc/shared/genCollectedHeap.hpp" # include "gc/shared/genCollectedHeap.hpp"
# include "gc/shared/generation.hpp" # include "gc/shared/generation.hpp"
# include "gc/shared/generationCounters.hpp" # include "gc/shared/generationCounters.hpp"
# include "gc/shared/jvmFlagConstraintsGC.hpp"
# include "gc/shared/modRefBarrierSet.hpp" # include "gc/shared/modRefBarrierSet.hpp"
# include "gc/shared/referencePolicy.hpp" # include "gc/shared/referencePolicy.hpp"
# include "gc/shared/referenceProcessor.hpp" # include "gc/shared/referenceProcessor.hpp"
@ -163,6 +164,13 @@
# include "runtime/extendedPC.hpp" # include "runtime/extendedPC.hpp"
# include "runtime/fieldDescriptor.hpp" # include "runtime/fieldDescriptor.hpp"
# include "runtime/fieldType.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.hpp"
# include "runtime/frame.inline.hpp" # include "runtime/frame.inline.hpp"
# include "runtime/globals.hpp" # include "runtime/globals.hpp"
@ -292,6 +300,7 @@
# include "gc/cms/concurrentMarkSweepGeneration.hpp" # include "gc/cms/concurrentMarkSweepGeneration.hpp"
# include "gc/cms/freeChunk.hpp" # include "gc/cms/freeChunk.hpp"
# include "gc/cms/gSpaceCounters.hpp" # include "gc/cms/gSpaceCounters.hpp"
# include "gc/cms/jvmFlagConstraintsCMS.hpp"
# include "gc/cms/parOopClosures.hpp" # include "gc/cms/parOopClosures.hpp"
# include "gc/cms/promotionInfo.hpp" # include "gc/cms/promotionInfo.hpp"
# include "gc/cms/yieldingWorkgroup.hpp" # include "gc/cms/yieldingWorkgroup.hpp"
@ -299,10 +308,12 @@
# include "gc/g1/g1BlockOffsetTable.hpp" # include "gc/g1/g1BlockOffsetTable.hpp"
# include "gc/g1/g1OopClosures.hpp" # include "gc/g1/g1OopClosures.hpp"
# include "gc/g1/g1_globals.hpp" # include "gc/g1/g1_globals.hpp"
# include "gc/g1/jvmFlagConstraintsG1.hpp"
# include "gc/g1/ptrQueue.hpp" # include "gc/g1/ptrQueue.hpp"
# include "gc/g1/satbMarkQueue.hpp" # include "gc/g1/satbMarkQueue.hpp"
# include "gc/parallel/gcAdaptivePolicyCounters.hpp" # include "gc/parallel/gcAdaptivePolicyCounters.hpp"
# include "gc/parallel/immutableSpace.hpp" # include "gc/parallel/immutableSpace.hpp"
# include "gc/parallel/jvmFlagConstraintsParallel.hpp"
# include "gc/parallel/mutableSpace.hpp" # include "gc/parallel/mutableSpace.hpp"
# include "gc/parallel/objectStartArray.hpp" # include "gc/parallel/objectStartArray.hpp"
# include "gc/parallel/parMarkBitMap.hpp" # include "gc/parallel/parMarkBitMap.hpp"

View File

@ -53,6 +53,7 @@
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/compilationPolicy.hpp" #include "runtime/compilationPolicy.hpp"
#include "runtime/deoptimization.hpp" #include "runtime/deoptimization.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/frame.inline.hpp" #include "runtime/frame.inline.hpp"
#include "runtime/handshake.hpp" #include "runtime/handshake.hpp"
#include "runtime/interfaceSupport.inline.hpp" #include "runtime/interfaceSupport.inline.hpp"
@ -971,29 +972,29 @@ WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method))
WB_END WB_END
template <typename T> 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) { if (name == NULL) {
return false; return false;
} }
ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
const char* flag_name = env->GetStringUTFChars(name, NULL); const char* flag_name = env->GetStringUTFChars(name, NULL);
CHECK_JNI_EXCEPTION_(env, false); 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); env->ReleaseStringUTFChars(name, flag_name);
return (result == Flag::SUCCESS); return (result == JVMFlag::SUCCESS);
} }
template <typename T> 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) { if (name == NULL) {
return false; return false;
} }
ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
const char* flag_name = env->GetStringUTFChars(name, NULL); const char* flag_name = env->GetStringUTFChars(name, NULL);
CHECK_JNI_EXCEPTION_(env, false); 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); env->ReleaseStringUTFChars(name, flag_name);
return (result == Flag::SUCCESS); return (result == JVMFlag::SUCCESS);
} }
template <typename T> template <typename T>
@ -1026,28 +1027,28 @@ static jobject doubleBox(JavaThread* thread, JNIEnv* env, jdouble value) {
return box(thread, env, vmSymbols::java_lang_Double(), vmSymbols::Double_valueOf_signature(), value); 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 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
const char* flag_name = env->GetStringUTFChars(name, NULL); const char* flag_name = env->GetStringUTFChars(name, NULL);
CHECK_JNI_EXCEPTION_(env, 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); env->ReleaseStringUTFChars(name, flag_name);
return result; return result;
} }
WB_ENTRY(jboolean, WB_IsConstantVMFlag(JNIEnv* env, jobject o, jstring name)) 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(); return (flag != NULL) && flag->is_constant_in_binary();
WB_END WB_END
WB_ENTRY(jboolean, WB_IsLockedVMFlag(JNIEnv* env, jobject o, jstring name)) 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()); return (flag != NULL) && !(flag->is_unlocked() || flag->is_unlocker());
WB_END WB_END
WB_ENTRY(jobject, WB_GetBooleanVMFlag(JNIEnv* env, jobject o, jstring name)) WB_ENTRY(jobject, WB_GetBooleanVMFlag(JNIEnv* env, jobject o, jstring name))
bool result; 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 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
return booleanBox(thread, env, result); return booleanBox(thread, env, result);
} }
@ -1056,7 +1057,7 @@ WB_END
WB_ENTRY(jobject, WB_GetIntVMFlag(JNIEnv* env, jobject o, jstring name)) WB_ENTRY(jobject, WB_GetIntVMFlag(JNIEnv* env, jobject o, jstring name))
int result; 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 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
return longBox(thread, env, result); return longBox(thread, env, result);
} }
@ -1065,7 +1066,7 @@ WB_END
WB_ENTRY(jobject, WB_GetUintVMFlag(JNIEnv* env, jobject o, jstring name)) WB_ENTRY(jobject, WB_GetUintVMFlag(JNIEnv* env, jobject o, jstring name))
uint result; 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 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
return longBox(thread, env, result); return longBox(thread, env, result);
} }
@ -1074,7 +1075,7 @@ WB_END
WB_ENTRY(jobject, WB_GetIntxVMFlag(JNIEnv* env, jobject o, jstring name)) WB_ENTRY(jobject, WB_GetIntxVMFlag(JNIEnv* env, jobject o, jstring name))
intx result; 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 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
return longBox(thread, env, result); return longBox(thread, env, result);
} }
@ -1083,7 +1084,7 @@ WB_END
WB_ENTRY(jobject, WB_GetUintxVMFlag(JNIEnv* env, jobject o, jstring name)) WB_ENTRY(jobject, WB_GetUintxVMFlag(JNIEnv* env, jobject o, jstring name))
uintx result; 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 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
return longBox(thread, env, result); return longBox(thread, env, result);
} }
@ -1092,7 +1093,7 @@ WB_END
WB_ENTRY(jobject, WB_GetUint64VMFlag(JNIEnv* env, jobject o, jstring name)) WB_ENTRY(jobject, WB_GetUint64VMFlag(JNIEnv* env, jobject o, jstring name))
uint64_t result; 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 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
return longBox(thread, env, result); return longBox(thread, env, result);
} }
@ -1101,7 +1102,7 @@ WB_END
WB_ENTRY(jobject, WB_GetSizeTVMFlag(JNIEnv* env, jobject o, jstring name)) WB_ENTRY(jobject, WB_GetSizeTVMFlag(JNIEnv* env, jobject o, jstring name))
uintx result; 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 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
return longBox(thread, env, result); return longBox(thread, env, result);
} }
@ -1110,7 +1111,7 @@ WB_END
WB_ENTRY(jobject, WB_GetDoubleVMFlag(JNIEnv* env, jobject o, jstring name)) WB_ENTRY(jobject, WB_GetDoubleVMFlag(JNIEnv* env, jobject o, jstring name))
double result; 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 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
return doubleBox(thread, env, result); return doubleBox(thread, env, result);
} }
@ -1119,7 +1120,7 @@ WB_END
WB_ENTRY(jstring, WB_GetStringVMFlag(JNIEnv* env, jobject o, jstring name)) WB_ENTRY(jstring, WB_GetStringVMFlag(JNIEnv* env, jobject o, jstring name))
ccstr ccstrResult; 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 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
jstring result = env->NewStringUTF(ccstrResult); jstring result = env->NewStringUTF(ccstrResult);
CHECK_JNI_EXCEPTION_(env, NULL); CHECK_JNI_EXCEPTION_(env, NULL);
@ -1130,42 +1131,42 @@ WB_END
WB_ENTRY(void, WB_SetBooleanVMFlag(JNIEnv* env, jobject o, jstring name, jboolean value)) WB_ENTRY(void, WB_SetBooleanVMFlag(JNIEnv* env, jobject o, jstring name, jboolean value))
bool result = value == JNI_TRUE ? true : false; 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_END
WB_ENTRY(void, WB_SetIntVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) WB_ENTRY(void, WB_SetIntVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
int result = value; int result = value;
SetVMFlag <int> (thread, env, name, &result, &CommandLineFlags::intAtPut); SetVMFlag <int> (thread, env, name, &result, &JVMFlag::intAtPut);
WB_END WB_END
WB_ENTRY(void, WB_SetUintVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) WB_ENTRY(void, WB_SetUintVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
uint result = value; uint result = value;
SetVMFlag <uint> (thread, env, name, &result, &CommandLineFlags::uintAtPut); SetVMFlag <uint> (thread, env, name, &result, &JVMFlag::uintAtPut);
WB_END WB_END
WB_ENTRY(void, WB_SetIntxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) WB_ENTRY(void, WB_SetIntxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
intx result = value; intx result = value;
SetVMFlag <intx> (thread, env, name, &result, &CommandLineFlags::intxAtPut); SetVMFlag <intx> (thread, env, name, &result, &JVMFlag::intxAtPut);
WB_END WB_END
WB_ENTRY(void, WB_SetUintxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) WB_ENTRY(void, WB_SetUintxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
uintx result = value; uintx result = value;
SetVMFlag <uintx> (thread, env, name, &result, &CommandLineFlags::uintxAtPut); SetVMFlag <uintx> (thread, env, name, &result, &JVMFlag::uintxAtPut);
WB_END WB_END
WB_ENTRY(void, WB_SetUint64VMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) WB_ENTRY(void, WB_SetUint64VMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
uint64_t result = 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_END
WB_ENTRY(void, WB_SetSizeTVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) WB_ENTRY(void, WB_SetSizeTVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
size_t result = 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_END
WB_ENTRY(void, WB_SetDoubleVMFlag(JNIEnv* env, jobject o, jstring name, jdouble value)) WB_ENTRY(void, WB_SetDoubleVMFlag(JNIEnv* env, jobject o, jstring name, jdouble value))
double result = value; double result = value;
SetVMFlag <double> (thread, env, name, &result, &CommandLineFlags::doubleAtPut); SetVMFlag <double> (thread, env, name, &result, &JVMFlag::doubleAtPut);
WB_END WB_END
WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value)) WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value))
@ -1182,7 +1183,7 @@ WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring
bool needFree; bool needFree;
{ {
ThreadInVMfromNative ttvfn(thread); // back to VM 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) { if (value != NULL) {
env->ReleaseStringUTFChars(value, ccstrValue); env->ReleaseStringUTFChars(value, ccstrValue);

View File

@ -42,10 +42,10 @@
#include "prims/jvmtiExport.hpp" #include "prims/jvmtiExport.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/arguments_ext.hpp" #include "runtime/arguments_ext.hpp"
#include "runtime/commandLineFlagConstraintList.hpp" #include "runtime/flags/jvmFlag.hpp"
#include "runtime/commandLineFlagWriteableList.hpp" #include "runtime/flags/jvmFlagConstraintList.hpp"
#include "runtime/commandLineFlagRangeList.hpp" #include "runtime/flags/jvmFlagWriteableList.hpp"
#include "runtime/globals.hpp" #include "runtime/flags/jvmFlagRangeList.hpp"
#include "runtime/globals_extension.hpp" #include "runtime/globals_extension.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"
#include "runtime/os.inline.hpp" #include "runtime/os.inline.hpp"
@ -739,7 +739,7 @@ static bool verify_special_jvm_flags() {
// if flag has become obsolete it should not have a "globals" flag defined anymore. // 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 (!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 // Temporarily disable the warning: 8196739
// warning("Global variable for obsolete special flag entry \"%s\" should be removed", flag.name); // warning("Global variable for obsolete special flag entry \"%s\" should be removed", flag.name);
} }
@ -749,7 +749,7 @@ static bool verify_special_jvm_flags() {
if (!flag.expired_in.is_undefined()) { if (!flag.expired_in.is_undefined()) {
// if flag has become expired it should not have a "globals" flag defined anymore. // 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 (!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 // Temporarily disable the warning: 8196739
// warning("Global variable for expired flag entry \"%s\" should be removed", flag.name); // warning("Global variable for expired flag entry \"%s\" should be removed", flag.name);
} }
@ -833,15 +833,15 @@ void Arguments::describe_range_error(ArgsRange errcode) {
} }
} }
static bool set_bool_flag(const char* name, bool value, Flag::Flags origin) { static bool set_bool_flag(const char* name, bool value, JVMFlag::Flags origin) {
if (CommandLineFlags::boolAtPut(name, &value, origin) == Flag::SUCCESS) { if (JVMFlag::boolAtPut(name, &value, origin) == JVMFlag::SUCCESS) {
return true; return true;
} else { } else {
return false; 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; char* end;
errno = 0; errno = 0;
double v = strtod(value, &end); double v = strtod(value, &end);
@ -849,18 +849,18 @@ static bool set_fp_numeric_flag(const char* name, char* value, Flag::Flags origi
return false; return false;
} }
if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) { if (JVMFlag::doubleAtPut(name, &v, origin) == JVMFlag::SUCCESS) {
return true; return true;
} }
return false; 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; julong v;
int int_v; int int_v;
intx intx_v; intx intx_v;
bool is_neg = false; bool is_neg = false;
Flag* result = Flag::find_flag(name, strlen(name)); JVMFlag* result = JVMFlag::find_flag(name, strlen(name));
if (result == NULL) { if (result == NULL) {
return false; return false;
@ -882,43 +882,43 @@ static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin)
if (is_neg) { if (is_neg) {
int_v = -int_v; 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()) { } else if (result->is_uint()) {
uint uint_v = (uint) v; 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()) { } else if (result->is_intx()) {
intx_v = (intx) v; intx_v = (intx) v;
if (is_neg) { if (is_neg) {
intx_v = -intx_v; 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()) { } else if (result->is_uintx()) {
uintx uintx_v = (uintx) v; 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()) { } else if (result->is_uint64_t()) {
uint64_t uint64_t_v = (uint64_t) v; 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()) { } else if (result->is_size_t()) {
size_t size_t_v = (size_t) v; 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()) { } else if (result->is_double()) {
double double_v = (double) v; double double_v = (double) v;
return CommandLineFlags::doubleAtPut(result, &double_v, origin) == Flag::SUCCESS; return JVMFlag::doubleAtPut(result, &double_v, origin) == JVMFlag::SUCCESS;
} else { } else {
return false; return false;
} }
} }
static bool set_string_flag(const char* name, const char* value, Flag::Flags origin) { static bool set_string_flag(const char* name, const char* value, JVMFlag::Flags origin) {
if (CommandLineFlags::ccstrAtPut(name, &value, origin) != Flag::SUCCESS) return false; if (JVMFlag::ccstrAtPut(name, &value, origin) != JVMFlag::SUCCESS) return false;
// Contract: CommandLineFlags always returns a pointer that needs freeing. // Contract: JVMFlag always returns a pointer that needs freeing.
FREE_C_HEAP_ARRAY(char, value); FREE_C_HEAP_ARRAY(char, value);
return true; 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 = ""; 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 old_len = old_value != NULL ? strlen(old_value) : 0;
size_t new_len = strlen(new_value); size_t new_len = strlen(new_value);
const char* value; const char* value;
@ -935,11 +935,11 @@ static bool append_to_string_flag(const char* name, const char* new_value, Flag:
value = buf; value = buf;
free_this_too = buf; free_this_too = buf;
} }
(void) CommandLineFlags::ccstrAtPut(name, &value, origin); (void) JVMFlag::ccstrAtPut(name, &value, origin);
// CommandLineFlags always returns a pointer that needs freeing. // JVMFlag always returns a pointer that needs freeing.
FREE_C_HEAP_ARRAY(char, value); FREE_C_HEAP_ARRAY(char, value);
if (free_this_too != NULL) { 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); FREE_C_HEAP_ARRAY(char, free_this_too);
} }
return true; return true;
@ -1010,7 +1010,7 @@ AliasedLoggingFlag Arguments::catch_logging_aliases(const char* name, bool on){
return a; 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 // range of acceptable characters spelled out for portability reasons
#define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]" #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
@ -1048,7 +1048,7 @@ bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
char punct; char punct;
if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') { if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
const char* value = strchr(arg, '=') + 1; const char* value = strchr(arg, '=') + 1;
Flag* flag; JVMFlag* flag;
// this scanf pattern matches both strings (handled here) and numbers (handled later)) // this scanf pattern matches both strings (handled here) and numbers (handled later))
AliasedLoggingFlag alf = catch_logging_aliases(name, true); AliasedLoggingFlag alf = catch_logging_aliases(name, true);
@ -1060,7 +1060,7 @@ bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
if (real_name == NULL) { if (real_name == NULL) {
return false; return false;
} }
flag = Flag::find_flag(real_name); flag = JVMFlag::find_flag(real_name);
if (flag != NULL && flag->is_ccstr()) { if (flag != NULL && flag->is_ccstr()) {
if (flag->ccstr_accumulates()) { if (flag->ccstr_accumulates()) {
return append_to_string_flag(real_name, value, origin); return append_to_string_flag(real_name, value, origin);
@ -1221,7 +1221,7 @@ void Arguments::print_jvm_args_on(outputStream* st) {
bool Arguments::process_argument(const char* arg, bool Arguments::process_argument(const char* arg,
jboolean ignore_unrecognized, jboolean ignore_unrecognized,
Flag::Flags origin) { JVMFlag::Flags origin) {
JDK_Version since = JDK_Version(); JDK_Version since = JDK_Version();
if (parse_argument(arg, origin)) { if (parse_argument(arg, origin)) {
@ -1266,10 +1266,10 @@ bool Arguments::process_argument(const char* arg,
// For locked flags, report a custom error message if available. // For locked flags, report a custom error message if available.
// Otherwise, report the standard unrecognized VM option. // 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) { if (found_flag != NULL) {
char locked_message_buf[BUFLEN]; 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 (strlen(locked_message_buf) == 0) {
if (found_flag->is_bool() && !has_plus_minus) { if (found_flag->is_bool() && !has_plus_minus) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
@ -1283,8 +1283,8 @@ bool Arguments::process_argument(const char* arg,
} }
} else { } else {
#ifdef PRODUCT #ifdef PRODUCT
bool mismatched = ((msg_type == Flag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD) || bool mismatched = ((msg_type == JVMFlag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD) ||
(msg_type == Flag::DEVELOPER_FLAG_BUT_PRODUCT_BUILD)); (msg_type == JVMFlag::DEVELOPER_FLAG_BUT_PRODUCT_BUILD));
if (ignore_unrecognized && mismatched) { if (ignore_unrecognized && mismatched) {
return true; return true;
} }
@ -1297,7 +1297,7 @@ bool Arguments::process_argument(const char* arg,
} }
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
"Unrecognized VM option '%s'\n", argname); "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) { if (fuzzy_matched != NULL) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
"Did you mean '%s%s%s'? ", "Did you mean '%s%s%s'? ",
@ -1350,7 +1350,7 @@ bool Arguments::process_settings_file(const char* file_name, bool should_exist,
// this allows a way to include spaces in string-valued options // this allows a way to include spaces in string-valued options
token[pos] = '\0'; token[pos] = '\0';
logOption(token); logOption(token);
result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE); result &= process_argument(token, ignore_unrecognized, JVMFlag::CONFIG_FILE);
build_jvm_flags(token); build_jvm_flags(token);
pos = 0; pos = 0;
in_white_space = true; in_white_space = true;
@ -1368,7 +1368,7 @@ bool Arguments::process_settings_file(const char* file_name, bool should_exist,
} }
if (pos > 0) { if (pos > 0) {
token[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); build_jvm_flags(token);
} }
fclose(stream); fclose(stream);
@ -1991,10 +1991,10 @@ jint Arguments::set_aggressive_heap_flags() {
initHeapSize = limit_by_allocatable_memory(initHeapSize); initHeapSize = limit_by_allocatable_memory(initHeapSize);
if (FLAG_IS_DEFAULT(MaxHeapSize)) { 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; 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; return JNI_EINVAL;
} }
// Currently the minimum size and the initial heap sizes are the same. // Currently the minimum size and the initial heap sizes are the same.
@ -2003,10 +2003,10 @@ jint Arguments::set_aggressive_heap_flags() {
if (FLAG_IS_DEFAULT(NewSize)) { if (FLAG_IS_DEFAULT(NewSize)) {
// Make the young generation 3/8ths of the total heap. // Make the young generation 3/8ths of the total heap.
if (FLAG_SET_CMDLINE(size_t, NewSize, 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; 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; return JNI_EINVAL;
} }
} }
@ -2016,20 +2016,20 @@ jint Arguments::set_aggressive_heap_flags() {
#endif #endif
// Increase some data structure sizes for efficiency // 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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, ResizeTLAB, false) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, ResizeTLAB, false) != JVMFlag::SUCCESS) {
return JNI_EINVAL; 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; return JNI_EINVAL;
} }
// See the OldPLABSize comment below, but replace 'after promotion' // See the OldPLABSize comment below, but replace 'after promotion'
// with 'after copying'. YoungPLABSize is the size of the survivor // with 'after copying'. YoungPLABSize is the size of the survivor
// space per-gc-thread buffers. The default is 4kw. // 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; return JNI_EINVAL;
} }
@ -2046,29 +2046,29 @@ jint Arguments::set_aggressive_heap_flags() {
// locality. A minor effect may be that larger PLABs reduce the // locality. A minor effect may be that larger PLABs reduce the
// number of PLAB allocation events during gc. The value of 8kw // number of PLAB allocation events during gc. The value of 8kw
// was arrived at by experimenting with specjbb. // 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; return JNI_EINVAL;
} }
// Enable parallel GC and adaptive generation sizing // 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; return JNI_EINVAL;
} }
// Encourage steady state memory management // 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; return JNI_EINVAL;
} }
// This appears to improve mutator locality // 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; return JNI_EINVAL;
} }
// Get around early Solaris scheduling bug // Get around early Solaris scheduling bug
// (affinity vs other jobs on system) // (affinity vs other jobs on system)
// but disallow DR and offlining (5008695). // 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; return JNI_EINVAL;
} }
@ -2409,20 +2409,20 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
// Parse args structure generated from JAVA_TOOL_OPTIONS environment // Parse args structure generated from JAVA_TOOL_OPTIONS environment
// variable (if present). // 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) { if (result != JNI_OK) {
return result; return result;
} }
// Parse args structure generated from the command line flags. // 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) { if (result != JNI_OK) {
return result; return result;
} }
// Parse args structure generated from the _JAVA_OPTIONS environment // Parse args structure generated from the _JAVA_OPTIONS environment
// variable (if present) (mimics classic VM) // 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) { if (result != JNI_OK) {
return result; return result;
} }
@ -2566,7 +2566,7 @@ jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* ou
return JNI_OK; 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 // For match_option to return remaining or value part of option string
const char* tail; const char* tail;
@ -2599,7 +2599,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
} else if (!strcmp(tail, ":gc")) { } else if (!strcmp(tail, ":gc")) {
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc)); LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc));
} else if (!strcmp(tail, ":jni")) { } 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; return JNI_EINVAL;
} }
} }
@ -2736,24 +2736,24 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
set_enable_preview(); set_enable_preview();
// -Xnoclassgc // -Xnoclassgc
} else if (match_option(option, "-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; return JNI_EINVAL;
} }
// -Xconcgc // -Xconcgc
} else if (match_option(option, "-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; return JNI_EINVAL;
} }
handle_extra_cms_flags("-Xconcgc uses UseConcMarkSweepGC"); handle_extra_cms_flags("-Xconcgc uses UseConcMarkSweepGC");
// -Xnoconcgc // -Xnoconcgc
} else if (match_option(option, "-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; return JNI_EINVAL;
} }
handle_extra_cms_flags("-Xnoconcgc uses UseConcMarkSweepGC"); handle_extra_cms_flags("-Xnoconcgc uses UseConcMarkSweepGC");
// -Xbatch // -Xbatch
} else if (match_option(option, "-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; return JNI_EINVAL;
} }
// -Xmn for compatibility with other JVM vendors // -Xmn for compatibility with other JVM vendors
@ -2766,10 +2766,10 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
describe_range_error(errcode); describe_range_error(errcode);
return JNI_EINVAL; 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; 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; return JNI_EINVAL;
} }
// -Xms // -Xms
@ -2786,7 +2786,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
set_min_heap_size((size_t)long_initial_heap_size); set_min_heap_size((size_t)long_initial_heap_size);
// Currently the minimum size and the initial heap sizes are the same. // Currently the minimum size and the initial heap sizes are the same.
// Can be overridden with -XX:InitialHeapSize. // 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; return JNI_EINVAL;
} }
// -Xmx // -Xmx
@ -2799,7 +2799,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
describe_range_error(errcode); describe_range_error(errcode);
return JNI_EINVAL; 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; return JNI_EINVAL;
} }
// Xmaxf // Xmaxf
@ -2812,7 +2812,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
option->optionString); option->optionString);
return JNI_EINVAL; return JNI_EINVAL;
} else { } else {
if (FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} }
@ -2826,7 +2826,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
option->optionString); option->optionString);
return JNI_EINVAL; return JNI_EINVAL;
} else { } else {
if (FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} }
@ -2837,7 +2837,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
if (err != JNI_OK) { if (err != JNI_OK) {
return err; return err;
} }
if (FLAG_SET_CMDLINE(intx, ThreadStackSize, value) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(intx, ThreadStackSize, value) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} else if (match_option(option, "-Xmaxjitcodesize", &tail) || } else if (match_option(option, "-Xmaxjitcodesize", &tail) ||
@ -2850,7 +2850,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
"Invalid maximum code cache size: %s.\n", option->optionString); "Invalid maximum code cache size: %s.\n", option->optionString);
return JNI_EINVAL; 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; return JNI_EINVAL;
} }
// -green // -green
@ -2864,7 +2864,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
// -Xrs // -Xrs
} else if (match_option(option, "-Xrs")) { } else if (match_option(option, "-Xrs")) {
// Classic/EVM option, new functionality // 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; return JNI_EINVAL;
} }
// -Xprof // -Xprof
@ -2875,17 +2875,17 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
warning("Ignoring option %s; support was removed in %s", option->optionString, version); warning("Ignoring option %s; support was removed in %s", option->optionString, version);
// -Xconcurrentio // -Xconcurrentio
} else if (match_option(option, "-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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, BackgroundCompilation, false) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
SafepointSynchronize::set_defer_thr_suspend_loop_count(); 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; 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; return JNI_EINVAL;
} }
@ -2897,7 +2897,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
#ifndef PRODUCT #ifndef PRODUCT
// -Xprintflags // -Xprintflags
} else if (match_option(option, "-Xprintflags")) { } else if (match_option(option, "-Xprintflags")) {
CommandLineFlags::printFlags(tty, false); JVMFlag::printFlags(tty, false);
vm_exit(0); vm_exit(0);
#endif #endif
// -D // -D
@ -2932,7 +2932,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
// Out of the box management support // Out of the box management support
if (match_option(option, "-Dcom.sun.management", &tail)) { if (match_option(option, "-Dcom.sun.management", &tail)) {
#if INCLUDE_MANAGEMENT #if INCLUDE_MANAGEMENT
if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, ManagementServer, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
// management agent in module jdk.management.agent // management agent in module jdk.management.agent
@ -2957,55 +2957,55 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
set_mode_flags(_comp); set_mode_flags(_comp);
// -Xshare:dump // -Xshare:dump
} else if (match_option(option, "-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; return JNI_EINVAL;
} }
set_mode_flags(_int); // Prevent compilation, which creates objects set_mode_flags(_int); // Prevent compilation, which creates objects
// -Xshare:on // -Xshare:on
} else if (match_option(option, "-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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
// -Xshare:auto // -Xshare:auto
} else if (match_option(option, "-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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
// -Xshare:off // -Xshare:off
} else if (match_option(option, "-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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
// -Xverify // -Xverify
} else if (match_option(option, "-Xverify", &tail)) { } else if (match_option(option, "-Xverify", &tail)) {
if (strcmp(tail, ":all") == 0 || strcmp(tail, "") == 0) { 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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} else if (strcmp(tail, ":remote") == 0) { } 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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} else if (strcmp(tail, ":none") == 0) { } 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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) { } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) {
@ -3064,23 +3064,23 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
// Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure; // Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure;
// and the last option wins. // and the last option wins.
} else if (match_option(option, "-XX:+NeverTenure")) { } 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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != JVMFlag::SUCCESS) {
return JNI_EINVAL; 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; return JNI_EINVAL;
} }
} else if (match_option(option, "-XX:+AlwaysTenure")) { } 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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} else if (match_option(option, "-XX:MaxTenuringThreshold=", &tail)) { } else if (match_option(option, "-XX:MaxTenuringThreshold=", &tail)) {
@ -3091,51 +3091,51 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
return JNI_EINVAL; 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; return JNI_EINVAL;
} }
if (MaxTenuringThreshold == 0) { if (MaxTenuringThreshold == 0) {
if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} else { } else {
if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} }
} else if (match_option(option, "-XX:+DisplayVMOutputToStderr")) { } 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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} else if (match_option(option, "-XX:+DisplayVMOutputToStdout")) { } 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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} else if (match_option(option, "-XX:+ExtendedDTraceProbes")) { } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) {
#if defined(DTRACE_ENABLED) #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; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
#else // defined(DTRACE_ENABLED) #else // defined(DTRACE_ENABLED)
@ -3145,11 +3145,11 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
#endif // defined(DTRACE_ENABLED) #endif // defined(DTRACE_ENABLED)
#ifdef ASSERT #ifdef ASSERT
} else if (match_option(option, "-XX:+FullGCALot")) { } 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; return JNI_EINVAL;
} }
// disable scavenge before parallel mark-compact // 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; return JNI_EINVAL;
} }
#endif #endif
@ -3178,10 +3178,10 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
// -Xshare:on // -Xshare:on
// -Xlog:class+path=info // -Xlog:class+path=info
if (PrintSharedArchiveAndExit) { if (PrintSharedArchiveAndExit) {
if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) { if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != JVMFlag::SUCCESS) {
return JNI_EINVAL; return JNI_EINVAL;
} }
LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path)); LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path));
@ -3856,7 +3856,7 @@ jint Arguments::match_special_option_and_act(const JavaVMInitArgs* args,
continue; continue;
} }
if (match_option(option, "-XX:+PrintFlagsInitial")) { if (match_option(option, "-XX:+PrintFlagsInitial")) {
CommandLineFlags::printFlags(tty, false); JVMFlag::printFlags(tty, false);
vm_exit(0); vm_exit(0);
} }
if (match_option(option, "-XX:NativeMemoryTracking", &tail)) { if (match_option(option, "-XX:NativeMemoryTracking", &tail)) {
@ -3885,13 +3885,13 @@ jint Arguments::match_special_option_and_act(const JavaVMInitArgs* args,
#ifndef PRODUCT #ifndef PRODUCT
if (match_option(option, "-XX:+PrintFlagsWithComments")) { if (match_option(option, "-XX:+PrintFlagsWithComments")) {
CommandLineFlags::printFlags(tty, true); JVMFlag::printFlags(tty, true);
vm_exit(0); vm_exit(0);
} }
#endif #endif
if (match_option(option, "-XX:+UseAppCDS")) { 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()) { if (flag->is_diagnostic()) {
flag->clear_diagnostic(); flag->clear_diagnostic();
} }
@ -3947,9 +3947,9 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
assert(verify_special_jvm_flags(), "deprecated and obsolete flag table inconsistent"); assert(verify_special_jvm_flags(), "deprecated and obsolete flag table inconsistent");
// Initialize ranges, constraints and writeables // Initialize ranges, constraints and writeables
CommandLineFlagRangeList::init(); JVMFlagRangeList::init();
CommandLineFlagConstraintList::init(); JVMFlagConstraintList::init();
CommandLineFlagWriteableList::init(); JVMFlagWriteableList::init();
// If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed.
const char* hotspotrc = ".hotspotrc"; const char* hotspotrc = ".hotspotrc";
@ -4250,7 +4250,7 @@ jint Arguments::apply_ergo() {
#endif // PRODUCT #endif // PRODUCT
if (PrintCommandLineFlags) { if (PrintCommandLineFlags) {
CommandLineFlags::printSetFlags(tty); JVMFlag::printSetFlags(tty);
} }
// Apply CPU specific policy for the BiasedLocking // Apply CPU specific policy for the BiasedLocking

View File

@ -28,6 +28,7 @@
#include "logging/logLevel.hpp" #include "logging/logLevel.hpp"
#include "logging/logTag.hpp" #include "logging/logTag.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"
#include "runtime/perfData.hpp" #include "runtime/perfData.hpp"
@ -413,8 +414,8 @@ class Arguments : AllStatic {
// Argument parsing // Argument parsing
static void do_pd_flag_adjustments(); static void do_pd_flag_adjustments();
static bool parse_argument(const char* arg, Flag::Flags origin); static bool parse_argument(const char* arg, JVMFlag::Flags origin);
static bool process_argument(const char* arg, jboolean ignore_unrecognized, Flag::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_launcher_argument(const char*, void*);
static void process_java_compiler_argument(const char* arg); static void process_java_compiler_argument(const char* arg);
static jint parse_options_environment_variable(const char* name, ScopedVMInitArgs* vm_args); static jint parse_options_environment_variable(const char* name, ScopedVMInitArgs* vm_args);
@ -442,7 +443,7 @@ class Arguments : AllStatic {
static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
const JavaVMInitArgs *java_options_args, const JavaVMInitArgs *java_options_args,
const JavaVMInitArgs *cmd_line_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 jint finalize_vm_init_args(bool patch_mod_javabase);
static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type); static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);

View File

@ -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 */

View File

@ -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 */

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -25,11 +25,12 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "classfile/stringTable.hpp" #include "classfile/stringTable.hpp"
#include "classfile/symbolTable.hpp" #include "classfile/symbolTable.hpp"
#include "gc/shared/commandLineFlagConstraintsGC.hpp" #include "gc/shared/jvmFlagConstraintsGC.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/commandLineFlagConstraintList.hpp" #include "runtime/flags/jvmFlag.hpp"
#include "runtime/commandLineFlagConstraintsCompiler.hpp" #include "runtime/flags/jvmFlagConstraintList.hpp"
#include "runtime/commandLineFlagConstraintsRuntime.hpp" #include "runtime/flags/jvmFlagConstraintsCompiler.hpp"
#include "runtime/flags/jvmFlagConstraintsRuntime.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
#ifdef COMPILER1 #ifdef COMPILER1
@ -39,162 +40,161 @@
#include "opto/c2_globals.hpp" #include "opto/c2_globals.hpp"
#endif #endif
class JVMFlagConstraint_bool : public JVMFlagConstraint {
class CommandLineFlagConstraint_bool : public CommandLineFlagConstraint { JVMFlagConstraintFunc_bool _constraint;
CommandLineFlagConstraintFunc_bool _constraint;
const bool* _ptr; const bool* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagConstraint_bool(const char* name, const bool* ptr, JVMFlagConstraint_bool(const char* name, const bool* ptr,
CommandLineFlagConstraintFunc_bool func, JVMFlagConstraintFunc_bool func,
ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
Flag::Error apply(bool verbose) { JVMFlag::Error apply(bool verbose) {
bool value = *_ptr; bool value = *_ptr;
return _constraint(value, verbose); return _constraint(value, verbose);
} }
Flag::Error apply_bool(bool value, bool verbose) { JVMFlag::Error apply_bool(bool value, bool verbose) {
return _constraint(value, verbose); return _constraint(value, verbose);
} }
}; };
class CommandLineFlagConstraint_int : public CommandLineFlagConstraint { class JVMFlagConstraint_int : public JVMFlagConstraint {
CommandLineFlagConstraintFunc_int _constraint; JVMFlagConstraintFunc_int _constraint;
const int* _ptr; const int* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagConstraint_int(const char* name, const int* ptr, JVMFlagConstraint_int(const char* name, const int* ptr,
CommandLineFlagConstraintFunc_int func, JVMFlagConstraintFunc_int func,
ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
Flag::Error apply(bool verbose) { JVMFlag::Error apply(bool verbose) {
int value = *_ptr; int value = *_ptr;
return _constraint(value, verbose); return _constraint(value, verbose);
} }
Flag::Error apply_int(int value, bool verbose) { JVMFlag::Error apply_int(int value, bool verbose) {
return _constraint(value, verbose); return _constraint(value, verbose);
} }
}; };
class CommandLineFlagConstraint_intx : public CommandLineFlagConstraint { class JVMFlagConstraint_intx : public JVMFlagConstraint {
CommandLineFlagConstraintFunc_intx _constraint; JVMFlagConstraintFunc_intx _constraint;
const intx* _ptr; const intx* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagConstraint_intx(const char* name, const intx* ptr, JVMFlagConstraint_intx(const char* name, const intx* ptr,
CommandLineFlagConstraintFunc_intx func, JVMFlagConstraintFunc_intx func,
ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
Flag::Error apply(bool verbose) { JVMFlag::Error apply(bool verbose) {
intx value = *_ptr; intx value = *_ptr;
return _constraint(value, verbose); return _constraint(value, verbose);
} }
Flag::Error apply_intx(intx value, bool verbose) { JVMFlag::Error apply_intx(intx value, bool verbose) {
return _constraint(value, verbose); return _constraint(value, verbose);
} }
}; };
class CommandLineFlagConstraint_uint : public CommandLineFlagConstraint { class JVMFlagConstraint_uint : public JVMFlagConstraint {
CommandLineFlagConstraintFunc_uint _constraint; JVMFlagConstraintFunc_uint _constraint;
const uint* _ptr; const uint* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagConstraint_uint(const char* name, const uint* ptr, JVMFlagConstraint_uint(const char* name, const uint* ptr,
CommandLineFlagConstraintFunc_uint func, JVMFlagConstraintFunc_uint func,
ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
Flag::Error apply(bool verbose) { JVMFlag::Error apply(bool verbose) {
uint value = *_ptr; uint value = *_ptr;
return _constraint(value, verbose); return _constraint(value, verbose);
} }
Flag::Error apply_uint(uint value, bool verbose) { JVMFlag::Error apply_uint(uint value, bool verbose) {
return _constraint(value, verbose); return _constraint(value, verbose);
} }
}; };
class CommandLineFlagConstraint_uintx : public CommandLineFlagConstraint { class JVMFlagConstraint_uintx : public JVMFlagConstraint {
CommandLineFlagConstraintFunc_uintx _constraint; JVMFlagConstraintFunc_uintx _constraint;
const uintx* _ptr; const uintx* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagConstraint_uintx(const char* name, const uintx* ptr, JVMFlagConstraint_uintx(const char* name, const uintx* ptr,
CommandLineFlagConstraintFunc_uintx func, JVMFlagConstraintFunc_uintx func,
ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
Flag::Error apply(bool verbose) { JVMFlag::Error apply(bool verbose) {
uintx value = *_ptr; uintx value = *_ptr;
return _constraint(value, verbose); return _constraint(value, verbose);
} }
Flag::Error apply_uintx(uintx value, bool verbose) { JVMFlag::Error apply_uintx(uintx value, bool verbose) {
return _constraint(value, verbose); return _constraint(value, verbose);
} }
}; };
class CommandLineFlagConstraint_uint64_t : public CommandLineFlagConstraint { class JVMFlagConstraint_uint64_t : public JVMFlagConstraint {
CommandLineFlagConstraintFunc_uint64_t _constraint; JVMFlagConstraintFunc_uint64_t _constraint;
const uint64_t* _ptr; const uint64_t* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagConstraint_uint64_t(const char* name, const uint64_t* ptr, JVMFlagConstraint_uint64_t(const char* name, const uint64_t* ptr,
CommandLineFlagConstraintFunc_uint64_t func, JVMFlagConstraintFunc_uint64_t func,
ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
Flag::Error apply(bool verbose) { JVMFlag::Error apply(bool verbose) {
uint64_t value = *_ptr; uint64_t value = *_ptr;
return _constraint(value, verbose); return _constraint(value, verbose);
} }
Flag::Error apply_uint64_t(uint64_t value, bool verbose) { JVMFlag::Error apply_uint64_t(uint64_t value, bool verbose) {
return _constraint(value, verbose); return _constraint(value, verbose);
} }
}; };
class CommandLineFlagConstraint_size_t : public CommandLineFlagConstraint { class JVMFlagConstraint_size_t : public JVMFlagConstraint {
CommandLineFlagConstraintFunc_size_t _constraint; JVMFlagConstraintFunc_size_t _constraint;
const size_t* _ptr; const size_t* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagConstraint_size_t(const char* name, const size_t* ptr, JVMFlagConstraint_size_t(const char* name, const size_t* ptr,
CommandLineFlagConstraintFunc_size_t func, JVMFlagConstraintFunc_size_t func,
ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
Flag::Error apply(bool verbose) { JVMFlag::Error apply(bool verbose) {
size_t value = *_ptr; size_t value = *_ptr;
return _constraint(value, verbose); return _constraint(value, verbose);
} }
Flag::Error apply_size_t(size_t value, bool verbose) { JVMFlag::Error apply_size_t(size_t value, bool verbose) {
return _constraint(value, verbose); return _constraint(value, verbose);
} }
}; };
class CommandLineFlagConstraint_double : public CommandLineFlagConstraint { class JVMFlagConstraint_double : public JVMFlagConstraint {
CommandLineFlagConstraintFunc_double _constraint; JVMFlagConstraintFunc_double _constraint;
const double* _ptr; const double* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagConstraint_double(const char* name, const double* ptr, JVMFlagConstraint_double(const char* name, const double* ptr,
CommandLineFlagConstraintFunc_double func, JVMFlagConstraintFunc_double func,
ConstraintType type) : CommandLineFlagConstraint(name, type), _constraint(func), _ptr(ptr) {} ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
Flag::Error apply(bool verbose) { JVMFlag::Error apply(bool verbose) {
double value = *_ptr; double value = *_ptr;
return _constraint(value, verbose); return _constraint(value, verbose);
} }
Flag::Error apply_double(double value, bool verbose) { JVMFlag::Error apply_double(double value, bool verbose) {
return _constraint(value, verbose); return _constraint(value, verbose);
} }
}; };
@ -214,30 +214,30 @@ void emit_constraint_uint64_t(const char* /*name*/, const uint64_t* /*value*/)
void emit_constraint_size_t(const char* /*name*/, const size_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 */ } void emit_constraint_double(const char* /*name*/, const double* /*value*/) { /* NOP */ }
// CommandLineFlagConstraint emitting code functions if function argument is provided // JVMFlagConstraint emitting code functions if function argument is provided
void emit_constraint_bool(const char* name, const bool* ptr, CommandLineFlagConstraintFunc_bool func, CommandLineFlagConstraint::ConstraintType type) { void emit_constraint_bool(const char* name, const bool* ptr, JVMFlagConstraintFunc_bool func, JVMFlagConstraint::ConstraintType type) {
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_bool(name, ptr, func, type)); JVMFlagConstraintList::add(new JVMFlagConstraint_bool(name, ptr, func, type));
} }
void emit_constraint_int(const char* name, const int* ptr, CommandLineFlagConstraintFunc_int func, CommandLineFlagConstraint::ConstraintType type) { void emit_constraint_int(const char* name, const int* ptr, JVMFlagConstraintFunc_int func, JVMFlagConstraint::ConstraintType type) {
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_int(name, ptr, func, type)); JVMFlagConstraintList::add(new JVMFlagConstraint_int(name, ptr, func, type));
} }
void emit_constraint_intx(const char* name, const intx* ptr, CommandLineFlagConstraintFunc_intx func, CommandLineFlagConstraint::ConstraintType type) { void emit_constraint_intx(const char* name, const intx* ptr, JVMFlagConstraintFunc_intx func, JVMFlagConstraint::ConstraintType type) {
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_intx(name, ptr, func, type)); JVMFlagConstraintList::add(new JVMFlagConstraint_intx(name, ptr, func, type));
} }
void emit_constraint_uint(const char* name, const uint* ptr, CommandLineFlagConstraintFunc_uint func, CommandLineFlagConstraint::ConstraintType type) { void emit_constraint_uint(const char* name, const uint* ptr, JVMFlagConstraintFunc_uint func, JVMFlagConstraint::ConstraintType type) {
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uint(name, ptr, func, type)); JVMFlagConstraintList::add(new JVMFlagConstraint_uint(name, ptr, func, type));
} }
void emit_constraint_uintx(const char* name, const uintx* ptr, CommandLineFlagConstraintFunc_uintx func, CommandLineFlagConstraint::ConstraintType type) { void emit_constraint_uintx(const char* name, const uintx* ptr, JVMFlagConstraintFunc_uintx func, JVMFlagConstraint::ConstraintType type) {
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uintx(name, ptr, func, type)); JVMFlagConstraintList::add(new JVMFlagConstraint_uintx(name, ptr, func, type));
} }
void emit_constraint_uint64_t(const char* name, const uint64_t* ptr, CommandLineFlagConstraintFunc_uint64_t func, CommandLineFlagConstraint::ConstraintType type) { void emit_constraint_uint64_t(const char* name, const uint64_t* ptr, JVMFlagConstraintFunc_uint64_t func, JVMFlagConstraint::ConstraintType type) {
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uint64_t(name, ptr, func, type)); JVMFlagConstraintList::add(new JVMFlagConstraint_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) { void emit_constraint_size_t(const char* name, const size_t* ptr, JVMFlagConstraintFunc_size_t func, JVMFlagConstraint::ConstraintType type) {
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_size_t(name, ptr, func, type)); JVMFlagConstraintList::add(new JVMFlagConstraint_size_t(name, ptr, func, type));
} }
void emit_constraint_double(const char* name, const double* ptr, CommandLineFlagConstraintFunc_double func, CommandLineFlagConstraint::ConstraintType type) { void emit_constraint_double(const char* name, const double* ptr, JVMFlagConstraintFunc_double func, JVMFlagConstraint::ConstraintType type) {
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_double(name, ptr, func, type)); JVMFlagConstraintList::add(new JVMFlagConstraint_double(name, ptr, func, type));
} }
// Generate code to call emit_constraint_xxx function // Generate code to call emit_constraint_xxx function
@ -265,16 +265,16 @@ void emit_constraint_double(const char* name, const double* ptr, CommandLineFlag
#endif #endif
// Generate func argument to pass into emit_constraint_xxx functions // Generate func argument to pass into emit_constraint_xxx functions
#define EMIT_CONSTRAINT_CHECK(func, type) , func, CommandLineFlagConstraint::type #define EMIT_CONSTRAINT_CHECK(func, type) , func, JVMFlagConstraint::type
// the "name" argument must be a string literal // the "name" argument must be a string literal
#define INITIAL_CONSTRAINTS_SIZE 72 #define INITIAL_CONSTRAINTS_SIZE 72
GrowableArray<CommandLineFlagConstraint*>* CommandLineFlagConstraintList::_constraints = NULL; GrowableArray<JVMFlagConstraint*>* JVMFlagConstraintList::_constraints = NULL;
CommandLineFlagConstraint::ConstraintType CommandLineFlagConstraintList::_validating_type = CommandLineFlagConstraint::AtParse; JVMFlagConstraint::ConstraintType JVMFlagConstraintList::_validating_type = JVMFlagConstraint::AtParse;
// Check the ranges of all flags that have them or print them out and exit if requested // Check the ranges of all flags that have them or print them out and exit if requested
void CommandLineFlagConstraintList::init(void) { void JVMFlagConstraintList::init(void) {
_constraints = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<CommandLineFlagConstraint*>(INITIAL_CONSTRAINTS_SIZE, true); _constraints = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<JVMFlagConstraint*>(INITIAL_CONSTRAINTS_SIZE, true);
emit_constraint_no(NULL VM_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG, emit_constraint_no(NULL VM_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
EMIT_CONSTRAINT_PD_DEVELOPER_FLAG, EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
@ -331,10 +331,10 @@ void CommandLineFlagConstraintList::init(void) {
#endif // COMPILER2 #endif // COMPILER2
} }
CommandLineFlagConstraint* CommandLineFlagConstraintList::find(const char* name) { JVMFlagConstraint* JVMFlagConstraintList::find(const char* name) {
CommandLineFlagConstraint* found = NULL; JVMFlagConstraint* found = NULL;
for (int i=0; i<length(); i++) { for (int i=0; i<length(); i++) {
CommandLineFlagConstraint* constraint = at(i); JVMFlagConstraint* constraint = at(i);
if (strcmp(constraint->name(), name) == 0) { if (strcmp(constraint->name(), name) == 0) {
found = constraint; found = constraint;
break; break;
@ -344,9 +344,9 @@ CommandLineFlagConstraint* CommandLineFlagConstraintList::find(const char* name)
} }
// Find constraints by name and return only if found constraint's type is equal or lower than current validating type. // 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) { JVMFlagConstraint* JVMFlagConstraintList::find_if_needs_check(const char* name) {
CommandLineFlagConstraint* found = NULL; JVMFlagConstraint* found = NULL;
CommandLineFlagConstraint* constraint = find(name); JVMFlagConstraint* constraint = find(name);
if (constraint && (constraint->type() <= _validating_type)) { if (constraint && (constraint->type() <= _validating_type)) {
found = constraint; found = constraint;
} }
@ -354,15 +354,15 @@ CommandLineFlagConstraint* CommandLineFlagConstraintList::find_if_needs_check(co
} }
// Check constraints for specific constraint type. // Check constraints for specific constraint type.
bool CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::ConstraintType type) { bool JVMFlagConstraintList::check_constraints(JVMFlagConstraint::ConstraintType type) {
guarantee(type > _validating_type, "Constraint check is out of order."); guarantee(type > _validating_type, "Constraint check is out of order.");
_validating_type = type; _validating_type = type;
bool status = true; bool status = true;
for (int i=0; i<length(); i++) { for (int i=0; i<length(); i++) {
CommandLineFlagConstraint* constraint = at(i); JVMFlagConstraint* constraint = at(i);
if (type != constraint->type()) continue; if (type != constraint->type()) continue;
if (constraint->apply(true) != Flag::SUCCESS) status = false; if (constraint->apply(true) != JVMFlag::SUCCESS) status = false;
} }
return status; return status;
} }

View File

@ -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 */

View File

@ -29,21 +29,22 @@
#include "runtime/os.hpp" #include "runtime/os.hpp"
#include "interpreter/invocationCounter.hpp" #include "interpreter/invocationCounter.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/commandLineFlagConstraintsCompiler.hpp" #include "runtime/flags/jvmFlag.hpp"
#include "runtime/commandLineFlagRangeList.hpp" #include "runtime/flags/jvmFlagConstraintsCompiler.hpp"
#include "runtime/flags/jvmFlagRangeList.hpp"
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "runtime/globals_extension.hpp" #include "runtime/globals_extension.hpp"
#include "utilities/defaultStream.hpp" #include "utilities/defaultStream.hpp"
Flag::Error AliasLevelConstraintFunc(intx value, bool verbose) { JVMFlag::Error AliasLevelConstraintFunc(intx value, bool verbose) {
if ((value <= 1) && (Arguments::mode() == Arguments::_comp || Arguments::mode() == Arguments::_mixed)) { if ((value <= 1) && (Arguments::mode() == Arguments::_comp || Arguments::mode() == Arguments::_mixed)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"AliasLevel (" INTX_FORMAT ") is not " "AliasLevel (" INTX_FORMAT ") is not "
"compatible with -Xcomp or -Xmixed\n", "compatible with -Xcomp or -Xmixed\n",
value); value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
@ -62,7 +63,7 @@ Flag::Error AliasLevelConstraintFunc(intx value, bool verbose) {
* 'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result, * 'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result,
* the minimum number of compiler threads is 2. * the minimum number of compiler threads is 2.
*/ */
Flag::Error CICompilerCountConstraintFunc(intx value, bool verbose) { JVMFlag::Error CICompilerCountConstraintFunc(intx value, bool verbose) {
int min_number_of_compiler_threads = 0; int min_number_of_compiler_threads = 0;
#if !defined(COMPILER1) && !defined(COMPILER2) && !INCLUDE_JVMCI #if !defined(COMPILER1) && !defined(COMPILER2) && !INCLUDE_JVMCI
// case 1 // case 1
@ -85,37 +86,37 @@ Flag::Error CICompilerCountConstraintFunc(intx value, bool verbose) {
"CICompilerCount (" INTX_FORMAT ") must be " "CICompilerCount (" INTX_FORMAT ") must be "
"at least %d \n", "at least %d \n",
value, min_number_of_compiler_threads); value, min_number_of_compiler_threads);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) { JVMFlag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) {
if (value < 0 || value > 512) { if (value < 0 || value > 512) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"AllocatePrefetchDistance (" INTX_FORMAT ") must be " "AllocatePrefetchDistance (" INTX_FORMAT ") must be "
"between 0 and " INTX_FORMAT "\n", "between 0 and " INTX_FORMAT "\n",
AllocatePrefetchDistance, 512); AllocatePrefetchDistance, 512);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) { JVMFlag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) {
if (AllocatePrefetchStyle == 3) { if (AllocatePrefetchStyle == 3) {
if (value % wordSize != 0) { if (value % wordSize != 0) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"AllocatePrefetchStepSize (" INTX_FORMAT ") must be multiple of %d\n", "AllocatePrefetchStepSize (" INTX_FORMAT ") must be multiple of %d\n",
value, wordSize); value, wordSize);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { JVMFlag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) {
intx max_value = max_intx; intx max_value = max_intx;
#if defined(SPARC) #if defined(SPARC)
max_value = 1; max_value = 1;
@ -126,26 +127,26 @@ Flag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"AllocatePrefetchInstr (" INTX_FORMAT ") must be " "AllocatePrefetchInstr (" INTX_FORMAT ") must be "
"between 0 and " INTX_FORMAT "\n", value, max_value); "between 0 and " INTX_FORMAT "\n", value, max_value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error CompileThresholdConstraintFunc(intx value, bool verbose) { JVMFlag::Error CompileThresholdConstraintFunc(intx value, bool verbose) {
if (value < 0 || value > INT_MAX >> InvocationCounter::count_shift) { if (value < 0 || value > INT_MAX >> InvocationCounter::count_shift) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"CompileThreshold (" INTX_FORMAT ") " "CompileThreshold (" INTX_FORMAT ") "
"must be between 0 and %d\n", "must be between 0 and %d\n",
value, value,
INT_MAX >> InvocationCounter::count_shift); INT_MAX >> InvocationCounter::count_shift);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) { JVMFlag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) {
int backward_branch_limit; int backward_branch_limit;
if (ProfileInterpreter) { if (ProfileInterpreter) {
if (OnStackReplacePercentage < InterpreterProfilePercentage) { if (OnStackReplacePercentage < InterpreterProfilePercentage) {
@ -153,7 +154,7 @@ Flag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) {
"OnStackReplacePercentage (" INTX_FORMAT ") must be " "OnStackReplacePercentage (" INTX_FORMAT ") must be "
"larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n", "larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n",
OnStackReplacePercentage, InterpreterProfilePercentage); OnStackReplacePercentage, InterpreterProfilePercentage);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
backward_branch_limit = ((CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100) backward_branch_limit = ((CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100)
@ -167,14 +168,14 @@ Flag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) {
"CompileThreshold, InterpreterProfilePercentage, and/or OnStackReplacePercentage\n", "CompileThreshold, InterpreterProfilePercentage, and/or OnStackReplacePercentage\n",
(CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100, (CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100,
INT_MAX >> InvocationCounter::count_shift); INT_MAX >> InvocationCounter::count_shift);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} else { } else {
if (OnStackReplacePercentage < 0 ) { if (OnStackReplacePercentage < 0 ) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"OnStackReplacePercentage (" INTX_FORMAT ") must be " "OnStackReplacePercentage (" INTX_FORMAT ") must be "
"non-negative\n", OnStackReplacePercentage); "non-negative\n", OnStackReplacePercentage);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
backward_branch_limit = ((CompileThreshold * OnStackReplacePercentage) / 100) backward_branch_limit = ((CompileThreshold * OnStackReplacePercentage) / 100)
@ -187,20 +188,20 @@ Flag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) {
"CompileThreshold and/or OnStackReplacePercentage\n", "CompileThreshold and/or OnStackReplacePercentage\n",
(CompileThreshold * OnStackReplacePercentage) / 100, (CompileThreshold * OnStackReplacePercentage) / 100,
INT_MAX >> InvocationCounter::count_shift); INT_MAX >> InvocationCounter::count_shift);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose) { JVMFlag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose) {
if (CodeCacheSegmentSize < (uintx)CodeEntryAlignment) { if (CodeCacheSegmentSize < (uintx)CodeEntryAlignment) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"CodeCacheSegmentSize (" UINTX_FORMAT ") must be " "CodeCacheSegmentSize (" UINTX_FORMAT ") must be "
"larger than or equal to CodeEntryAlignment (" INTX_FORMAT ") " "larger than or equal to CodeEntryAlignment (" INTX_FORMAT ") "
"to align entry points\n", "to align entry points\n",
CodeCacheSegmentSize, CodeEntryAlignment); CodeCacheSegmentSize, CodeEntryAlignment);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
if (CodeCacheSegmentSize < sizeof(jdouble)) { if (CodeCacheSegmentSize < sizeof(jdouble)) {
@ -208,7 +209,7 @@ Flag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose) {
"CodeCacheSegmentSize (" UINTX_FORMAT ") must be " "CodeCacheSegmentSize (" UINTX_FORMAT ") must be "
"at least " SIZE_FORMAT " to align constants\n", "at least " SIZE_FORMAT " to align constants\n",
CodeCacheSegmentSize, sizeof(jdouble)); CodeCacheSegmentSize, sizeof(jdouble));
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
#ifdef COMPILER2 #ifdef COMPILER2
@ -218,14 +219,14 @@ Flag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose) {
"larger than or equal to OptoLoopAlignment (" INTX_FORMAT ") " "larger than or equal to OptoLoopAlignment (" INTX_FORMAT ") "
"to align inner loops\n", "to align inner loops\n",
CodeCacheSegmentSize, OptoLoopAlignment); CodeCacheSegmentSize, OptoLoopAlignment);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
#endif #endif
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose) { JVMFlag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose) {
#ifdef SOLARIS #ifdef SOLARIS
if ((value < MinimumPriority || value > MaximumPriority) && if ((value < MinimumPriority || value > MaximumPriority) &&
(value != -1) && (value != -FXCriticalPriority)) { (value != -1) && (value != -FXCriticalPriority)) {
@ -234,20 +235,20 @@ Flag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose) {
"between %d and %d inclusively or -1 (means no change) " "between %d and %d inclusively or -1 (means no change) "
"or %d (special value for critical thread class/priority)\n", "or %d (special value for critical thread class/priority)\n",
value, MinimumPriority, MaximumPriority, -FXCriticalPriority); value, MinimumPriority, MaximumPriority, -FXCriticalPriority);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
#endif #endif
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) { JVMFlag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) {
#ifdef SPARC #ifdef SPARC
if (CodeEntryAlignment % relocInfo::addr_unit() != 0) { if (CodeEntryAlignment % relocInfo::addr_unit() != 0) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"CodeEntryAlignment (" INTX_FORMAT ") must be " "CodeEntryAlignment (" INTX_FORMAT ") must be "
"multiple of NOP size\n", CodeEntryAlignment); "multiple of NOP size\n", CodeEntryAlignment);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
#endif #endif
@ -255,7 +256,7 @@ Flag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"CodeEntryAlignment (" INTX_FORMAT ") must be " "CodeEntryAlignment (" INTX_FORMAT ") must be "
"a power of two\n", CodeEntryAlignment); "a power of two\n", CodeEntryAlignment);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
if (CodeEntryAlignment < 16) { if (CodeEntryAlignment < 16) {
@ -263,19 +264,19 @@ Flag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) {
"CodeEntryAlignment (" INTX_FORMAT ") must be " "CodeEntryAlignment (" INTX_FORMAT ") must be "
"greater than or equal to %d\n", "greater than or equal to %d\n",
CodeEntryAlignment, 16); CodeEntryAlignment, 16);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose) { JVMFlag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose) {
if (!is_power_of_2(value)) { if (!is_power_of_2(value)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"OptoLoopAlignment (" INTX_FORMAT ") " "OptoLoopAlignment (" INTX_FORMAT ") "
"must be a power of two\n", "must be a power of two\n",
value); value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
// Relevant on ppc, s390, sparc. Will be optimized where // Relevant on ppc, s390, sparc. Will be optimized where
@ -285,64 +286,64 @@ Flag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose) {
"OptoLoopAlignment (" INTX_FORMAT ") must be " "OptoLoopAlignment (" INTX_FORMAT ") must be "
"multiple of NOP size (%d)\n", "multiple of NOP size (%d)\n",
value, relocInfo::addr_unit()); value, relocInfo::addr_unit());
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verbose) { JVMFlag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verbose) {
if (value >= 4032) { if (value >= 4032) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"ArraycopyDstPrefetchDistance (" UINTX_FORMAT ") must be" "ArraycopyDstPrefetchDistance (" UINTX_FORMAT ") must be"
"between 0 and 4031\n", value); "between 0 and 4031\n", value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose) { JVMFlag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose) {
if (value >= 4032) { if (value >= 4032) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"ArraycopySrcPrefetchDistance (" UINTX_FORMAT ") must be" "ArraycopySrcPrefetchDistance (" UINTX_FORMAT ") must be"
"between 0 and 4031\n", value); "between 0 and 4031\n", value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose) { JVMFlag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (value % 10 > 2) { if (value % 10 > 2) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"Invalid value (" UINTX_FORMAT ") " "Invalid value (" UINTX_FORMAT ") "
"in TypeProfileLevel at position %d\n", value, i); "in TypeProfileLevel at position %d\n", value, i);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
value = value / 10; value = value / 10;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose) { JVMFlag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose) {
if (value % BytesPerLong != 0) { if (value % BytesPerLong != 0) {
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
#ifdef COMPILER2 #ifdef COMPILER2
Flag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) { JVMFlag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) {
if (InteriorEntryAlignment > CodeEntryAlignment) { if (InteriorEntryAlignment > CodeEntryAlignment) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"InteriorEntryAlignment (" INTX_FORMAT ") must be " "InteriorEntryAlignment (" INTX_FORMAT ") must be "
"less than or equal to CodeEntryAlignment (" INTX_FORMAT ")\n", "less than or equal to CodeEntryAlignment (" INTX_FORMAT ")\n",
InteriorEntryAlignment, CodeEntryAlignment); InteriorEntryAlignment, CodeEntryAlignment);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
#ifdef SPARC #ifdef SPARC
@ -350,7 +351,7 @@ Flag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"InteriorEntryAlignment (" INTX_FORMAT ") must be " "InteriorEntryAlignment (" INTX_FORMAT ") must be "
"multiple of NOP size\n"); "multiple of NOP size\n");
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
#endif #endif
@ -358,7 +359,7 @@ Flag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"InteriorEntryAlignment (" INTX_FORMAT ") must be " "InteriorEntryAlignment (" INTX_FORMAT ") must be "
"a power of two\n", InteriorEntryAlignment); "a power of two\n", InteriorEntryAlignment);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
int minimum_alignment = 16; int minimum_alignment = 16;
@ -373,26 +374,26 @@ Flag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) {
"InteriorEntryAlignment (" INTX_FORMAT ") must be " "InteriorEntryAlignment (" INTX_FORMAT ") must be "
"greater than or equal to %d\n", "greater than or equal to %d\n",
InteriorEntryAlignment, minimum_alignment); InteriorEntryAlignment, minimum_alignment);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
Flag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose) { JVMFlag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose) {
if (value < MaxNodeLimit * 2 / 100 || value > MaxNodeLimit * 40 / 100) { if (value < MaxNodeLimit * 2 / 100 || value > MaxNodeLimit * 40 / 100) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"NodeLimitFudgeFactor must be between 2%% and 40%% " "NodeLimitFudgeFactor must be between 2%% and 40%% "
"of MaxNodeLimit (" INTX_FORMAT ")\n", "of MaxNodeLimit (" INTX_FORMAT ")\n",
MaxNodeLimit); MaxNodeLimit);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
#endif // COMPILER2 #endif // COMPILER2
Flag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) { JVMFlag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) {
#if INCLUDE_RTM_OPT #if INCLUDE_RTM_OPT
if (UseRTMLocking && !is_power_of_2(RTMTotalCountIncrRate)) { if (UseRTMLocking && !is_power_of_2(RTMTotalCountIncrRate)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
@ -403,5 +404,5 @@ Flag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) {
} }
#endif #endif
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }

View File

@ -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 */

View File

@ -24,20 +24,21 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/commandLineFlagConstraintsRuntime.hpp" #include "runtime/flags/jvmFlag.hpp"
#include "runtime/commandLineFlagRangeList.hpp" #include "runtime/flags/jvmFlagConstraintsRuntime.hpp"
#include "runtime/flags/jvmFlagRangeList.hpp"
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "runtime/safepointMechanism.hpp" #include "runtime/safepointMechanism.hpp"
#include "runtime/task.hpp" #include "runtime/task.hpp"
#include "utilities/defaultStream.hpp" #include "utilities/defaultStream.hpp"
Flag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) { JVMFlag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) {
if (!is_power_of_2(value)) { if (!is_power_of_2(value)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"ObjectAlignmentInBytes (" INTX_FORMAT ") must be " "ObjectAlignmentInBytes (" INTX_FORMAT ") must be "
"power of 2\n", "power of 2\n",
value); value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
// In case page size is very small. // In case page size is very small.
if (value >= (intx)os::vm_page_size()) { if (value >= (intx)os::vm_page_size()) {
@ -45,99 +46,99 @@ Flag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) {
"ObjectAlignmentInBytes (" INTX_FORMAT ") must be " "ObjectAlignmentInBytes (" INTX_FORMAT ") must be "
"less than page size (" INTX_FORMAT ")\n", "less than page size (" INTX_FORMAT ")\n",
value, (intx)os::vm_page_size()); value, (intx)os::vm_page_size());
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
// Need to enforce the padding not to break the existing field alignments. // Need to enforce the padding not to break the existing field alignments.
// It is sufficient to check against the largest type size. // It is sufficient to check against the largest type size.
Flag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose) { JVMFlag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose) {
if ((value % BytesPerLong) != 0) { if ((value % BytesPerLong) != 0) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"ContendedPaddingWidth (" INTX_FORMAT ") must be " "ContendedPaddingWidth (" INTX_FORMAT ") must be "
"a multiple of %d\n", "a multiple of %d\n",
value, BytesPerLong); value, BytesPerLong);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose) { JVMFlag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose) {
if (value > BiasedLockingBulkRevokeThreshold) { if (value > BiasedLockingBulkRevokeThreshold) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ") must be " "BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ") must be "
"less than or equal to BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")\n", "less than or equal to BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")\n",
value, BiasedLockingBulkRevokeThreshold); value, BiasedLockingBulkRevokeThreshold);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose) { JVMFlag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose) {
if ((value % PeriodicTask::interval_gran) != 0) { if ((value % PeriodicTask::interval_gran) != 0) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"BiasedLockingStartupDelay (" INTX_FORMAT ") must be " "BiasedLockingStartupDelay (" INTX_FORMAT ") must be "
"evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n", "evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n",
value, PeriodicTask::interval_gran); value, PeriodicTask::interval_gran);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose) { JVMFlag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose) {
if (value < BiasedLockingBulkRebiasThreshold) { if (value < BiasedLockingBulkRebiasThreshold) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ") must be " "BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ") must be "
"greater than or equal to BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")\n", "greater than or equal to BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")\n",
value, BiasedLockingBulkRebiasThreshold); value, BiasedLockingBulkRebiasThreshold);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else if ((double)value/(double)BiasedLockingDecayTime > 0.1) { } else if ((double)value/(double)BiasedLockingDecayTime > 0.1) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"The ratio of BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")" "The ratio of BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")"
" to BiasedLockingDecayTime (" INTX_FORMAT ") must be " " to BiasedLockingDecayTime (" INTX_FORMAT ") must be "
"less than or equal to 0.1\n", "less than or equal to 0.1\n",
value, BiasedLockingBulkRebiasThreshold); value, BiasedLockingBulkRebiasThreshold);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose) { JVMFlag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose) {
if (BiasedLockingBulkRebiasThreshold/(double)value > 0.1) { if (BiasedLockingBulkRebiasThreshold/(double)value > 0.1) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"The ratio of BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")" "The ratio of BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")"
" to BiasedLockingDecayTime (" INTX_FORMAT ") must be " " to BiasedLockingDecayTime (" INTX_FORMAT ") must be "
"less than or equal to 0.1\n", "less than or equal to 0.1\n",
BiasedLockingBulkRebiasThreshold, value); BiasedLockingBulkRebiasThreshold, value);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) { JVMFlag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) {
if ((value % PeriodicTask::interval_gran != 0)) { if ((value % PeriodicTask::interval_gran != 0)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"PerfDataSamplingInterval (" INTX_FORMAT ") must be " "PerfDataSamplingInterval (" INTX_FORMAT ") must be "
"evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n", "evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n",
value, PeriodicTask::interval_gran); value, PeriodicTask::interval_gran);
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
Flag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose) { JVMFlag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose) {
if (value) { if (value) {
if (!SafepointMechanism::supports_thread_local_poll()) { if (!SafepointMechanism::supports_thread_local_poll()) {
CommandLineError::print(verbose, "ThreadLocalHandshakes not yet supported on this platform\n"); CommandLineError::print(verbose, "ThreadLocalHandshakes not yet supported on this platform\n");
return Flag::VIOLATES_CONSTRAINT; return JVMFlag::VIOLATES_CONSTRAINT;
} }
} }
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }

View File

@ -22,11 +22,10 @@
* *
*/ */
#ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSRUNTIME_HPP #ifndef SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTSRUNTIME_HPP
#define SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSRUNTIME_HPP #define SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTSRUNTIME_HPP
#include "runtime/globals.hpp" #include "runtime/flags/jvmFlag.hpp"
#include "utilities/globalDefinitions.hpp"
/* /*
* Here we have runtime arguments constraints functions, which are called automatically * Here we have runtime arguments constraints functions, which are called automatically
@ -34,18 +33,18 @@
* an appropriate error value. * an appropriate error value.
*/ */
Flag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose); JVMFlag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose);
Flag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose); JVMFlag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose);
Flag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose); JVMFlag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose);
Flag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose); JVMFlag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose);
Flag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose); JVMFlag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose);
Flag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose); JVMFlag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose);
Flag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose); JVMFlag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose);
Flag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose); JVMFlag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose);
#endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSRUNTIME_HPP */ #endif /* SHARE_VM_RUNTIME_JVMFLAGCONSTRAINTSRUNTIME_HPP */

View File

@ -29,8 +29,9 @@
#include "gc/shared/referenceProcessor.hpp" #include "gc/shared/referenceProcessor.hpp"
#include "oops/markOop.hpp" #include "oops/markOop.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/commandLineFlagConstraintList.hpp" #include "runtime/flags/jvmFlag.hpp"
#include "runtime/commandLineFlagRangeList.hpp" #include "runtime/flags/jvmFlagConstraintList.hpp"
#include "runtime/flags/jvmFlagRangeList.hpp"
#include "runtime/globals_extension.hpp" #include "runtime/globals_extension.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"
#include "runtime/task.hpp" #include "runtime/task.hpp"
@ -46,29 +47,29 @@ void CommandLineError::print(bool verbose, const char* msg, ...) {
} }
} }
class CommandLineFlagRange_int : public CommandLineFlagRange { class JVMFlagRange_int : public JVMFlagRange {
int _min; int _min;
int _max; int _max;
const int* _ptr; const int* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagRange_int(const char* name, const int* ptr, int min, int max) JVMFlagRange_int(const char* name, const int* ptr, int min, int max)
: CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
Flag::Error check(bool verbose = true) { JVMFlag::Error check(bool verbose = true) {
return check_int(*_ptr, verbose); return check_int(*_ptr, verbose);
} }
Flag::Error check_int(int value, bool verbose = true) { JVMFlag::Error check_int(int value, bool verbose = true) {
if ((value < _min) || (value > _max)) { if ((value < _min) || (value > _max)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"int %s=%d is outside the allowed range " "int %s=%d is outside the allowed range "
"[ %d ... %d ]\n", "[ %d ... %d ]\n",
name(), value, _min, _max); name(), value, _min, _max);
return Flag::OUT_OF_BOUNDS; return JVMFlag::OUT_OF_BOUNDS;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
@ -77,28 +78,28 @@ public:
} }
}; };
class CommandLineFlagRange_intx : public CommandLineFlagRange { class JVMFlagRange_intx : public JVMFlagRange {
intx _min; intx _min;
intx _max; intx _max;
const intx* _ptr; const intx* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagRange_intx(const char* name, const intx* ptr, intx min, intx max) JVMFlagRange_intx(const char* name, const intx* ptr, intx min, intx max)
: CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
Flag::Error check(bool verbose = true) { JVMFlag::Error check(bool verbose = true) {
return check_intx(*_ptr, verbose); return check_intx(*_ptr, verbose);
} }
Flag::Error check_intx(intx value, bool verbose = true) { JVMFlag::Error check_intx(intx value, bool verbose = true) {
if ((value < _min) || (value > _max)) { if ((value < _min) || (value > _max)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"intx %s=" INTX_FORMAT " is outside the allowed range " "intx %s=" INTX_FORMAT " is outside the allowed range "
"[ " INTX_FORMAT " ... " INTX_FORMAT " ]\n", "[ " INTX_FORMAT " ... " INTX_FORMAT " ]\n",
name(), value, _min, _max); name(), value, _min, _max);
return Flag::OUT_OF_BOUNDS; return JVMFlag::OUT_OF_BOUNDS;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
@ -107,29 +108,29 @@ public:
} }
}; };
class CommandLineFlagRange_uint : public CommandLineFlagRange { class JVMFlagRange_uint : public JVMFlagRange {
uint _min; uint _min;
uint _max; uint _max;
const uint* _ptr; const uint* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagRange_uint(const char* name, const uint* ptr, uint min, uint max) JVMFlagRange_uint(const char* name, const uint* ptr, uint min, uint max)
: CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
Flag::Error check(bool verbose = true) { JVMFlag::Error check(bool verbose = true) {
return check_uint(*_ptr, verbose); return check_uint(*_ptr, verbose);
} }
Flag::Error check_uint(uint value, bool verbose = true) { JVMFlag::Error check_uint(uint value, bool verbose = true) {
if ((value < _min) || (value > _max)) { if ((value < _min) || (value > _max)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"uint %s=%u is outside the allowed range " "uint %s=%u is outside the allowed range "
"[ %u ... %u ]\n", "[ %u ... %u ]\n",
name(), value, _min, _max); name(), value, _min, _max);
return Flag::OUT_OF_BOUNDS; return JVMFlag::OUT_OF_BOUNDS;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
@ -138,29 +139,29 @@ public:
} }
}; };
class CommandLineFlagRange_uintx : public CommandLineFlagRange { class JVMFlagRange_uintx : public JVMFlagRange {
uintx _min; uintx _min;
uintx _max; uintx _max;
const uintx* _ptr; const uintx* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagRange_uintx(const char* name, const uintx* ptr, uintx min, uintx max) JVMFlagRange_uintx(const char* name, const uintx* ptr, uintx min, uintx max)
: CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
Flag::Error check(bool verbose = true) { JVMFlag::Error check(bool verbose = true) {
return check_uintx(*_ptr, verbose); return check_uintx(*_ptr, verbose);
} }
Flag::Error check_uintx(uintx value, bool verbose = true) { JVMFlag::Error check_uintx(uintx value, bool verbose = true) {
if ((value < _min) || (value > _max)) { if ((value < _min) || (value > _max)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"uintx %s=" UINTX_FORMAT " is outside the allowed range " "uintx %s=" UINTX_FORMAT " is outside the allowed range "
"[ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n", "[ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n",
name(), value, _min, _max); name(), value, _min, _max);
return Flag::OUT_OF_BOUNDS; return JVMFlag::OUT_OF_BOUNDS;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
@ -169,29 +170,29 @@ public:
} }
}; };
class CommandLineFlagRange_uint64_t : public CommandLineFlagRange { class JVMFlagRange_uint64_t : public JVMFlagRange {
uint64_t _min; uint64_t _min;
uint64_t _max; uint64_t _max;
const uint64_t* _ptr; const uint64_t* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagRange_uint64_t(const char* name, const uint64_t* ptr, uint64_t min, uint64_t max) JVMFlagRange_uint64_t(const char* name, const uint64_t* ptr, uint64_t min, uint64_t max)
: CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
Flag::Error check(bool verbose = true) { JVMFlag::Error check(bool verbose = true) {
return check_uint64_t(*_ptr, verbose); return check_uint64_t(*_ptr, verbose);
} }
Flag::Error check_uint64_t(uint64_t value, bool verbose = true) { JVMFlag::Error check_uint64_t(uint64_t value, bool verbose = true) {
if ((value < _min) || (value > _max)) { if ((value < _min) || (value > _max)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"uint64_t %s=" UINT64_FORMAT " is outside the allowed range " "uint64_t %s=" UINT64_FORMAT " is outside the allowed range "
"[ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n", "[ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n",
name(), value, _min, _max); name(), value, _min, _max);
return Flag::OUT_OF_BOUNDS; return JVMFlag::OUT_OF_BOUNDS;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
@ -200,29 +201,29 @@ public:
} }
}; };
class CommandLineFlagRange_size_t : public CommandLineFlagRange { class JVMFlagRange_size_t : public JVMFlagRange {
size_t _min; size_t _min;
size_t _max; size_t _max;
const size_t* _ptr; const size_t* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagRange_size_t(const char* name, const size_t* ptr, size_t min, size_t max) JVMFlagRange_size_t(const char* name, const size_t* ptr, size_t min, size_t max)
: CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
Flag::Error check(bool verbose = true) { JVMFlag::Error check(bool verbose = true) {
return check_size_t(*_ptr, verbose); return check_size_t(*_ptr, verbose);
} }
Flag::Error check_size_t(size_t value, bool verbose = true) { JVMFlag::Error check_size_t(size_t value, bool verbose = true) {
if ((value < _min) || (value > _max)) { if ((value < _min) || (value > _max)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"size_t %s=" SIZE_FORMAT " is outside the allowed range " "size_t %s=" SIZE_FORMAT " is outside the allowed range "
"[ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n", "[ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n",
name(), value, _min, _max); name(), value, _min, _max);
return Flag::OUT_OF_BOUNDS; return JVMFlag::OUT_OF_BOUNDS;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
@ -231,29 +232,29 @@ public:
} }
}; };
class CommandLineFlagRange_double : public CommandLineFlagRange { class JVMFlagRange_double : public JVMFlagRange {
double _min; double _min;
double _max; double _max;
const double* _ptr; const double* _ptr;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagRange_double(const char* name, const double* ptr, double min, double max) JVMFlagRange_double(const char* name, const double* ptr, double min, double max)
: CommandLineFlagRange(name), _min(min), _max(max), _ptr(ptr) {} : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
Flag::Error check(bool verbose = true) { JVMFlag::Error check(bool verbose = true) {
return check_double(*_ptr, verbose); return check_double(*_ptr, verbose);
} }
Flag::Error check_double(double value, bool verbose = true) { JVMFlag::Error check_double(double value, bool verbose = true) {
if ((value < _min) || (value > _max)) { if ((value < _min) || (value > _max)) {
CommandLineError::print(verbose, CommandLineError::print(verbose,
"double %s=%f is outside the allowed range " "double %s=%f is outside the allowed range "
"[ %f ... %f ]\n", "[ %f ... %f ]\n",
name(), value, _min, _max); name(), value, _min, _max);
return Flag::OUT_OF_BOUNDS; return JVMFlag::OUT_OF_BOUNDS;
} else { } else {
return Flag::SUCCESS; return JVMFlag::SUCCESS;
} }
} }
@ -277,27 +278,27 @@ void emit_range_uint64_t(const char* /*name*/, const uint64_t* /*value*/) { /
void emit_range_size_t(const char* /*name*/, const size_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 */ } void emit_range_double(const char* /*name*/, const double* /*value*/) { /* NOP */ }
// CommandLineFlagRange emitting code functions if range arguments are provided // JVMFlagRange emitting code functions if range arguments are provided
void emit_range_int(const char* name, const int* ptr, int min, int max) { void emit_range_int(const char* name, const int* ptr, int min, int max) {
CommandLineFlagRangeList::add(new CommandLineFlagRange_int(name, ptr, min, max)); JVMFlagRangeList::add(new JVMFlagRange_int(name, ptr, min, max));
} }
void emit_range_intx(const char* name, const intx* ptr, intx min, intx max) { void emit_range_intx(const char* name, const intx* ptr, intx min, intx max) {
CommandLineFlagRangeList::add(new CommandLineFlagRange_intx(name, ptr, min, max)); JVMFlagRangeList::add(new JVMFlagRange_intx(name, ptr, min, max));
} }
void emit_range_uint(const char* name, const uint* ptr, uint min, uint max) { void emit_range_uint(const char* name, const uint* ptr, uint min, uint max) {
CommandLineFlagRangeList::add(new CommandLineFlagRange_uint(name, ptr, min, max)); JVMFlagRangeList::add(new JVMFlagRange_uint(name, ptr, min, max));
} }
void emit_range_uintx(const char* name, const uintx* ptr, uintx min, uintx max) { void emit_range_uintx(const char* name, const uintx* ptr, uintx min, uintx max) {
CommandLineFlagRangeList::add(new CommandLineFlagRange_uintx(name, ptr, min, 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) { 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)); 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) { 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)); JVMFlagRangeList::add(new JVMFlagRange_size_t(name, ptr, min, max));
} }
void emit_range_double(const char* name, const double* ptr, double min, double max) { void emit_range_double(const char* name, const double* ptr, double min, double max) {
CommandLineFlagRangeList::add(new CommandLineFlagRange_double(name, ptr, min, max)); JVMFlagRangeList::add(new JVMFlagRange_double(name, ptr, min, max));
} }
// Generate code to call emit_range_xxx function // Generate code to call emit_range_xxx function
@ -328,12 +329,12 @@ void emit_range_double(const char* name, const double* ptr, double min, double m
#define EMIT_RANGE_CHECK(a, b) , a, b #define EMIT_RANGE_CHECK(a, b) , a, b
#define INITIAL_RANGES_SIZE 379 #define INITIAL_RANGES_SIZE 379
GrowableArray<CommandLineFlagRange*>* CommandLineFlagRangeList::_ranges = NULL; GrowableArray<JVMFlagRange*>* JVMFlagRangeList::_ranges = NULL;
// Check the ranges of all flags that have them // Check the ranges of all flags that have them
void CommandLineFlagRangeList::init(void) { void JVMFlagRangeList::init(void) {
_ranges = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<CommandLineFlagRange*>(INITIAL_RANGES_SIZE, true); _ranges = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<JVMFlagRange*>(INITIAL_RANGES_SIZE, true);
emit_range_no(NULL VM_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, emit_range_no(NULL VM_FLAGS(EMIT_RANGE_DEVELOPER_FLAG,
EMIT_RANGE_PD_DEVELOPER_FLAG, EMIT_RANGE_PD_DEVELOPER_FLAG,
@ -403,10 +404,10 @@ void CommandLineFlagRangeList::init(void) {
#endif // COMPILER2 #endif // COMPILER2
} }
CommandLineFlagRange* CommandLineFlagRangeList::find(const char* name) { JVMFlagRange* JVMFlagRangeList::find(const char* name) {
CommandLineFlagRange* found = NULL; JVMFlagRange* found = NULL;
for (int i=0; i<length(); i++) { for (int i=0; i<length(); i++) {
CommandLineFlagRange* range = at(i); JVMFlagRange* range = at(i);
if (strcmp(range->name(), name) == 0) { if (strcmp(range->name(), name) == 0) {
found = range; found = range;
break; break;
@ -415,12 +416,12 @@ CommandLineFlagRange* CommandLineFlagRangeList::find(const char* name) {
return found; return found;
} }
void CommandLineFlagRangeList::print(outputStream* st, const char* name, RangeStrFunc default_range_str_func) { void JVMFlagRangeList::print(outputStream* st, const char* name, RangeStrFunc default_range_str_func) {
CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); JVMFlagRange* range = JVMFlagRangeList::find(name);
if (range != NULL) { if (range != NULL) {
range->print(st); range->print(st);
} else { } else {
CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); JVMFlagConstraint* constraint = JVMFlagConstraintList::find(name);
if (constraint != NULL) { if (constraint != NULL) {
assert(default_range_str_func!=NULL, "default_range_str_func must be provided"); assert(default_range_str_func!=NULL, "default_range_str_func must be provided");
st->print("%s", default_range_str_func()); st->print("%s", default_range_str_func());
@ -430,12 +431,12 @@ void CommandLineFlagRangeList::print(outputStream* st, const char* name, RangeSt
} }
} }
bool CommandLineFlagRangeList::check_ranges() { bool JVMFlagRangeList::check_ranges() {
// Check ranges. // Check ranges.
bool status = true; bool status = true;
for (int i=0; i<length(); i++) { for (int i=0; i<length(); i++) {
CommandLineFlagRange* range = at(i); JVMFlagRange* range = at(i);
if (range->check(true) != Flag::SUCCESS) status = false; if (range->check(true) != JVMFlag::SUCCESS) status = false;
} }
return status; return status;
} }

View File

@ -22,11 +22,11 @@
* *
*/ */
#ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGRANGELIST_HPP #ifndef SHARE_VM_RUNTIME_JVMFLAGRANGELIST_HPP
#define SHARE_VM_RUNTIME_COMMANDLINEFLAGRANGELIST_HPP #define SHARE_VM_RUNTIME_JVMFLAGRANGELIST_HPP
#include "memory/metaspaceShared.hpp" #include "memory/metaspaceShared.hpp"
#include "runtime/globals.hpp" #include "runtime/flags/jvmFlag.hpp"
#include "utilities/growableArray.hpp" #include "utilities/growableArray.hpp"
/* /*
@ -44,36 +44,36 @@ public:
static void print(bool verbose, const char* msg, ...); static void print(bool verbose, const char* msg, ...);
}; };
class CommandLineFlagRange : public CHeapObj<mtArguments> { class JVMFlagRange : public CHeapObj<mtArguments> {
private: private:
const char* _name; const char* _name;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagRange(const char* name) { _name=name; } JVMFlagRange(const char* name) { _name=name; }
~CommandLineFlagRange() {} ~JVMFlagRange() {}
const char* name() { return _name; } const char* name() { return _name; }
virtual Flag::Error check(bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } virtual JVMFlag::Error check(bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
virtual Flag::Error check_int(int value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } virtual JVMFlag::Error check_int(int value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
virtual Flag::Error check_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } virtual JVMFlag::Error check_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
virtual Flag::Error check_uint(uint value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } virtual JVMFlag::Error check_uint(uint value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
virtual Flag::Error check_uintx(uintx value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } virtual JVMFlag::Error check_uintx(uintx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
virtual Flag::Error check_uint64_t(uint64_t value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } virtual JVMFlag::Error check_uint64_t(uint64_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
virtual Flag::Error check_size_t(size_t value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } virtual JVMFlag::Error check_size_t(size_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
virtual Flag::Error check_double(double value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; } virtual JVMFlag::Error check_double(double value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
virtual void print(outputStream* st) { ; } virtual void print(outputStream* st) { ; }
}; };
class CommandLineFlagRangeList : public AllStatic { class JVMFlagRangeList : public AllStatic {
static GrowableArray<CommandLineFlagRange*>* _ranges; static GrowableArray<JVMFlagRange*>* _ranges;
public: public:
static void init(); static void init();
static int length() { return (_ranges != NULL) ? _ranges->length() : 0; } static int length() { return (_ranges != NULL) ? _ranges->length() : 0; }
static CommandLineFlagRange* at(int i) { return (_ranges != NULL) ? _ranges->at(i) : NULL; } static JVMFlagRange* at(int i) { return (_ranges != NULL) ? _ranges->at(i) : NULL; }
static CommandLineFlagRange* find(const char* name); static JVMFlagRange* find(const char* name);
static void add(CommandLineFlagRange* range) { _ranges->append(range); } static void add(JVMFlagRange* range) { _ranges->append(range); }
static void print(outputStream* st, const char* name, RangeStrFunc default_range_str_func); static void print(outputStream* st, const char* name, RangeStrFunc default_range_str_func);
// Check the final values of all flags for ranges. // Check the final values of all flags for ranges.
static bool check_ranges(); static bool check_ranges();
}; };
#endif // SHARE_VM_RUNTIME_COMMANDLINEFLAGRANGELIST_HPP #endif // SHARE_VM_RUNTIME_JVMFLAGRANGELIST_HPP

View File

@ -24,7 +24,7 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "gc/shared/plab.hpp" #include "gc/shared/plab.hpp"
#include "runtime/commandLineFlagWriteableList.hpp" #include "runtime/flags/jvmFlagWriteableList.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"
#ifdef COMPILER1 #ifdef COMPILER1
#include "c1/c1_globals.hpp" #include "c1/c1_globals.hpp"
@ -36,18 +36,18 @@
#include "jvmci/jvmci_globals.hpp" #include "jvmci/jvmci_globals.hpp"
#endif #endif
bool CommandLineFlagWriteable::is_writeable(void) { bool JVMFlagWriteable::is_writeable(void) {
return _writeable; return _writeable;
} }
void CommandLineFlagWriteable::mark_once(void) { void JVMFlagWriteable::mark_once(void) {
if (_type == Once) { if (_type == Once) {
_writeable = false; _writeable = false;
} }
} }
void CommandLineFlagWriteable::mark_startup(void) { void JVMFlagWriteable::mark_startup(void) {
if (_type == CommandLineFlagWriteable::CommandLineOnly) { if (_type == JVMFlagWriteable::CommandLineOnly) {
_writeable = false; _writeable = false;
} }
} }
@ -67,30 +67,30 @@ void emit_writeable_uint64_t(const char* /*name*/) { /* NOP */ }
void emit_writeable_size_t(const char* /*name*/) { /* NOP */ } void emit_writeable_size_t(const char* /*name*/) { /* NOP */ }
void emit_writeable_double(const char* /*name*/) { /* NOP */ } void emit_writeable_double(const char* /*name*/) { /* NOP */ }
// CommandLineFlagWriteable emitting code functions if range arguments are provided // JVMFlagWriteable emitting code functions if range arguments are provided
void emit_writeable_bool(const char* name, CommandLineFlagWriteable::WriteableType type) { void emit_writeable_bool(const char* name, JVMFlagWriteable::WriteableType type) {
CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
} }
void emit_writeable_int(const char* name, CommandLineFlagWriteable::WriteableType type) { void emit_writeable_int(const char* name, JVMFlagWriteable::WriteableType type) {
CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
} }
void emit_writeable_intx(const char* name, CommandLineFlagWriteable::WriteableType type) { void emit_writeable_intx(const char* name, JVMFlagWriteable::WriteableType type) {
CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
} }
void emit_writeable_uint(const char* name, CommandLineFlagWriteable::WriteableType type) { void emit_writeable_uint(const char* name, JVMFlagWriteable::WriteableType type) {
CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
} }
void emit_writeable_uintx(const char* name, CommandLineFlagWriteable::WriteableType type) { void emit_writeable_uintx(const char* name, JVMFlagWriteable::WriteableType type) {
CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
} }
void emit_writeable_uint64_t(const char* name, CommandLineFlagWriteable::WriteableType type) { void emit_writeable_uint64_t(const char* name, JVMFlagWriteable::WriteableType type) {
CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
} }
void emit_writeable_size_t(const char* name, CommandLineFlagWriteable::WriteableType type) { void emit_writeable_size_t(const char* name, JVMFlagWriteable::WriteableType type) {
CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
} }
void emit_writeable_double(const char* name, CommandLineFlagWriteable::WriteableType type) { void emit_writeable_double(const char* name, JVMFlagWriteable::WriteableType type) {
CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); JVMFlagWriteableList::add(new JVMFlagWriteable(name, type));
} }
// Generate code to call emit_writeable_xxx function // Generate code to call emit_writeable_xxx function
@ -108,14 +108,14 @@ void emit_writeable_double(const char* name, CommandLineFlagWriteable::Writeable
#define EMIT_WRITEABLE_LP64_PRODUCT_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 // Generate type argument to pass into emit_writeable_xxx functions
#define EMIT_WRITEABLE(a) , CommandLineFlagWriteable::a #define EMIT_WRITEABLE(a) , JVMFlagWriteable::a
#define INITIAL_WRITEABLES_SIZE 2 #define INITIAL_WRITEABLES_SIZE 2
GrowableArray<CommandLineFlagWriteable*>* CommandLineFlagWriteableList::_controls = NULL; GrowableArray<JVMFlagWriteable*>* JVMFlagWriteableList::_controls = NULL;
void CommandLineFlagWriteableList::init(void) { void JVMFlagWriteableList::init(void) {
_controls = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<CommandLineFlagWriteable*>(INITIAL_WRITEABLES_SIZE, true); _controls = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<JVMFlagWriteable*>(INITIAL_WRITEABLES_SIZE, true);
emit_writeable_no(NULL VM_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, emit_writeable_no(NULL VM_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG,
EMIT_WRITEABLE_PD_DEVELOPER_FLAG, EMIT_WRITEABLE_PD_DEVELOPER_FLAG,
@ -185,10 +185,10 @@ void CommandLineFlagWriteableList::init(void) {
#endif // COMPILER2 #endif // COMPILER2
} }
CommandLineFlagWriteable* CommandLineFlagWriteableList::find(const char* name) { JVMFlagWriteable* JVMFlagWriteableList::find(const char* name) {
CommandLineFlagWriteable* found = NULL; JVMFlagWriteable* found = NULL;
for (int i=0; i<length(); i++) { for (int i=0; i<length(); i++) {
CommandLineFlagWriteable* writeable = at(i); JVMFlagWriteable* writeable = at(i);
if (strcmp(writeable->name(), name) == 0) { if (strcmp(writeable->name(), name) == 0) {
found = writeable; found = writeable;
break; break;
@ -197,9 +197,9 @@ CommandLineFlagWriteable* CommandLineFlagWriteableList::find(const char* name) {
return found; return found;
} }
void CommandLineFlagWriteableList::mark_startup(void) { void JVMFlagWriteableList::mark_startup(void) {
for (int i=0; i<length(); i++) { for (int i=0; i<length(); i++) {
CommandLineFlagWriteable* writeable = at(i); JVMFlagWriteable* writeable = at(i);
writeable->mark_startup(); writeable->mark_startup();
} }
} }

View File

@ -22,13 +22,12 @@
* *
*/ */
#ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP #ifndef SHARE_VM_RUNTIME_JVMFLAGWRITEABLE_HPP
#define SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP #define SHARE_VM_RUNTIME_JVMFLAGWRITEABLE_HPP
#include "runtime/globals.hpp"
#include "utilities/growableArray.hpp" #include "utilities/growableArray.hpp"
class CommandLineFlagWriteable : public CHeapObj<mtArguments> { class JVMFlagWriteable : public CHeapObj<mtArguments> {
public: public:
enum WriteableType { enum WriteableType {
// can be set without any limits // can be set without any limits
@ -45,8 +44,8 @@ private:
bool _startup_done; bool _startup_done;
public: public:
// the "name" argument must be a string literal // the "name" argument must be a string literal
CommandLineFlagWriteable(const char* name, WriteableType type) { _name=name; _type=type; _writeable=true; _startup_done=false; } JVMFlagWriteable(const char* name, WriteableType type) { _name=name; _type=type; _writeable=true; _startup_done=false; }
~CommandLineFlagWriteable() {} ~JVMFlagWriteable() {}
const char* name() { return _name; } const char* name() { return _name; }
const WriteableType type() { return _type; } const WriteableType type() { return _type; }
bool is_writeable(void); bool is_writeable(void);
@ -54,15 +53,15 @@ public:
void mark_startup(void); void mark_startup(void);
}; };
class CommandLineFlagWriteableList : public AllStatic { class JVMFlagWriteableList : public AllStatic {
static GrowableArray<CommandLineFlagWriteable*>* _controls; static GrowableArray<JVMFlagWriteable*>* _controls;
public: public:
static void init(); static void init();
static int length() { return (_controls != NULL) ? _controls->length() : 0; } static int length() { return (_controls != NULL) ? _controls->length() : 0; }
static CommandLineFlagWriteable* at(int i) { return (_controls != NULL) ? _controls->at(i) : NULL; } static JVMFlagWriteable* at(int i) { return (_controls != NULL) ? _controls->at(i) : NULL; }
static CommandLineFlagWriteable* find(const char* name); static JVMFlagWriteable* find(const char* name);
static void add(CommandLineFlagWriteable* range) { _controls->append(range); } static void add(JVMFlagWriteable* range) { _controls->append(range); }
static void mark_startup(void); static void mark_startup(void);
}; };
#endif // SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP #endif // SHARE_VM_RUNTIME_JVMFLAGWRITEABLE_HPP

File diff suppressed because it is too large Load Diff

View File

@ -108,349 +108,6 @@ define_pd_global(uint64_t,MaxRAM, 1ULL*G);
#endif // no compilers #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 // use this for flags that are true by default in the debug version but
// false in the optimized version, and vice versa // false in the optimized version, and vice versa
#ifdef ASSERT #ifdef ASSERT
@ -536,10 +193,10 @@ public:
// it can be done in the same way as product_rw. // 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 // 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 // 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 // writeable is a macro that controls if and how the value can change during the runtime
// //

View File

@ -27,11 +27,11 @@
// globals_extension.hpp extension // globals_extension.hpp extension
// Additional CommandLineFlags enum values // Additional JVMFlags enum values
#define COMMANDLINEFLAG_EXT #define JVMFLAGS_EXT
// Additional CommandLineFlagsWithType enum values // Additional JVMFlagsWithType enum values
#define COMMANDLINEFLAGWITHTYPE_EXT #define JVMFLAGSWITHTYPE_EXT
// globals.cpp extension // globals.cpp extension
@ -45,26 +45,26 @@
// Default method implementations // Default method implementations
inline bool Flag::is_unlocker_ext() const { inline bool JVMFlag::is_unlocker_ext() const {
return false; return false;
} }
inline bool Flag::is_unlocked_ext() const { inline bool JVMFlag::is_unlocked_ext() const {
return true; return true;
} }
inline bool Flag::is_writeable_ext() const { inline bool JVMFlag::is_writeable_ext() const {
return false; return false;
} }
inline bool Flag::is_external_ext() const { inline bool JVMFlag::is_external_ext() const {
return false; 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"); assert(buf != NULL, "Buffer cannot be NULL");
buf[0] = '\0'; buf[0] = '\0';
return Flag::NONE; return JVMFlag::NONE;
} }
#endif // SHARE_VM_RUNTIME_GLOBALS_EXT_HPP #endif // SHARE_VM_RUNTIME_GLOBALS_EXT_HPP

View File

@ -27,7 +27,6 @@
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
#include "utilities/macros.hpp"
#if INCLUDE_JVMCI #if INCLUDE_JVMCI
#include "jvmci/jvmci_globals.hpp" #include "jvmci/jvmci_globals.hpp"
#endif #endif
@ -164,9 +163,9 @@ typedef enum {
IGNORE_RANGE, \ IGNORE_RANGE, \
IGNORE_CONSTRAINT, \ IGNORE_CONSTRAINT, \
IGNORE_WRITEABLE) IGNORE_WRITEABLE)
COMMANDLINEFLAG_EXT JVMFLAGS_EXT
NUM_CommandLineFlag NUM_JVMFlags
} CommandLineFlag; } JVMFlags;
// Construct enum of Flag_<cmdline-arg>_<type> constants. // Construct enum of Flag_<cmdline-arg>_<type> constants.
@ -293,19 +292,19 @@ typedef enum {
IGNORE_RANGE, IGNORE_RANGE,
IGNORE_CONSTRAINT, IGNORE_CONSTRAINT,
IGNORE_WRITEABLE) IGNORE_WRITEABLE)
COMMANDLINEFLAGWITHTYPE_EXT JVMFLAGSWITHTYPE_EXT
NUM_CommandLineFlagWithType NUM_JVMFlagsWithType
} CommandLineFlagWithType; } JVMFlagsWithType;
#define FLAG_IS_DEFAULT(name) (CommandLineFlagsEx::is_default(FLAG_MEMBER(name))) #define FLAG_IS_DEFAULT(name) (JVMFlagEx::is_default(FLAG_MEMBER(name)))
#define FLAG_IS_ERGO(name) (CommandLineFlagsEx::is_ergo(FLAG_MEMBER(name))) #define FLAG_IS_ERGO(name) (JVMFlagEx::is_ergo(FLAG_MEMBER(name)))
#define FLAG_IS_CMDLINE(name) (CommandLineFlagsEx::is_cmdline(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_DEFAULT(name, value) ((name) = (value))
#define FLAG_SET_CMDLINE(type, name, value) (CommandLineFlagsEx::setOnCmdLine(FLAG_MEMBER_WITH_TYPE(name, type)), \ #define FLAG_SET_CMDLINE(type, name, value) (JVMFlagEx::setOnCmdLine(FLAG_MEMBER_WITH_TYPE(name, type)), \
CommandLineFlagsEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name, type), (type)(value), Flag::COMMAND_LINE)) JVMFlagEx::type##AtPut(FLAG_MEMBER_WITH_TYPE(name, type), (type)(value), JVMFlag::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_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) \ #define FLAG_SET_ERGO_IF_DEFAULT(type, name, value) \
do { \ do { \
if (FLAG_IS_DEFAULT(name)) { \ if (FLAG_IS_DEFAULT(name)) { \
@ -313,26 +312,26 @@ typedef enum {
} \ } \
} while (0) } 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. // of a circular dependency on the enum definition.
class CommandLineFlagsEx : CommandLineFlags { class JVMFlagEx : JVMFlag {
public: public:
static Flag::Error boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin); static JVMFlag::Error boolAtPut(JVMFlagsWithType flag, bool value, JVMFlag::Flags origin);
static Flag::Error intAtPut(CommandLineFlagWithType flag, int value, Flag::Flags origin); static JVMFlag::Error intAtPut(JVMFlagsWithType flag, int value, JVMFlag::Flags origin);
static Flag::Error uintAtPut(CommandLineFlagWithType flag, uint value, Flag::Flags origin); static JVMFlag::Error uintAtPut(JVMFlagsWithType flag, uint value, JVMFlag::Flags origin);
static Flag::Error intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin); static JVMFlag::Error intxAtPut(JVMFlagsWithType flag, intx value, JVMFlag::Flags origin);
static Flag::Error uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin); static JVMFlag::Error uintxAtPut(JVMFlagsWithType flag, uintx value, JVMFlag::Flags origin);
static Flag::Error uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin); static JVMFlag::Error uint64_tAtPut(JVMFlagsWithType flag, uint64_t value, JVMFlag::Flags origin);
static Flag::Error size_tAtPut(CommandLineFlagWithType flag, size_t value, Flag::Flags origin); static JVMFlag::Error size_tAtPut(JVMFlagsWithType flag, size_t value, JVMFlag::Flags origin);
static Flag::Error doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin); static JVMFlag::Error doubleAtPut(JVMFlagsWithType flag, double value, JVMFlag::Flags origin);
// Contract: Flag will make private copy of the incoming value // 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_default(JVMFlags flag);
static bool is_ergo(CommandLineFlag flag); static bool is_ergo(JVMFlags flag);
static bool is_cmdline(CommandLineFlag flag); static bool is_cmdline(JVMFlags flag);
static void setOnCmdLine(CommandLineFlagWithType flag); static void setOnCmdLine(JVMFlagsWithType flag);
}; };
#endif // SHARE_VM_RUNTIME_GLOBALS_EXTENSION_HPP #endif // SHARE_VM_RUNTIME_GLOBALS_EXTENSION_HPP

View File

@ -26,6 +26,7 @@
#define SHARE_VM_RUNTIME_HANDSHAKE_HPP #define SHARE_VM_RUNTIME_HANDSHAKE_HPP
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/semaphore.hpp" #include "runtime/semaphore.hpp"
class ThreadClosure; class ThreadClosure;

View File

@ -30,7 +30,7 @@
#include "interpreter/bytecodes.hpp" #include "interpreter/bytecodes.hpp"
#include "memory/universe.hpp" #include "memory/universe.hpp"
#include "prims/methodHandles.hpp" #include "prims/methodHandles.hpp"
#include "runtime/globals.hpp" #include "runtime/flags/jvmFlag.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/icache.hpp" #include "runtime/icache.hpp"
#include "runtime/init.hpp" #include "runtime/init.hpp"
@ -155,7 +155,7 @@ jint init_globals() {
// All the flags that get adjusted by VM_Version_init and os::init_2 // All the flags that get adjusted by VM_Version_init and os::init_2
// have been set so dump the flags now. // have been set so dump the flags now.
if (PrintFlagsFinal || PrintFlagsRanges) { if (PrintFlagsFinal || PrintFlagsRanges) {
CommandLineFlags::printFlags(tty, false, PrintFlagsRanges); JVMFlag::printFlags(tty, false, PrintFlagsRanges);
} }
return JNI_OK; return JNI_OK;

View File

@ -54,6 +54,7 @@
#include "runtime/biasedLocking.hpp" #include "runtime/biasedLocking.hpp"
#include "runtime/compilationPolicy.hpp" #include "runtime/compilationPolicy.hpp"
#include "runtime/deoptimization.hpp" #include "runtime/deoptimization.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/init.hpp" #include "runtime/init.hpp"
#include "runtime/interfaceSupport.inline.hpp" #include "runtime/interfaceSupport.inline.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"

View File

@ -26,6 +26,7 @@
#define SHARE_VM_RUNTIME_MUTEXLOCKER_HPP #define SHARE_VM_RUNTIME_MUTEXLOCKER_HPP
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/mutex.hpp" #include "runtime/mutex.hpp"
// Mutexes used in the VM. // Mutexes used in the VM.

View File

@ -63,12 +63,11 @@
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "runtime/biasedLocking.hpp" #include "runtime/biasedLocking.hpp"
#include "runtime/commandLineFlagConstraintList.hpp" #include "runtime/flags/jvmFlagConstraintList.hpp"
#include "runtime/commandLineFlagWriteableList.hpp" #include "runtime/flags/jvmFlagRangeList.hpp"
#include "runtime/commandLineFlagRangeList.hpp" #include "runtime/flags/jvmFlagWriteableList.hpp"
#include "runtime/deoptimization.hpp" #include "runtime/deoptimization.hpp"
#include "runtime/frame.inline.hpp" #include "runtime/frame.inline.hpp"
#include "runtime/globals.hpp"
#include "runtime/handshake.hpp" #include "runtime/handshake.hpp"
#include "runtime/init.hpp" #include "runtime/init.hpp"
#include "runtime/interfaceSupport.inline.hpp" #include "runtime/interfaceSupport.inline.hpp"
@ -3663,17 +3662,17 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
if (ergo_result != JNI_OK) return ergo_result; if (ergo_result != JNI_OK) return ergo_result;
// Final check of all ranges after ergonomics which may change values. // Final check of all ranges after ergonomics which may change values.
if (!CommandLineFlagRangeList::check_ranges()) { if (!JVMFlagRangeList::check_ranges()) {
return JNI_EINVAL; return JNI_EINVAL;
} }
// Final check of all 'AfterErgo' constraints after ergonomics which may change values. // 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) { if (!constraint_result) {
return JNI_EINVAL; return JNI_EINVAL;
} }
CommandLineFlagWriteableList::mark_startup(); JVMFlagWriteableList::mark_startup();
if (PauseAtStartup) { if (PauseAtStartup) {
os::pause(); os::pause();

View File

@ -82,6 +82,7 @@
#include "prims/jvmtiAgentThread.hpp" #include "prims/jvmtiAgentThread.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/deoptimization.hpp" #include "runtime/deoptimization.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"
#include "runtime/javaCalls.hpp" #include "runtime/javaCalls.hpp"
@ -1059,12 +1060,12 @@ typedef PaddedEnd<ObjectMonitor> PaddedObjectMonitor;
/* -XX flags */ \ /* -XX flags */ \
/*********************/ \ /*********************/ \
\ \
nonstatic_field(Flag, _type, const char*) \ nonstatic_field(JVMFlag, _type, const char*) \
nonstatic_field(Flag, _name, const char*) \ nonstatic_field(JVMFlag, _name, const char*) \
unchecked_nonstatic_field(Flag, _addr, sizeof(void*)) /* NOTE: no type */ \ unchecked_nonstatic_field(JVMFlag, _addr, sizeof(void*)) /* NOTE: no type */ \
nonstatic_field(Flag, _flags, Flag::Flags) \ nonstatic_field(JVMFlag, _flags, JVMFlag::Flags) \
static_field(Flag, flags, Flag*) \ static_field(JVMFlag, flags, JVMFlag*) \
static_field(Flag, numFlags, size_t) \ static_field(JVMFlag, numFlags, size_t) \
\ \
/*************************/ \ /*************************/ \
/* JDK / VM version info */ \ /* JDK / VM version info */ \
@ -1896,8 +1897,8 @@ typedef PaddedEnd<ObjectMonitor> PaddedObjectMonitor;
/* -XX flags */ \ /* -XX flags */ \
/********************/ \ /********************/ \
\ \
declare_toplevel_type(Flag) \ declare_toplevel_type(JVMFlag) \
declare_toplevel_type(Flag*) \ declare_toplevel_type(JVMFlag*) \
\ \
/********************/ \ /********************/ \
/* JVMTI */ \ /* JVMTI */ \
@ -1937,7 +1938,7 @@ typedef PaddedEnd<ObjectMonitor> PaddedObjectMonitor;
declare_integer_type(ThreadState) \ declare_integer_type(ThreadState) \
declare_integer_type(Location::Type) \ declare_integer_type(Location::Type) \
declare_integer_type(Location::Where) \ declare_integer_type(Location::Where) \
declare_integer_type(Flag::Flags) \ declare_integer_type(JVMFlag::Flags) \
COMPILER2_PRESENT(declare_integer_type(OptoReg::Name)) \ COMPILER2_PRESENT(declare_integer_type(OptoReg::Name)) \
\ \
declare_toplevel_type(CHeapObj<mtInternal>) \ declare_toplevel_type(CHeapObj<mtInternal>) \

View File

@ -31,6 +31,7 @@
#include "oops/typeArrayOop.inline.hpp" #include "oops/typeArrayOop.inline.hpp"
#include "prims/jvmtiExport.hpp" #include "prims/jvmtiExport.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"
@ -275,9 +276,9 @@ static jint set_flag(AttachOperation* op, outputStream* out) {
FormatBuffer<80> err_msg("%s", ""); FormatBuffer<80> err_msg("%s", "");
int ret = WriteableFlags::set_flag(op->arg(0), op->arg(1), Flag::ATTACH_ON_DEMAND, err_msg); int ret = WriteableFlags::set_flag(op->arg(0), op->arg(1), JVMFlag::ATTACH_ON_DEMAND, err_msg);
if (ret != Flag::SUCCESS) { if (ret != JVMFlag::SUCCESS) {
if (ret == Flag::NON_WRITABLE) { if (ret == JVMFlag::NON_WRITABLE) {
// if the flag is not manageable try to change it through // if the flag is not manageable try to change it through
// the platform dependent implementation // the platform dependent implementation
return AttachListener::pd_set_flag(op, out); return AttachListener::pd_set_flag(op, out);
@ -298,7 +299,7 @@ static jint print_flag(AttachOperation* op, outputStream* out) {
out->print_cr("flag name is missing"); out->print_cr("flag name is missing");
return JNI_ERR; return JNI_ERR;
} }
Flag* f = Flag::find_flag((char*)name, strlen(name)); JVMFlag* f = JVMFlag::find_flag((char*)name, strlen(name));
if (f) { if (f) {
f->print_as_flag(out); f->print_as_flag(out);
out->cr(); out->cr();

View File

@ -33,7 +33,7 @@
#include "oops/objArrayOop.inline.hpp" #include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "oops/typeArrayOop.inline.hpp" #include "oops/typeArrayOop.inline.hpp"
#include "runtime/globals.hpp" #include "runtime/flags/jvmFlag.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/javaCalls.hpp" #include "runtime/javaCalls.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"
@ -231,9 +231,9 @@ PrintVMFlagsDCmd::PrintVMFlagsDCmd(outputStream* output, bool heap) :
void PrintVMFlagsDCmd::execute(DCmdSource source, TRAPS) { void PrintVMFlagsDCmd::execute(DCmdSource source, TRAPS) {
if (_all.value()) { if (_all.value()) {
CommandLineFlags::printFlags(output(), true); JVMFlag::printFlags(output(), true);
} else { } else {
CommandLineFlags::printSetFlags(output()); JVMFlag::printSetFlags(output());
} }
} }
@ -264,9 +264,9 @@ void SetVMFlagDCmd::execute(DCmdSource source, TRAPS) {
} }
FormatBuffer<80> err_msg("%s", ""); 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()); output()->print_cr("%s", err_msg.buffer());
} }
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
#include "code/codeCache.hpp" #include "code/codeCache.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "runtime/deoptimization.hpp" #include "runtime/deoptimization.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/vmThread.hpp" #include "runtime/vmThread.hpp"
#include "runtime/vm_operations.hpp" #include "runtime/vm_operations.hpp"
#include "services/dtraceAttacher.hpp" #include "services/dtraceAttacher.hpp"
@ -50,8 +51,8 @@ class VM_DeoptimizeTheWorld : public VM_Operation {
}; };
static void set_bool_flag(const char* flag, bool value) { static void set_bool_flag(const char* flag, bool value) {
CommandLineFlags::boolAtPut((char*)flag, strlen(flag), &value, JVMFlag::boolAtPut((char*)flag, strlen(flag), &value,
Flag::ATTACH_ON_DEMAND); JVMFlag::ATTACH_ON_DEMAND);
} }
// Enable only the "fine grained" flags. Do *not* touch // Enable only the "fine grained" flags. Do *not* touch

View File

@ -36,6 +36,7 @@
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "oops/typeArrayOop.inline.hpp" #include "oops/typeArrayOop.inline.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/interfaceSupport.inline.hpp" #include "runtime/interfaceSupport.inline.hpp"
@ -866,10 +867,10 @@ static jint get_vm_thread_count() {
static jint get_num_flags() { static jint get_num_flags() {
// last flag entry is always NULL, so subtract 1 // last flag entry is always NULL, so subtract 1
int nFlags = (int) Flag::numFlags - 1; int nFlags = (int) JVMFlag::numFlags - 1;
int count = 0; int count = 0;
for (int i = 0; i < nFlags; i++) { for (int i = 0; i < nFlags; i++) {
Flag* flag = &Flag::flags[i]; JVMFlag* flag = &JVMFlag::flags[i];
// Exclude the locked (diagnostic, experimental) flags // Exclude the locked (diagnostic, experimental) flags
if (flag->is_unlocked() || flag->is_unlocker()) { if (flag->is_unlocked() || flag->is_unlocker()) {
count++; count++;
@ -1419,14 +1420,14 @@ JVM_END
// Returns a String array of all VM global flag names // Returns a String array of all VM global flag names
JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env)) JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env))
// last flag entry is always NULL, so subtract 1 // 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 // allocate a temp array
objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(),
nFlags, CHECK_0); nFlags, CHECK_0);
objArrayHandle flags_ah(THREAD, r); objArrayHandle flags_ah(THREAD, r);
int num_entries = 0; int num_entries = 0;
for (int i = 0; i < nFlags; i++) { 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. // Exclude notproduct and develop flags in product builds.
if (flag->is_constant_in_binary()) { if (flag->is_constant_in_binary()) {
continue; continue;
@ -1454,7 +1455,7 @@ JVM_END
// Utility function used by jmm_GetVMGlobals. Returns false if flag type // Utility function used by jmm_GetVMGlobals. Returns false if flag type
// can't be determined, true otherwise. If false is returned, then *global // can't be determined, true otherwise. If false is returned, then *global
// will be incomplete and invalid. // 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; Handle flag_name;
if (name() == NULL) { if (name() == NULL) {
flag_name = java_lang_String::create_from_str(flag->_name, CHECK_false); flag_name = java_lang_String::create_from_str(flag->_name, CHECK_false);
@ -1499,25 +1500,25 @@ bool add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag,
global->writeable = flag->is_writeable(); global->writeable = flag->is_writeable();
global->external = flag->is_external(); global->external = flag->is_external();
switch (flag->get_origin()) { switch (flag->get_origin()) {
case Flag::DEFAULT: case JVMFlag::DEFAULT:
global->origin = JMM_VMGLOBAL_ORIGIN_DEFAULT; global->origin = JMM_VMGLOBAL_ORIGIN_DEFAULT;
break; break;
case Flag::COMMAND_LINE: case JVMFlag::COMMAND_LINE:
global->origin = JMM_VMGLOBAL_ORIGIN_COMMAND_LINE; global->origin = JMM_VMGLOBAL_ORIGIN_COMMAND_LINE;
break; break;
case Flag::ENVIRON_VAR: case JVMFlag::ENVIRON_VAR:
global->origin = JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR; global->origin = JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR;
break; break;
case Flag::CONFIG_FILE: case JVMFlag::CONFIG_FILE:
global->origin = JMM_VMGLOBAL_ORIGIN_CONFIG_FILE; global->origin = JMM_VMGLOBAL_ORIGIN_CONFIG_FILE;
break; break;
case Flag::MANAGEMENT: case JVMFlag::MANAGEMENT:
global->origin = JMM_VMGLOBAL_ORIGIN_MANAGEMENT; global->origin = JMM_VMGLOBAL_ORIGIN_MANAGEMENT;
break; break;
case Flag::ERGONOMIC: case JVMFlag::ERGONOMIC:
global->origin = JMM_VMGLOBAL_ORIGIN_ERGONOMIC; global->origin = JMM_VMGLOBAL_ORIGIN_ERGONOMIC;
break; break;
case Flag::ATTACH_ON_DEMAND: case JVMFlag::ATTACH_ON_DEMAND:
global->origin = JMM_VMGLOBAL_ORIGIN_ATTACH_ON_DEMAND; global->origin = JMM_VMGLOBAL_ORIGIN_ATTACH_ON_DEMAND;
break; break;
default: default:
@ -1531,7 +1532,7 @@ bool add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag,
// specified by names. If names == NULL, fill globals array // specified by names. If names == NULL, fill globals array
// with all Flags. Return value is number of entries // with all Flags. Return value is number of entries
// created in globals. // 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. // exist, globals[i].name will be set to NULL.
JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env, JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env,
jobjectArray names, jobjectArray names,
@ -1566,7 +1567,7 @@ JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env,
Handle sh(THREAD, s); Handle sh(THREAD, s);
char* str = java_lang_String::as_utf8_string(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 && if (flag != NULL &&
add_global_entry(env, sh, &globals[i], flag, THREAD)) { add_global_entry(env, sh, &globals[i], flag, THREAD)) {
num_entries++; num_entries++;
@ -1579,11 +1580,11 @@ JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env,
// return all globals if names == NULL // return all globals if names == NULL
// last flag entry is always NULL, so subtract 1 // last flag entry is always NULL, so subtract 1
int nFlags = (int) Flag::numFlags - 1; int nFlags = (int) JVMFlag::numFlags - 1;
Handle null_h; Handle null_h;
int num_entries = 0; int num_entries = 0;
for (int i = 0; i < nFlags && num_entries < count; i++) { 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. // Exclude notproduct and develop flags in product builds.
if (flag->is_constant_in_binary()) { if (flag->is_constant_in_binary()) {
continue; continue;
@ -1609,10 +1610,10 @@ JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value
char* name = java_lang_String::as_utf8_string(fn); char* name = java_lang_String::as_utf8_string(fn);
FormatBuffer<80> error_msg("%s", ""); 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 != JVMFlag::SUCCESS) {
if (succeed == Flag::MISSING_VALUE) { if (succeed == JVMFlag::MISSING_VALUE) {
// missing value causes NPE to be thrown // missing value causes NPE to be thrown
THROW(vmSymbols::java_lang_NullPointerException()); THROW(vmSymbols::java_lang_NullPointerException());
} else { } else {
@ -1621,7 +1622,7 @@ JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value
error_msg.buffer()); error_msg.buffer());
} }
} }
assert(succeed == Flag::SUCCESS, "Setting flag should succeed"); assert(succeed == JVMFlag::SUCCESS, "Setting flag should succeed");
JVM_END JVM_END
class ThreadTimesClosure: public ThreadClosure { class ThreadTimesClosure: public ThreadClosure {

View File

@ -26,7 +26,8 @@
#include "classfile/javaClasses.hpp" #include "classfile/javaClasses.hpp"
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "runtime/arguments.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/java.hpp"
#include "runtime/jniHandles.hpp" #include "runtime/jniHandles.hpp"
#include "services/writeableFlags.hpp" #include "services/writeableFlags.hpp"
@ -38,7 +39,7 @@ static void buffer_concat(char* buffer, const char* src) {
} }
static void print_flag_error_message_bounds(const char* name, char* buffer) { 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) { if (range != NULL) {
buffer_concat(buffer, "must have value in range "); buffer_concat(buffer, "must have value in range ");
@ -58,34 +59,34 @@ static void print_flag_error_message_bounds(const char* name, char* buffer) {
} }
} }
static void print_flag_error_message_if_needed(Flag::Error error, const char* name, FormatBuffer<80>& err_msg) { static void print_flag_error_message_if_needed(JVMFlag::Error error, const char* name, FormatBuffer<80>& err_msg) {
if (error == Flag::SUCCESS) { if (error == JVMFlag::SUCCESS) {
return; return;
} }
char buffer[TEMP_BUF_SIZE] = {'\0'}; 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, name);
buffer_concat(buffer, " error: "); buffer_concat(buffer, " error: ");
} else { } else {
buffer_concat(buffer, "Error: "); buffer_concat(buffer, "Error: ");
} }
switch (error) { switch (error) {
case Flag::MISSING_NAME: case JVMFlag::MISSING_NAME:
buffer_concat(buffer, "flag name is missing."); break; 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; 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; 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; 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; 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; 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; buffer_concat(buffer, "other, unspecified error related to setting the flag."); break;
case Flag::SUCCESS: case JVMFlag::SUCCESS:
break; break;
default: default:
break; break;
@ -95,127 +96,127 @@ static void print_flag_error_message_if_needed(Flag::Error error, const char* na
} }
// set a boolean global flag // 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)) { if ((strcasecmp(arg, "true") == 0) || (*arg == '1' && *(arg + 1) == 0)) {
return set_bool_flag(name, true, origin, err_msg); return set_bool_flag(name, true, origin, err_msg);
} else if ((strcasecmp(arg, "false") == 0) || (*arg == '0' && *(arg + 1) == 0)) { } else if ((strcasecmp(arg, "false") == 0) || (*arg == '0' && *(arg + 1) == 0)) {
return set_bool_flag(name, false, origin, err_msg); return set_bool_flag(name, false, origin, err_msg);
} }
err_msg.print("flag value must be a boolean (1/0 or true/false)"); 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) { JVMFlag::Error WriteableFlags::set_bool_flag(const char* name, bool value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
Flag::Error err = CommandLineFlags::boolAtPut(name, &value, origin); JVMFlag::Error err = JVMFlag::boolAtPut(name, &value, origin);
print_flag_error_message_if_needed(err, name, err_msg); print_flag_error_message_if_needed(err, name, err_msg);
return err; return err;
} }
// set a int global flag // 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; int value;
if (sscanf(arg, "%d", &value)) { if (sscanf(arg, "%d", &value)) {
return set_int_flag(name, value, origin, err_msg); return set_int_flag(name, value, origin, err_msg);
} }
err_msg.print("flag value must be an integer"); 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) { JVMFlag::Error WriteableFlags::set_int_flag(const char* name, int value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
Flag::Error err = CommandLineFlags::intAtPut(name, &value, origin); JVMFlag::Error err = JVMFlag::intAtPut(name, &value, origin);
print_flag_error_message_if_needed(err, name, err_msg); print_flag_error_message_if_needed(err, name, err_msg);
return err; return err;
} }
// set a uint global flag // 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; uint value;
if (sscanf(arg, "%u", &value)) { if (sscanf(arg, "%u", &value)) {
return set_uint_flag(name, value, origin, err_msg); return set_uint_flag(name, value, origin, err_msg);
} }
err_msg.print("flag value must be an unsigned integer"); 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) { JVMFlag::Error WriteableFlags::set_uint_flag(const char* name, uint value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
Flag::Error err = CommandLineFlags::uintAtPut(name, &value, origin); JVMFlag::Error err = JVMFlag::uintAtPut(name, &value, origin);
print_flag_error_message_if_needed(err, name, err_msg); print_flag_error_message_if_needed(err, name, err_msg);
return err; return err;
} }
// set a intx global flag // 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; intx value;
if (sscanf(arg, INTX_FORMAT, &value)) { if (sscanf(arg, INTX_FORMAT, &value)) {
return set_intx_flag(name, value, origin, err_msg); return set_intx_flag(name, value, origin, err_msg);
} }
err_msg.print("flag value must be an integer"); 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) { JVMFlag::Error WriteableFlags::set_intx_flag(const char* name, intx value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
Flag::Error err = CommandLineFlags::intxAtPut(name, &value, origin); JVMFlag::Error err = JVMFlag::intxAtPut(name, &value, origin);
print_flag_error_message_if_needed(err, name, err_msg); print_flag_error_message_if_needed(err, name, err_msg);
return err; return err;
} }
// set a uintx global flag // 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; uintx value;
if (sscanf(arg, UINTX_FORMAT, &value)) { if (sscanf(arg, UINTX_FORMAT, &value)) {
return set_uintx_flag(name, value, origin, err_msg); return set_uintx_flag(name, value, origin, err_msg);
} }
err_msg.print("flag value must be an unsigned integer"); 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) { JVMFlag::Error WriteableFlags::set_uintx_flag(const char* name, uintx value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
Flag::Error err = CommandLineFlags::uintxAtPut(name, &value, origin); JVMFlag::Error err = JVMFlag::uintxAtPut(name, &value, origin);
print_flag_error_message_if_needed(err, name, err_msg); print_flag_error_message_if_needed(err, name, err_msg);
return err; return err;
} }
// set a uint64_t global flag // 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; uint64_t value;
if (sscanf(arg, UINT64_FORMAT, &value)) { if (sscanf(arg, UINT64_FORMAT, &value)) {
return set_uint64_t_flag(name, value, origin, err_msg); return set_uint64_t_flag(name, value, origin, err_msg);
} }
err_msg.print("flag value must be an unsigned 64-bit integer"); 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) { JVMFlag::Error WriteableFlags::set_uint64_t_flag(const char* name, uint64_t value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
Flag::Error err = CommandLineFlags::uint64_tAtPut(name, &value, origin); JVMFlag::Error err = JVMFlag::uint64_tAtPut(name, &value, origin);
print_flag_error_message_if_needed(err, name, err_msg); print_flag_error_message_if_needed(err, name, err_msg);
return err; return err;
} }
// set a size_t global flag // 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; size_t value;
if (sscanf(arg, SIZE_FORMAT, &value)) { if (sscanf(arg, SIZE_FORMAT, &value)) {
return set_size_t_flag(name, value, origin, err_msg); return set_size_t_flag(name, value, origin, err_msg);
} }
err_msg.print("flag value must be an unsigned integer"); 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) { JVMFlag::Error WriteableFlags::set_size_t_flag(const char* name, size_t value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
Flag::Error err = CommandLineFlags::size_tAtPut(name, &value, origin); JVMFlag::Error err = JVMFlag::size_tAtPut(name, &value, origin);
print_flag_error_message_if_needed(err, name, err_msg); print_flag_error_message_if_needed(err, name, err_msg);
return err; return err;
} }
// set a string global flag using value from AttachOperation // 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) { JVMFlag::Error WriteableFlags::set_ccstr_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
Flag::Error err = CommandLineFlags::ccstrAtPut((char*)name, &value, origin); JVMFlag::Error err = JVMFlag::ccstrAtPut((char*)name, &value, origin);
print_flag_error_message_if_needed(err, name, err_msg); print_flag_error_message_if_needed(err, name, err_msg);
return err; return err;
} }
@ -225,7 +226,7 @@ Flag::Error WriteableFlags::set_ccstr_flag(const char* name, const char* value,
* - return status is one of the WriteableFlags::err enum values * - return status is one of the WriteableFlags::err enum values
* - an eventual error message will be generated to the provided err_msg buffer * - 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); return set_flag(flag_name, &flag_value, set_flag_from_char, origin, err_msg);
} }
@ -234,42 +235,42 @@ Flag::Error WriteableFlags::set_flag(const char* flag_name, const char* flag_val
* - return status is one of the WriteableFlags::err enum values * - return status is one of the WriteableFlags::err enum values
* - an eventual error message will be generated to the provided err_msg buffer * - 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); return set_flag(flag_name, &flag_value, set_flag_from_jvalue, origin, err_msg);
} }
// a writeable flag setter accepting either 'jvalue' or 'char *' values // 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) { if (name == NULL) {
err_msg.print("flag name is missing"); err_msg.print("flag name is missing");
return Flag::MISSING_NAME; return JVMFlag::MISSING_NAME;
} }
if (value == NULL) { if (value == NULL) {
err_msg.print("flag value is missing"); 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) { if (f) {
// only writeable flags are allowed to be set // only writeable flags are allowed to be set
if (f->is_writeable()) { if (f->is_writeable()) {
return setter(f, value, origin, err_msg); return setter(f, value, origin, err_msg);
} else { } else {
err_msg.print("only 'writeable' flags can be set"); 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); err_msg.print("flag %s does not exist", name);
return Flag::INVALID_FLAG; return JVMFlag::INVALID_FLAG;
} }
// a writeable flag setter accepting 'char *' values // 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; char* flag_value = *(char**)value;
if (flag_value == NULL) { if (flag_value == NULL) {
err_msg.print("flag value is missing"); err_msg.print("flag value is missing");
return Flag::MISSING_VALUE; return JVMFlag::MISSING_VALUE;
} }
if (f->is_bool()) { if (f->is_bool()) {
return set_bool_flag(f->_name, flag_value, origin, err_msg); return set_bool_flag(f->_name, flag_value, origin, err_msg);
@ -290,11 +291,11 @@ Flag::Error WriteableFlags::set_flag_from_char(Flag* f, const void* value, Flag:
} else { } else {
ShouldNotReachHere(); ShouldNotReachHere();
} }
return Flag::ERR_OTHER; return JVMFlag::ERR_OTHER;
} }
// a writeable flag setter accepting 'jvalue' values // 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) { FormatBuffer<80>& err_msg) {
jvalue new_value = *(jvalue*)value; jvalue new_value = *(jvalue*)value;
if (f->is_bool()) { if (f->is_bool()) {
@ -322,16 +323,16 @@ Flag::Error WriteableFlags::set_flag_from_jvalue(Flag* f, const void* value, Fla
oop str = JNIHandles::resolve_external_guard(new_value.l); oop str = JNIHandles::resolve_external_guard(new_value.l);
if (str == NULL) { if (str == NULL) {
err_msg.print("flag value is missing"); err_msg.print("flag value is missing");
return Flag::MISSING_VALUE; return JVMFlag::MISSING_VALUE;
} }
ccstr svalue = java_lang_String::as_utf8_string(str); ccstr svalue = java_lang_String::as_utf8_string(str);
Flag::Error ret = WriteableFlags::set_ccstr_flag(f->_name, svalue, origin, err_msg); JVMFlag::Error ret = WriteableFlags::set_ccstr_flag(f->_name, svalue, origin, err_msg);
if (ret != Flag::SUCCESS) { if (ret != JVMFlag::SUCCESS) {
FREE_C_HEAP_ARRAY(char, svalue); FREE_C_HEAP_ARRAY(char, svalue);
} }
return ret; return ret;
} else { } else {
ShouldNotReachHere(); ShouldNotReachHere();
} }
return Flag::ERR_OTHER; return JVMFlag::ERR_OTHER;
} }

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,48 +25,49 @@
#ifndef SHARE_VM_SERVICES_WRITEABLEFLAG_HPP #ifndef SHARE_VM_SERVICES_WRITEABLEFLAG_HPP
#define SHARE_VM_SERVICES_WRITEABLEFLAG_HPP #define SHARE_VM_SERVICES_WRITEABLEFLAG_HPP
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "utilities/formatBuffer.hpp" #include "utilities/formatBuffer.hpp"
class WriteableFlags : AllStatic { class WriteableFlags : AllStatic {
private: private:
// a writeable flag setter accepting either 'jvalue' or 'char *' values // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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 // 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: public:
/* sets a writeable flag to the provided value /* sets a writeable flag to the provided value
@ -74,14 +75,14 @@ public:
* - return status is one of the WriteableFlags::err enum values * - return status is one of the WriteableFlags::err enum values
* - an eventual error message will be generated to the provided err_msg buffer * - 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 /* sets a writeable flag to the provided value
* *
* - return status is one of the WriteableFlags::err enum values * - return status is one of the WriteableFlags::err enum values
* - an eventual error message will be generated to the provided err_msg buffer * - 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 */ #endif /* SHARE_VM_SERVICES_WRITEABLEFLAG_HPP */

View File

@ -40,6 +40,7 @@
#include "prims/privilegedStack.hpp" #include "prims/privilegedStack.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/frame.inline.hpp" #include "runtime/frame.inline.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"

View File

@ -1259,4 +1259,11 @@ static inline void* dereference_vptr(const void* addr) {
return *(void**)addr; 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 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -136,7 +136,7 @@ public class VM {
private Boolean compressedOopsEnabled; private Boolean compressedOopsEnabled;
private Boolean compressedKlassPointersEnabled; 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 { public static final class Flag {
private String type; private String type;
private String name; private String name;
@ -905,7 +905,7 @@ public class VM {
private void readCommandLineFlags() { private void readCommandLineFlags() {
// get command line flags // get command line flags
TypeDataBase db = getTypeDataBase(); TypeDataBase db = getTypeDataBase();
Type flagType = db.lookupType("Flag"); Type flagType = db.lookupType("JVMFlag");
int numFlags = (int) flagType.getCIntegerField("numFlags").getValue(); int numFlags = (int) flagType.getCIntegerField("numFlags").getValue();
// NOTE: last flag contains null values. // NOTE: last flag contains null values.
commandLineFlags = new Flag[numFlags - 1]; commandLineFlags = new Flag[numFlags - 1];

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "gc/shared/collectorPolicy.hpp" #include "gc/shared/collectorPolicy.hpp"
#include "runtime/arguments.hpp" #include "runtime/arguments.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/globals_extension.hpp" #include "runtime/globals_extension.hpp"
#include "utilities/align.hpp" #include "utilities/align.hpp"
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,11 +23,12 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "runtime/globals.hpp" #include "runtime/globals.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "unittest.hpp" #include "unittest.hpp"
#define TEST_FLAG(f, type, value) \ #define TEST_FLAG(f, type, value) \
do { \ do { \
ASSERT_TRUE(Flag::find_flag(#f)->is_ ## type()); \ ASSERT_TRUE(JVMFlag::find_flag(#f)->is_ ## type()); \
type original_value = f; \ type original_value = f; \
{ \ { \
FLAG_GUARD(f); \ FLAG_GUARD(f); \