Skip to content
Permalink
Browse files

8238782: Cleanup Deoptimization::deoptimize(): remove unused Register…

…Map argument and don't update RegisterMap in callers if UseBiasedLocking is enabled

Reviewed-by: dholmes, kvn
  • Loading branch information
Richard Reingruber
Richard Reingruber committed Feb 12, 2020
1 parent 446f59a commit b0b8190ea2b2031c2b385f12f99e69d373ac5d1a
@@ -1461,7 +1461,7 @@ C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv* env, jobject, jobject _hs_
JVMCIENV->HotSpotStackFrameReference_initialize(JVMCI_CHECK);

// look for the given stack frame
StackFrameStream fst(thread);
StackFrameStream fst(thread, false);
intptr_t* stack_pointer = (intptr_t*) JVMCIENV->get_HotSpotStackFrameReference_stackPointer(hs_frame);
while (fst.current()->sp() != stack_pointer && !fst.is_done()) {
fst.next();
@@ -1477,7 +1477,7 @@ C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv* env, jobject, jobject _hs_
assert(fst.current()->cb()->is_nmethod(), "nmethod expected");
((nmethod*) fst.current()->cb())->make_not_entrant();
}
Deoptimization::deoptimize(thread, *fst.current(), fst.register_map(), Deoptimization::Reason_none);
Deoptimization::deoptimize(thread, *fst.current(), Deoptimization::Reason_none);
// look for the frame again as it has been updated by deopt (pc, deopt state...)
StackFrameStream fstAfterDeopt(thread);
while (fstAfterDeopt.current()->sp() != stack_pointer && !fstAfterDeopt.is_done()) {
@@ -834,11 +834,10 @@ class VM_WhiteBoxDeoptimizeFrames : public VM_WhiteBoxOperation {
void doit() {
for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
if (t->has_last_Java_frame()) {
for (StackFrameStream fst(t, UseBiasedLocking); !fst.is_done(); fst.next()) {
for (StackFrameStream fst(t, false); !fst.is_done(); fst.next()) {
frame* f = fst.current();
if (f->can_be_deoptimized() && !f->is_deoptimized_frame()) {
RegisterMap* reg_map = fst.register_map();
Deoptimization::deoptimize(t, *f, reg_map);
Deoptimization::deoptimize(t, *f);
if (_make_not_entrant) {
CompiledMethod* cm = CodeCache::find_compiled(f->pc());
assert(cm != NULL, "sanity check");
@@ -1516,7 +1516,7 @@ void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deopt
fr.deoptimize(thread);
}

void Deoptimization::deoptimize(JavaThread* thread, frame fr, RegisterMap *map, DeoptReason reason) {
void Deoptimization::deoptimize(JavaThread* thread, frame fr, 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.
@@ -1534,15 +1534,15 @@ address Deoptimization::deoptimize_for_missing_exception_handler(CompiledMethod*
cm->make_not_entrant();

// Use Deoptimization::deoptimize for all of its side-effects:
// revoking biases of monitors, gathering traps statistics, logging...
// gathering traps statistics, logging...
// it also patches the return pc but we do not care about that
// since we return a continuation to the deopt_blob below.
JavaThread* thread = JavaThread::current();
RegisterMap reg_map(thread, UseBiasedLocking);
RegisterMap reg_map(thread, false);
frame runtime_frame = thread->last_frame();
frame caller_frame = runtime_frame.sender(&reg_map);
assert(caller_frame.cb()->as_compiled_method_or_null() == cm, "expect top frame compiled method");
Deoptimization::deoptimize(thread, caller_frame, &reg_map, Deoptimization::Reason_not_compiled_exception_handler);
Deoptimization::deoptimize(thread, caller_frame, Deoptimization::Reason_not_compiled_exception_handler);

MethodData* trap_mdo = get_method_data(thread, methodHandle(thread, cm->method()), true);
if (trap_mdo != NULL) {
@@ -1557,12 +1557,12 @@ void Deoptimization::deoptimize_frame_internal(JavaThread* thread, intptr_t* id,
assert(thread == Thread::current() || SafepointSynchronize::is_at_safepoint(),
"can only deoptimize other thread at a safepoint");
// Compute frame and register map based on thread and sp.
RegisterMap reg_map(thread, UseBiasedLocking);
RegisterMap reg_map(thread, false);
frame fr = thread->last_frame();
while (fr.id() != id) {
fr = fr.sender(&reg_map);
}
deoptimize(thread, fr, &reg_map, reason);
deoptimize(thread, fr, reason);
}


@@ -148,8 +148,8 @@ class Deoptimization : AllStatic {
static void revoke_from_deopt_handler(JavaThread* thread, frame fr, RegisterMap* map);

public:
// Deoptimizes a frame lazily. nmethod gets patched deopt happens on return to the frame
static void deoptimize(JavaThread* thread, frame fr, RegisterMap *reg_map, DeoptReason reason = Reason_constraint);
// Deoptimizes a frame lazily. Deopt happens on return to the frame.
static void deoptimize(JavaThread* thread, frame fr, DeoptReason reason = Reason_constraint);

#if INCLUDE_JVMCI
static address deoptimize_for_missing_exception_handler(CompiledMethod* cm);
@@ -2413,11 +2413,10 @@ void JavaThread::send_thread_stop(oop java_throwable) {
if (has_last_Java_frame()) {
frame f = last_frame();
if (f.is_runtime_frame() || f.is_safepoint_blob_frame()) {
// BiasedLocking needs an updated RegisterMap for the revoke monitors pass
RegisterMap reg_map(this, UseBiasedLocking);
RegisterMap reg_map(this, false);
frame compiled_frame = f.sender(&reg_map);
if (!StressCompiledExceptionHandlers && compiled_frame.can_be_deoptimized()) {
Deoptimization::deoptimize(this, compiled_frame, &reg_map);
Deoptimization::deoptimize(this, compiled_frame);
}
}
}
@@ -2862,8 +2861,7 @@ void JavaThread::frames_do(void f(frame*, const RegisterMap* map)) {
// Deoptimization
// Function for testing deoptimization
void JavaThread::deoptimize() {
// BiasedLocking needs an updated RegisterMap for the revoke monitors pass
StackFrameStream fst(this, UseBiasedLocking);
StackFrameStream fst(this, false);
bool deopt = false; // Dump stack only if a deopt actually happens.
bool only_at = strlen(DeoptimizeOnlyAt) > 0;
// Iterate over all frames in the thread and deoptimize
@@ -2900,7 +2898,7 @@ void JavaThread::deoptimize() {
trace_frames();
trace_stack();
}
Deoptimization::deoptimize(this, *fst.current(), fst.register_map());
Deoptimization::deoptimize(this, *fst.current());
}
}

@@ -2926,11 +2924,10 @@ void JavaThread::make_zombies() {

void JavaThread::deoptimize_marked_methods() {
if (!has_last_Java_frame()) return;
// BiasedLocking needs an updated RegisterMap for the revoke monitors pass
StackFrameStream fst(this, UseBiasedLocking);
StackFrameStream fst(this, false);
for (; !fst.is_done(); fst.next()) {
if (fst.current()->should_be_deoptimized()) {
Deoptimization::deoptimize(this, *fst.current(), fst.register_map());
Deoptimization::deoptimize(this, *fst.current());
}
}
}
@@ -134,12 +134,11 @@ void VM_DeoptimizeAll::doit() {
tcount = 0;
int fcount = 0;
// Deoptimize some selected frames.
// Biased llocking wants a updated register map
for(StackFrameStream fst(thread, UseBiasedLocking); !fst.is_done(); fst.next()) {
for(StackFrameStream fst(thread, false); !fst.is_done(); fst.next()) {
if (fst.current()->can_be_deoptimized()) {
if (fcount++ == fnum) {
fcount = 0;
Deoptimization::deoptimize(thread, *fst.current(), fst.register_map());
Deoptimization::deoptimize(thread, *fst.current());
}
}
}

0 comments on commit b0b8190

Please sign in to comment.