8305506: Add support for fractional values of SafepointTimeoutDelay

Reviewed-by: mdoerr, dholmes
This commit is contained in:
Wojciech Kudla 2023-07-20 05:10:39 +00:00 committed by David Holmes
parent dfe764e3f8
commit 37c756a7be
3 changed files with 18 additions and 11 deletions

View File

@ -1292,9 +1292,10 @@ const int ObjectAlignmentInBytes = 8;
"(0 means none)") \ "(0 means none)") \
range(0, max_jint) \ range(0, max_jint) \
\ \
product(intx, SafepointTimeoutDelay, 10000, \ product(double, SafepointTimeoutDelay, 10000, \
"Delay in milliseconds for option SafepointTimeout") \ "Delay in milliseconds for option SafepointTimeout; " \
range(0, max_intx LP64_ONLY(/MICROUNITS)) \ "supports sub-millisecond resolution with fractional values.") \
range(0, max_jlongDouble LP64_ONLY(/MICROUNITS)) \
\ \
product(bool, UseSystemMemoryBarrier, false, \ product(bool, UseSystemMemoryBarrier, false, \
"Try to enable system memory barrier if supported by OS") \ "Try to enable system memory barrier if supported by OS") \

View File

@ -379,7 +379,7 @@ void SafepointSynchronize::begin() {
if (SafepointTimeout) { if (SafepointTimeout) {
// Set the limit time, so that it can be compared to see if this has taken // Set the limit time, so that it can be compared to see if this has taken
// too long to complete. // too long to complete.
safepoint_limit_time = SafepointTracing::start_of_safepoint() + (jlong)SafepointTimeoutDelay * (NANOUNITS / MILLIUNITS); safepoint_limit_time = SafepointTracing::start_of_safepoint() + (jlong)(SafepointTimeoutDelay * NANOSECS_PER_MILLISEC);
timeout_error_printed = false; timeout_error_printed = false;
} }
@ -819,7 +819,7 @@ void SafepointSynchronize::print_safepoint_timeout() {
os::naked_sleep(3000); os::naked_sleep(3000);
} }
} }
fatal("Safepoint sync time longer than " INTX_FORMAT "ms detected when executing %s.", fatal("Safepoint sync time longer than %.6f ms detected when executing %s.",
SafepointTimeoutDelay, VMThread::vm_operation()->name()); SafepointTimeoutDelay, VMThread::vm_operation()->name());
} }
} }

View File

@ -35,18 +35,24 @@ import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
public class DoubleFlagWithIntegerValue { public class DoubleFlagWithIntegerValue {
public static void testDoubleFlagWithValue(String value) throws Exception { public static void testDoubleFlagWithValue(String flag, String value) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:SweeperThreshold=" + value, "-version"); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flag + "=" + value, "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotContain("Improperly specified VM option"); output.shouldNotContain("Improperly specified VM option");
output.shouldHaveExitValue(0); output.shouldHaveExitValue(0);
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// Test double format // Test double format for -XX:SweeperThreshold
testDoubleFlagWithValue("10.0"); testDoubleFlagWithValue("-XX:SweeperThreshold", "10.0");
// Test integer format // Test integer format -XX:SweeperThreshold
testDoubleFlagWithValue("10"); testDoubleFlagWithValue("-XX:SweeperThreshold", "10");
// Test double format for -XX:SafepointTimeoutDelay
testDoubleFlagWithValue("-XX:SafepointTimeoutDelay", "5.0");
// Test integer format -XX:SafepointTimeoutDelay
testDoubleFlagWithValue("-XX:SafepointTimeoutDelay", "5");
} }
} }