Esempio n. 1
0
TEST(Type, CanRunDtor) {
  TypeSet types = allTypes();
  auto expectTrue = [&](Type t) {
    EXPECT_TRUE(t.canRunDtor()) << t.toString() << ".canRunDtor() == true";
    types.erase(t);
  };
  expectTrue(Type::Arr);
  expectTrue(Type::CountedArr);
  expectTrue(Type::Obj);
  expectTrue(Type::Res);
  expectTrue(Type::Counted);
  expectTrue(Type::BoxedArr);
  expectTrue(Type::BoxedCountedArr);
  expectTrue(Type::BoxedObj);
  expectTrue(Type::BoxedRes);
  expectTrue(Type::BoxedCell);
  expectTrue(Type::Cell);
  expectTrue(Type::Gen);
  expectTrue(Type::Ctx);
  expectTrue(Type::Obj | Type::Func);
  expectTrue(Type::Init);
  expectTrue(Type::Top);
  expectTrue(Type::StackElem);
  expectTrue(Type::AnyObj);
  expectTrue(Type::AnyRes);
  expectTrue(Type::AnyArr);
  expectTrue(Type::AnyCountedArr);
  expectTrue(Type::AnyCell);

  for (Type t : types) {
    EXPECT_FALSE(t.canRunDtor()) << t.toString() << ".canRunDtor == false";
  }
}
Esempio n. 2
0
void RemoveInterfacePass::remove_interfaces_for_root(
    const Scope& scope,
    const DexStoresVector& stores,
    const DexType* root,
    const TypeSystem& type_system) {
  TRACE(RM_INTF, 5, "Processing root %s\n", SHOW(root));
  TypeSet interfaces;
  type_system.get_all_interface_children(root, interfaces);
  include_parent_interfaces(root, interfaces);

  m_total_num_interface += interfaces.size();
  m_num_interface_excluded += exclude_unremovables(
      scope, stores, type_system, m_skip_multiple_targets_roots,
      m_include_primary_dex, interfaces);

  TRACE(RM_INTF, 5, "removable interfaces %ld\n", interfaces.size());
  TypeSet removed =
      remove_leaf_interfaces(scope, root, interfaces, type_system);

  while (removed.size() > 0) {
    for (const auto intf : removed) {
      interfaces.erase(intf);
      m_removed_interfaces.insert(intf);
    }
    TRACE(RM_INTF, 5, "non-leaf removable interfaces %ld\n", interfaces.size());
    removed = remove_leaf_interfaces(scope, root, interfaces, type_system);
  }

  // Update type reference to removed interfaces all at once.
  remove_interface_references(scope, type_system, root, m_removed_interfaces);

  if (traceEnabled(RM_INTF, 9)) {
    TypeSystem updated_ts(scope);
    for (const auto intf : interfaces) {
      TRACE(RM_INTF, 9, "unremoved interface %s\n", SHOW(intf));
      TypeSet children;
      updated_ts.get_all_interface_children(intf, children);
      for (const auto cintf : children) {
        TRACE(RM_INTF, 9, "  child %s\n", SHOW(cintf));
      }
    }
  }
}