author | dholmes |
Sat, 23 Jun 2018 01:32:41 -0400 | |
changeset 50735 | 2f2af62dfac7 |
parent 50626 | 9fdfe5ca0e5e |
child 50921 | 7f462e8383f6 |
permissions | -rw-r--r-- |
47881 | 1 |
/* |
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#ifndef SHARE_VM_RUNTIME_SAFEPOINTMECHANISM_INLINE_HPP |
|
26 |
#define SHARE_VM_RUNTIME_SAFEPOINTMECHANISM_INLINE_HPP |
|
27 |
||
28 |
#include "runtime/safepointMechanism.hpp" |
|
29 |
#include "runtime/safepoint.hpp" |
|
30 |
#include "runtime/thread.inline.hpp" |
|
31 |
||
32 |
bool SafepointMechanism::local_poll_armed(JavaThread* thread) { |
|
33 |
const intptr_t poll_word = reinterpret_cast<intptr_t>(thread->get_polling_page()); |
|
34 |
return mask_bits_are_true(poll_word, poll_bit()); |
|
35 |
} |
|
36 |
||
37 |
bool SafepointMechanism::global_poll() { |
|
38 |
return SafepointSynchronize::do_call_back(); |
|
39 |
} |
|
40 |
||
41 |
bool SafepointMechanism::local_poll(Thread* thread) { |
|
42 |
if (thread->is_Java_thread()) { |
|
43 |
return local_poll_armed((JavaThread*)thread); |
|
44 |
} else { |
|
45 |
// If the poll is on a non-java thread we can only check the global state. |
|
46 |
return global_poll(); |
|
47 |
} |
|
48 |
} |
|
49 |
||
50 |
bool SafepointMechanism::poll(Thread* thread) { |
|
51 |
if (uses_thread_local_poll()) { |
|
52 |
return local_poll(thread); |
|
53 |
} else { |
|
54 |
return global_poll(); |
|
55 |
} |
|
56 |
} |
|
57 |
||
58 |
void SafepointMechanism::block_if_requested_local_poll(JavaThread *thread) { |
|
59 |
bool armed = local_poll_armed(thread); // load acquire, polling page -> op / global state |
|
60 |
if(armed) { |
|
61 |
// We could be armed for either a handshake operation or a safepoint |
|
50626
9fdfe5ca0e5e
8204166: TLH: Semaphore may not be destroy until signal have returned.
rehn
parents:
47881
diff
changeset
|
62 |
if (global_poll()) { |
9fdfe5ca0e5e
8204166: TLH: Semaphore may not be destroy until signal have returned.
rehn
parents:
47881
diff
changeset
|
63 |
SafepointSynchronize::block(thread); |
9fdfe5ca0e5e
8204166: TLH: Semaphore may not be destroy until signal have returned.
rehn
parents:
47881
diff
changeset
|
64 |
} |
47881 | 65 |
if (thread->has_handshake()) { |
66 |
thread->handshake_process_by_self(); |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
70 |
||
71 |
void SafepointMechanism::block_if_requested(JavaThread *thread) { |
|
72 |
if (uses_thread_local_poll()) { |
|
73 |
block_if_requested_local_poll(thread); |
|
74 |
} else { |
|
75 |
// If we don't have per thread poll this could a handshake or a safepoint |
|
76 |
if (global_poll()) { |
|
77 |
SafepointSynchronize::block(thread); |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
||
82 |
void SafepointMechanism::arm_local_poll(JavaThread* thread) { |
|
83 |
thread->set_polling_page(poll_armed_value()); |
|
84 |
} |
|
85 |
||
86 |
void SafepointMechanism::disarm_local_poll(JavaThread* thread) { |
|
87 |
thread->set_polling_page(poll_disarmed_value()); |
|
88 |
} |
|
89 |
||
90 |
#endif // SHARE_VM_RUNTIME_SAFEPOINTMECHANISM_INLINE_HPP |