Skip to content

Commit

Permalink
relocate_method does not change_visibility
Browse files Browse the repository at this point in the history
Summary:
Note that the comment on `relocate_method` even says that it doesn't deal with visibility. This is actually honored in this diff, where the visibility changes are made explicit wherever methods are relocated.

This is a behavior-preserving change.

Reviewed By: thezhangwei

Differential Revision: D49213735

fbshipit-source-id: 49ef4e315632db85ed3bdce6a46e2b227a5ce116
  • Loading branch information
Nikolai Tillmann authored and facebook-github-bot committed Sep 15, 2023
1 parent d8f2552 commit f643043
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions libredex/DexUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ void create_store(const std::string& store_name,
}

void relocate_field(DexField* field, DexType* to_type) {
// change_visibility(field, to_type);
auto from_cls = type_class(field->get_class());
auto to_cls = type_class(to_type);
from_cls->remove_field(field);
Expand All @@ -259,7 +258,6 @@ void relocate_field(DexField* field, DexType* to_type) {
}

void relocate_method(DexMethod* method, DexType* to_type) {
change_visibility(method, to_type);
auto from_cls = type_class(method->get_class());
auto to_cls = type_class(to_type);
from_cls->remove_method(method);
Expand Down Expand Up @@ -441,6 +439,7 @@ bool relocate_method_if_no_changes(DexMethod* method, DexType* to_type) {
}

set_public(method);
change_visibility(method, to_type);
relocate_method(method, to_type);
change_visibility(method);

Expand Down
1 change: 1 addition & 0 deletions opt/kotlin-lambda/KotlinObjectInliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ void make_static_and_relocate_method(DexMethod* method, DexType* to_type) {
uses_this(method, true) ? mutators::KeepThis::Yes
: mutators::KeepThis::No);
}
change_visibility(method, to_type);
relocate_method(method, to_type);
}

Expand Down
1 change: 1 addition & 0 deletions opt/outliner/InstructionSequenceOutliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2716,6 +2716,7 @@ void reorder_with_method_profiles(
"from %s to %s",
SHOW(method->get_name()), SHOW(method->get_class()),
SHOW(target_class));
change_visibility(method, target_class->get_type());
relocate_method(method, target_class->get_type());
method->set_deobfuscated_name(show(method));
relocated_outlined_methods++;
Expand Down
2 changes: 2 additions & 0 deletions opt/staticrelo/StaticReloV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ int relocate_clusters(const StaticCallGraph& graph, const Scope& scope) {
// caller
int caller_id = *graph.callers[vertex.id].begin();
DexMethod* caller = graph.vertices[caller_id].method;
change_visibility(vertex.method, caller->get_class());
relocate_method(vertex.method, caller->get_class());
relocated_methods++;
set_public(vertex.method);
Expand All @@ -212,6 +213,7 @@ int relocate_clusters(const StaticCallGraph& graph, const Scope& scope) {
// higher or equal to the api level of the method.
if (to_class->rstate.get_api_level() >=
api::LevelChecker::get_method_level(vertex.method)) {
change_visibility(vertex.method, to_class->get_type());
relocate_method(vertex.method, to_class->get_type());
relocated_methods++;
}
Expand Down
2 changes: 2 additions & 0 deletions service/class-merging/ModelMethodMerger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ void ModelMethodMerger::dedup_non_ctor_non_virt_methods() {
SHOW(merger_type));

TRACE(CLMG, 8, "dedup: moving static|non_virt method %s", SHOW(m));
change_visibility(m, merger_type);
relocate_method(m, merger_type);
}

Expand Down Expand Up @@ -920,6 +921,7 @@ void ModelMethodMerger::merge_virt_itf_methods() {
for (const auto& pair : not_inlined_dispatch_entries) {
auto merger_type = pair.first;
auto not_inlined = pair.second;
change_visibility(not_inlined, merger_type);
relocate_method(not_inlined, merger_type);
}
}
Expand Down
1 change: 1 addition & 0 deletions service/class-splitting/ClassSplitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ void ClassSplitter::cleanup(const Scope& final_scope) {
if (!is_static(method)) {
mutators::make_static(method);
}
change_visibility(method, target_cls->get_type());
relocate_method(method, target_cls->get_type());
change_visibility(method);
}
Expand Down

0 comments on commit f643043

Please sign in to comment.