Skip to content

Commit

Permalink
streamline handling of external methods in override graph
Browse files Browse the repository at this point in the history
Summary: This is a behavior-preserving change.

Reviewed By: thezhangwei

Differential Revision: D49800672

fbshipit-source-id: 30d454a726a07553079759ecdd67d7c3eaffee63
  • Loading branch information
Nikolai Tillmann authored and facebook-github-bot committed Oct 17, 2023
1 parent a31a62c commit 392c265
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions libredex/CallGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,22 @@ RootAndDynamic MultipleCalleeBaseStrategy::get_roots() const {
const auto& overriding_methods =
mog::get_overriding_methods(m_method_override_graph, method);
for (auto* overriding : overriding_methods) {
if (overriding->is_external()) {
dynamic_methods.emplace(overriding);
}
// We don't need to add overriding to dynamic_methods here, as that will
// happen anyway.
if (!overriding->is_external() && overriding->get_code()) {
roots.insert(overriding);
}
}
// Internal methods might be overriden by external methods. Add such
// methods to dynamic methods to avoid return value propagation as well.
const auto& overiden_methods =
// We don't need to add overridden external methods to dynamic_methods, as
// that will happen anyway. Internal interface methods can be overridden
// by external methods as well.
const auto& overridden_methods =
mog::get_overridden_methods(m_method_override_graph, method, true);
for (auto m : overiden_methods) {
dynamic_methods.emplace(m);
for (auto m : overridden_methods) {
if (!m->is_external()) {
always_assert(is_interface(type_class(m->get_class())));
dynamic_methods.emplace(m);
}
}
}
if (is_native(method)) {
Expand Down

0 comments on commit 392c265

Please sign in to comment.