Exemplo n.º 1
0
void TypeErasurePass::run_pass(DexStoresVector& stores,
                               ConfigFiles& conf,
                               PassManager& mgr) {
  // Type mapping file
  ModelMerger::s_mapping_file = conf.metafile(m_merged_type_mapping_file);
  Model::s_outdir = conf.get_outdir();

  // Setup Interdex plugin if any models.
  if (m_dex_sharding_model_specs.size() > 0) {
    interdex::InterDexRegistry* registry =
        static_cast<interdex::InterDexRegistry*>(
            PluginRegistry::get().pass_registry(interdex::INTERDEX_PASS_NAME));
    std::function<interdex::InterDexPassPlugin*()> fn =
        [&]() -> interdex::InterDexPassPlugin* {
      return new TypeErasureInterDexPlugin(m_dex_sharding_model_specs, mgr);
    };
    registry->register_plugin("TYPE_ERASURE_PLUGIN", std::move(fn));
  }

  if (m_model_specs.empty()) {
    return;
  }
  auto scope = build_class_scope(stores);
  Model::build_interdex_groups(&conf);
  for (ModelSpec& model_spec : m_model_specs) {
    if (!model_spec.enabled) {
      continue;
    }
    handle_interface_as_root(model_spec, scope, stores);
    erase_model(model_spec, scope, mgr, stores, conf);
  }
  post_dexen_changes(scope, stores);
}
Exemplo n.º 2
0
void RemoveUnreachablePass::run_pass(DexStoresVector& stores,
                                     ConfigFiles& conf,
                                     PassManager& pm) {
  // Store names of removed classes and methods
  ConcurrentSet<std::string> removed_symbols;

  if (pm.no_proguard_rules()) {
    TRACE(RMU,
          1,
          "RemoveUnreachablePass not run because no "
          "ProGuard configuration was provided.");
    return;
  }
  bool output_unreachable_symbols = pm.get_current_pass_info()->repeat == 0 &&
                                    !m_unreachable_symbols_file_name.empty();
  int num_ignore_check_strings = 0;
  auto reachables = reachability::compute_reachable_objects(
      stores, m_ignore_sets, &num_ignore_check_strings);
  reachability::ObjectCounts before = reachability::count_objects(stores);
  TRACE(RMU, 1, "before: %lu classes, %lu fields, %lu methods\n",
        before.num_classes, before.num_fields, before.num_methods);
  reachability::sweep(stores, *reachables,
                      output_unreachable_symbols ? &removed_symbols : nullptr);
  reachability::ObjectCounts after = reachability::count_objects(stores);
  TRACE(RMU, 1, "after: %lu classes, %lu fields, %lu methods\n",
        after.num_classes, after.num_fields, after.num_methods);
  pm.incr_metric("num_ignore_check_strings", num_ignore_check_strings);
  pm.incr_metric("classes_removed", before.num_classes - after.num_classes);
  pm.incr_metric("fields_removed", before.num_fields - after.num_fields);
  pm.incr_metric("methods_removed", before.num_methods - after.num_methods);

  if (output_unreachable_symbols) {
    std::string filepath = conf.metafile(m_unreachable_symbols_file_name);
    write_out_removed_symbols(filepath, removed_symbols);
  }
}
Exemplo n.º 3
0
void ShortenSrcStringsPass::run_pass(DexStoresVector& stores,
                                     ConfigFiles& conf,
                                     PassManager& mgr) {
  m_filename_mappings = conf.metafile(m_filename_mappings);
  strip_src_strings(stores, m_filename_mappings.c_str(), mgr);
}