mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 10:34:38 +02:00
8226699: [BACKOUT] JDK-8221734 Deoptimize with handshakes
Reviewed-by: dholmes, rehn, dlong
This commit is contained in:
parent
01c739c34a
commit
d6be015b16
28 changed files with 175 additions and 274 deletions
|
@ -779,35 +779,10 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
|
|||
return bt;
|
||||
JRT_END
|
||||
|
||||
class DeoptimizeMarkedTC : public ThreadClosure {
|
||||
bool _in_handshake;
|
||||
public:
|
||||
DeoptimizeMarkedTC(bool in_handshake) : _in_handshake(in_handshake) {}
|
||||
virtual void do_thread(Thread* thread) {
|
||||
assert(thread->is_Java_thread(), "must be");
|
||||
JavaThread* jt = (JavaThread*)thread;
|
||||
jt->deoptimize_marked_methods(_in_handshake);
|
||||
}
|
||||
};
|
||||
|
||||
void Deoptimization::deoptimize_all_marked() {
|
||||
ResourceMark rm;
|
||||
DeoptimizationMarker dm;
|
||||
|
||||
if (SafepointSynchronize::is_at_safepoint()) {
|
||||
DeoptimizeMarkedTC deopt(false);
|
||||
// Make the dependent methods not entrant
|
||||
CodeCache::make_marked_nmethods_not_entrant();
|
||||
Threads::java_threads_do(&deopt);
|
||||
} else {
|
||||
// Make the dependent methods not entrant
|
||||
{
|
||||
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
|
||||
CodeCache::make_marked_nmethods_not_entrant();
|
||||
}
|
||||
DeoptimizeMarkedTC deopt(true);
|
||||
Handshake::execute(&deopt);
|
||||
}
|
||||
int Deoptimization::deoptimize_dependents() {
|
||||
Threads::deoptimized_wrt_marked_nmethods();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Deoptimization::DeoptAction Deoptimization::_unloaded_action
|
||||
|
@ -1412,7 +1387,14 @@ static void collect_monitors(compiledVFrame* cvf, GrowableArray<Handle>* objects
|
|||
}
|
||||
}
|
||||
|
||||
static void get_monitors_from_stack(GrowableArray<Handle>* objects_to_revoke, JavaThread* thread, frame fr, RegisterMap* map) {
|
||||
|
||||
void Deoptimization::revoke_biases_of_monitors(JavaThread* thread, frame fr, RegisterMap* map) {
|
||||
if (!UseBiasedLocking) {
|
||||
return;
|
||||
}
|
||||
|
||||
GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>();
|
||||
|
||||
// Unfortunately we don't have a RegisterMap available in most of
|
||||
// the places we want to call this routine so we need to walk the
|
||||
// stack again to update the register map.
|
||||
|
@ -1436,14 +1418,6 @@ static void get_monitors_from_stack(GrowableArray<Handle>* objects_to_revoke, Ja
|
|||
cvf = compiledVFrame::cast(cvf->sender());
|
||||
}
|
||||
collect_monitors(cvf, objects_to_revoke);
|
||||
}
|
||||
|
||||
void Deoptimization::revoke_using_safepoint(JavaThread* thread, frame fr, RegisterMap* map) {
|
||||
if (!UseBiasedLocking) {
|
||||
return;
|
||||
}
|
||||
GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>();
|
||||
get_monitors_from_stack(objects_to_revoke, thread, fr, map);
|
||||
|
||||
if (SafepointSynchronize::is_at_safepoint()) {
|
||||
BiasedLocking::revoke_at_safepoint(objects_to_revoke);
|
||||
|
@ -1452,21 +1426,6 @@ void Deoptimization::revoke_using_safepoint(JavaThread* thread, frame fr, Regist
|
|||
}
|
||||
}
|
||||
|
||||
void Deoptimization::revoke_using_handshake(JavaThread* thread, frame fr, RegisterMap* map) {
|
||||
if (!UseBiasedLocking) {
|
||||
return;
|
||||
}
|
||||
GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>();
|
||||
get_monitors_from_stack(objects_to_revoke, thread, fr, map);
|
||||
|
||||
int len = objects_to_revoke->length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
oop obj = (objects_to_revoke->at(i))();
|
||||
BiasedLocking::revoke_own_locks_in_handshake(objects_to_revoke->at(i), thread);
|
||||
assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) {
|
||||
assert(fr.can_be_deoptimized(), "checking frame type");
|
||||
|
@ -1495,16 +1454,11 @@ void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deopt
|
|||
fr.deoptimize(thread);
|
||||
}
|
||||
|
||||
void Deoptimization::deoptimize(JavaThread* thread, frame fr, RegisterMap *map, bool in_handshake) {
|
||||
deopt_thread(in_handshake, thread, fr, map, Reason_constraint);
|
||||
void Deoptimization::deoptimize(JavaThread* thread, frame fr, RegisterMap *map) {
|
||||
deoptimize(thread, fr, map, Reason_constraint);
|
||||
}
|
||||
|
||||
void Deoptimization::deoptimize(JavaThread* thread, frame fr, RegisterMap *map, DeoptReason reason) {
|
||||
deopt_thread(false, thread, fr, map, reason);
|
||||
}
|
||||
|
||||
void Deoptimization::deopt_thread(bool in_handshake, JavaThread* thread,
|
||||
frame fr, RegisterMap *map, DeoptReason reason) {
|
||||
// Deoptimize only if the frame comes from compile code.
|
||||
// Do not deoptimize the frame which is already patched
|
||||
// during the execution of the loops below.
|
||||
|
@ -1514,11 +1468,7 @@ void Deoptimization::deopt_thread(bool in_handshake, JavaThread* thread,
|
|||
ResourceMark rm;
|
||||
DeoptimizationMarker dm;
|
||||
if (UseBiasedLocking) {
|
||||
if (in_handshake) {
|
||||
revoke_using_handshake(thread, fr, map);
|
||||
} else {
|
||||
revoke_using_safepoint(thread, fr, map);
|
||||
}
|
||||
revoke_biases_of_monitors(thread, fr, map);
|
||||
}
|
||||
deoptimize_single_frame(thread, fr, reason);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue