comparison src/os/bsd/vm/os_bsd.cpp @ 12997:e4f478e7781b

8027294: Prepare hotspot for non TOD based uptime counter Summary: Use HR timer when available for os::elapsed_counter() on linux/bsd. Add a new counter for the JVM uptime. Reviewed-by: dholmes, sla
author jbachorik
date Fri, 25 Oct 2013 09:07:58 +0200
parents 3e265ce4d2dd
children 3b32d287da89
comparison
equal deleted inserted replaced
12996:d70a665e25d7 12997:e4f478e7781b
943 943
944 // Time since start-up in seconds to a fine granularity. 944 // Time since start-up in seconds to a fine granularity.
945 // Used by VMSelfDestructTimer and the MemProfiler. 945 // Used by VMSelfDestructTimer and the MemProfiler.
946 double os::elapsedTime() { 946 double os::elapsedTime() {
947 947
948 return (double)(os::elapsed_counter()) * 0.000001; 948 return ((double)os::elapsed_counter()) / os::elapsed_frequency();
949 } 949 }
950 950
951 jlong os::elapsed_counter() { 951 jlong os::elapsed_counter() {
952 timeval time; 952 return javaTimeNanos() - initial_time_count;
953 int status = gettimeofday(&time, NULL);
954 return jlong(time.tv_sec) * 1000 * 1000 + jlong(time.tv_usec) - initial_time_count;
955 } 953 }
956 954
957 jlong os::elapsed_frequency() { 955 jlong os::elapsed_frequency() {
958 return (1000 * 1000); 956 return NANOSECS_PER_SEC; // nanosecond resolution
959 } 957 }
960 958
961 bool os::supports_vtime() { return true; } 959 bool os::supports_vtime() { return true; }
962 bool os::enable_vtime() { return false; } 960 bool os::enable_vtime() { return false; }
963 bool os::vtime_enabled() { return false; } 961 bool os::vtime_enabled() { return false; }
3580 3578
3581 // main_thread points to the aboriginal thread 3579 // main_thread points to the aboriginal thread
3582 Bsd::_main_thread = pthread_self(); 3580 Bsd::_main_thread = pthread_self();
3583 3581
3584 Bsd::clock_init(); 3582 Bsd::clock_init();
3585 initial_time_count = os::elapsed_counter(); 3583 initial_time_count = javaTimeNanos();
3586 3584
3587 #ifdef __APPLE__ 3585 #ifdef __APPLE__
3588 // XXXDARWIN 3586 // XXXDARWIN
3589 // Work around the unaligned VM callbacks in hotspot's 3587 // Work around the unaligned VM callbacks in hotspot's
3590 // sharedRuntime. The callbacks don't use SSE2 instructions, and work on 3588 // sharedRuntime. The callbacks don't use SSE2 instructions, and work on