Skip to content

Commit

Permalink
Add flag to toggle reshuffle
Browse files Browse the repository at this point in the history
Summary: as title, no behavior change.

Reviewed By: thezhangwei

Differential Revision: D57133577

fbshipit-source-id: f9cdc993dc91ef5e7e3236e9f1a70b295c5d93b8
  • Loading branch information
beicy authored and facebook-github-bot committed May 9, 2024
1 parent 81a132a commit a93afe1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
24 changes: 16 additions & 8 deletions opt/class-merging/IntraDexClassMergingPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ void IntraDexClassMergingPass::bind_config() {
m_merging_spec.interdex_config.init_inferring_mode(
interdex_grouping_inferring_mode);
bind("enable_reshuffle", true, m_enable_reshuffle);
bind("enable_mergeability_aware_reshuffle", true,
m_enable_mergeability_aware_reshuffle);
// Bind reshuffle config.
bind("reserved_extra_frefs",
m_reshuffle_config.reserved_extra_frefs,
Expand Down Expand Up @@ -131,14 +133,20 @@ void IntraDexClassMergingPass::run_pass(DexStoresVector& stores,
auto& root_dexen = root_store.get_dexen();
if (m_enable_reshuffle && interdex_pass->minimize_cross_dex_refs() &&
root_dexen.size() > 1) {
class_merging::Model merging_model = class_merging::construct_global_model(
scope, mgr, conf, stores, m_merging_spec, m_global_min_count);

InterDexReshuffleImpl impl(conf, mgr, m_reshuffle_config, scope, root_dexen,
merging_model);
impl.compute_plan();
impl.apply_plan();

if (m_enable_mergeability_aware_reshuffle) {
class_merging::Model merging_model =
class_merging::construct_global_model(
scope, mgr, conf, stores, m_merging_spec, m_global_min_count);
InterDexReshuffleImpl impl(conf, mgr, m_reshuffle_config, scope,
root_dexen, merging_model);
impl.compute_plan();
impl.apply_plan();
} else {
InterDexReshuffleImpl impl(conf, mgr, m_reshuffle_config, scope,
root_dexen);
impl.compute_plan();
impl.apply_plan();
}
// Sanity check
std::unordered_set<DexClass*> original_scope_set(scope.begin(),
scope.end());
Expand Down
1 change: 1 addition & 0 deletions opt/class-merging/IntraDexClassMergingPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class IntraDexClassMergingPass : public Pass {
private:
ModelSpec m_merging_spec;
bool m_enable_reshuffle;
bool m_enable_mergeability_aware_reshuffle;
ReshuffleConfig m_reshuffle_config;
size_t m_global_min_count;
};
Expand Down

0 comments on commit a93afe1

Please sign in to comment.