[vm/aot] Minor improvements to make snapshot profiles more useful.
Change-Id: I614d0af3fb3b2bcb642f13d767c385d255b43d5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105580
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
diff --git a/pkg/vm/lib/v8_snapshot_profile.dart b/pkg/vm/lib/v8_snapshot_profile.dart
index efda4c1..2b1ad73 100644
--- a/pkg/vm/lib/v8_snapshot_profile.dart
+++ b/pkg/vm/lib/v8_snapshot_profile.dart
@@ -46,10 +46,10 @@
];
class NodeInfo {
- String type;
- String name;
- int id;
- int selfSize;
+ final String type;
+ final String name;
+ final int id;
+ final int selfSize;
NodeInfo(
this.type,
this.name,
@@ -58,6 +58,16 @@
);
}
+class EdgeInfo {
+ final int target;
+ final String type;
+
+ // Either a string for property names or an int for array/context elements.
+ final dynamic nameOrIndex;
+
+ EdgeInfo(this.target, this.type, this.nameOrIndex);
+}
+
class V8SnapshotProfile extends Graph<int> {
// Indexed by node offset.
final Map<int, _NodeInfo> _nodes = {};
@@ -265,4 +275,12 @@
final name = info.name != null ? _strings[info.name] : null;
return NodeInfo(type, name, info.id, info.selfSize);
}
+
+ Iterable<EdgeInfo> targets(int node) sync* {
+ for (final _EdgeInfo info in _toEdges[node]) {
+ final String type = _edgeTypes[info.type];
+ yield EdgeInfo(info.nodeOffset, type,
+ type == "property" ? _strings[info.nameOrIndex] : info.nameOrIndex);
+ }
+ }
}
diff --git a/runtime/vm/v8_snapshot_writer.cc b/runtime/vm/v8_snapshot_writer.cc
index b8ef328..9c04c5a 100644
--- a/runtime/vm/v8_snapshot_writer.cc
+++ b/runtime/vm/v8_snapshot_writer.cc
@@ -31,14 +31,8 @@
edge_types_.Insert({"element", kElement});
edge_types_.Insert({"property", kProperty});
edge_types_.Insert({"internal", kInternal});
- edge_types_.Insert({"hidden", kHidden});
- edge_types_.Insert({"shortcut", kShortcut});
- edge_types_.Insert({"weak", kWeak});
- edge_types_.Insert({"extra", kExtra});
strings_.Insert({"<unknown>", kUnknownString});
- strings_.Insert({"<object>", kObjectString});
- strings_.Insert({"<property>", kPropertyString});
strings_.Insert({"<artificial root>", kArtificialRootString});
}
@@ -55,11 +49,11 @@
intptr_t type_id = node_types_.LookupValue(type);
ASSERT(info->type == kUnknown || info->type == type_id);
info->type = type_id;
-
if (name != nullptr) {
- info->name = EnsureString(OS::SCreate(zone_, "[%s] %s", type, name));
+ info->name = EnsureString(name);
} else {
- info->name = EnsureString(type);
+ info->name =
+ EnsureString(OS::SCreate(zone_, "Unnamed [%s] %s", type, name));
}
}
@@ -245,7 +239,7 @@
ObjectIdToNodeInfoTraits::Pair* entry = nullptr;
auto roots_it = roots_.GetIterator();
for (int i = 0; (entry = roots_it.Next()) != nullptr; ++i) {
- WriteEdgeInfo(writer, {kElement, i, entry->key});
+ WriteEdgeInfo(writer, {kInternal, i, entry->key});
}
auto nodes_it = nodes_.GetIterator();
diff --git a/runtime/vm/v8_snapshot_writer.h b/runtime/vm/v8_snapshot_writer.h
index 63d0617..b3e5e09 100644
--- a/runtime/vm/v8_snapshot_writer.h
+++ b/runtime/vm/v8_snapshot_writer.h
@@ -61,9 +61,7 @@
enum ConstantStrings {
kUnknownString = 0,
- kPropertyString = 1,
- kObjectString = 2,
- kArtificialRootString = 3,
+ kArtificialRootString = 1,
};
#if !defined(DART_PRECOMPILER)