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;
|
JavaThread* java_thread = nullptr;
|
||||||
oop thread_obj = nullptr;
|
oop thread_obj = nullptr;
|
||||||
jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj);
|
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) {
|
if (err != JVMTI_ERROR_NONE) {
|
||||||
return err;
|
return err;
|
||||||
@ -1774,11 +1775,7 @@ JvmtiEnv::PopFrame(jthread thread) {
|
|||||||
|
|
||||||
MutexLocker mu(JvmtiThreadState_lock);
|
MutexLocker mu(JvmtiThreadState_lock);
|
||||||
UpdateForPopTopFrameClosure op(state);
|
UpdateForPopTopFrameClosure op(state);
|
||||||
if (self) {
|
JvmtiHandshake::execute(&op, &tlh, java_thread, thread_handle);
|
||||||
op.doit(java_thread, self);
|
|
||||||
} else {
|
|
||||||
Handshake::execute(&op, java_thread);
|
|
||||||
}
|
|
||||||
return op.result();
|
return op.result();
|
||||||
} /* end PopFrame */
|
} /* end PopFrame */
|
||||||
|
|
||||||
|
@ -2166,6 +2166,7 @@ JvmtiEnvBase::force_early_return(jthread thread, jvalue value, TosState tos) {
|
|||||||
if (err != JVMTI_ERROR_NONE) {
|
if (err != JVMTI_ERROR_NONE) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Handle thread_handle(current_thread, thread_obj);
|
||||||
bool self = java_thread == current_thread;
|
bool self = java_thread == current_thread;
|
||||||
|
|
||||||
err = check_non_suspended_or_opaque_frame(java_thread, thread_obj, self);
|
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;
|
return JVMTI_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MutexLocker mu(JvmtiThreadState_lock);
|
||||||
SetForceEarlyReturn op(state, value, tos);
|
SetForceEarlyReturn op(state, value, tos);
|
||||||
if (self) {
|
JvmtiHandshake::execute(&op, &tlh, java_thread, thread_handle);
|
||||||
op.doit(java_thread, self);
|
|
||||||
} else {
|
|
||||||
Handshake::execute(&op, java_thread);
|
|
||||||
}
|
|
||||||
return op.result();
|
return op.result();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SetForceEarlyReturn::doit(Thread *target, bool self) {
|
SetForceEarlyReturn::doit(Thread *target) {
|
||||||
JavaThread* java_thread = JavaThread::cast(target);
|
JavaThread* java_thread = JavaThread::cast(target);
|
||||||
Thread* current_thread = Thread::current();
|
Thread* current_thread = Thread::current();
|
||||||
HandleMark hm(current_thread);
|
HandleMark hm(current_thread);
|
||||||
@ -2331,7 +2329,7 @@ JvmtiModuleClosure::get_all_modules(JvmtiEnv* env, jint* module_count_ptr, jobje
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UpdateForPopTopFrameClosure::doit(Thread *target, bool self) {
|
UpdateForPopTopFrameClosure::doit(Thread *target) {
|
||||||
Thread* current_thread = Thread::current();
|
Thread* current_thread = Thread::current();
|
||||||
HandleMark hm(current_thread);
|
HandleMark hm(current_thread);
|
||||||
JavaThread* java_thread = JavaThread::cast(target);
|
JavaThread* java_thread = JavaThread::cast(target);
|
||||||
|
@ -456,16 +456,6 @@ class JvmtiEnvIterator : public StackObj {
|
|||||||
JvmtiEnv* next(JvmtiEnvBase* env) { return env->next_environment(); }
|
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.
|
// Used in combination with the JvmtiHandshake class.
|
||||||
// It is intended to support both platform and virtual threads.
|
// It is intended to support both platform and virtual threads.
|
||||||
class JvmtiUnitedHandshakeClosure : public HandshakeClosure {
|
class JvmtiUnitedHandshakeClosure : public HandshakeClosure {
|
||||||
@ -499,36 +489,46 @@ class JvmtiHandshake : public Handshake {
|
|||||||
static void execute(JvmtiUnitedHandshakeClosure* hs_cl, jthread target);
|
static void execute(JvmtiUnitedHandshakeClosure* hs_cl, jthread target);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SetForceEarlyReturn : public JvmtiHandshakeClosure {
|
class SetForceEarlyReturn : public JvmtiUnitedHandshakeClosure {
|
||||||
private:
|
private:
|
||||||
JvmtiThreadState* _state;
|
JvmtiThreadState* _state;
|
||||||
jvalue _value;
|
jvalue _value;
|
||||||
TosState _tos;
|
TosState _tos;
|
||||||
public:
|
public:
|
||||||
SetForceEarlyReturn(JvmtiThreadState* state, jvalue value, TosState tos)
|
SetForceEarlyReturn(JvmtiThreadState* state, jvalue value, TosState tos)
|
||||||
: JvmtiHandshakeClosure("SetForceEarlyReturn"),
|
: JvmtiUnitedHandshakeClosure("SetForceEarlyReturn"),
|
||||||
_state(state),
|
_state(state),
|
||||||
_value(value),
|
_value(value),
|
||||||
_tos(tos) {}
|
_tos(tos) {}
|
||||||
|
void doit(Thread *target);
|
||||||
void do_thread(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.
|
// HandshakeClosure to update for pop top frame.
|
||||||
class UpdateForPopTopFrameClosure : public JvmtiHandshakeClosure {
|
class UpdateForPopTopFrameClosure : public JvmtiUnitedHandshakeClosure {
|
||||||
private:
|
private:
|
||||||
JvmtiThreadState* _state;
|
JvmtiThreadState* _state;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UpdateForPopTopFrameClosure(JvmtiThreadState* state)
|
UpdateForPopTopFrameClosure(JvmtiThreadState* state)
|
||||||
: JvmtiHandshakeClosure("UpdateForPopTopFrame"),
|
: JvmtiUnitedHandshakeClosure("UpdateForPopTopFrame"),
|
||||||
_state(state) {}
|
_state(state) {}
|
||||||
|
void doit(Thread *target);
|
||||||
void do_thread(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.
|
// HandshakeClosure to set frame pop.
|
||||||
|
Loading…
Reference in New Issue
Block a user