Skip to content

Commit 411a63e

Browse files
author
Serguei Spitsyn
committed
8356251: Need minor cleanup for interp_only_mode
Reviewed-by: lmesnik, cjplummer
1 parent 568dcc1 commit 411a63e

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

src/hotspot/share/prims/jvmtiThreadState.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop)
123123
// Set this only if thread_oop is current thread->jvmti_vthread().
124124
thread->set_jvmti_thread_state(this);
125125
}
126-
thread->set_interp_only_mode(0);
126+
thread->set_interp_only_mode(false);
127127
}
128128
}
129129

@@ -790,18 +790,19 @@ void JvmtiThreadState::add_env(JvmtiEnvBase *env) {
790790

791791
void JvmtiThreadState::enter_interp_only_mode() {
792792
assert(_thread != nullptr, "sanity check");
793+
assert(!is_interp_only_mode(), "entering interp only when in interp only mode");
793794
_seen_interp_only_mode = true;
794-
_thread->increment_interp_only_mode();
795+
_thread->set_interp_only_mode(true);
795796
invalidate_cur_stack_depth();
796797
}
797798

798799
void JvmtiThreadState::leave_interp_only_mode() {
799800
assert(is_interp_only_mode(), "leaving interp only when not in interp only mode");
800801
if (_thread == nullptr) {
801802
// Unmounted virtual thread updates the saved value.
802-
--_saved_interp_only_mode;
803+
_saved_interp_only_mode = 0;
803804
} else {
804-
_thread->decrement_interp_only_mode();
805+
_thread->set_interp_only_mode(false);
805806
}
806807
}
807808

src/hotspot/share/prims/jvmtiThreadState.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ class JvmtiThreadState : public CHeapObj<mtInternal> {
193193
bool _pending_step_for_popframe;
194194
bool _pending_step_for_earlyret;
195195
bool _top_frame_is_exiting;
196+
bool _saved_interp_only_mode;
196197
int _hide_level;
197198

198199
public:
@@ -213,7 +214,6 @@ class JvmtiThreadState : public CHeapObj<mtInternal> {
213214

214215
// This is only valid when is_interp_only_mode() returns true
215216
int _cur_stack_depth;
216-
int _saved_interp_only_mode;
217217

218218
JvmtiThreadEventEnable _thread_event_enable;
219219

@@ -275,7 +275,7 @@ class JvmtiThreadState : public CHeapObj<mtInternal> {
275275

276276
// Used by the interpreter for fullspeed debugging support
277277
bool is_interp_only_mode() {
278-
return _thread == nullptr ? _saved_interp_only_mode != 0 : _thread->is_interp_only_mode();
278+
return _thread == nullptr ? _saved_interp_only_mode : _thread->is_interp_only_mode();
279279
}
280280
void enter_interp_only_mode();
281281
void leave_interp_only_mode();

src/hotspot/share/prims/jvmtiThreadState.inline.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ inline void JvmtiThreadState::unbind_from(JvmtiThreadState* state, JavaThread* t
144144
return;
145145
}
146146
// Save thread's interp_only_mode.
147-
state->_saved_interp_only_mode = thread->get_interp_only_mode();
147+
state->_saved_interp_only_mode = thread->is_interp_only_mode();
148148
state->set_thread(nullptr); // Make sure stale _thread value is never used.
149149
}
150150

151151
inline void JvmtiThreadState::bind_to(JvmtiThreadState* state, JavaThread* thread) {
152152
// Restore thread's interp_only_mode.
153-
thread->set_interp_only_mode(state == nullptr ? 0 : state->_saved_interp_only_mode);
153+
thread->set_interp_only_mode(state != nullptr && state->_saved_interp_only_mode);
154154

155155
// Make continuation notice the interp_only_mode change.
156156
Continuation::set_cont_fastpath_thread_state(thread);
@@ -168,11 +168,7 @@ inline void JvmtiThreadState::process_pending_interp_only(JavaThread* current) {
168168
JvmtiThreadState* state = current->jvmti_thread_state();
169169

170170
if (state != nullptr && state->is_pending_interp_only_mode()) {
171-
MutexLocker mu(JvmtiThreadState_lock);
172-
state = current->jvmti_thread_state();
173-
if (state != nullptr && state->is_pending_interp_only_mode()) {
174-
JvmtiEventController::enter_interp_only_mode(state);
175-
}
171+
JvmtiEventController::enter_interp_only_mode(state);
176172
}
177173
}
178174
#endif // SHARE_PRIMS_JVMTITHREADSTATE_INLINE_HPP

src/hotspot/share/runtime/javaThread.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,16 +1167,14 @@ class JavaThread: public Thread {
11671167
// It can be set to zero asynchronously to this threads execution (i.e., without
11681168
// safepoint/handshake or a lock) so we have to be very careful.
11691169
// Accesses by other threads are synchronized using JvmtiThreadState_lock though.
1170+
// This field is checked by the interpreter which expects it to be an integer.
11701171
int _interp_only_mode;
11711172

11721173
public:
11731174
// used by the interpreter for fullspeed debugging support (see above)
11741175
static ByteSize interp_only_mode_offset() { return byte_offset_of(JavaThread, _interp_only_mode); }
11751176
bool is_interp_only_mode() { return (_interp_only_mode != 0); }
1176-
int get_interp_only_mode() { return _interp_only_mode; }
1177-
int set_interp_only_mode(int val) { return _interp_only_mode = val; }
1178-
void increment_interp_only_mode() { ++_interp_only_mode; }
1179-
void decrement_interp_only_mode() { --_interp_only_mode; }
1177+
void set_interp_only_mode(bool val) { _interp_only_mode = val ? 1 : 0; }
11801178

11811179
// support for cached flag that indicates whether exceptions need to be posted for this thread
11821180
// if this is false, we can avoid deoptimizing when events are thrown

0 commit comments

Comments
 (0)