8329432: PopFrame and ForceEarlyReturn functions should use JvmtiHandshake
Reviewed-by: pchilanomate, lmesnik
This commit is contained in:
parent
70944ca54a
commit
643dd48a2a
@ -1748,6 +1748,7 @@ JvmtiEnv::PopFrame(jthread thread) {
|
||||
JavaThread* java_thread = nullptr;
|
||||
oop thread_obj = nullptr;
|
||||
jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj);
|
||||
Handle thread_handle(current_thread, thread_obj);
|
||||
|
||||
if (err != JVMTI_ERROR_NONE) {
|
||||
return err;
|
||||
@ -1774,11 +1775,7 @@ JvmtiEnv::PopFrame(jthread thread) {
|
||||
|
||||
MutexLocker mu(JvmtiThreadState_lock);
|
||||
UpdateForPopTopFrameClosure op(state);
|
||||
if (self) {
|
||||
op.doit(java_thread, self);
|
||||
} else {
|
||||
Handshake::execute(&op, java_thread);
|
||||
}
|
||||
JvmtiHandshake::execute(&op, &tlh, java_thread, thread_handle);
|
||||
return op.result();
|
||||
} /* end PopFrame */
|
||||
|
||||
|
@ -2166,6 +2166,7 @@ JvmtiEnvBase::force_early_return(jthread thread, jvalue value, TosState tos) {
|
||||
if (err != JVMTI_ERROR_NONE) {
|
||||
return err;
|
||||
}
|
||||
Handle thread_handle(current_thread, thread_obj);
|
||||
bool self = java_thread == current_thread;
|
||||
|
||||
err = check_non_suspended_or_opaque_frame(java_thread, thread_obj, self);
|
||||
@ -2186,17 +2187,14 @@ JvmtiEnvBase::force_early_return(jthread thread, jvalue value, TosState tos) {
|
||||
return JVMTI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
MutexLocker mu(JvmtiThreadState_lock);
|
||||
SetForceEarlyReturn op(state, value, tos);
|
||||
if (self) {
|
||||
op.doit(java_thread, self);
|
||||
} else {
|
||||
Handshake::execute(&op, java_thread);
|
||||
}
|
||||
JvmtiHandshake::execute(&op, &tlh, java_thread, thread_handle);
|
||||
return op.result();
|
||||
}
|
||||
|
||||
void
|
||||
SetForceEarlyReturn::doit(Thread *target, bool self) {
|
||||
SetForceEarlyReturn::doit(Thread *target) {
|
||||
JavaThread* java_thread = JavaThread::cast(target);
|
||||
Thread* current_thread = Thread::current();
|
||||
HandleMark hm(current_thread);
|
||||
@ -2331,7 +2329,7 @@ JvmtiModuleClosure::get_all_modules(JvmtiEnv* env, jint* module_count_ptr, jobje
|
||||
}
|
||||
|
||||
void
|
||||
UpdateForPopTopFrameClosure::doit(Thread *target, bool self) {
|
||||
UpdateForPopTopFrameClosure::doit(Thread *target) {
|
||||
Thread* current_thread = Thread::current();
|
||||
HandleMark hm(current_thread);
|
||||
JavaThread* java_thread = JavaThread::cast(target);
|
||||
|
@ -456,16 +456,6 @@ class JvmtiEnvIterator : public StackObj {
|
||||
JvmtiEnv* next(JvmtiEnvBase* env) { return env->next_environment(); }
|
||||
};
|
||||
|
||||
class JvmtiHandshakeClosure : public HandshakeClosure {
|
||||
protected:
|
||||
jvmtiError _result;
|
||||
public:
|
||||
JvmtiHandshakeClosure(const char* name)
|
||||
: HandshakeClosure(name),
|
||||
_result(JVMTI_ERROR_THREAD_NOT_ALIVE) {}
|
||||
jvmtiError result() { return _result; }
|
||||
};
|
||||
|
||||
// Used in combination with the JvmtiHandshake class.
|
||||
// It is intended to support both platform and virtual threads.
|
||||
class JvmtiUnitedHandshakeClosure : public HandshakeClosure {
|
||||
@ -499,36 +489,46 @@ class JvmtiHandshake : public Handshake {
|
||||
static void execute(JvmtiUnitedHandshakeClosure* hs_cl, jthread target);
|
||||
};
|
||||
|
||||
class SetForceEarlyReturn : public JvmtiHandshakeClosure {
|
||||
class SetForceEarlyReturn : public JvmtiUnitedHandshakeClosure {
|
||||
private:
|
||||
JvmtiThreadState* _state;
|
||||
jvalue _value;
|
||||
TosState _tos;
|
||||
public:
|
||||
SetForceEarlyReturn(JvmtiThreadState* state, jvalue value, TosState tos)
|
||||
: JvmtiHandshakeClosure("SetForceEarlyReturn"),
|
||||
: JvmtiUnitedHandshakeClosure("SetForceEarlyReturn"),
|
||||
_state(state),
|
||||
_value(value),
|
||||
_tos(tos) {}
|
||||
void doit(Thread *target);
|
||||
void do_thread(Thread *target) {
|
||||
doit(target, false /* self */);
|
||||
doit(target);
|
||||
}
|
||||
void do_vthread(Handle target_h) {
|
||||
assert(_target_jt != nullptr, "sanity check");
|
||||
assert(_target_jt->vthread() == target_h(), "sanity check");
|
||||
doit(_target_jt); // mounted virtual thread
|
||||
}
|
||||
void doit(Thread *target, bool self);
|
||||
};
|
||||
|
||||
// HandshakeClosure to update for pop top frame.
|
||||
class UpdateForPopTopFrameClosure : public JvmtiHandshakeClosure {
|
||||
class UpdateForPopTopFrameClosure : public JvmtiUnitedHandshakeClosure {
|
||||
private:
|
||||
JvmtiThreadState* _state;
|
||||
|
||||
public:
|
||||
UpdateForPopTopFrameClosure(JvmtiThreadState* state)
|
||||
: JvmtiHandshakeClosure("UpdateForPopTopFrame"),
|
||||
: JvmtiUnitedHandshakeClosure("UpdateForPopTopFrame"),
|
||||
_state(state) {}
|
||||
void doit(Thread *target);
|
||||
void do_thread(Thread *target) {
|
||||
doit(target, false /* self */);
|
||||
doit(target);
|
||||
}
|
||||
void do_vthread(Handle target_h) {
|
||||
assert(_target_jt != nullptr, "sanity check");
|
||||
assert(_target_jt->vthread() == target_h(), "sanity check");
|
||||
doit(_target_jt); // mounted virtual thread
|
||||
}
|
||||
void doit(Thread *target, bool self);
|
||||
};
|
||||
|
||||
// HandshakeClosure to set frame pop.
|
||||
|
Loading…
Reference in New Issue
Block a user