Commit 5062bb41 authored by Jasper Chapman-Black's avatar Jasper Chapman-Black Committed by Commit Bot

SuperSize: Caspian: Group dex classes with no path

Change-Id: Ic53887c62d7907f096520b5074fd55195c1ec530
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933382
Commit-Queue: Jasper Chapman-Black <jaspercb@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718790}
parent 2e2b5c64
...@@ -319,6 +319,9 @@ void TreeNode::WriteIntoJson( ...@@ -319,6 +319,9 @@ void TreeNode::WriteIntoJson(
compare_func, compare_func,
Json::Value* out) { Json::Value* out) {
if (symbol) { if (symbol) {
if (symbol->NumAliases() > 1) {
(*out)["numAliases"] = symbol->NumAliases();
}
if (symbol->IsDex()) { if (symbol->IsDex()) {
(*out)["idPath"] = std::string(symbol->FullName()); (*out)["idPath"] = std::string(symbol->FullName());
} else { } else {
......
...@@ -239,10 +239,7 @@ void TreeBuilder::JoinDexMethodClasses(TreeNode* node) { ...@@ -239,10 +239,7 @@ void TreeBuilder::JoinDexMethodClasses(TreeNode* node) {
const bool has_dex = const bool has_dex =
node->node_stats.child_stats.count(SectionId::kDex) || node->node_stats.child_stats.count(SectionId::kDex) ||
node->node_stats.child_stats.count(SectionId::kDexMethod); node->node_stats.child_stats.count(SectionId::kDexMethod);
// Don't try to merge dex symbols for catch-all symbols under (No path). if (!is_file_node || !has_dex || node->children.empty()) {
const bool is_no_path = node->id_path.path == kNoName;
if (!is_file_node || !has_dex || is_no_path || node->children.empty()) {
return; return;
} }
...@@ -263,7 +260,10 @@ void TreeBuilder::JoinDexMethodClasses(TreeNode* node) { ...@@ -263,7 +260,10 @@ void TreeBuilder::JoinDexMethodClasses(TreeNode* node) {
const bool has_class_prefix = const bool has_class_prefix =
is_class_node || split_index != std::string_view::npos; is_class_node || split_index != std::string_view::npos;
if (has_class_prefix) { const SectionId section =
child->symbol ? child->symbol->Section() : SectionId::kNone;
if (has_class_prefix &&
(section == SectionId::kDex || section == SectionId::kDexMethod)) {
const std::string_view class_id_path = const std::string_view class_id_path =
child->id_path.path.substr(0, split_index); child->id_path.path.substr(0, split_index);
...@@ -278,11 +278,21 @@ void TreeBuilder::JoinDexMethodClasses(TreeNode* node) { ...@@ -278,11 +278,21 @@ void TreeBuilder::JoinDexMethodClasses(TreeNode* node) {
TreeNode*& class_node = java_class_containers[class_id_path]; TreeNode*& class_node = java_class_containers[class_id_path];
if (class_node == nullptr) { if (class_node == nullptr) {
// We have to construct the class node id_path, because parent nodes
// need to have an id_path that describes how to reach them from root.
// Symbol (leaf) nodes typically store their full name in the id_path,
// which for class nodes would be as "org.x.y.ClassName" even if that
// node's parent is the file "a/b/c". So if we want an id_path of the
// form "a/b/c/ClassName$0", we have to create it.
class_node = new TreeNode(); class_node = new TreeNode();
class_node->id_path = GroupedPath{child->id_path.group, class_id_path}; owned_strings_.push_back(std::string(node->id_path.path) + "/" +
std::string(class_id_path));
class_node->id_path =
GroupedPath{node->id_path.group, owned_strings_.back()};
class_node->short_name_index =
short_name_index + node->id_path.path.size() + 1;
class_node->src_path = node->src_path; class_node->src_path = node->src_path;
class_node->component = node->component; class_node->component = node->component;
class_node->short_name_index = short_name_index;
class_node->container_type = ContainerType::kJavaClass; class_node->container_type = ContainerType::kJavaClass;
_parents[class_node->id_path] = class_node; _parents[class_node->id_path] = class_node;
} }
......
...@@ -152,6 +152,8 @@ TEST(TreeBuilderTest, TestJoinDexMethodClasses) { ...@@ -152,6 +152,8 @@ TEST(TreeBuilderTest, TestJoinDexMethodClasses) {
["children"][0]; ["children"][0];
EXPECT_EQ( EXPECT_EQ(
"Mobile/chrome/android/features/start_surface/public/java/src/"
"org/chromium/chrome/features/start_surface/StartSurface.java/"
"org.chromium.chrome.features.start_surface.StartSurface$" "org.chromium.chrome.features.start_surface.StartSurface$"
"OverviewModeObserver", "OverviewModeObserver",
class_symbol["idPath"].asString()); class_symbol["idPath"].asString());
......
...@@ -107,6 +107,7 @@ class DataFetcher { ...@@ -107,6 +107,7 @@ class DataFetcher {
} }
} else { } else {
// In-memory version for browsers without stream support // In-memory version for browsers without stream support
result = new Uint8Array(await response.arrayBuffer());
yield result; yield result;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment