Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8266074: Vtable-based CHA implementation
Reviewed-by: kvn, jrose, dlong
  • Loading branch information
Vladimir Ivanov committed May 13, 2021
1 parent 347d41d commit 127bfe4
Show file tree
Hide file tree
Showing 11 changed files with 551 additions and 75 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/c1/c1_GraphBuilder.cpp
Expand Up @@ -2026,7 +2026,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
// by dynamic class loading. Be sure to test the "static" receiver
// dest_method here, as opposed to the actual receiver, which may
// falsely lead us to believe that the receiver is final or private.
dependency_recorder()->assert_unique_concrete_method(actual_recv, cha_monomorphic_target);
dependency_recorder()->assert_unique_concrete_method(actual_recv, cha_monomorphic_target, callee_holder, target);
}
code = Bytecodes::_invokespecial;
}
Expand Down
13 changes: 9 additions & 4 deletions src/hotspot/share/ci/bcEscapeAnalyzer.cpp
Expand Up @@ -346,6 +346,9 @@ void BCEscapeAnalyzer::invoke(StateInfo &state, Bytecodes::Code code, ciMethod*
(code == Bytecodes::_invokevirtual && !target->is_final_method())) {
_dependencies.append(actual_recv);
_dependencies.append(inline_target);
_dependencies.append(callee_holder);
_dependencies.append(target);
assert(callee_holder->is_interface() == (code == Bytecodes::_invokeinterface), "sanity");
}
_dependencies.appendAll(analyzer.dependencies());
}
Expand Down Expand Up @@ -1495,9 +1498,11 @@ void BCEscapeAnalyzer::copy_dependencies(Dependencies *deps) {
// callee will trigger recompilation.
deps->assert_evol_method(method());
}
for (int i = 0; i < _dependencies.length(); i+=2) {
ciKlass *k = _dependencies.at(i)->as_klass();
ciMethod *m = _dependencies.at(i+1)->as_method();
deps->assert_unique_concrete_method(k, m);
for (int i = 0; i < _dependencies.length(); i+=4) {
ciKlass* recv_klass = _dependencies.at(i+0)->as_klass();
ciMethod* target = _dependencies.at(i+1)->as_method();
ciKlass* resolved_klass = _dependencies.at(i+2)->as_klass();
ciMethod* resolved_method = _dependencies.at(i+3)->as_method();
deps->assert_unique_concrete_method(recv_klass, target, resolved_klass, resolved_method);
}
}
10 changes: 9 additions & 1 deletion src/hotspot/share/ci/ciMethod.cpp
Expand Up @@ -714,7 +714,15 @@ ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller,
{
MutexLocker locker(Compile_lock);
InstanceKlass* context = actual_recv->get_instanceKlass();
target = methodHandle(THREAD, Dependencies::find_unique_concrete_method(context, root_m->get_Method()));
if (UseVtableBasedCHA) {
target = methodHandle(THREAD, Dependencies::find_unique_concrete_method(context,
root_m->get_Method(),
callee_holder->get_Klass(),
this->get_Method()));
} else {
target = methodHandle(THREAD, Dependencies::find_unique_concrete_method(context, root_m->get_Method()));
}
assert(target() == NULL || !target()->is_abstract(), "not allowed");
// %%% Should upgrade this ciMethod API to look for 1 or 2 concrete methods.
}

Expand Down
14 changes: 11 additions & 3 deletions src/hotspot/share/code/codeCache.cpp
Expand Up @@ -1184,10 +1184,18 @@ void CodeCache::flush_dependents_on(InstanceKlass* dependee) {

if (number_of_nmethods_with_dependencies() == 0) return;

KlassDepChange changes(dependee);
int marked = 0;
if (dependee->is_linked()) {
// Class initialization state change.
KlassInitDepChange changes(dependee);
marked = mark_for_deoptimization(changes);
} else {
// New class is loaded.
NewKlassDepChange changes(dependee);
marked = mark_for_deoptimization(changes);
}

// Compute the dependent nmethods
if (mark_for_deoptimization(changes) > 0) {
if (marked > 0) {
// At least one nmethod has been marked for deoptimization
Deoptimization::deoptimize_all_marked();
}
Expand Down

1 comment on commit 127bfe4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.