diff --git a/pkg/vm/lib/v8_snapshot_profile.dart b/pkg/vm/lib/v8_snapshot_profile.dart index efda4c157e5..2b1ad739c86 100644 --- a/pkg/vm/lib/v8_snapshot_profile.dart +++ b/pkg/vm/lib/v8_snapshot_profile.dart @@ -46,10 +46,10 @@ const List _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 { // Indexed by node offset. final Map _nodes = {}; @@ -265,4 +275,12 @@ class V8SnapshotProfile extends Graph { final name = info.name != null ? _strings[info.name] : null; return NodeInfo(type, name, info.id, info.selfSize); } + + Iterable 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 b8ef3286e59..9c04c5ae539 100644 --- a/runtime/vm/v8_snapshot_writer.cc +++ b/runtime/vm/v8_snapshot_writer.cc @@ -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({"", kUnknownString}); - strings_.Insert({"", kObjectString}); - strings_.Insert({"", kPropertyString}); strings_.Insert({"", 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(); diff --git a/runtime/vm/v8_snapshot_writer.h b/runtime/vm/v8_snapshot_writer.h index 63d061743b2..b3e5e09f54a 100644 --- a/runtime/vm/v8_snapshot_writer.h +++ b/runtime/vm/v8_snapshot_writer.h @@ -61,9 +61,7 @@ class V8SnapshotProfileWriter : public ZoneAllocated { enum ConstantStrings { kUnknownString = 0, - kPropertyString = 1, - kObjectString = 2, - kArtificialRootString = 3, + kArtificialRootString = 1, }; #if !defined(DART_PRECOMPILER)