Skip to content

Commit

Permalink
Contraints check for spark test
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyilin committed Oct 29, 2024
1 parent a1d7246 commit ab920bd
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 178 deletions.
9 changes: 3 additions & 6 deletions src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ JVMFlag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) {
JVMFlag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) {
if (!UseG1GC) return JVMFlag::SUCCESS;
if (value > G1MaxNewSizePercent) {
if (VerifyFlagConstraints)
{
if (VerifyFlagConstraints) {
G1NewSizePercent = G1MaxNewSizePercent;
JVMFlag::printError(true, "G1NewSizePercent:"UINTX_FORMAT"\n", G1MaxNewSizePercent);
return JVMFlag::SUCCESS;
Expand All @@ -112,8 +111,7 @@ JVMFlag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) {
JVMFlag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) {
if (!UseG1GC) return JVMFlag::SUCCESS;
if (value < G1NewSizePercent) {
if (VerifyFlagConstraints)
{
if (VerifyFlagConstraints) {
G1MaxNewSizePercent = G1NewSizePercent;
JVMFlag::printError(true, "G1MaxNewSizePercent:"UINTX_FORMAT"\n", G1NewSizePercent);
return JVMFlag::SUCCESS;
Expand All @@ -130,8 +128,7 @@ JVMFlag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) {

JVMFlag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose) {
if (UseG1GC && FLAG_IS_CMDLINE(MaxGCPauseMillis) && (value >= GCPauseIntervalMillis)) {
if (VerifyFlagConstraints)
{
if (VerifyFlagConstraints) {
if (GCPauseIntervalMillis <= 1) {
GCPauseIntervalMillis = 2;
JVMFlag::printError(true, "GCPauseIntervalMillis:"UINTX_FORMAT"\n", GCPauseIntervalMillis);
Expand Down
7 changes: 5 additions & 2 deletions src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ JVMFlag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose)
// So can't exceed with "max_jint"
if (UseParallelGC && (value > (uint)max_jint)) {
if (VerifyFlagConstraints) {
JVMFlag::printError(true, "ParallelGCThreads:"UINT32_FORMAT"\n", max_jint);
ParallelGCThreads = max_jint;
JVMFlag::printError(true, "ParallelGCThreads:"UINT32_FORMAT"\n", ParallelGCThreads);
return JVMFlag::SUCCESS;
}
JVMFlag::printError(verbose,
Expand All @@ -48,7 +49,8 @@ JVMFlag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool
// InitialTenuringThreshold is only used for ParallelGC.
if (UseParallelGC && (value > MaxTenuringThreshold)) {
if (VerifyFlagConstraints) {
JVMFlag::printError(true, "InitialTenuringThreshold"UINTX_FORMAT"\n", MaxTenuringThreshold);
InitialTenuringThreshold = MaxTenuringThreshold;
JVMFlag::printError(true, "InitialTenuringThreshold"UINTX_FORMAT"\n", InitialTenuringThreshold);
return JVMFlag::SUCCESS;
}
JVMFlag::printError(verbose,
Expand All @@ -65,6 +67,7 @@ JVMFlag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verb
// we don't need to compare InitialTenuringThreshold with MaxTenuringThreshold.
if (UseParallelGC && (value < InitialTenuringThreshold)) {
if (VerifyFlagConstraints) {
MaxTenuringThreshold = InitialTenuringThreshold;
JVMFlag::printError(true, "MaxTenuringThreshold"UINTX_FORMAT"\n", InitialTenuringThreshold);
return JVMFlag::SUCCESS;
}
Expand Down
22 changes: 12 additions & 10 deletions src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) {
if ((GCConfig::is_gc_selected(CollectedHeap::CMS) ||
GCConfig::is_gc_selected(CollectedHeap::G1)) && (value > ParallelGCThreads)) {
if (VerifyFlagConstraints) {
JVMFlag::printError(true, "ConcGCThreads"UINT32_FORMAT"\n", ParallelGCThreads);
ConcGCThreads = ParallelGCThreads;
JVMFlag::printError(true, "ConcGCThreads"UINT32_FORMAT"\n", ConcGCThreads);
return JVMFlag::SUCCESS;
}
JVMFlag::printError(verbose,
Expand Down Expand Up @@ -596,32 +597,33 @@ JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
JVMFlag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
if (value != 0) {
bool verifyFailed = false;
if (!is_power_of_2(value)) {
if (value < ObjectAlignmentInBytes) {
if (VerifyFlagConstraints) {
verifyFailed = true;
int logValue = log2_intptr(value);
value = (intx)pow(2, logValue);
value = ObjectAlignmentInBytes;
} else {
JVMFlag::printError(verbose,
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
"power of 2\n",
value);
"greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
value, ObjectAlignmentInBytes);
return JVMFlag::VIOLATES_CONSTRAINT;
}
}
if (value < ObjectAlignmentInBytes) {
if (!is_power_of_2(value)) {
if (VerifyFlagConstraints) {
verifyFailed = true;
value = ObjectAlignmentInBytes;
int logValue = log2_intptr(value);
value = (intx)pow(2, logValue);
} else {
JVMFlag::printError(verbose,
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
"greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
value, ObjectAlignmentInBytes);
"power of 2\n",
value);
return JVMFlag::VIOLATES_CONSTRAINT;
}
}
if (verifyFailed) {
SurvivorAlignmentInBytes = value;
JVMFlag::printError(true, "SurvivorAlignmentInBytes:"INTX_FORMAT"\n", value);
}
}
Expand Down
60 changes: 46 additions & 14 deletions src/hotspot/share/runtime/flags/jvmFlag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,16 @@ JVMFlag::Error JVMFlag::intAtPut(JVMFlag* flag, int* value, JVMFlag::Flags origi
if (flag == NULL) return JVMFlag::INVALID_FLAG;
if (!flag->is_int()) return JVMFlag::WRONG_FORMAT;
name = flag->_name;
int old_value = flag->get_int();
JVMFlag::Error check = apply_constraint_and_check_range_int(name, *value, !JVMFlagConstraintList::validated_after_ergo());
if (check != JVMFlag::SUCCESS) return check;
int old_value = flag->get_int();

trace_flag_changed<EventIntFlagChanged, s4>(name, old_value, *value, origin);
check = flag->set_int(*value);
if (VerifyFlagConstraints && old_value != flag->get_int()) {
check = JVMFlag::SUCCESS;
} else {
check = flag->set_int(*value);
}
*value = old_value;
flag->set_origin(origin);
return check;
Expand Down Expand Up @@ -1135,11 +1140,16 @@ JVMFlag::Error JVMFlag::uintAtPut(JVMFlag* flag, uint* value, JVMFlag::Flags ori
if (flag == NULL) return JVMFlag::INVALID_FLAG;
if (!flag->is_uint()) return JVMFlag::WRONG_FORMAT;
name = flag->_name;
uint old_value = flag->get_uint();
JVMFlag::Error check = apply_constraint_and_check_range_uint(name, *value, !JVMFlagConstraintList::validated_after_ergo());
if (check != JVMFlag::SUCCESS) return check;
uint old_value = flag->get_uint();

trace_flag_changed<EventUnsignedIntFlagChanged, u4>(name, old_value, *value, origin);
check = flag->set_uint(*value);
if (VerifyFlagConstraints && old_value != flag->get_uint()) {
check = JVMFlag::SUCCESS;
} else {
check = flag->set_uint(*value);
}
*value = old_value;
flag->set_origin(origin);
return check;
Expand Down Expand Up @@ -1184,11 +1194,16 @@ JVMFlag::Error JVMFlag::intxAtPut(JVMFlag* flag, intx* value, JVMFlag::Flags ori
if (flag == NULL) return JVMFlag::INVALID_FLAG;
if (!flag->is_intx()) return JVMFlag::WRONG_FORMAT;
name = flag->_name;
intx old_value = flag->get_intx();
JVMFlag::Error check = apply_constraint_and_check_range_intx(name, *value, !JVMFlagConstraintList::validated_after_ergo());
if (check != JVMFlag::SUCCESS) return check;
intx old_value = flag->get_intx();

trace_flag_changed<EventLongFlagChanged, intx>(name, old_value, *value, origin);
check = flag->set_intx(*value);
if (VerifyFlagConstraints && old_value != flag->get_intx()) {
check = JVMFlag::SUCCESS;
} else {
check = flag->set_intx(*value);
}
*value = old_value;
flag->set_origin(origin);
return check;
Expand Down Expand Up @@ -1233,11 +1248,15 @@ JVMFlag::Error JVMFlag::uintxAtPut(JVMFlag* flag, uintx* value, JVMFlag::Flags o
if (flag == NULL) return JVMFlag::INVALID_FLAG;
if (!flag->is_uintx()) return JVMFlag::WRONG_FORMAT;
name = flag->_name;
uintx old_value = flag->get_uintx();
JVMFlag::Error check = apply_constraint_and_check_range_uintx(name, *value, !JVMFlagConstraintList::validated_after_ergo());
if (check != JVMFlag::SUCCESS) return check;
uintx old_value = flag->get_uintx();
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
check = flag->set_uintx(*value);
if (VerifyFlagConstraints && old_value != flag->get_uintx()) {
check = JVMFlag::SUCCESS;
} else {
check = flag->set_uintx(*value);
}
*value = old_value;
flag->set_origin(origin);
return check;
Expand Down Expand Up @@ -1282,11 +1301,15 @@ JVMFlag::Error JVMFlag::uint64_tAtPut(JVMFlag* flag, uint64_t* value, JVMFlag::F
if (flag == NULL) return JVMFlag::INVALID_FLAG;
if (!flag->is_uint64_t()) return JVMFlag::WRONG_FORMAT;
name = flag->_name;
uint64_t old_value = flag->get_uint64_t();
JVMFlag::Error check = apply_constraint_and_check_range_uint64_t(name, *value, !JVMFlagConstraintList::validated_after_ergo());
if (check != JVMFlag::SUCCESS) return check;
uint64_t old_value = flag->get_uint64_t();
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
check = flag->set_uint64_t(*value);
if (VerifyFlagConstraints && old_value != flag->get_uint64_t()) {
check = JVMFlag::SUCCESS;
} else {
check = flag->set_uint64_t(*value);
}
*value = old_value;
flag->set_origin(origin);
return check;
Expand Down Expand Up @@ -1332,11 +1355,15 @@ JVMFlag::Error JVMFlag::size_tAtPut(JVMFlag* flag, size_t* value, JVMFlag::Flags
if (flag == NULL) return JVMFlag::INVALID_FLAG;
if (!flag->is_size_t()) return JVMFlag::WRONG_FORMAT;
name = flag->_name;
size_t old_value = flag->get_size_t();
JVMFlag::Error check = apply_constraint_and_check_range_size_t(name, *value, !JVMFlagConstraintList::validated_after_ergo());
if (check != JVMFlag::SUCCESS) return check;
size_t old_value = flag->get_size_t();
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
check = flag->set_size_t(*value);
if (VerifyFlagConstraints && old_value != flag->get_size_t()) {
check = JVMFlag::SUCCESS;
} else {
check = flag->set_size_t(*value);
}
*value = old_value;
flag->set_origin(origin);
return check;
Expand Down Expand Up @@ -1381,11 +1408,16 @@ JVMFlag::Error JVMFlag::doubleAtPut(JVMFlag* flag, double* value, JVMFlag::Flags
if (flag == NULL) return JVMFlag::INVALID_FLAG;
if (!flag->is_double()) return JVMFlag::WRONG_FORMAT;
name = flag->_name;
double old_value = flag->get_double();
JVMFlag::Error check = apply_constraint_and_check_range_double(name, *value, !JVMFlagConstraintList::validated_after_ergo());
if (check != JVMFlag::SUCCESS) return check;
double old_value = flag->get_double();

trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
check = flag->set_double(*value);
if (VerifyFlagConstraints && old_value != flag->get_double()) {
check = JVMFlag::SUCCESS;
} else {
check = flag->set_double(*value);
}
*value = old_value;
flag->set_origin(origin);
return check;
Expand Down
Loading

0 comments on commit ab920bd

Please sign in to comment.