author | coleenp |
Wed, 31 Jul 2019 06:54:50 -0400 | |
changeset 57603 | f9d9bed12d1a |
parent 54323 | 846bc643f4ef |
permissions | -rw-r--r-- |
47881 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52450
diff
changeset
|
2 |
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
47881 | 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 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52450
diff
changeset
|
25 |
#ifndef SHARE_RUNTIME_SAFEPOINTMECHANISM_INLINE_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52450
diff
changeset
|
26 |
#define SHARE_RUNTIME_SAFEPOINTMECHANISM_INLINE_HPP |
47881 | 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() { |
|
53775 | 38 |
return (SafepointSynchronize::_state != SafepointSynchronize::_not_synchronized); |
47881 | 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 |
||
52450 | 50 |
bool SafepointMechanism::should_block(Thread* thread) { |
47881 | 51 |
if (uses_thread_local_poll()) { |
52 |
return local_poll(thread); |
|
53 |
} else { |
|
54 |
return global_poll(); |
|
55 |
} |
|
56 |
} |
|
57 |
||
53631
a5321bcfa2de
8218145: block_if_requested is not proper inlined due to size
rehn
parents:
53244
diff
changeset
|
58 |
void SafepointMechanism::block_if_requested(JavaThread *thread) { |
54323 | 59 |
if (uses_thread_local_poll() && !local_poll_armed(thread)) { |
53631
a5321bcfa2de
8218145: block_if_requested is not proper inlined due to size
rehn
parents:
53244
diff
changeset
|
60 |
return; |
47881 | 61 |
} |
53631
a5321bcfa2de
8218145: block_if_requested is not proper inlined due to size
rehn
parents:
53244
diff
changeset
|
62 |
block_if_requested_slow(thread); |
47881 | 63 |
} |
64 |
||
65 |
void SafepointMechanism::arm_local_poll(JavaThread* thread) { |
|
66 |
thread->set_polling_page(poll_armed_value()); |
|
67 |
} |
|
68 |
||
69 |
void SafepointMechanism::disarm_local_poll(JavaThread* thread) { |
|
70 |
thread->set_polling_page(poll_disarmed_value()); |
|
71 |
} |
|
72 |
||
54323 | 73 |
void SafepointMechanism::disarm_if_needed(JavaThread* thread, bool memory_order_release) { |
74 |
JavaThreadState jts = thread->thread_state(); |
|
75 |
if (jts == _thread_in_native || jts == _thread_in_native_trans) { |
|
76 |
// JavaThread will disarm itself and execute cross_modify_fence() before continuing |
|
77 |
return; |
|
78 |
} |
|
79 |
if (memory_order_release) { |
|
80 |
thread->set_polling_page_release(poll_disarmed_value()); |
|
81 |
} else { |
|
82 |
thread->set_polling_page(poll_disarmed_value()); |
|
83 |
} |
|
84 |
} |
|
85 |
||
50921
7f462e8383f6
8206003: SafepointSynchronize with TLH: StoreStore barriers should be moved out of the loop
mdoerr
parents:
50626
diff
changeset
|
86 |
void SafepointMechanism::arm_local_poll_release(JavaThread* thread) { |
7f462e8383f6
8206003: SafepointSynchronize with TLH: StoreStore barriers should be moved out of the loop
mdoerr
parents:
50626
diff
changeset
|
87 |
thread->set_polling_page_release(poll_armed_value()); |
7f462e8383f6
8206003: SafepointSynchronize with TLH: StoreStore barriers should be moved out of the loop
mdoerr
parents:
50626
diff
changeset
|
88 |
} |
7f462e8383f6
8206003: SafepointSynchronize with TLH: StoreStore barriers should be moved out of the loop
mdoerr
parents:
50626
diff
changeset
|
89 |
|
7f462e8383f6
8206003: SafepointSynchronize with TLH: StoreStore barriers should be moved out of the loop
mdoerr
parents:
50626
diff
changeset
|
90 |
void SafepointMechanism::disarm_local_poll_release(JavaThread* thread) { |
7f462e8383f6
8206003: SafepointSynchronize with TLH: StoreStore barriers should be moved out of the loop
mdoerr
parents:
50626
diff
changeset
|
91 |
thread->set_polling_page_release(poll_disarmed_value()); |
7f462e8383f6
8206003: SafepointSynchronize with TLH: StoreStore barriers should be moved out of the loop
mdoerr
parents:
50626
diff
changeset
|
92 |
} |
7f462e8383f6
8206003: SafepointSynchronize with TLH: StoreStore barriers should be moved out of the loop
mdoerr
parents:
50626
diff
changeset
|
93 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52450
diff
changeset
|
94 |
#endif // SHARE_RUNTIME_SAFEPOINTMECHANISM_INLINE_HPP |