This commit is contained in:
Yumin Qi 2015-08-14 20:40:48 +00:00
commit 211b74795e
16 changed files with 405 additions and 470 deletions

View File

@ -5785,9 +5785,11 @@ void Parker::unpark() {
status = pthread_mutex_unlock(_mutex);
assert(status == 0, "invariant");
} else {
// must capture correct index before unlocking
int index = _cur_index;
status = pthread_mutex_unlock(_mutex);
assert(status == 0, "invariant");
status = pthread_cond_signal(&_cond[_cur_index]);
status = pthread_cond_signal(&_cond[index]);
assert(status == 0, "invariant");
}
} else {

View File

@ -3088,29 +3088,6 @@ void ConcurrentMark::print_finger() {
}
#endif
template<bool scan>
inline void CMTask::process_grey_object(oop obj) {
assert(scan || obj->is_typeArray(), "Skipping scan of grey non-typeArray");
assert(_nextMarkBitMap->isMarked((HeapWord*) obj), "invariant");
if (_cm->verbose_high()) {
gclog_or_tty->print_cr("[%u] processing grey object " PTR_FORMAT,
_worker_id, p2i((void*) obj));
}
size_t obj_size = obj->size();
_words_scanned += obj_size;
if (scan) {
obj->oop_iterate(_cm_oop_closure);
}
statsOnly( ++_objs_scanned );
check_limits();
}
template void CMTask::process_grey_object<true>(oop);
template void CMTask::process_grey_object<false>(oop);
// Closure for iteration over bitmaps
class CMBitMapClosure : public BitMapClosure {
private:

View File

@ -1126,7 +1126,7 @@ public:
inline void deal_with_reference(oop obj);
// It scans an object and visits its children.
void scan_object(oop obj) { process_grey_object<true>(obj); }
inline void scan_object(oop obj);
// It pushes an object on the local queue.
inline void push(oop obj);

View File

@ -232,6 +232,9 @@ inline void CMMarkStack::iterate(Fn fn) {
}
}
// It scans an object and visits its children.
inline void CMTask::scan_object(oop obj) { process_grey_object<true>(obj); }
inline void CMTask::push(oop obj) {
HeapWord* objAddr = (HeapWord*) obj;
assert(_g1h->is_in_g1_reserved(objAddr), "invariant");
@ -299,6 +302,28 @@ inline bool CMTask::is_below_finger(oop obj, HeapWord* global_finger) const {
return objAddr < global_finger;
}
template<bool scan>
inline void CMTask::process_grey_object(oop obj) {
assert(scan || obj->is_typeArray(), "Skipping scan of grey non-typeArray");
assert(_nextMarkBitMap->isMarked((HeapWord*) obj), "invariant");
if (_cm->verbose_high()) {
gclog_or_tty->print_cr("[%u] processing grey object " PTR_FORMAT,
_worker_id, p2i((void*) obj));
}
size_t obj_size = obj->size();
_words_scanned += obj_size;
if (scan) {
obj->oop_iterate(_cm_oop_closure);
}
statsOnly( ++_objs_scanned );
check_limits();
}
inline void CMTask::make_reference_grey(oop obj, HeapRegion* hr) {
if (_cm->par_mark_and_count(obj, hr, _marked_bytes_array, _card_bm)) {

View File

@ -45,8 +45,8 @@ public:
_constraint=func;
}
Flag::Error apply_bool(bool* value, bool verbose) {
return _constraint(verbose, value);
Flag::Error apply_bool(bool value, bool verbose) {
return _constraint(value, verbose);
}
};
@ -61,8 +61,8 @@ public:
_constraint=func;
}
Flag::Error apply_int(int* value, bool verbose) {
return _constraint(verbose, value);
Flag::Error apply_int(int value, bool verbose) {
return _constraint(value, verbose);
}
};
@ -77,8 +77,8 @@ public:
_constraint=func;
}
Flag::Error apply_intx(intx* value, bool verbose) {
return _constraint(verbose, value);
Flag::Error apply_intx(intx value, bool verbose) {
return _constraint(value, verbose);
}
};
@ -93,8 +93,8 @@ public:
_constraint=func;
}
Flag::Error apply_uint(uint* value, bool verbose) {
return _constraint(verbose, value);
Flag::Error apply_uint(uint value, bool verbose) {
return _constraint(value, verbose);
}
};
@ -109,8 +109,8 @@ public:
_constraint=func;
}
Flag::Error apply_uintx(uintx* value, bool verbose) {
return _constraint(verbose, value);
Flag::Error apply_uintx(uintx value, bool verbose) {
return _constraint(value, verbose);
}
};
@ -125,8 +125,8 @@ public:
_constraint=func;
}
Flag::Error apply_uint64_t(uint64_t* value, bool verbose) {
return _constraint(verbose, value);
Flag::Error apply_uint64_t(uint64_t value, bool verbose) {
return _constraint(value, verbose);
}
};
@ -141,8 +141,8 @@ public:
_constraint=func;
}
Flag::Error apply_size_t(size_t* value, bool verbose) {
return _constraint(verbose, value);
Flag::Error apply_size_t(size_t value, bool verbose) {
return _constraint(value, verbose);
}
};
@ -157,8 +157,8 @@ public:
_constraint=func;
}
Flag::Error apply_double(double* value, bool verbose) {
return _constraint(verbose, value);
Flag::Error apply_double(double value, bool verbose) {
return _constraint(value, verbose);
}
};
@ -226,7 +226,6 @@ CommandLineFlagConstraint::ConstraintType CommandLineFlagConstraintList::_valida
// Check the ranges of all flags that have them or print them out and exit if requested
void CommandLineFlagConstraintList::init(void) {
_constraints = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<CommandLineFlagConstraint*>(INITIAL_CONSTRAINTS_SIZE, true);
emit_constraint_no(NULL RUNTIME_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
@ -306,40 +305,6 @@ CommandLineFlagConstraint* CommandLineFlagConstraintList::find_if_needs_check(co
// Check constraints for specific constraint type.
bool CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::ConstraintType type) {
//#define PRINT_CONSTRAINTS_SIZES
#ifdef PRINT_CONSTRAINTS_SIZES
{
size_t size_constraints = sizeof(CommandLineFlagConstraintList);
for (int i=0; i<length(); i++) {
size_constraints += sizeof(CommandLineFlagConstraint);
CommandLineFlagConstraint* constraint = at(i);
const char* name = constraint->name();
Flag* flag = Flag::find_flag(name, strlen(name), true, true);
if (flag->is_bool()) {
size_constraints += sizeof(CommandLineFlagConstraintFunc_bool);
size_constraints += sizeof(CommandLineFlagConstraint*);
} else if (flag->is_intx()) {
size_constraints += sizeof(CommandLineFlagConstraintFunc_intx);
size_constraints += sizeof(CommandLineFlagConstraint*);
} else if (flag->is_uintx()) {
size_constraints += sizeof(CommandLineFlagConstraintFunc_uintx);
size_constraints += sizeof(CommandLineFlagConstraint*);
} else if (flag->is_uint64_t()) {
size_constraints += sizeof(CommandLineFlagConstraintFunc_uint64_t);
size_constraints += sizeof(CommandLineFlagConstraint*);
} else if (flag->is_size_t()) {
size_constraints += sizeof(CommandLineFlagConstraintFunc_size_t);
size_constraints += sizeof(CommandLineFlagConstraint*);
} else if (flag->is_double()) {
size_constraints += sizeof(CommandLineFlagConstraintFunc_double);
size_constraints += sizeof(CommandLineFlagConstraint*);
}
}
fprintf(stderr, "Size of %d constraints: " SIZE_FORMAT " bytes\n",
length(), size_constraints);
}
#endif // PRINT_CONSTRAINTS_SIZES
// Skip if we already checked.
if (type < _validating_type) {
return true;
@ -352,25 +317,34 @@ bool CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint:
if (type != constraint->type()) continue;
const char* name = constraint->name();
Flag* flag = Flag::find_flag(name, strlen(name), true, true);
// We must check for NULL here as lp64_product flags on 32 bit architecture
// can generate constraint check (despite that they are declared as constants),
// but they will not be returned by Flag::find_flag()
if (flag != NULL) {
if (flag->is_bool()) {
bool value = flag->get_bool();
if (constraint->apply_bool(&value, true) != Flag::SUCCESS) status = false;
if (constraint->apply_bool(value, true) != Flag::SUCCESS) status = false;
} else if (flag->is_int()) {
int value = flag->get_int();
if (constraint->apply_int(value, true) != Flag::SUCCESS) status = false;
} else if (flag->is_uint()) {
uint value = flag->get_uint();
if (constraint->apply_uint(value, true) != Flag::SUCCESS) status = false;
} else if (flag->is_intx()) {
intx value = flag->get_intx();
if (constraint->apply_intx(&value, true) != Flag::SUCCESS) status = false;
if (constraint->apply_intx(value, true) != Flag::SUCCESS) status = false;
} else if (flag->is_uintx()) {
uintx value = flag->get_uintx();
if (constraint->apply_uintx(&value, true) != Flag::SUCCESS) status = false;
if (constraint->apply_uintx(value, true) != Flag::SUCCESS) status = false;
} else if (flag->is_uint64_t()) {
uint64_t value = flag->get_uint64_t();
if (constraint->apply_uint64_t(&value, true) != Flag::SUCCESS) status = false;
if (constraint->apply_uint64_t(value, true) != Flag::SUCCESS) status = false;
} else if (flag->is_size_t()) {
size_t value = flag->get_size_t();
if (constraint->apply_size_t(&value, true) != Flag::SUCCESS) status = false;
if (constraint->apply_size_t(value, true) != Flag::SUCCESS) status = false;
} else if (flag->is_double()) {
double value = flag->get_double();
if (constraint->apply_double(&value, true) != Flag::SUCCESS) status = false;
if (constraint->apply_double(value, true) != Flag::SUCCESS) status = false;
}
}
}

View File

@ -39,14 +39,14 @@
* "runtime/commandLineFlagConstraintsRuntime.hpp" for the functions themselves.
*/
typedef Flag::Error (*CommandLineFlagConstraintFunc_bool)(bool verbose, bool* value);
typedef Flag::Error (*CommandLineFlagConstraintFunc_int)(bool verbose, int* value);
typedef Flag::Error (*CommandLineFlagConstraintFunc_intx)(bool verbose, intx* value);
typedef Flag::Error (*CommandLineFlagConstraintFunc_uint)(bool verbose, uint* value);
typedef Flag::Error (*CommandLineFlagConstraintFunc_uintx)(bool verbose, uintx* value);
typedef Flag::Error (*CommandLineFlagConstraintFunc_uint64_t)(bool verbose, uint64_t* value);
typedef Flag::Error (*CommandLineFlagConstraintFunc_size_t)(bool verbose, size_t* value);
typedef Flag::Error (*CommandLineFlagConstraintFunc_double)(bool verbose, double* value);
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<mtInternal> {
public:
@ -70,14 +70,14 @@ public:
~CommandLineFlagConstraint() {};
const char* name() const { return _name; }
ConstraintType type() const { return _validate_type; }
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; };
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 {

View File

@ -25,17 +25,16 @@
#include "precompiled.hpp"
#include "runtime/arguments.hpp"
#include "runtime/commandLineFlagConstraintsCompiler.hpp"
#include "runtime/commandLineFlagRangeList.hpp"
#include "runtime/globals.hpp"
#include "utilities/defaultStream.hpp"
Flag::Error AliasLevelConstraintFunc(bool verbose, intx* value) {
if ((*value <= 1) && (Arguments::mode() == Arguments::_comp)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"AliasLevel (" INTX_FORMAT ") is not compatible "
"with -Xcomp \n",
*value);
}
Flag::Error AliasLevelConstraintFunc(intx value, bool verbose) {
if ((value <= 1) && (Arguments::mode() == Arguments::_comp)) {
CommandLineError::print(verbose,
"AliasLevel (" INTX_FORMAT ") is not "
"compatible with -Xcomp \n",
value);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
@ -57,7 +56,7 @@ Flag::Error AliasLevelConstraintFunc(bool verbose, intx* value) {
* 'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result,
* the minimum number of compiler threads is 2.
*/
Flag::Error CICompilerCountConstraintFunc(bool verbose, intx* value) {
Flag::Error CICompilerCountConstraintFunc(intx value, bool verbose) {
int min_number_of_compiler_threads = 0;
#if !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK)
// case 1
@ -75,12 +74,11 @@ Flag::Error CICompilerCountConstraintFunc(bool verbose, intx* value) {
// min_number_of_compiler_threads to exceed CI_COMPILER_COUNT.
min_number_of_compiler_threads = MIN2(min_number_of_compiler_threads, CI_COMPILER_COUNT);
if (*value < (intx)min_number_of_compiler_threads) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"CICompilerCount=" INTX_FORMAT " must be at least %d \n",
*value, min_number_of_compiler_threads);
}
if (value < (intx)min_number_of_compiler_threads) {
CommandLineError::print(verbose,
"CICompilerCount (" INTX_FORMAT ") must be "
"at least %d \n",
value, min_number_of_compiler_threads);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;

View File

@ -34,8 +34,8 @@
* an appropriate error value.
*/
Flag::Error AliasLevelConstraintFunc(bool verbose, intx* value);
Flag::Error AliasLevelConstraintFunc(intx value, bool verbose);
Flag::Error CICompilerCountConstraintFunc(bool verbose, intx* value);
Flag::Error CICompilerCountConstraintFunc(intx value, bool verbose);
#endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSCOMPILER_HPP */

View File

@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "runtime/arguments.hpp"
#include "runtime/commandLineFlagConstraintsGC.hpp"
#include "runtime/commandLineFlagRangeList.hpp"
#include "runtime/globals.hpp"
#include "utilities/defaultStream.hpp"
@ -41,97 +42,85 @@
#include "opto/c2_globals.hpp"
#endif // COMPILER2
static Flag::Error MinPLABSizeBounds(const char* name, bool verbose, size_t* value) {
static Flag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) {
#if INCLUDE_ALL_GCS
if ((UseConcMarkSweepGC || UseG1GC) && (*value < PLAB::min_size())) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"%s (" SIZE_FORMAT ") must be greater than "
"ergonomic PLAB minimum size (" SIZE_FORMAT ")\n",
name, *value, PLAB::min_size());
}
if ((UseConcMarkSweepGC || UseG1GC) && (value < PLAB::min_size())) {
CommandLineError::print(verbose,
"%s (" SIZE_FORMAT ") must be "
"greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n",
name, value, PLAB::min_size());
return Flag::VIOLATES_CONSTRAINT;
}
#endif // INCLUDE_ALL_GCS
return Flag::SUCCESS;
}
static Flag::Error MaxPLABSizeBounds(const char* name, bool verbose, size_t* value) {
static Flag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
#if INCLUDE_ALL_GCS
if ((UseConcMarkSweepGC || UseG1GC) && (*value > PLAB::max_size())) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"%s (" SIZE_FORMAT ") must be less than "
"ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
name, *value, PLAB::max_size());
}
if ((UseConcMarkSweepGC || UseG1GC) && (value > PLAB::max_size())) {
CommandLineError::print(verbose,
"%s (" SIZE_FORMAT ") must be "
"less than ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
name, value, PLAB::min_size());
return Flag::VIOLATES_CONSTRAINT;
}
#endif // INCLUDE_ALL_GCS
return Flag::SUCCESS;
}
static Flag::Error MinMaxPLABSizeBounds(const char* name, bool verbose, size_t* value) {
if (MinPLABSizeBounds(name, verbose, value) == Flag::SUCCESS) {
return MaxPLABSizeBounds(name, verbose, value);
static Flag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
if (MinPLABSizeBounds(name, value, verbose) == Flag::SUCCESS) {
return MaxPLABSizeBounds(name, value, verbose);
}
return Flag::VIOLATES_CONSTRAINT;
}
Flag::Error YoungPLABSizeConstraintFunc(bool verbose, size_t* value) {
return MinMaxPLABSizeBounds("YoungPLABSize", verbose, value);
Flag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) {
return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose);
}
Flag::Error MinHeapFreeRatioConstraintFunc(bool verbose, uintx* value) {
if (*value > MaxHeapFreeRatio) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
"equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
*value, MaxHeapFreeRatio);
}
Flag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
if (value > MaxHeapFreeRatio) {
CommandLineError::print(verbose,
"MinHeapFreeRatio (" UINTX_FORMAT ") must be "
"less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
value, MaxHeapFreeRatio);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
}
}
Flag::Error MaxHeapFreeRatioConstraintFunc(bool verbose, uintx* value) {
if (*value < MinHeapFreeRatio) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
"equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
*value, MinHeapFreeRatio);
}
Flag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
if (value < MinHeapFreeRatio) {
CommandLineError::print(verbose,
"MaxHeapFreeRatio (" UINTX_FORMAT ") must be "
"greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
value, MinHeapFreeRatio);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
}
}
Flag::Error MinMetaspaceFreeRatioConstraintFunc(bool verbose, uintx* value) {
if (*value > MaxMetaspaceFreeRatio) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be less than or "
"equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
*value, MaxMetaspaceFreeRatio);
}
Flag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
if (value > MaxMetaspaceFreeRatio) {
CommandLineError::print(verbose,
"MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
"less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
value, MaxMetaspaceFreeRatio);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
}
}
Flag::Error MaxMetaspaceFreeRatioConstraintFunc(bool verbose, uintx* value) {
if (*value < MinMetaspaceFreeRatio) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be greater than or "
"equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
*value, MinMetaspaceFreeRatio);
}
Flag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
if (value < MinMetaspaceFreeRatio) {
CommandLineError::print(verbose,
"MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
"greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
value, MinMetaspaceFreeRatio);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
@ -147,32 +136,28 @@ Flag::Error MaxMetaspaceFreeRatioConstraintFunc(bool verbose, uintx* value) {
} \
}
Flag::Error InitialTenuringThresholdConstraintFunc(bool verbose, uintx* value) {
UseConcMarkSweepGCWorkaroundIfNeeded(*value, MaxTenuringThreshold);
Flag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) {
UseConcMarkSweepGCWorkaroundIfNeeded(value, MaxTenuringThreshold);
if (*value > MaxTenuringThreshold) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"InitialTenuringThreshold (" UINTX_FORMAT ") must be less than or "
"equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n",
*value, MaxTenuringThreshold);
}
if (value > MaxTenuringThreshold) {
CommandLineError::print(verbose,
"InitialTenuringThreshold (" UINTX_FORMAT ") must be "
"less than or equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n",
value, MaxTenuringThreshold);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
}
}
Flag::Error MaxTenuringThresholdConstraintFunc(bool verbose, uintx* value) {
UseConcMarkSweepGCWorkaroundIfNeeded(InitialTenuringThreshold, *value);
Flag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) {
UseConcMarkSweepGCWorkaroundIfNeeded(InitialTenuringThreshold, value);
if (*value < InitialTenuringThreshold) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"MaxTenuringThreshold (" UINTX_FORMAT ") must be greater than or "
"equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n",
*value, InitialTenuringThreshold);
}
if (value < InitialTenuringThreshold) {
CommandLineError::print(verbose,
"MaxTenuringThreshold (" UINTX_FORMAT ") must be "
"greater than or equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n",
value, InitialTenuringThreshold);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
@ -180,28 +165,24 @@ Flag::Error MaxTenuringThresholdConstraintFunc(bool verbose, uintx* value) {
}
#if INCLUDE_ALL_GCS
Flag::Error G1NewSizePercentConstraintFunc(bool verbose, uintx* value) {
if (*value > G1MaxNewSizePercent) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"G1NewSizePercent (" UINTX_FORMAT ") must be less than or "
"equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n",
*value, G1MaxNewSizePercent);
}
Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) {
if (value > G1MaxNewSizePercent) {
CommandLineError::print(verbose,
"G1NewSizePercent (" UINTX_FORMAT ") must be "
"less than or equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n",
value, G1MaxNewSizePercent);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
}
}
Flag::Error G1MaxNewSizePercentConstraintFunc(bool verbose, uintx* value) {
if (*value < G1NewSizePercent) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"G1MaxNewSizePercent (" UINTX_FORMAT ") must be greater than or "
"equal to G1NewSizePercent (" UINTX_FORMAT ")\n",
*value, G1NewSizePercent);
}
Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) {
if (value < G1NewSizePercent) {
CommandLineError::print(verbose,
"G1MaxNewSizePercent (" UINTX_FORMAT ") must be "
"greater than or equal to G1NewSizePercent (" UINTX_FORMAT ")\n",
value, G1NewSizePercent);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
@ -210,65 +191,56 @@ Flag::Error G1MaxNewSizePercentConstraintFunc(bool verbose, uintx* value) {
#endif // INCLUDE_ALL_GCS
Flag::Error CMSOldPLABMinConstraintFunc(bool verbose, size_t* value) {
if (*value > CMSOldPLABMax) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"CMSOldPLABMin (" SIZE_FORMAT ") must be less than or "
"equal to CMSOldPLABMax (" SIZE_FORMAT ")\n",
*value, CMSOldPLABMax);
}
Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) {
if (value > CMSOldPLABMax) {
CommandLineError::print(verbose,
"CMSOldPLABMin (" SIZE_FORMAT ") must be "
"less than or equal to CMSOldPLABMax (" SIZE_FORMAT ")\n",
value, CMSOldPLABMax);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
}
}
Flag::Error CMSPrecleanDenominatorConstraintFunc(bool verbose, uintx* value) {
if (*value <= CMSPrecleanNumerator) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"CMSPrecleanDenominator (" UINTX_FORMAT ") must be strickly greater than "
"CMSPrecleanNumerator (" UINTX_FORMAT ")\n",
*value, CMSPrecleanNumerator);
}
Flag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose) {
if (value <= CMSPrecleanNumerator) {
CommandLineError::print(verbose,
"CMSPrecleanDenominator (" UINTX_FORMAT ") must be "
"strickly greater than CMSPrecleanNumerator (" UINTX_FORMAT ")\n",
value, CMSPrecleanNumerator);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
}
}
Flag::Error CMSPrecleanNumeratorConstraintFunc(bool verbose, uintx* value) {
if (*value > (CMSPrecleanDenominator - 1)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"CMSPrecleanNumerator (" UINTX_FORMAT ") must be less than or "
"equal to CMSPrecleanDenominator - 1 (" UINTX_FORMAT ")\n", *value,
CMSPrecleanDenominator - 1);
}
Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose) {
if (value > (CMSPrecleanDenominator - 1)) {
CommandLineError::print(verbose,
"CMSPrecleanNumerator (" UINTX_FORMAT ") must be "
"less than or equal to CMSPrecleanDenominator - 1 (" UINTX_FORMAT ")\n",
value, CMSPrecleanDenominator - 1);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;
}
}
Flag::Error SurvivorAlignmentInBytesConstraintFunc(bool verbose, intx* value) {
if (*value != 0) {
if (!is_power_of_2(*value)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be power of 2\n",
*value);
}
Flag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
if (value != 0) {
if (!is_power_of_2(value)) {
CommandLineError::print(verbose,
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
"power of 2\n",
value);
return Flag::VIOLATES_CONSTRAINT;
}
if (*value < ObjectAlignmentInBytes) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be greater than or "
"equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
*value, ObjectAlignmentInBytes);
}
if (value < ObjectAlignmentInBytes) {
CommandLineError::print(verbose,
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
"greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
value, ObjectAlignmentInBytes);
return Flag::VIOLATES_CONSTRAINT;
}
}

View File

@ -34,27 +34,27 @@
* an appropriate error value.
*/
Flag::Error YoungPLABSizeConstraintFunc(bool verbose, size_t* value);
Flag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose);
Flag::Error MinHeapFreeRatioConstraintFunc(bool verbose, uintx* value);
Flag::Error MaxHeapFreeRatioConstraintFunc(bool verbose, uintx* value);
Flag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose);
Flag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose);
Flag::Error MinMetaspaceFreeRatioConstraintFunc(bool verbose, uintx* value);
Flag::Error MaxMetaspaceFreeRatioConstraintFunc(bool verbose, uintx* value);
Flag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose);
Flag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose);
Flag::Error InitialTenuringThresholdConstraintFunc(bool verbose, uintx* value);
Flag::Error MaxTenuringThresholdConstraintFunc(bool verbose, uintx* value);
Flag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose);
Flag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose);
#if INCLUDE_ALL_GCS
Flag::Error G1NewSizePercentConstraintFunc(bool verbose, uintx* value);
Flag::Error G1MaxNewSizePercentConstraintFunc(bool verbose, uintx* value);
Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose);
Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose);
#endif // INCLUDE_ALL_GCS
Flag::Error CMSOldPLABMinConstraintFunc(bool verbose, size_t* value);
Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose);
Flag::Error CMSPrecleanDenominatorConstraintFunc(bool verbose, uintx* value);
Flag::Error CMSPrecleanNumeratorConstraintFunc(bool verbose, uintx* value);
Flag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose);
Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose);
Flag::Error SurvivorAlignmentInBytesConstraintFunc(bool verbose, intx* value);
Flag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose);
#endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSGC_HPP */

View File

@ -25,25 +25,24 @@
#include "precompiled.hpp"
#include "runtime/arguments.hpp"
#include "runtime/commandLineFlagConstraintsRuntime.hpp"
#include "runtime/commandLineFlagRangeList.hpp"
#include "runtime/globals.hpp"
#include "utilities/defaultStream.hpp"
Flag::Error ObjectAlignmentInBytesConstraintFunc(bool verbose, intx* value) {
if (!is_power_of_2(*value)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"ObjectAlignmentInBytes=" INTX_FORMAT " must be power of 2\n",
*value);
}
Flag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) {
if (!is_power_of_2(value)) {
CommandLineError::print(verbose,
"ObjectAlignmentInBytes (" INTX_FORMAT ") must be "
"power of 2\n",
value);
return Flag::VIOLATES_CONSTRAINT;
}
// In case page size is very small.
if (*value >= (intx)os::vm_page_size()) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"ObjectAlignmentInBytes=" INTX_FORMAT " must be less than page size " INTX_FORMAT "\n",
*value, (intx)os::vm_page_size());
}
if (value >= (intx)os::vm_page_size()) {
CommandLineError::print(verbose,
"ObjectAlignmentInBytes (" INTX_FORMAT ") must be "
"less than page size " INTX_FORMAT "\n",
value, (intx)os::vm_page_size());
return Flag::VIOLATES_CONSTRAINT;
}
return Flag::SUCCESS;
@ -51,13 +50,12 @@ Flag::Error ObjectAlignmentInBytesConstraintFunc(bool verbose, intx* value) {
// Need to enforce the padding not to break the existing field alignments.
// It is sufficient to check against the largest type size.
Flag::Error ContendedPaddingWidthConstraintFunc(bool verbose, intx* value) {
if ((*value != 0) && ((*value % BytesPerLong) != 0)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"ContendedPaddingWidth=" INTX_FORMAT " must be a multiple of %d\n",
*value, BytesPerLong);
}
Flag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose) {
if ((value != 0) && ((value % BytesPerLong) != 0)) {
CommandLineError::print(verbose,
"ContendedPaddingWidth (" INTX_FORMAT ") must be "
"a multiple of %d\n",
value, BytesPerLong);
return Flag::VIOLATES_CONSTRAINT;
} else {
return Flag::SUCCESS;

View File

@ -34,8 +34,8 @@
* an appropriate error value.
*/
Flag::Error ObjectAlignmentInBytesConstraintFunc(bool verbose, intx* value);
Flag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose);
Flag::Error ContendedPaddingWidthConstraintFunc(bool verbose, intx* value);
Flag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose);
#endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSRUNTIME_HPP */

View File

@ -32,6 +32,15 @@
#include "utilities/defaultStream.hpp"
#include "utilities/macros.hpp"
void CommandLineError::print(bool verbose, const char* msg, ...) {
if (verbose) {
va_list listPointer;
va_start(listPointer, msg);
jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
va_end(listPointer);
}
}
class CommandLineFlagRange_int : public CommandLineFlagRange {
int _min;
int _max;
@ -44,11 +53,10 @@ public:
Flag::Error check_int(int value, bool verbose = true) {
if ((value < _min) || (value > _max)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"int %s=%d is outside the allowed range [ %d ... %d ]\n",
CommandLineError::print(verbose,
"int %s=%d is outside the allowed range "
"[ %d ... %d ]\n",
name(), value, _min, _max);
}
return Flag::OUT_OF_BOUNDS;
} else {
return Flag::SUCCESS;
@ -72,11 +80,10 @@ public:
Flag::Error check_intx(intx value, bool verbose = true) {
if ((value < _min) || (value > _max)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"intx %s=" INTX_FORMAT " is outside the allowed range [ " INTX_FORMAT " ... " INTX_FORMAT " ]\n",
CommandLineError::print(verbose,
"intx %s=" INTX_FORMAT " is outside the allowed range "
"[ " INTX_FORMAT " ... " INTX_FORMAT " ]\n",
name(), value, _min, _max);
}
return Flag::OUT_OF_BOUNDS;
} else {
return Flag::SUCCESS;
@ -100,11 +107,10 @@ public:
Flag::Error check_uint(uint value, bool verbose = true) {
if ((value < _min) || (value > _max)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"uintx %s=%u is outside the allowed range [ %u ... %u ]\n",
CommandLineError::print(verbose,
"uint %s=%u is outside the allowed range "
"[ %u ... %u ]\n",
name(), value, _min, _max);
}
return Flag::OUT_OF_BOUNDS;
} else {
return Flag::SUCCESS;
@ -128,11 +134,10 @@ public:
Flag::Error check_uintx(uintx value, bool verbose = true) {
if ((value < _min) || (value > _max)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"uintx %s=" UINTX_FORMAT " is outside the allowed range [ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n",
CommandLineError::print(verbose,
"uintx %s=" UINTX_FORMAT " is outside the allowed range "
"[ " UINTX_FORMAT " ... " UINTX_FORMAT " ]\n",
name(), value, _min, _max);
}
return Flag::OUT_OF_BOUNDS;
} else {
return Flag::SUCCESS;
@ -156,11 +161,10 @@ public:
Flag::Error check_uint64_t(uint64_t value, bool verbose = true) {
if ((value < _min) || (value > _max)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"uint64_t %s=" UINT64_FORMAT " is outside the allowed range [ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n",
CommandLineError::print(verbose,
"uint64_t %s=" UINT64_FORMAT " is outside the allowed range "
"[ " UINT64_FORMAT " ... " UINT64_FORMAT " ]\n",
name(), value, _min, _max);
}
return Flag::OUT_OF_BOUNDS;
} else {
return Flag::SUCCESS;
@ -184,11 +188,10 @@ public:
Flag::Error check_size_t(size_t value, bool verbose = true) {
if ((value < _min) || (value > _max)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"size_t %s=" SIZE_FORMAT " is outside the allowed range [ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n",
CommandLineError::print(verbose,
"size_t %s=" SIZE_FORMAT " is outside the allowed range "
"[ " SIZE_FORMAT " ... " SIZE_FORMAT " ]\n",
name(), value, _min, _max);
}
return Flag::OUT_OF_BOUNDS;
} else {
return Flag::SUCCESS;
@ -212,11 +215,10 @@ public:
Flag::Error check_double(double value, bool verbose = true) {
if ((value < _min) || (value > _max)) {
if (verbose == true) {
jio_fprintf(defaultStream::error_stream(),
"double %s=%f is outside the allowed range [ %f ... %f ]\n",
CommandLineError::print(verbose,
"double %s=%f is outside the allowed range "
"[ %f ... %f ]\n",
name(), value, _min, _max);
}
return Flag::OUT_OF_BOUNDS;
} else {
return Flag::SUCCESS;
@ -367,45 +369,23 @@ void CommandLineFlagRangeList::print(const char* name, outputStream* st, bool un
}
bool CommandLineFlagRangeList::check_ranges() {
//#define PRINT_RANGES_SIZES
#ifdef PRINT_RANGES_SIZES
{
size_t size_ranges = sizeof(CommandLineFlagRangeList);
for (int i=0; i<length(); i++) {
size_ranges += sizeof(CommandLineFlagRange);
CommandLineFlagRange* range = at(i);
const char* name = range->name();
Flag* flag = Flag::find_flag(name, strlen(name), true, true);
if (flag->is_intx()) {
size_ranges += 2*sizeof(intx);
size_ranges += sizeof(CommandLineFlagRange*);
} else if (flag->is_uintx()) {
size_ranges += 2*sizeof(uintx);
size_ranges += sizeof(CommandLineFlagRange*);
} else if (flag->is_uint64_t()) {
size_ranges += 2*sizeof(uint64_t);
size_ranges += sizeof(CommandLineFlagRange*);
} else if (flag->is_size_t()) {
size_ranges += 2*sizeof(size_t);
size_ranges += sizeof(CommandLineFlagRange*);
} else if (flag->is_double()) {
size_ranges += 2*sizeof(double);
size_ranges += sizeof(CommandLineFlagRange*);
}
}
fprintf(stderr, "Size of %d ranges: " SIZE_FORMAT " bytes\n",
length(), size_ranges);
}
#endif // PRINT_RANGES_SIZES
// Check ranges.
bool status = true;
for (int i=0; i<length(); i++) {
CommandLineFlagRange* range = at(i);
const char* name = range->name();
Flag* flag = Flag::find_flag(name, strlen(name), true, true);
// We must check for NULL here as lp64_product flags on 32 bit architecture
// can generate range check (despite that they are declared as constants),
// but they will not be returned by Flag::find_flag()
if (flag != NULL) {
if (flag->is_intx()) {
if (flag->is_int()) {
int value = flag->get_int();
if (range->check_int(value, true) != Flag::SUCCESS) status = false;
} else if (flag->is_uint()) {
uint value = flag->get_uint();
if (range->check_uint(value, true) != Flag::SUCCESS) status = false;
} else if (flag->is_intx()) {
intx value = flag->get_intx();
if (range->check_intx(value, true) != Flag::SUCCESS) status = false;
} else if (flag->is_uintx()) {

View File

@ -38,6 +38,11 @@
* then we need to use constraint instead.
*/
class CommandLineError : public AllStatic {
public:
static void print(bool verbose, const char* msg, ...);
};
class CommandLineFlagRange : public CHeapObj<mtInternal> {
private:
const char* _name;

View File

@ -515,6 +515,20 @@ void Flag::print_as_flag(outputStream* st) {
}
}
const char* Flag::flag_error_str(Flag::Error error) {
switch (error) {
case Flag::MISSING_NAME: return "MISSING_NAME";
case Flag::MISSING_VALUE: return "MISSING_VALUE";
case Flag::NON_WRITABLE: return "NON_WRITABLE";
case Flag::OUT_OF_BOUNDS: return "OUT_OF_BOUNDS";
case Flag::VIOLATES_CONSTRAINT: return "VIOLATES_CONSTRAINT";
case Flag::INVALID_FLAG: return "INVALID_FLAG";
case Flag::ERR_OTHER: return "ERR_OTHER";
case Flag::SUCCESS: return "SUCCESS";
default: ShouldNotReachHere(); return "NULL";
}
}
// 4991491 do not "optimize out" the was_set false values: omitting them
// tickles a Microsoft compiler bug causing flagTable to be malformed
@ -758,17 +772,7 @@ static void trace_flag_changed(const char* name, const T old_value, const T new_
e.commit();
}
static Flag::Error get_status_error(Flag::Error status_range, Flag::Error status_constraint) {
if (status_range != Flag::SUCCESS) {
return status_range;
} else if (status_constraint != Flag::SUCCESS) {
return status_constraint;
} else {
return Flag::SUCCESS;
}
}
static Flag::Error apply_constraint_and_check_range_bool(const char* name, bool* new_value, bool verbose = true) {
static Flag::Error apply_constraint_and_check_range_bool(const char* name, bool new_value, bool verbose = true) {
Flag::Error status = Flag::SUCCESS;
CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
if (constraint != NULL) {
@ -789,7 +793,7 @@ Flag::Error CommandLineFlags::boolAtPut(const char* name, size_t len, bool* valu
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return Flag::INVALID_FLAG;
if (!result->is_bool()) return Flag::WRONG_FORMAT;
Flag::Error check = apply_constraint_and_check_range_bool(name, value, !CommandLineFlagConstraintList::validated_after_ergo());
Flag::Error check = apply_constraint_and_check_range_bool(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
if (check != Flag::SUCCESS) return check;
bool old_value = result->get_bool();
trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin);
@ -802,7 +806,7 @@ Flag::Error CommandLineFlags::boolAtPut(const char* name, size_t len, bool* valu
Flag::Error CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
Flag::Error check = apply_constraint_and_check_range_bool(faddr->_name, &value);
Flag::Error check = apply_constraint_and_check_range_bool(faddr->_name, value);
if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventBooleanFlagChanged, bool>(faddr->_name, faddr->get_bool(), value, origin);
faddr->set_bool(value);
@ -810,18 +814,19 @@ Flag::Error CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool val
return Flag::SUCCESS;
}
static Flag::Error apply_constraint_and_check_range_int(const char* name, int* new_value, bool verbose = true) {
Flag::Error range_status = Flag::SUCCESS;
static Flag::Error apply_constraint_and_check_range_int(const char* name, int new_value, bool verbose = true) {
Flag::Error status = Flag::SUCCESS;
CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
if (range != NULL) {
range_status = range->check_int(*new_value, verbose);
status = range->check_int(new_value, verbose);
}
Flag::Error constraint_status = Flag::SUCCESS;
if (status == Flag::SUCCESS) {
CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
if (constraint != NULL) {
constraint_status = constraint->apply_int(new_value, verbose);
status = constraint->apply_int(new_value, verbose);
}
return get_status_error(range_status, constraint_status);
}
return status;
}
Flag::Error CommandLineFlags::intAt(const char* name, size_t len, int* value, bool allow_locked, bool return_flag) {
@ -836,7 +841,7 @@ Flag::Error CommandLineFlags::intAtPut(const char* name, size_t len, int* value,
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return Flag::INVALID_FLAG;
if (!result->is_int()) return Flag::WRONG_FORMAT;
Flag::Error check = apply_constraint_and_check_range_int(name, value, !CommandLineFlagConstraintList::validated_after_ergo());
Flag::Error check = apply_constraint_and_check_range_int(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
if (check != Flag::SUCCESS) return check;
int old_value = result->get_int();
trace_flag_changed<EventIntFlagChanged, s4>(name, old_value, *value, origin);
@ -849,24 +854,27 @@ Flag::Error CommandLineFlags::intAtPut(const char* name, size_t len, int* value,
Flag::Error CommandLineFlagsEx::intAtPut(CommandLineFlagWithType flag, int value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_int(), "wrong flag type");
Flag::Error check = apply_constraint_and_check_range_int(faddr->_name, value, !CommandLineFlagConstraintList::validated_after_ergo());
if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventIntFlagChanged, s4>(faddr->_name, faddr->get_int(), value, origin);
faddr->set_int(value);
faddr->set_origin(origin);
return Flag::SUCCESS;
}
static Flag::Error apply_constraint_and_check_range_uint(const char* name, uint* new_value, bool verbose = true) {
Flag::Error range_status = Flag::SUCCESS;
static Flag::Error apply_constraint_and_check_range_uint(const char* name, uint new_value, bool verbose = true) {
Flag::Error status = Flag::SUCCESS;
CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
if (range != NULL) {
range_status = range->check_uint(*new_value, verbose);
status = range->check_uint(new_value, verbose);
}
Flag::Error constraint_status = Flag::SUCCESS;
if (status == Flag::SUCCESS) {
CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
if (constraint != NULL) {
constraint_status = constraint->apply_uint(new_value, verbose);
status = constraint->apply_uint(new_value, verbose);
}
return get_status_error(range_status, constraint_status);
}
return status;
}
Flag::Error CommandLineFlags::uintAt(const char* name, size_t len, uint* value, bool allow_locked, bool return_flag) {
@ -881,7 +889,7 @@ Flag::Error CommandLineFlags::uintAtPut(const char* name, size_t len, uint* valu
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return Flag::INVALID_FLAG;
if (!result->is_uint()) return Flag::WRONG_FORMAT;
Flag::Error check = apply_constraint_and_check_range_uint(name, value, !CommandLineFlagConstraintList::validated_after_ergo());
Flag::Error check = apply_constraint_and_check_range_uint(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
if (check != Flag::SUCCESS) return check;
uint old_value = result->get_uint();
trace_flag_changed<EventUnsignedIntFlagChanged, u4>(name, old_value, *value, origin);
@ -894,6 +902,8 @@ Flag::Error CommandLineFlags::uintAtPut(const char* name, size_t len, uint* valu
Flag::Error CommandLineFlagsEx::uintAtPut(CommandLineFlagWithType flag, uint value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_uint(), "wrong flag type");
Flag::Error check = apply_constraint_and_check_range_uint(faddr->_name, value, !CommandLineFlagConstraintList::validated_after_ergo());
if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventUnsignedIntFlagChanged, u4>(faddr->_name, faddr->get_uint(), value, origin);
faddr->set_uint(value);
faddr->set_origin(origin);
@ -908,25 +918,26 @@ Flag::Error CommandLineFlags::intxAt(const char* name, size_t len, intx* value,
return Flag::SUCCESS;
}
static Flag::Error apply_constraint_and_check_range_intx(const char* name, intx* new_value, bool verbose = true) {
Flag::Error range_status = Flag::SUCCESS;
static Flag::Error apply_constraint_and_check_range_intx(const char* name, intx new_value, bool verbose = true) {
Flag::Error status = Flag::SUCCESS;
CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
if (range != NULL) {
range_status = range->check_intx(*new_value, verbose);
status = range->check_intx(new_value, verbose);
}
Flag::Error constraint_status = Flag::SUCCESS;
if (status == Flag::SUCCESS) {
CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
if (constraint != NULL) {
constraint_status = constraint->apply_intx(new_value, verbose);
status = constraint->apply_intx(new_value, verbose);
}
return get_status_error(range_status, constraint_status);
}
return status;
}
Flag::Error CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return Flag::INVALID_FLAG;
if (!result->is_intx()) return Flag::WRONG_FORMAT;
Flag::Error check = apply_constraint_and_check_range_intx(name, value, !CommandLineFlagConstraintList::validated_after_ergo());
Flag::Error check = apply_constraint_and_check_range_intx(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
if (check != Flag::SUCCESS) return check;
intx old_value = result->get_intx();
trace_flag_changed<EventLongFlagChanged, intx>(name, old_value, *value, origin);
@ -939,7 +950,7 @@ Flag::Error CommandLineFlags::intxAtPut(const char* name, size_t len, intx* valu
Flag::Error CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
Flag::Error check = apply_constraint_and_check_range_intx(faddr->_name, &value);
Flag::Error check = apply_constraint_and_check_range_intx(faddr->_name, value);
if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventLongFlagChanged, intx>(faddr->_name, faddr->get_intx(), value, origin);
faddr->set_intx(value);
@ -955,25 +966,26 @@ Flag::Error CommandLineFlags::uintxAt(const char* name, size_t len, uintx* value
return Flag::SUCCESS;
}
static Flag::Error apply_constraint_and_check_range_uintx(const char* name, uintx* new_value, bool verbose = true) {
Flag::Error range_status = Flag::SUCCESS;
static Flag::Error apply_constraint_and_check_range_uintx(const char* name, uintx new_value, bool verbose = true) {
Flag::Error status = Flag::SUCCESS;
CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
if (range != NULL) {
range_status = range->check_uintx(*new_value, verbose);
status = range->check_uintx(new_value, verbose);
}
Flag::Error constraint_status = Flag::SUCCESS;
if (status == Flag::SUCCESS) {
CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
if (constraint != NULL) {
constraint_status = constraint->apply_uintx(new_value, verbose);
status = constraint->apply_uintx(new_value, verbose);
}
return get_status_error(range_status, constraint_status);
}
return status;
}
Flag::Error CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return Flag::INVALID_FLAG;
if (!result->is_uintx()) return Flag::WRONG_FORMAT;
Flag::Error check = apply_constraint_and_check_range_uintx(name, value, !CommandLineFlagConstraintList::validated_after_ergo());
Flag::Error check = apply_constraint_and_check_range_uintx(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
if (check != Flag::SUCCESS) return check;
uintx old_value = result->get_uintx();
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
@ -986,7 +998,7 @@ Flag::Error CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* va
Flag::Error CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
Flag::Error check = apply_constraint_and_check_range_uintx(faddr->_name, &value);
Flag::Error check = apply_constraint_and_check_range_uintx(faddr->_name, value);
if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uintx(), value, origin);
faddr->set_uintx(value);
@ -1002,25 +1014,26 @@ Flag::Error CommandLineFlags::uint64_tAt(const char* name, size_t len, uint64_t*
return Flag::SUCCESS;
}
static Flag::Error apply_constraint_and_check_range_uint64_t(const char* name, uint64_t* new_value, bool verbose = true) {
Flag::Error range_status = Flag::SUCCESS;
static Flag::Error apply_constraint_and_check_range_uint64_t(const char* name, uint64_t new_value, bool verbose = true) {
Flag::Error status = Flag::SUCCESS;
CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
if (range != NULL) {
range_status = range->check_uint64_t(*new_value, verbose);
status = range->check_uint64_t(new_value, verbose);
}
Flag::Error constraint_status = Flag::SUCCESS;
if (status == Flag::SUCCESS) {
CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
if (constraint != NULL) {
constraint_status = constraint->apply_uint64_t(new_value, verbose);
status = constraint->apply_uint64_t(new_value, verbose);
}
return get_status_error(range_status, constraint_status);
}
return status;
}
Flag::Error CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return Flag::INVALID_FLAG;
if (!result->is_uint64_t()) return Flag::WRONG_FORMAT;
Flag::Error check = apply_constraint_and_check_range_uint64_t(name, value, !CommandLineFlagConstraintList::validated_after_ergo());
Flag::Error check = apply_constraint_and_check_range_uint64_t(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
if (check != Flag::SUCCESS) return check;
uint64_t old_value = result->get_uint64_t();
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
@ -1033,7 +1046,7 @@ Flag::Error CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64
Flag::Error CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
Flag::Error check = apply_constraint_and_check_range_uint64_t(faddr->_name, &value);
Flag::Error check = apply_constraint_and_check_range_uint64_t(faddr->_name, value);
if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uint64_t(), value, origin);
faddr->set_uint64_t(value);
@ -1049,25 +1062,26 @@ Flag::Error CommandLineFlags::size_tAt(const char* name, size_t len, size_t* val
return Flag::SUCCESS;
}
static Flag::Error apply_constraint_and_check_range_size_t(const char* name, size_t* new_value, bool verbose = true) {
Flag::Error range_status = Flag::SUCCESS;
static Flag::Error apply_constraint_and_check_range_size_t(const char* name, size_t new_value, bool verbose = true) {
Flag::Error status = Flag::SUCCESS;
CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
if (range != NULL) {
range_status = range->check_size_t(*new_value, verbose);
status = range->check_size_t(new_value, verbose);
}
Flag::Error constraint_status = Flag::SUCCESS;
if (status == Flag::SUCCESS) {
CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
if (constraint != NULL) {
constraint_status = constraint->apply_size_t(new_value, verbose);
status = constraint->apply_size_t(new_value, verbose);
}
return get_status_error(range_status, constraint_status);
}
return status;
}
Flag::Error CommandLineFlags::size_tAtPut(const char* name, size_t len, size_t* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return Flag::INVALID_FLAG;
if (!result->is_size_t()) return Flag::WRONG_FORMAT;
Flag::Error check = apply_constraint_and_check_range_size_t(name, value, !CommandLineFlagConstraintList::validated_after_ergo());
Flag::Error check = apply_constraint_and_check_range_size_t(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
if (check != Flag::SUCCESS) return check;
size_t old_value = result->get_size_t();
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
@ -1080,7 +1094,7 @@ Flag::Error CommandLineFlags::size_tAtPut(const char* name, size_t len, size_t*
Flag::Error CommandLineFlagsEx::size_tAtPut(CommandLineFlagWithType flag, size_t value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_size_t(), "wrong flag type");
Flag::Error check = apply_constraint_and_check_range_size_t(faddr->_name, &value);
Flag::Error check = apply_constraint_and_check_range_size_t(faddr->_name, value);
if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_size_t(), value, origin);
faddr->set_size_t(value);
@ -1096,25 +1110,26 @@ Flag::Error CommandLineFlags::doubleAt(const char* name, size_t len, double* val
return Flag::SUCCESS;
}
static Flag::Error apply_constraint_and_check_range_double(const char* name, double* new_value, bool verbose = true) {
Flag::Error range_status = Flag::SUCCESS;
static Flag::Error apply_constraint_and_check_range_double(const char* name, double new_value, bool verbose = true) {
Flag::Error status = Flag::SUCCESS;
CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
if (range != NULL) {
range_status = range->check_double(*new_value, verbose);
status = range->check_double(new_value, verbose);
}
Flag::Error constraint_status = Flag::SUCCESS;
if (status == Flag::SUCCESS) {
CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name);
if (constraint != NULL) {
constraint_status = constraint->apply_double(new_value, verbose);
status = constraint->apply_double(new_value, verbose);
}
return get_status_error(range_status, constraint_status);
}
return status;
}
Flag::Error CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return Flag::INVALID_FLAG;
if (!result->is_double()) return Flag::WRONG_FORMAT;
Flag::Error check = apply_constraint_and_check_range_double(name, value, !CommandLineFlagConstraintList::validated_after_ergo());
Flag::Error check = apply_constraint_and_check_range_double(name, *value, !CommandLineFlagConstraintList::validated_after_ergo());
if (check != Flag::SUCCESS) return check;
double old_value = result->get_double();
trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
@ -1127,7 +1142,7 @@ Flag::Error CommandLineFlags::doubleAtPut(const char* name, size_t len, double*
Flag::Error CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
Flag::Error check = apply_constraint_and_check_range_double(faddr->_name, &value);
Flag::Error check = apply_constraint_and_check_range_double(faddr->_name, value);
if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventDoubleFlagChanged, double>(faddr->_name, faddr->get_double(), value, origin);
faddr->set_double(value);

View File

@ -372,19 +372,7 @@ struct Flag {
void print_kind(outputStream* st);
void print_as_flag(outputStream* st);
static const char* flag_error_str(Flag::Error error) {
switch (error) {
case Flag::MISSING_NAME: return "MISSING_NAME";
case Flag::MISSING_VALUE: return "MISSING_VALUE";
case Flag::NON_WRITABLE: return "NON_WRITABLE";
case Flag::OUT_OF_BOUNDS: return "OUT_OF_BOUNDS";
case Flag::VIOLATES_CONSTRAINT: return "VIOLATES_CONSTRAINT";
case Flag::INVALID_FLAG: return "INVALID_FLAG";
case Flag::ERR_OTHER: return "ERR_OTHER";
case Flag::SUCCESS: return "SUCCESS";
default: return "NULL";
}
}
static const char* flag_error_str(Flag::Error error);
};
// debug flags control various aspects of the VM and are global accessible
@ -1575,7 +1563,7 @@ public:
product(size_t, HeapSizePerGCThread, ScaleForWordSize(64*M), \
"Size of heap (bytes) per GC thread used in calculating the " \
"number of GC threads") \
range((uintx)os::vm_page_size(), max_uintx) \
range((size_t)os::vm_page_size(), (size_t)max_uintx) \
\
product(bool, TraceDynamicGCThreads, false, \
"Trace the dynamic GC thread usage") \
@ -1856,6 +1844,7 @@ public:
product(size_t, MarkStackSize, NOT_LP64(32*K) LP64_ONLY(4*M), \
"Size of marking stack") \
\
/* where does the range max value of (max_jint - 1) come from? */ \
product(size_t, MarkStackSizeMax, NOT_LP64(4*M) LP64_ONLY(512*M), \
"Maximum size of marking stack") \
range(1, (max_jint - 1)) \