35 : encoded_((static_cast<uint64_t>(
nonce) << kIdSpaceBits) |
36 static_cast<intptr_t>(
space)) {
41 return encoded_ != other.encoded_;
44 return !(*
this != other);
48 inline int64_t
nonce()
const {
return encoded_ >> kIdSpaceBits; }
50 return static_cast<IdSpace>(encoded_ & kIdSpaceMask);
59 static constexpr size_t kIdSpaceBits =
61 static constexpr int64_t kIdSpaceMask =
62 Utils::NBitMask<int64_t>(kIdSpaceBits);
88#if !defined(DART_PRECOMPILER)
102 const ObjectId& replacement_object_id) {}
125 const Reference& reference,
126 const ObjectId& to_object_id);
134 void AttributeDroppedReferenceTo(
const ObjectId& from_object_id,
135 const Reference& reference,
136 const ObjectId& to_object_id,
137 const ObjectId& replacement_object_id);
141 void AddRoot(
const ObjectId& object_id,
const char*
name =
nullptr);
144 void Write(
const char* file);
148 bool HasId(
const ObjectId& object_id);
151 static constexpr intptr_t kInvalidString =
153 static constexpr intptr_t kNumNodeFields = 5;
154 static constexpr intptr_t kNumEdgeFields = 3;
157 enum class Type : int32_t {
170 Edge(V8SnapshotProfileWriter* profile_writer,
const Reference& reference)
171 :
Edge(profile_writer,
172 reference.
type == Reference::
Type::kElement ?
Type::kElement
174 reference.
type == Reference::
Type::kElement
176 : profile_writer->strings_.Add(reference.
name)) {}
177 Edge(V8SnapshotProfileWriter* profile_writer,
179 intptr_t name_or_offset)
180 :
type(
type), name_or_offset(name_or_offset) {}
183 return type != other.type || name_or_offset != other.name_or_offset;
185 inline bool operator==(
const Edge& other) {
return !(*
this != other); }
187 void Write(V8SnapshotProfileWriter* profile_writer,
189 const ObjectId& target_id)
const;
190 void WriteDebug(V8SnapshotProfileWriter* profile_writer,
192 const ObjectId& target_id)
const;
195 int32_t name_or_offset;
198 struct EdgeToObjectIdMapTrait {
200 using Value = ObjectId;
209 static Key KeyOf(
Pair kv) {
return kv.edge; }
210 static Value ValueOf(
Pair kv) {
return kv.target; }
215 static bool IsKeyEqual(
Pair kv,
Key key) {
return kv.edge ==
key; }
218 struct EdgeMap :
public ZoneDirectChainedHashMap<EdgeToObjectIdMapTrait> {
220 : ZoneDirectChainedHashMap<EdgeToObjectIdMapTrait>(zone, 1) {}
222 const char* ToCString(V8SnapshotProfileWriter* profile_writer,
224 void WriteDebug(V8SnapshotProfileWriter* profile_writer,
226 const char* property =
nullptr)
const;
231 NodeInfo(V8SnapshotProfileWriter* profile_writer,
233 intptr_t
type = kInvalidString,
234 intptr_t
name = kInvalidString)
236 edges(new(profile_writer->zone_)
EdgeMap(profile_writer->zone_)),
240 inline bool operator!=(
const NodeInfo& other) {
241 return id != other.id ||
type != other.type ||
name != other.name ||
242 self_size != other.self_size || edges != other.edges ||
243 offset_ != other.offset_;
245 inline bool operator==(
const NodeInfo& other) {
return !(*
this != other); }
247 void AddEdge(
const Edge& edge,
const ObjectId&
target) {
248 edges->Insert({edge,
target});
250 bool HasEdge(
const Edge& edge) {
return edges->HasKey(edge); }
252 const char* ToCString(V8SnapshotProfileWriter* profile_writer,
254 void Write(V8SnapshotProfileWriter* profile_writer,
255 JSONWriter* writer)
const;
256 void WriteDebug(V8SnapshotProfileWriter* profile_writer,
257 JSONWriter* writer)
const;
259 intptr_t
offset()
const {
return offset_; }
260 void set_offset(intptr_t
offset) {
267 intptr_t
type = kInvalidString;
268 intptr_t
name = kInvalidString;
269 intptr_t self_size = 0;
273 intptr_t offset_ = -1;
278 NodeInfo* EnsureId(
const ObjectId& object_id);
279 void Write(JSONWriter* writer);
285 explicit StringsTable(Zone* zone)
286 : zone_(zone), index_map_(zone), strings_(zone, 2) {}
288 intptr_t Add(
const char* str);
290 const
char* At(intptr_t index) const;
291 void Write(JSONWriter* writer, const
char* property =
nullptr) const;
295 CStringIntMap index_map_;
296 GrowableArray<const
char*> strings_;
299 struct ObjectIdToNodeInfoTraits {
300 typedef NodeInfo
Pair;
301 typedef ObjectId
Key;
304 static Key KeyOf(
const Pair& pair) {
return pair.id; }
306 static Value ValueOf(
const Pair& pair) {
return pair; }
310 static bool IsKeyEqual(
const Pair&
x,
const Key&
y) {
return x.id ==
y; }
313 struct ObjectIdSetKeyValueTrait {
314 using Pair = ObjectId;
318 static Key KeyOf(
const Pair& pair) {
return pair; }
319 static Value ValueOf(
const Pair& pair) {
return pair; }
321 static bool IsKeyEqual(
const Pair& pair,
const Key&
key) {
327 DirectChainedHashMap<ObjectIdToNodeInfoTraits> nodes_;
328 StringsTable node_types_;
329 StringsTable edge_types_;
330 StringsTable strings_;
331 DirectChainedHashMap<ObjectIdSetKeyValueTrait> roots_;