mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:59:47 +00:00
[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>
This commit is contained in:
parent
977ae22f29
commit
8d39e3456f
|
@ -46,10 +46,10 @@ const List<String> _kRequiredEdgeFields = [
|
|||
];
|
||||
|
||||
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 NodeInfo {
|
|||
);
|
||||
}
|
||||
|
||||
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 @@ class V8SnapshotProfile extends Graph<int> {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,14 +31,8 @@ V8SnapshotProfileWriter::V8SnapshotProfileWriter(Zone* zone)
|
|||
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 @@ void V8SnapshotProfileWriter::SetObjectTypeAndName(ObjectId object_id,
|
|||
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 @@ void V8SnapshotProfileWriter::Write(JSONWriter* writer) {
|
|||
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();
|
||||
|
|
|
@ -61,9 +61,7 @@ class V8SnapshotProfileWriter : public ZoneAllocated {
|
|||
|
||||
enum ConstantStrings {
|
||||
kUnknownString = 0,
|
||||
kPropertyString = 1,
|
||||
kObjectString = 2,
|
||||
kArtificialRootString = 3,
|
||||
kArtificialRootString = 1,
|
||||
};
|
||||
|
||||
#if !defined(DART_PRECOMPILER)
|
||||
|
|
Loading…
Reference in a new issue