diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 0618a3eb006..41736c91bc3 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -1292,9 +1292,10 @@ const int ObjectAlignmentInBytes = 8; "(0 means none)") \ range(0, max_jint) \ \ - product(intx, SafepointTimeoutDelay, 10000, \ - "Delay in milliseconds for option SafepointTimeout") \ - range(0, max_intx LP64_ONLY(/MICROUNITS)) \ + product(double, SafepointTimeoutDelay, 10000, \ + "Delay in milliseconds for option SafepointTimeout; " \ + "supports sub-millisecond resolution with fractional values.") \ + range(0, max_jlongDouble LP64_ONLY(/MICROUNITS)) \ \ product(bool, UseSystemMemoryBarrier, false, \ "Try to enable system memory barrier if supported by OS") \ diff --git a/src/hotspot/share/runtime/safepoint.cpp b/src/hotspot/share/runtime/safepoint.cpp index 1d0997914c5..b2bdf22298b 100644 --- a/src/hotspot/share/runtime/safepoint.cpp +++ b/src/hotspot/share/runtime/safepoint.cpp @@ -379,7 +379,7 @@ void SafepointSynchronize::begin() { if (SafepointTimeout) { // Set the limit time, so that it can be compared to see if this has taken // 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; } @@ -819,7 +819,7 @@ void SafepointSynchronize::print_safepoint_timeout() { 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()); } } diff --git a/test/hotspot/jtreg/runtime/CommandLine/DoubleFlagWithIntegerValue.java b/test/hotspot/jtreg/runtime/CommandLine/DoubleFlagWithIntegerValue.java index f26b7399671..861160ee787 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/DoubleFlagWithIntegerValue.java +++ b/test/hotspot/jtreg/runtime/CommandLine/DoubleFlagWithIntegerValue.java @@ -35,18 +35,24 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; public class DoubleFlagWithIntegerValue { - public static void testDoubleFlagWithValue(String value) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:SweeperThreshold=" + value, "-version"); + public static void testDoubleFlagWithValue(String flag, String value) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flag + "=" + value, "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Improperly specified VM option"); output.shouldHaveExitValue(0); } public static void main(String[] args) throws Exception { - // Test double format - testDoubleFlagWithValue("10.0"); + // Test double format for -XX:SweeperThreshold + testDoubleFlagWithValue("-XX:SweeperThreshold", "10.0"); - // Test integer format - testDoubleFlagWithValue("10"); + // Test integer format -XX:SweeperThreshold + testDoubleFlagWithValue("-XX:SweeperThreshold", "10"); + + // Test double format for -XX:SafepointTimeoutDelay + testDoubleFlagWithValue("-XX:SafepointTimeoutDelay", "5.0"); + + // Test integer format -XX:SafepointTimeoutDelay + testDoubleFlagWithValue("-XX:SafepointTimeoutDelay", "5"); } }