8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's
Reviewed-by: shade, rriggs, dcubed
This commit is contained in:
parent
c4bafa7975
commit
0adae4d914
@ -1351,24 +1351,29 @@ double os::elapsedVTime() {
|
|||||||
return (double)gethrvtime() / (double)hrtime_hz;
|
return (double)gethrvtime() / (double)hrtime_hz;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used internally for comparisons only
|
// in-memory timestamp support - has update accuracy of 1ms
|
||||||
// getTimeMillis guaranteed to not move backwards on Solaris
|
typedef void (*_get_nsec_fromepoch_func_t)(hrtime_t*);
|
||||||
jlong getTimeMillis() {
|
static _get_nsec_fromepoch_func_t _get_nsec_fromepoch = NULL;
|
||||||
jlong nanotime = getTimeNanos();
|
|
||||||
return (jlong)(nanotime / NANOSECS_PER_MILLISEC);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
|
// Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis
|
||||||
jlong os::javaTimeMillis() {
|
jlong os::javaTimeMillis() {
|
||||||
timeval t;
|
if (_get_nsec_fromepoch != NULL) {
|
||||||
if (gettimeofday(&t, NULL) == -1) {
|
hrtime_t now;
|
||||||
fatal("os::javaTimeMillis: gettimeofday (%s)", os::strerror(errno));
|
_get_nsec_fromepoch(&now);
|
||||||
|
return now / NANOSECS_PER_MILLISEC;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
timeval t;
|
||||||
|
if (gettimeofday(&t, NULL) == -1) {
|
||||||
|
fatal("os::javaTimeMillis: gettimeofday (%s)", os::strerror(errno));
|
||||||
|
}
|
||||||
|
return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000;
|
||||||
}
|
}
|
||||||
return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
|
void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
|
||||||
timeval t;
|
timeval t;
|
||||||
|
// can't use get_nsec_fromepoch here as we need better accuracy than 1ms
|
||||||
if (gettimeofday(&t, NULL) == -1) {
|
if (gettimeofday(&t, NULL) == -1) {
|
||||||
fatal("os::javaTimeSystemUTC: gettimeofday (%s)", os::strerror(errno));
|
fatal("os::javaTimeSystemUTC: gettimeofday (%s)", os::strerror(errno));
|
||||||
}
|
}
|
||||||
@ -4432,11 +4437,15 @@ void os::init(void) {
|
|||||||
// enough to allow the thread to get to user bytecode execution.
|
// enough to allow the thread to get to user bytecode execution.
|
||||||
Solaris::min_stack_allowed = MAX2(thr_min_stack(), Solaris::min_stack_allowed);
|
Solaris::min_stack_allowed = MAX2(thr_min_stack(), Solaris::min_stack_allowed);
|
||||||
|
|
||||||
// retrieve entry point for pthread_setname_np
|
// dynamic lookup of functions that may not be available in our lowest
|
||||||
|
// supported Solaris release
|
||||||
void * handle = dlopen("libc.so.1", RTLD_LAZY);
|
void * handle = dlopen("libc.so.1", RTLD_LAZY);
|
||||||
if (handle != NULL) {
|
if (handle != NULL) {
|
||||||
Solaris::_pthread_setname_np =
|
Solaris::_pthread_setname_np = // from 11.3
|
||||||
(Solaris::pthread_setname_np_func_t)dlsym(handle, "pthread_setname_np");
|
(Solaris::pthread_setname_np_func_t)dlsym(handle, "pthread_setname_np");
|
||||||
|
|
||||||
|
_get_nsec_fromepoch = // from 11.3.6
|
||||||
|
(_get_nsec_fromepoch_func_t) dlsym(handle, "get_nsec_fromepoch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user