author | kbarrett |
Tue, 19 Mar 2019 14:32:41 -0400 | |
changeset 54195 | 4b6a629d0615 |
parent 53886 | e94ed0236046 |
child 57738 | 807d192fb7dd |
permissions | -rw-r--r-- |
53654
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
1 |
/* |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
4 |
* |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
8 |
* |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
13 |
* accompanied this code). |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
14 |
* |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
18 |
* |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
21 |
* questions. |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
22 |
* |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
23 |
*/ |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
24 |
|
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
25 |
#ifndef OS_POSIX_OS_POSIX_INLINE_HPP |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
26 |
#define OS_POSIX_OS_POSIX_INLINE_HPP |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
27 |
|
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
28 |
#include "runtime/os.hpp" |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
29 |
|
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
30 |
#ifdef SUPPORTS_CLOCK_MONOTONIC |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
31 |
|
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
32 |
// Exported clock functionality |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
33 |
|
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
34 |
inline bool os::Posix::supports_monotonic_clock() { |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
35 |
return _clock_gettime != NULL; |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
36 |
} |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
37 |
|
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
38 |
inline int os::Posix::clock_gettime(clockid_t clock_id, struct timespec *tp) { |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
39 |
return _clock_gettime != NULL ? _clock_gettime(clock_id, tp) : -1; |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
40 |
} |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
41 |
|
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
42 |
inline int os::Posix::clock_getres(clockid_t clock_id, struct timespec *tp) { |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
43 |
return _clock_getres != NULL ? _clock_getres(clock_id, tp) : -1; |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
44 |
} |
53886
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
45 |
|
53654
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
46 |
#endif // SUPPORTS_CLOCK_MONOTONIC |
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
47 |
|
53886
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
48 |
#ifndef SOLARIS |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
49 |
|
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
50 |
// Platform Monitor implementation |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
51 |
|
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
52 |
inline void os::PlatformMonitor::lock() { |
54195 | 53 |
int status = pthread_mutex_lock(mutex()); |
53886
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
54 |
assert_status(status == 0, status, "mutex_lock"); |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
55 |
} |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
56 |
|
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
57 |
inline void os::PlatformMonitor::unlock() { |
54195 | 58 |
int status = pthread_mutex_unlock(mutex()); |
53886
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
59 |
assert_status(status == 0, status, "mutex_unlock"); |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
60 |
} |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
61 |
|
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
62 |
inline bool os::PlatformMonitor::try_lock() { |
54195 | 63 |
int status = pthread_mutex_trylock(mutex()); |
53886
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
64 |
assert_status(status == 0 || status == EBUSY, status, "mutex_trylock"); |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
65 |
return status == 0; |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
66 |
} |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
67 |
|
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
68 |
inline void os::PlatformMonitor::notify() { |
54195 | 69 |
int status = pthread_cond_signal(cond()); |
53886
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
70 |
assert_status(status == 0, status, "cond_signal"); |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
71 |
} |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
72 |
|
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
73 |
inline void os::PlatformMonitor::notify_all() { |
54195 | 74 |
int status = pthread_cond_broadcast(cond()); |
53886
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
75 |
assert_status(status == 0, status, "cond_broadcast"); |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
76 |
} |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
77 |
|
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
78 |
#endif // !SOLARIS |
e94ed0236046
8219247: Enable inlining of newly introduced PlatformMonitor methods
redestad
parents:
53654
diff
changeset
|
79 |
|
53654
7054249afee5
8217843: Performance regression related to os::supports_monotonic_clock() on linux
dholmes
parents:
diff
changeset
|
80 |
#endif // OS_POSIX_OS_POSIX_INLINE_HPP |