Skip to content

Commit 8d39e34

Browse files
sjindel-googlecommit-bot@chromium.org
authored andcommitted
[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>
1 parent 977ae22 commit 8d39e34

3 files changed

Lines changed: 27 additions & 17 deletions

File tree

pkg/vm/lib/v8_snapshot_profile.dart

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ const List<String> _kRequiredEdgeFields = [
4646
];
4747

4848
class NodeInfo {
49-
String type;
50-
String name;
51-
int id;
52-
int selfSize;
49+
final String type;
50+
final String name;
51+
final int id;
52+
final int selfSize;
5353
NodeInfo(
5454
this.type,
5555
this.name,
@@ -58,6 +58,16 @@ class NodeInfo {
5858
);
5959
}
6060

61+
class EdgeInfo {
62+
final int target;
63+
final String type;
64+
65+
// Either a string for property names or an int for array/context elements.
66+
final dynamic nameOrIndex;
67+
68+
EdgeInfo(this.target, this.type, this.nameOrIndex);
69+
}
70+
6171
class V8SnapshotProfile extends Graph<int> {
6272
// Indexed by node offset.
6373
final Map<int, _NodeInfo> _nodes = {};
@@ -265,4 +275,12 @@ class V8SnapshotProfile extends Graph<int> {
265275
final name = info.name != null ? _strings[info.name] : null;
266276
return NodeInfo(type, name, info.id, info.selfSize);
267277
}
278+
279+
Iterable<EdgeInfo> targets(int node) sync* {
280+
for (final _EdgeInfo info in _toEdges[node]) {
281+
final String type = _edgeTypes[info.type];
282+
yield EdgeInfo(info.nodeOffset, type,
283+
type == "property" ? _strings[info.nameOrIndex] : info.nameOrIndex);
284+
}
285+
}
268286
}

runtime/vm/v8_snapshot_writer.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,8 @@ V8SnapshotProfileWriter::V8SnapshotProfileWriter(Zone* zone)
3131
edge_types_.Insert({"element", kElement});
3232
edge_types_.Insert({"property", kProperty});
3333
edge_types_.Insert({"internal", kInternal});
34-
edge_types_.Insert({"hidden", kHidden});
35-
edge_types_.Insert({"shortcut", kShortcut});
36-
edge_types_.Insert({"weak", kWeak});
37-
edge_types_.Insert({"extra", kExtra});
3834

3935
strings_.Insert({"<unknown>", kUnknownString});
40-
strings_.Insert({"<object>", kObjectString});
41-
strings_.Insert({"<property>", kPropertyString});
4236
strings_.Insert({"<artificial root>", kArtificialRootString});
4337
}
4438

@@ -55,11 +49,11 @@ void V8SnapshotProfileWriter::SetObjectTypeAndName(ObjectId object_id,
5549
intptr_t type_id = node_types_.LookupValue(type);
5650
ASSERT(info->type == kUnknown || info->type == type_id);
5751
info->type = type_id;
58-
5952
if (name != nullptr) {
60-
info->name = EnsureString(OS::SCreate(zone_, "[%s] %s", type, name));
53+
info->name = EnsureString(name);
6154
} else {
62-
info->name = EnsureString(type);
55+
info->name =
56+
EnsureString(OS::SCreate(zone_, "Unnamed [%s] %s", type, name));
6357
}
6458
}
6559

@@ -245,7 +239,7 @@ void V8SnapshotProfileWriter::Write(JSONWriter* writer) {
245239
ObjectIdToNodeInfoTraits::Pair* entry = nullptr;
246240
auto roots_it = roots_.GetIterator();
247241
for (int i = 0; (entry = roots_it.Next()) != nullptr; ++i) {
248-
WriteEdgeInfo(writer, {kElement, i, entry->key});
242+
WriteEdgeInfo(writer, {kInternal, i, entry->key});
249243
}
250244

251245
auto nodes_it = nodes_.GetIterator();

runtime/vm/v8_snapshot_writer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ class V8SnapshotProfileWriter : public ZoneAllocated {
6161

6262
enum ConstantStrings {
6363
kUnknownString = 0,
64-
kPropertyString = 1,
65-
kObjectString = 2,
66-
kArtificialRootString = 3,
64+
kArtificialRootString = 1,
6765
};
6866

6967
#if !defined(DART_PRECOMPILER)

0 commit comments

Comments
 (0)