819 GetSystemTimeAsFileTime(&wt); |
819 GetSystemTimeAsFileTime(&wt); |
820 return windows_to_java_time(wt); |
820 return windows_to_java_time(wt); |
821 } |
821 } |
822 } |
822 } |
823 |
823 |
824 #define NANOS_PER_SEC CONST64(1000000000) |
|
825 #define NANOS_PER_MILLISEC 1000000 |
|
826 jlong os::javaTimeNanos() { |
824 jlong os::javaTimeNanos() { |
827 if (!has_performance_count) { |
825 if (!has_performance_count) { |
828 return javaTimeMillis() * NANOS_PER_MILLISEC; // the best we can do. |
826 return javaTimeMillis() * NANOSECS_PER_MILLISEC; // the best we can do. |
829 } else { |
827 } else { |
830 LARGE_INTEGER current_count; |
828 LARGE_INTEGER current_count; |
831 QueryPerformanceCounter(¤t_count); |
829 QueryPerformanceCounter(¤t_count); |
832 double current = as_long(current_count); |
830 double current = as_long(current_count); |
833 double freq = performance_frequency; |
831 double freq = performance_frequency; |
834 jlong time = (jlong)((current/freq) * NANOS_PER_SEC); |
832 jlong time = (jlong)((current/freq) * NANOSECS_PER_SEC); |
835 return time; |
833 return time; |
836 } |
834 } |
837 } |
835 } |
838 |
836 |
839 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { |
837 void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) { |
845 // this is a wall clock timer, so may skip |
843 // this is a wall clock timer, so may skip |
846 info_ptr->may_skip_backward = true; |
844 info_ptr->may_skip_backward = true; |
847 info_ptr->may_skip_forward = true; |
845 info_ptr->may_skip_forward = true; |
848 } else { |
846 } else { |
849 jlong freq = performance_frequency; |
847 jlong freq = performance_frequency; |
850 if (freq < NANOS_PER_SEC) { |
848 if (freq < NANOSECS_PER_SEC) { |
851 // the performance counter is 64 bits and we will |
849 // the performance counter is 64 bits and we will |
852 // be multiplying it -- so no wrap in 64 bits |
850 // be multiplying it -- so no wrap in 64 bits |
853 info_ptr->max_value = ALL_64_BITS; |
851 info_ptr->max_value = ALL_64_BITS; |
854 } else if (freq > NANOS_PER_SEC) { |
852 } else if (freq > NANOSECS_PER_SEC) { |
855 // use the max value the counter can reach to |
853 // use the max value the counter can reach to |
856 // determine the max value which could be returned |
854 // determine the max value which could be returned |
857 julong max_counter = (julong)ALL_64_BITS; |
855 julong max_counter = (julong)ALL_64_BITS; |
858 info_ptr->max_value = (jlong)(max_counter / (freq / NANOS_PER_SEC)); |
856 info_ptr->max_value = (jlong)(max_counter / (freq / NANOSECS_PER_SEC)); |
859 } else { |
857 } else { |
860 // the performance counter is 64 bits and we will |
858 // the performance counter is 64 bits and we will |
861 // be using it directly -- so no wrap in 64 bits |
859 // be using it directly -- so no wrap in 64 bits |
862 info_ptr->max_value = ALL_64_BITS; |
860 info_ptr->max_value = ALL_64_BITS; |
863 } |
861 } |