diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2015-12-23 00:22:15 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2015-12-23 00:22:15 +0000 |
commit | cafb8745f1638108b4c01a8c3993d20551d35fed (patch) | |
tree | f2c9c15ad2a32f15f8ec3ae81e52ec4203c2ed5b /java | |
parent | - Update to 6.400.3 (diff) |
Implement ThreadMXBean.getThreadCpuTime(), etc.
PR: 205523
Submitted by: will (via bsd-port-dev@openjdk.java.net)
Notes
Notes:
svn path=/head/; revision=404270
Diffstat (limited to 'java')
-rw-r--r-- | java/openjdk8/Makefile | 1 | ||||
-rw-r--r-- | java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.cpp | 79 | ||||
-rw-r--r-- | java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.hpp | 10 |
3 files changed, 90 insertions, 0 deletions
diff --git a/java/openjdk8/Makefile b/java/openjdk8/Makefile index 13f02ff4be6c..72d4b1ae95b8 100644 --- a/java/openjdk8/Makefile +++ b/java/openjdk8/Makefile @@ -2,6 +2,7 @@ PORTNAME= openjdk PORTVERSION= ${JDK_MAJOR_VERSION}.${JDK_UPDATE_VERSION}.${JDK_BUILD_NUMBER:S/^0//} +PORTREVISION= 1 CATEGORIES= java devel MASTER_SITES= http://download.java.net/openjdk/jdk${JDK_MAJOR_VERSION}/promoted/b${DIST_BUILD_NUMBER}/:jdk \ https://adopt-openjdk.ci.cloudbees.com/job/jtreg/${JTREG_JENKINS_BUILD}/artifact/:jtreg \ diff --git a/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.cpp b/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.cpp new file mode 100644 index 000000000000..46da39fcc6d6 --- /dev/null +++ b/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.cpp @@ -0,0 +1,79 @@ +--- hotspot/src/os/bsd/vm/os_bsd.cpp.orig 2015-12-22 22:54:16 UTC ++++ hotspot/src/os/bsd/vm/os_bsd.cpp +@@ -151,6 +151,7 @@ mach_timebase_info_data_t os::Bsd::_time + volatile uint64_t os::Bsd::_max_abstime = 0; + #else + int (*os::Bsd::_clock_gettime)(clockid_t, struct timespec *) = NULL; ++int (*os::Bsd::_getcpuclockid)(pthread_t, clockid_t *) = NULL; + #endif + pthread_t os::Bsd::_main_thread; + int os::Bsd::_page_size = -1; +@@ -1058,6 +1059,7 @@ void os::Bsd::clock_init() { + // yes, monotonic clock is supported + _clock_gettime = ::clock_gettime; + } ++ _getcpuclockid = (int (*)(pthread_t, clockid_t *))dlsym(RTLD_DEFAULT, "pthread_getcpuclockid"); + } + #endif + +@@ -4248,6 +4250,8 @@ jlong os::current_thread_cpu_time() { + #ifdef __APPLE__ + return os::thread_cpu_time(Thread::current(), true /* user + sys */); + #else ++ if (Bsd::_getcpuclockid != NULL) ++ return os::thread_cpu_time(Thread::current(), true /* user + sys */); + Unimplemented(); + return 0; + #endif +@@ -4257,6 +4261,8 @@ jlong os::thread_cpu_time(Thread* thread + #ifdef __APPLE__ + return os::thread_cpu_time(thread, true /* user + sys */); + #else ++ if (Bsd::_getcpuclockid != NULL) ++ return os::thread_cpu_time(thread, true /* user + sys */); + Unimplemented(); + return 0; + #endif +@@ -4266,6 +4272,8 @@ jlong os::current_thread_cpu_time(bool u + #ifdef __APPLE__ + return os::thread_cpu_time(Thread::current(), user_sys_cpu_time); + #else ++ if (Bsd::_getcpuclockid != NULL) ++ return os::thread_cpu_time(Thread::current(), user_sys_cpu_time); + Unimplemented(); + return 0; + #endif +@@ -4292,6 +4300,24 @@ jlong os::thread_cpu_time(Thread *thread + return ((jlong)tinfo.user_time.seconds * 1000000000) + ((jlong)tinfo.user_time.microseconds * (jlong)1000); + } + #else ++ if (Bsd::_getcpuclockid != NULL) { ++ struct timespec tp; ++ clockid_t clockid; ++ int ret; ++ ++ /* ++ * XXX This is essentially a copy of the Linux implementation, ++ * but with fewer indirections. ++ */ ++ ret = Bsd::_getcpuclockid(thread->osthread()->pthread_id(), &clockid); ++ if (ret != 0) ++ return -1; ++ /* NB: _clock_gettime only needs to be valid for CLOCK_MONOTONIC. */ ++ ret = ::clock_gettime(clockid, &tp); ++ if (ret != 0) ++ return -1; ++ return (tp.tv_sec * NANOSECS_PER_SEC) + tp.tv_nsec; ++ } + Unimplemented(); + return 0; + #endif +@@ -4316,7 +4342,7 @@ bool os::is_thread_cpu_time_supported() + #ifdef __APPLE__ + return true; + #else +- return false; ++ return (Bsd::_getcpuclockid != NULL); + #endif + } + diff --git a/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.hpp b/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.hpp new file mode 100644 index 000000000000..2b2b548f8f21 --- /dev/null +++ b/java/openjdk8/files/patch-hotspot_src_os_bsd_vm_os__bsd.hpp @@ -0,0 +1,10 @@ +--- hotspot/src/os/bsd/vm/os_bsd.hpp.orig 2015-12-22 22:53:56 UTC ++++ hotspot/src/os/bsd/vm/os_bsd.hpp +@@ -64,6 +64,7 @@ class Bsd { + static volatile uint64_t _max_abstime; + #else + static int (*_clock_gettime)(clockid_t, struct timespec *); ++ static int (*_getcpuclockid)(pthread_t, clockid_t *); + #endif + + static GrowableArray<int>* _cpu_to_node; |