heap-snapshot-generator.h 20.5 KB
Newer Older
1
// Copyright 2013 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5 6
#ifndef V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_
#define V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_
7

8
#include <deque>
9
#include <unordered_map>
10
#include <unordered_set>
11
#include <vector>
12

13
#include "include/v8-profiler.h"
14
#include "src/base/platform/time.h"
15
#include "src/objects.h"
16
#include "src/objects/fixed-array.h"
17
#include "src/objects/hash-table.h"
18
#include "src/objects/heap-object.h"
19
#include "src/objects/js-objects.h"
20
#include "src/objects/literal-objects.h"
21
#include "src/profiler/strings-storage.h"
22
#include "src/strings/string-hasher.h"
23
#include "src/visitors.h"
24

25 26 27
namespace v8 {
namespace internal {

28 29
class AllocationTracker;
class AllocationTraceNode;
30
class HeapEntry;
31 32
class HeapIterator;
class HeapProfiler;
33
class HeapSnapshot;
34
class HeapSnapshotGenerator;
35
class JSArrayBuffer;
36
class JSCollection;
37 38 39 40
class JSGeneratorObject;
class JSGlobalObject;
class JSGlobalProxy;
class JSPromise;
41
class JSWeakCollection;
42

43 44 45 46 47 48 49 50 51 52
struct SourceLocation {
  SourceLocation(int entry_index, int scriptId, int line, int col)
      : entry_index(entry_index), scriptId(scriptId), line(line), col(col) {}

  const int entry_index;
  const int scriptId;
  const int line;
  const int col;
};

53
class HeapGraphEdge {
54 55 56 57 58 59 60 61 62 63 64
 public:
  enum Type {
    kContextVariable = v8::HeapGraphEdge::kContextVariable,
    kElement = v8::HeapGraphEdge::kElement,
    kProperty = v8::HeapGraphEdge::kProperty,
    kInternal = v8::HeapGraphEdge::kInternal,
    kHidden = v8::HeapGraphEdge::kHidden,
    kShortcut = v8::HeapGraphEdge::kShortcut,
    kWeak = v8::HeapGraphEdge::kWeak
  };

65 66
  HeapGraphEdge(Type type, const char* name, HeapEntry* from, HeapEntry* to);
  HeapGraphEdge(Type type, int index, HeapEntry* from, HeapEntry* to);
67

68
  Type type() const { return TypeField::decode(bit_field_); }
69
  int index() const {
70
    DCHECK(type() == kElement || type() == kHidden);
71 72 73
    return index_;
  }
  const char* name() const {
74 75
    DCHECK(type() == kContextVariable || type() == kProperty ||
           type() == kInternal || type() == kShortcut || type() == kWeak);
76 77
    return name_;
  }
78
  V8_INLINE HeapEntry* from() const;
79 80
  HeapEntry* to() const { return to_entry_; }

81
  V8_INLINE Isolate* isolate() const;
82

83
 private:
84
  V8_INLINE HeapSnapshot* snapshot() const;
85
  int from_index() const { return FromIndexField::decode(bit_field_); }
86

87 88 89
  class TypeField : public BitField<Type, 0, 3> {};
  class FromIndexField : public BitField<int, 3, 29> {};
  uint32_t bit_field_;
90
  HeapEntry* to_entry_;
91 92 93 94 95 96 97 98 99
  union {
    int index_;
    const char* name_;
  };
};


// HeapEntry instances represent an entity from the heap (or a special
// virtual node, e.g. root).
100
class HeapEntry {
101 102 103 104 105 106 107 108 109 110 111
 public:
  enum Type {
    kHidden = v8::HeapGraphNode::kHidden,
    kArray = v8::HeapGraphNode::kArray,
    kString = v8::HeapGraphNode::kString,
    kObject = v8::HeapGraphNode::kObject,
    kCode = v8::HeapGraphNode::kCode,
    kClosure = v8::HeapGraphNode::kClosure,
    kRegExp = v8::HeapGraphNode::kRegExp,
    kHeapNumber = v8::HeapGraphNode::kHeapNumber,
    kNative = v8::HeapGraphNode::kNative,
112 113
    kSynthetic = v8::HeapGraphNode::kSynthetic,
    kConsString = v8::HeapGraphNode::kConsString,
114
    kSlicedString = v8::HeapGraphNode::kSlicedString,
115 116
    kSymbol = v8::HeapGraphNode::kSymbol,
    kBigInt = v8::HeapGraphNode::kBigInt
117 118
  };

119 120
  HeapEntry(HeapSnapshot* snapshot, int index, Type type, const char* name,
            SnapshotObjectId id, size_t self_size, unsigned trace_node_id);
121 122

  HeapSnapshot* snapshot() { return snapshot_; }
123
  Type type() const { return static_cast<Type>(type_); }
124
  void set_type(Type type) { type_ = type; }
125
  const char* name() const { return name_; }
126
  void set_name(const char* name) { name_ = name; }
127 128
  SnapshotObjectId id() const { return id_; }
  size_t self_size() const { return self_size_; }
129
  unsigned trace_node_id() const { return trace_node_id_; }
130 131
  int index() const { return index_; }
  V8_INLINE int children_count() const;
132
  V8_INLINE int set_children_index(int index);
133 134
  V8_INLINE void add_child(HeapGraphEdge* edge);
  V8_INLINE HeapGraphEdge* child(int i);
135
  V8_INLINE Isolate* isolate() const;
136 137 138 139 140

  void SetIndexedReference(
      HeapGraphEdge::Type type, int index, HeapEntry* entry);
  void SetNamedReference(
      HeapGraphEdge::Type type, const char* name, HeapEntry* entry);
141 142 143 144 145 146 147
  void SetIndexedAutoIndexReference(HeapGraphEdge::Type type,
                                    HeapEntry* child) {
    SetIndexedReference(type, children_count_ + 1, child);
  }
  void SetNamedAutoIndexReference(HeapGraphEdge::Type type,
                                  const char* description, HeapEntry* child,
                                  StringsStorage* strings);
148

149 150
  V8_EXPORT_PRIVATE void Print(const char* prefix, const char* edge_name,
                               int max_depth, int indent);
151 152

 private:
153 154
  V8_INLINE std::vector<HeapGraphEdge*>::iterator children_begin() const;
  V8_INLINE std::vector<HeapGraphEdge*>::iterator children_end() const;
155 156 157
  const char* TypeAsString();

  unsigned type_: 4;
158 159 160 161 162 163 164
  unsigned index_ : 28;  // Supports up to ~250M objects.
  union {
    // The count is used during the snapshot build phase,
    // then it gets converted into the index by the |FillChildren| function.
    unsigned children_count_;
    unsigned children_end_index_;
  };
165
  size_t self_size_;
166 167
  HeapSnapshot* snapshot_;
  const char* name_;
168 169 170
  SnapshotObjectId id_;
  // id of allocation stack trace top node
  unsigned trace_node_id_;
171 172 173
};

// HeapSnapshot represents a single heap snapshot. It is stored in
174
// HeapProfiler, which is also a factory for
175 176 177 178 179
// HeapSnapshots. All HeapSnapshots share strings copied from JS heap
// to be able to return them even if they were collected.
// HeapSnapshotGenerator fills in a HeapSnapshot.
class HeapSnapshot {
 public:
180
  explicit HeapSnapshot(HeapProfiler* profiler);
181 182
  void Delete();

183 184 185 186 187
  HeapProfiler* profiler() const { return profiler_; }
  HeapEntry* root() const { return root_entry_; }
  HeapEntry* gc_roots() const { return gc_roots_entry_; }
  HeapEntry* gc_subroot(Root root) const {
    return gc_subroot_entries_[static_cast<int>(root)];
188
  }
189
  std::deque<HeapEntry>& entries() { return entries_; }
190
  std::deque<HeapGraphEdge>& edges() { return edges_; }
191
  std::vector<HeapGraphEdge*>& children() { return children_; }
192
  const std::vector<SourceLocation>& locations() const { return locations_; }
193 194 195 196
  void RememberLastJSObjectId();
  SnapshotObjectId max_snapshot_js_object_id() const {
    return max_snapshot_js_object_id_;
  }
197
  bool is_complete() const { return !children_.empty(); }
198

199
  void AddLocation(HeapEntry* entry, int scriptId, int line, int col);
200 201 202
  HeapEntry* AddEntry(HeapEntry::Type type,
                      const char* name,
                      SnapshotObjectId id,
203 204
                      size_t size,
                      unsigned trace_node_id);
205
  void AddSyntheticRootEntries();
206 207 208 209 210 211
  HeapEntry* GetEntryById(SnapshotObjectId id);
  void FillChildren();

  void Print(int max_depth);

 private:
212 213 214
  void AddRootEntry();
  void AddGcRootsEntry();
  void AddGcSubrootEntry(Root root, SnapshotObjectId id);
215

216
  HeapProfiler* profiler_;
217 218 219 220 221 222 223
  HeapEntry* root_entry_ = nullptr;
  HeapEntry* gc_roots_entry_ = nullptr;
  HeapEntry* gc_subroot_entries_[static_cast<int>(Root::kNumberOfRoots)];
  // For |entries_| we rely on the deque property, that it never reallocates
  // backing storage, thus all entry pointers remain valid for the duration
  // of snapshotting.
  std::deque<HeapEntry> entries_;
224
  std::deque<HeapGraphEdge> edges_;
225 226
  std::vector<HeapGraphEdge*> children_;
  std::unordered_map<SnapshotObjectId, HeapEntry*> entries_by_id_cache_;
227
  std::vector<SourceLocation> locations_;
228
  SnapshotObjectId max_snapshot_js_object_id_ = -1;
229 230 231 232 233 234 235

  DISALLOW_COPY_AND_ASSIGN(HeapSnapshot);
};


class HeapObjectsMap {
 public:
236 237 238 239 240 241 242 243 244 245
  struct TimeInterval {
    explicit TimeInterval(SnapshotObjectId id)
        : id(id), size(0), count(0), timestamp(base::TimeTicks::Now()) {}
    SnapshotObjectId last_assigned_id() const { return id - kObjectIdStep; }
    SnapshotObjectId id;
    uint32_t size;
    uint32_t count;
    base::TimeTicks timestamp;
  };

246 247 248 249 250
  explicit HeapObjectsMap(Heap* heap);

  Heap* heap() const { return heap_; }

  SnapshotObjectId FindEntry(Address addr);
251 252 253
  SnapshotObjectId FindOrAddEntry(Address addr,
                                  unsigned int size,
                                  bool accessed = true);
254
  bool MoveObject(Address from, Address to, int size);
255
  void UpdateObjectSize(Address addr, int size);
256 257 258 259 260
  SnapshotObjectId last_assigned_id() const {
    return next_id_ - kObjectIdStep;
  }

  void StopHeapObjectsTracking();
261 262
  SnapshotObjectId PushHeapObjectsStats(OutputStream* stream,
                                        int64_t* timestamp_us);
263
  const std::vector<TimeInterval>& samples() const { return time_intervals_; }
264 265 266 267 268 269 270

  static const int kObjectIdStep = 2;
  static const SnapshotObjectId kInternalRootObjectId;
  static const SnapshotObjectId kGcRootsObjectId;
  static const SnapshotObjectId kGcRootsFirstSubrootId;
  static const SnapshotObjectId kFirstAvailableObjectId;

271
  void UpdateHeapObjectsMap();
272
  void RemoveDeadEntries();
273

274 275
 private:
  struct EntryInfo {
276 277 278
    EntryInfo(SnapshotObjectId id, Address addr, unsigned int size,
              bool accessed)
        : id(id), addr(addr), size(size), accessed(accessed) {}
279 280 281 282 283 284 285
    SnapshotObjectId id;
    Address addr;
    unsigned int size;
    bool accessed;
  };

  SnapshotObjectId next_id_;
286
  // TODO(jkummerow): Use a map that uses {Address} as the key type.
lpy's avatar
lpy committed
287
  base::HashMap entries_map_;
288
  std::vector<EntryInfo> entries_;
289
  std::vector<TimeInterval> time_intervals_;
290 291 292 293 294 295 296 297 298 299 300 301
  Heap* heap_;

  DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap);
};

// A typedef for referencing anything that can be snapshotted living
// in any kind of heap memory.
typedef void* HeapThing;

// An interface that creates HeapEntries by HeapThings.
class HeapEntriesAllocator {
 public:
302
  virtual ~HeapEntriesAllocator() = default;
303 304 305 306 307
  virtual HeapEntry* AllocateEntry(HeapThing ptr) = 0;
};

class SnapshottingProgressReportingInterface {
 public:
308
  virtual ~SnapshottingProgressReportingInterface() = default;
309 310 311 312 313
  virtual void ProgressStep() = 0;
  virtual bool ProgressReport(bool force) = 0;
};

// An implementation of V8 heap graph extractor.
314
class V8_EXPORT_PRIVATE V8HeapExplorer : public HeapEntriesAllocator {
315 316 317 318
 public:
  V8HeapExplorer(HeapSnapshot* snapshot,
                 SnapshottingProgressReportingInterface* progress,
                 v8::HeapProfiler::ObjectNameResolver* resolver);
319
  ~V8HeapExplorer() override = default;
320

321
  HeapEntry* AllocateEntry(HeapThing ptr) override;
322
  int EstimateObjectsCount();
323
  bool IterateAndExtractReferences(HeapSnapshotGenerator* generator);
324
  void TagGlobalObjects();
325
  void TagBuiltinCodeObject(Code code, const char* name);
326 327 328
  HeapEntry* AddEntry(Address address,
                      HeapEntry::Type type,
                      const char* name,
329
                      size_t size);
330

331 332
  static JSFunction GetConstructor(JSReceiver receiver);
  static String GetConstructorName(JSObject object);
333 334

 private:
335
  void MarkVisitedField(int offset);
336

337 338
  HeapEntry* AddEntry(HeapObject object);
  HeapEntry* AddEntry(HeapObject object, HeapEntry::Type type,
339
                      const char* name);
340

341
  const char* GetSystemEntryName(HeapObject object);
342

343
  void ExtractLocation(HeapEntry* entry, HeapObject object);
344
  void ExtractLocationForJSFunction(HeapEntry* entry, JSFunction func);
345
  void ExtractReferences(HeapEntry* entry, HeapObject obj);
346 347
  void ExtractJSGlobalProxyReferences(HeapEntry* entry, JSGlobalProxy proxy);
  void ExtractJSObjectReferences(HeapEntry* entry, JSObject js_obj);
348 349
  void ExtractStringReferences(HeapEntry* entry, String obj);
  void ExtractSymbolReferences(HeapEntry* entry, Symbol symbol);
350
  void ExtractJSCollectionReferences(HeapEntry* entry, JSCollection collection);
351
  void ExtractJSWeakCollectionReferences(HeapEntry* entry,
352
                                         JSWeakCollection collection);
353
  void ExtractEphemeronHashTableReferences(HeapEntry* entry,
354
                                           EphemeronHashTable table);
355
  void ExtractContextReferences(HeapEntry* entry, Context context);
356
  void ExtractMapReferences(HeapEntry* entry, Map map);
357
  void ExtractSharedFunctionInfoReferences(HeapEntry* entry,
358
                                           SharedFunctionInfo shared);
359
  void ExtractScriptReferences(HeapEntry* entry, Script script);
360
  void ExtractAccessorInfoReferences(HeapEntry* entry,
361 362
                                     AccessorInfo accessor_info);
  void ExtractAccessorPairReferences(HeapEntry* entry, AccessorPair accessors);
363
  void ExtractCodeReferences(HeapEntry* entry, Code code);
364
  void ExtractCellReferences(HeapEntry* entry, Cell cell);
365
  void ExtractFeedbackCellReferences(HeapEntry* entry,
366
                                     FeedbackCell feedback_cell);
367
  void ExtractPropertyCellReferences(HeapEntry* entry, PropertyCell cell);
368
  void ExtractAllocationSiteReferences(HeapEntry* entry, AllocationSite site);
369
  void ExtractArrayBoilerplateDescriptionReferences(
370
      HeapEntry* entry, ArrayBoilerplateDescription value);
371 372
  void ExtractJSArrayBufferReferences(HeapEntry* entry, JSArrayBuffer buffer);
  void ExtractJSPromiseReferences(HeapEntry* entry, JSPromise promise);
373
  void ExtractJSGeneratorObjectReferences(HeapEntry* entry,
374
                                          JSGeneratorObject generator);
375
  void ExtractFixedArrayReferences(HeapEntry* entry, FixedArray array);
376
  void ExtractFeedbackVectorReferences(HeapEntry* entry,
377
                                       FeedbackVector feedback_vector);
378
  void ExtractDescriptorArrayReferences(HeapEntry* entry,
379
                                        DescriptorArray array);
380
  template <typename T>
381
  void ExtractWeakArrayReferences(int header_size, HeapEntry* entry, T array);
382
  void ExtractPropertyReferences(JSObject js_obj, HeapEntry* entry);
383
  void ExtractAccessorPairProperty(HeapEntry* entry, Name key,
384
                                   Object callback_obj, int field_offset = -1);
385 386
  void ExtractElementReferences(JSObject js_obj, HeapEntry* entry);
  void ExtractInternalReferences(JSObject js_obj, HeapEntry* entry);
387

388 389
  bool IsEssentialObject(Object object);
  bool IsEssentialHiddenReference(Object parent, int field_offset);
390

391
  void SetContextReference(HeapEntry* parent_entry, String reference_name,
392
                           Object child, int field_offset);
393
  void SetNativeBindReference(HeapEntry* parent_entry,
394 395
                              const char* reference_name, Object child);
  void SetElementReference(HeapEntry* parent_entry, int index, Object child);
396
  void SetInternalReference(HeapEntry* parent_entry, const char* reference_name,
397 398
                            Object child, int field_offset = -1);
  void SetInternalReference(HeapEntry* parent_entry, int index, Object child,
399
                            int field_offset = -1);
400
  void SetHiddenReference(HeapObject parent_obj, HeapEntry* parent_entry,
401
                          int index, Object child, int field_offset);
402
  void SetWeakReference(HeapEntry* parent_entry, const char* reference_name,
403 404
                        Object child_obj, int field_offset);
  void SetWeakReference(HeapEntry* parent_entry, int index, Object child_obj,
405
                        int field_offset);
406
  void SetPropertyReference(HeapEntry* parent_entry, Name reference_name,
407
                            Object child,
408
                            const char* name_format_string = nullptr,
409
                            int field_offset = -1);
410
  void SetDataOrAccessorPropertyReference(
411
      PropertyKind kind, HeapEntry* parent_entry, Name reference_name,
412
      Object child, const char* name_format_string = nullptr,
413
      int field_offset = -1);
414

415
  void SetUserGlobalReference(Object user_global);
416
  void SetRootGcRootsReference();
417 418
  void SetGcRootsReference(Root root);
  void SetGcSubrootReference(Root root, const char* description, bool is_weak,
419 420 421
                             Object child);
  const char* GetStrongGcSubrootName(Object object);
  void TagObject(Object obj, const char* tag);
422

423
  HeapEntry* GetEntry(Object obj);
424 425 426

  Heap* heap_;
  HeapSnapshot* snapshot_;
427 428
  StringsStorage* names_;
  HeapObjectsMap* heap_object_map_;
429
  SnapshottingProgressReportingInterface* progress_;
430
  HeapSnapshotGenerator* generator_ = nullptr;
431
  std::unordered_map<JSGlobalObject, const char*, Object::Hasher> objects_tags_;
432 433
  std::unordered_map<Object, const char*, Object::Hasher>
      strong_gc_subroot_names_;
434
  std::unordered_set<JSGlobalObject, Object::Hasher> user_roots_;
435 436
  v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_;

437
  std::vector<bool> visited_fields_;
438

439 440 441 442 443 444 445 446 447 448
  friend class IndexedReferencesExtractor;
  friend class RootsReferencesExtractor;

  DISALLOW_COPY_AND_ASSIGN(V8HeapExplorer);
};

// An implementation of retained native objects extractor.
class NativeObjectsExplorer {
 public:
  NativeObjectsExplorer(HeapSnapshot* snapshot,
449
                        SnapshottingProgressReportingInterface* progress);
450
  bool IterateAndExtractReferences(HeapSnapshotGenerator* generator);
451 452

 private:
453 454
  HeapEntry* EntryForEmbedderGraphNode(EmbedderGraph::Node* node);

455
  Isolate* isolate_;
456
  HeapSnapshot* snapshot_;
457
  StringsStorage* names_;
458
  std::unique_ptr<HeapEntriesAllocator> embedder_graph_entries_allocator_;
459
  // Used during references extraction.
460
  HeapSnapshotGenerator* generator_ = nullptr;
461 462 463 464 465 466 467 468 469 470

  static HeapThing const kNativesRootObject;

  friend class GlobalHandlesExtractor;

  DISALLOW_COPY_AND_ASSIGN(NativeObjectsExplorer);
};

class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface {
 public:
471 472
  // The HeapEntriesMap instance is used to track a mapping between
  // real heap objects and their representations in heap snapshots.
473
  using HeapEntriesMap = std::unordered_map<HeapThing, HeapEntry*>;
474

475 476 477 478 479 480
  HeapSnapshotGenerator(HeapSnapshot* snapshot,
                        v8::ActivityControl* control,
                        v8::HeapProfiler::ObjectNameResolver* resolver,
                        Heap* heap);
  bool GenerateSnapshot();

481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
  HeapEntry* FindEntry(HeapThing ptr) {
    auto it = entries_map_.find(ptr);
    return it != entries_map_.end() ? it->second : nullptr;
  }

  HeapEntry* AddEntry(HeapThing ptr, HeapEntriesAllocator* allocator) {
    return entries_map_.emplace(ptr, allocator->AllocateEntry(ptr))
        .first->second;
  }

  HeapEntry* FindOrAddEntry(HeapThing ptr, HeapEntriesAllocator* allocator) {
    HeapEntry* entry = FindEntry(ptr);
    return entry != nullptr ? entry : AddEntry(ptr, allocator);
  }

496 497
 private:
  bool FillReferences();
498 499
  void ProgressStep() override;
  bool ProgressReport(bool force = false) override;
500
  void InitProgressCounter();
501 502 503 504 505

  HeapSnapshot* snapshot_;
  v8::ActivityControl* control_;
  V8HeapExplorer v8_heap_explorer_;
  NativeObjectsExplorer dom_explorer_;
506 507
  // Mapping from HeapThing pointers to HeapEntry indices.
  HeapEntriesMap entries_map_;
508 509 510 511 512 513 514 515 516 517 518 519 520 521
  // Used during snapshot generation.
  int progress_counter_;
  int progress_total_;
  Heap* heap_;

  DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator);
};

class OutputStreamWriter;

class HeapSnapshotJSONSerializer {
 public:
  explicit HeapSnapshotJSONSerializer(HeapSnapshot* snapshot)
      : snapshot_(snapshot),
522
        strings_(StringsMatch),
523 524
        next_node_id_(1),
        next_string_id_(1),
525
        writer_(nullptr) {}
526 527 528
  void Serialize(v8::OutputStream* stream);

 private:
529
  V8_INLINE static bool StringsMatch(void* key1, void* key2) {
530 531
    return strcmp(reinterpret_cast<char*>(key1),
                  reinterpret_cast<char*>(key2)) == 0;
532 533
  }

534
  V8_INLINE static uint32_t StringHash(const void* string);
535 536

  int GetStringId(const char* s);
537 538
  V8_INLINE int to_node_index(const HeapEntry* e);
  V8_INLINE int to_node_index(int entry_index);
539 540 541
  void SerializeEdge(HeapGraphEdge* edge, bool first_edge);
  void SerializeEdges();
  void SerializeImpl();
542
  void SerializeNode(const HeapEntry* entry);
543 544
  void SerializeNodes();
  void SerializeSnapshot();
545 546 547
  void SerializeTraceTree();
  void SerializeTraceNode(AllocationTraceNode* node);
  void SerializeTraceNodeInfos();
548
  void SerializeSamples();
549 550
  void SerializeString(const unsigned char* s);
  void SerializeStrings();
551 552
  void SerializeLocation(const SourceLocation& location);
  void SerializeLocations();
553 554 555 556 557

  static const int kEdgeFieldsCount;
  static const int kNodeFieldsCount;

  HeapSnapshot* snapshot_;
558
  base::CustomMatcherHashMap strings_;
559 560 561 562 563 564 565 566 567 568 569
  int next_node_id_;
  int next_string_id_;
  OutputStreamWriter* writer_;

  friend class HeapSnapshotJSONSerializerEnumerator;
  friend class HeapSnapshotJSONSerializerIterator;

  DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
};


570 571
}  // namespace internal
}  // namespace v8
572

573
#endif  // V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_