libv8 3.10.8.0 → 3.11.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. data/Rakefile +10 -3
  2. data/ext/libv8/compiler.rb +46 -0
  3. data/ext/libv8/extconf.rb +5 -1
  4. data/ext/libv8/make.rb +13 -0
  5. data/lib/libv8/version.rb +1 -1
  6. data/patches/add-freebsd9-and-freebsd10-to-gyp-GetFlavor.patch +11 -0
  7. data/patches/src_platform-freebsd.cc.patch +10 -0
  8. data/vendor/v8/ChangeLog +124 -0
  9. data/vendor/v8/DEPS +27 -0
  10. data/vendor/v8/Makefile +7 -0
  11. data/vendor/v8/SConstruct +15 -2
  12. data/vendor/v8/build/common.gypi +129 -157
  13. data/vendor/v8/build/gyp_v8 +11 -25
  14. data/vendor/v8/build/standalone.gypi +9 -3
  15. data/vendor/v8/include/v8.h +5 -3
  16. data/vendor/v8/src/SConscript +1 -0
  17. data/vendor/v8/src/api.cc +4 -33
  18. data/vendor/v8/src/api.h +2 -2
  19. data/vendor/v8/src/arm/builtins-arm.cc +5 -4
  20. data/vendor/v8/src/arm/code-stubs-arm.cc +21 -14
  21. data/vendor/v8/src/arm/codegen-arm.cc +2 -2
  22. data/vendor/v8/src/arm/debug-arm.cc +3 -1
  23. data/vendor/v8/src/arm/full-codegen-arm.cc +3 -102
  24. data/vendor/v8/src/arm/ic-arm.cc +30 -33
  25. data/vendor/v8/src/arm/lithium-arm.cc +20 -7
  26. data/vendor/v8/src/arm/lithium-arm.h +10 -4
  27. data/vendor/v8/src/arm/lithium-codegen-arm.cc +106 -60
  28. data/vendor/v8/src/arm/macro-assembler-arm.cc +49 -39
  29. data/vendor/v8/src/arm/macro-assembler-arm.h +5 -4
  30. data/vendor/v8/src/arm/regexp-macro-assembler-arm.cc +115 -55
  31. data/vendor/v8/src/arm/regexp-macro-assembler-arm.h +7 -6
  32. data/vendor/v8/src/arm/simulator-arm.h +6 -6
  33. data/vendor/v8/src/arm/stub-cache-arm.cc +64 -19
  34. data/vendor/v8/src/array.js +7 -3
  35. data/vendor/v8/src/ast.cc +11 -6
  36. data/vendor/v8/src/bootstrapper.cc +9 -11
  37. data/vendor/v8/src/builtins.cc +61 -31
  38. data/vendor/v8/src/code-stubs.cc +23 -9
  39. data/vendor/v8/src/code-stubs.h +1 -0
  40. data/vendor/v8/src/codegen.h +3 -3
  41. data/vendor/v8/src/compiler.cc +1 -1
  42. data/vendor/v8/src/contexts.h +2 -18
  43. data/vendor/v8/src/d8.cc +94 -93
  44. data/vendor/v8/src/d8.h +1 -1
  45. data/vendor/v8/src/debug-agent.cc +3 -3
  46. data/vendor/v8/src/debug.cc +41 -1
  47. data/vendor/v8/src/debug.h +50 -0
  48. data/vendor/v8/src/elements-kind.cc +134 -0
  49. data/vendor/v8/src/elements-kind.h +210 -0
  50. data/vendor/v8/src/elements.cc +356 -190
  51. data/vendor/v8/src/elements.h +36 -28
  52. data/vendor/v8/src/factory.cc +44 -4
  53. data/vendor/v8/src/factory.h +11 -7
  54. data/vendor/v8/src/flag-definitions.h +3 -0
  55. data/vendor/v8/src/frames.h +3 -0
  56. data/vendor/v8/src/full-codegen.cc +2 -1
  57. data/vendor/v8/src/func-name-inferrer.h +2 -0
  58. data/vendor/v8/src/globals.h +3 -0
  59. data/vendor/v8/src/heap-inl.h +16 -4
  60. data/vendor/v8/src/heap.cc +38 -32
  61. data/vendor/v8/src/heap.h +3 -17
  62. data/vendor/v8/src/hydrogen-instructions.cc +28 -5
  63. data/vendor/v8/src/hydrogen-instructions.h +142 -44
  64. data/vendor/v8/src/hydrogen.cc +160 -55
  65. data/vendor/v8/src/hydrogen.h +2 -0
  66. data/vendor/v8/src/ia32/assembler-ia32.h +3 -0
  67. data/vendor/v8/src/ia32/builtins-ia32.cc +5 -4
  68. data/vendor/v8/src/ia32/code-stubs-ia32.cc +22 -16
  69. data/vendor/v8/src/ia32/codegen-ia32.cc +2 -2
  70. data/vendor/v8/src/ia32/debug-ia32.cc +29 -2
  71. data/vendor/v8/src/ia32/full-codegen-ia32.cc +8 -101
  72. data/vendor/v8/src/ia32/ic-ia32.cc +23 -19
  73. data/vendor/v8/src/ia32/lithium-codegen-ia32.cc +126 -80
  74. data/vendor/v8/src/ia32/lithium-codegen-ia32.h +2 -1
  75. data/vendor/v8/src/ia32/lithium-ia32.cc +15 -9
  76. data/vendor/v8/src/ia32/lithium-ia32.h +14 -6
  77. data/vendor/v8/src/ia32/macro-assembler-ia32.cc +50 -40
  78. data/vendor/v8/src/ia32/macro-assembler-ia32.h +5 -4
  79. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.cc +113 -43
  80. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.h +9 -4
  81. data/vendor/v8/src/ia32/simulator-ia32.h +4 -4
  82. data/vendor/v8/src/ia32/stub-cache-ia32.cc +52 -14
  83. data/vendor/v8/src/ic.cc +77 -20
  84. data/vendor/v8/src/ic.h +18 -2
  85. data/vendor/v8/src/incremental-marking-inl.h +21 -5
  86. data/vendor/v8/src/incremental-marking.cc +35 -8
  87. data/vendor/v8/src/incremental-marking.h +12 -3
  88. data/vendor/v8/src/isolate.cc +12 -2
  89. data/vendor/v8/src/isolate.h +1 -1
  90. data/vendor/v8/src/jsregexp.cc +66 -26
  91. data/vendor/v8/src/jsregexp.h +60 -31
  92. data/vendor/v8/src/list-inl.h +8 -0
  93. data/vendor/v8/src/list.h +3 -0
  94. data/vendor/v8/src/lithium.cc +5 -2
  95. data/vendor/v8/src/liveedit.cc +57 -5
  96. data/vendor/v8/src/mark-compact-inl.h +17 -11
  97. data/vendor/v8/src/mark-compact.cc +100 -143
  98. data/vendor/v8/src/mark-compact.h +44 -20
  99. data/vendor/v8/src/messages.js +131 -99
  100. data/vendor/v8/src/mips/builtins-mips.cc +5 -4
  101. data/vendor/v8/src/mips/code-stubs-mips.cc +23 -15
  102. data/vendor/v8/src/mips/codegen-mips.cc +2 -2
  103. data/vendor/v8/src/mips/debug-mips.cc +3 -1
  104. data/vendor/v8/src/mips/full-codegen-mips.cc +4 -102
  105. data/vendor/v8/src/mips/ic-mips.cc +34 -36
  106. data/vendor/v8/src/mips/lithium-codegen-mips.cc +116 -68
  107. data/vendor/v8/src/mips/lithium-mips.cc +20 -7
  108. data/vendor/v8/src/mips/lithium-mips.h +11 -4
  109. data/vendor/v8/src/mips/macro-assembler-mips.cc +50 -39
  110. data/vendor/v8/src/mips/macro-assembler-mips.h +5 -4
  111. data/vendor/v8/src/mips/regexp-macro-assembler-mips.cc +110 -50
  112. data/vendor/v8/src/mips/regexp-macro-assembler-mips.h +6 -5
  113. data/vendor/v8/src/mips/simulator-mips.h +5 -5
  114. data/vendor/v8/src/mips/stub-cache-mips.cc +66 -20
  115. data/vendor/v8/src/mksnapshot.cc +5 -1
  116. data/vendor/v8/src/objects-debug.cc +103 -6
  117. data/vendor/v8/src/objects-inl.h +215 -116
  118. data/vendor/v8/src/objects-printer.cc +13 -8
  119. data/vendor/v8/src/objects.cc +608 -331
  120. data/vendor/v8/src/objects.h +129 -94
  121. data/vendor/v8/src/parser.cc +16 -4
  122. data/vendor/v8/src/platform-freebsd.cc +1 -0
  123. data/vendor/v8/src/platform-linux.cc +9 -30
  124. data/vendor/v8/src/platform-posix.cc +28 -7
  125. data/vendor/v8/src/platform-win32.cc +15 -3
  126. data/vendor/v8/src/platform.h +2 -1
  127. data/vendor/v8/src/profile-generator-inl.h +25 -2
  128. data/vendor/v8/src/profile-generator.cc +300 -822
  129. data/vendor/v8/src/profile-generator.h +97 -214
  130. data/vendor/v8/src/regexp-macro-assembler-irregexp.cc +2 -1
  131. data/vendor/v8/src/regexp-macro-assembler-irregexp.h +2 -2
  132. data/vendor/v8/src/regexp-macro-assembler-tracer.cc +6 -5
  133. data/vendor/v8/src/regexp-macro-assembler-tracer.h +1 -1
  134. data/vendor/v8/src/regexp-macro-assembler.cc +7 -3
  135. data/vendor/v8/src/regexp-macro-assembler.h +10 -2
  136. data/vendor/v8/src/regexp.js +6 -0
  137. data/vendor/v8/src/runtime.cc +265 -212
  138. data/vendor/v8/src/runtime.h +6 -5
  139. data/vendor/v8/src/scopes.cc +20 -0
  140. data/vendor/v8/src/scopes.h +6 -3
  141. data/vendor/v8/src/spaces.cc +0 -2
  142. data/vendor/v8/src/string-stream.cc +2 -2
  143. data/vendor/v8/src/v8-counters.h +0 -2
  144. data/vendor/v8/src/v8natives.js +2 -2
  145. data/vendor/v8/src/v8utils.h +6 -3
  146. data/vendor/v8/src/version.cc +1 -1
  147. data/vendor/v8/src/x64/assembler-x64.h +2 -1
  148. data/vendor/v8/src/x64/builtins-x64.cc +5 -4
  149. data/vendor/v8/src/x64/code-stubs-x64.cc +25 -16
  150. data/vendor/v8/src/x64/codegen-x64.cc +2 -2
  151. data/vendor/v8/src/x64/debug-x64.cc +14 -1
  152. data/vendor/v8/src/x64/disasm-x64.cc +1 -1
  153. data/vendor/v8/src/x64/full-codegen-x64.cc +10 -106
  154. data/vendor/v8/src/x64/ic-x64.cc +20 -16
  155. data/vendor/v8/src/x64/lithium-codegen-x64.cc +156 -79
  156. data/vendor/v8/src/x64/lithium-codegen-x64.h +2 -1
  157. data/vendor/v8/src/x64/lithium-x64.cc +18 -8
  158. data/vendor/v8/src/x64/lithium-x64.h +7 -2
  159. data/vendor/v8/src/x64/macro-assembler-x64.cc +50 -40
  160. data/vendor/v8/src/x64/macro-assembler-x64.h +5 -4
  161. data/vendor/v8/src/x64/regexp-macro-assembler-x64.cc +122 -51
  162. data/vendor/v8/src/x64/regexp-macro-assembler-x64.h +17 -8
  163. data/vendor/v8/src/x64/simulator-x64.h +4 -4
  164. data/vendor/v8/src/x64/stub-cache-x64.cc +55 -17
  165. data/vendor/v8/test/cctest/cctest.status +1 -0
  166. data/vendor/v8/test/cctest/test-api.cc +24 -0
  167. data/vendor/v8/test/cctest/test-func-name-inference.cc +38 -0
  168. data/vendor/v8/test/cctest/test-heap-profiler.cc +21 -77
  169. data/vendor/v8/test/cctest/test-heap.cc +164 -3
  170. data/vendor/v8/test/cctest/test-list.cc +12 -0
  171. data/vendor/v8/test/cctest/test-mark-compact.cc +5 -5
  172. data/vendor/v8/test/cctest/test-regexp.cc +14 -8
  173. data/vendor/v8/test/cctest/testcfg.py +2 -0
  174. data/vendor/v8/test/mjsunit/accessor-map-sharing.js +176 -0
  175. data/vendor/v8/test/mjsunit/array-construct-transition.js +3 -3
  176. data/vendor/v8/test/mjsunit/array-literal-transitions.js +10 -10
  177. data/vendor/v8/test/mjsunit/big-array-literal.js +3 -0
  178. data/vendor/v8/test/mjsunit/compiler/inline-construct.js +4 -2
  179. data/vendor/v8/test/mjsunit/debug-liveedit-stack-padding.js +88 -0
  180. data/vendor/v8/test/mjsunit/elements-kind.js +4 -4
  181. data/vendor/v8/test/mjsunit/elements-transition-hoisting.js +2 -2
  182. data/vendor/v8/test/mjsunit/elements-transition.js +5 -5
  183. data/vendor/v8/test/mjsunit/error-constructors.js +68 -33
  184. data/vendor/v8/test/mjsunit/harmony/proxies.js +14 -6
  185. data/vendor/v8/test/mjsunit/mjsunit.status +1 -0
  186. data/vendor/v8/test/mjsunit/packed-elements.js +112 -0
  187. data/vendor/v8/test/mjsunit/regexp-capture-3.js +6 -0
  188. data/vendor/v8/test/mjsunit/regexp-global.js +132 -0
  189. data/vendor/v8/test/mjsunit/regexp.js +11 -0
  190. data/vendor/v8/test/mjsunit/regress/regress-117409.js +52 -0
  191. data/vendor/v8/test/mjsunit/regress/regress-126412.js +33 -0
  192. data/vendor/v8/test/mjsunit/regress/regress-128018.js +35 -0
  193. data/vendor/v8/test/mjsunit/regress/regress-128146.js +33 -0
  194. data/vendor/v8/test/mjsunit/regress/regress-1639-2.js +4 -1
  195. data/vendor/v8/test/mjsunit/regress/regress-1639.js +14 -8
  196. data/vendor/v8/test/mjsunit/regress/regress-1849.js +3 -3
  197. data/vendor/v8/test/mjsunit/regress/regress-1878.js +2 -2
  198. data/vendor/v8/test/mjsunit/regress/regress-2071.js +79 -0
  199. data/vendor/v8/test/mjsunit/regress/regress-2153.js +32 -0
  200. data/vendor/v8/test/mjsunit/regress/regress-crbug-122271.js +4 -4
  201. data/vendor/v8/test/mjsunit/regress/regress-crbug-126414.js +32 -0
  202. data/vendor/v8/test/mjsunit/regress/regress-smi-only-concat.js +2 -2
  203. data/vendor/v8/test/mjsunit/regress/regress-transcendental.js +49 -0
  204. data/vendor/v8/test/mjsunit/stack-traces.js +14 -0
  205. data/vendor/v8/test/mjsunit/unbox-double-arrays.js +4 -3
  206. data/vendor/v8/test/test262/testcfg.py +6 -1
  207. data/vendor/v8/tools/check-static-initializers.sh +11 -3
  208. data/vendor/v8/tools/fuzz-harness.sh +92 -0
  209. data/vendor/v8/tools/grokdump.py +658 -67
  210. data/vendor/v8/tools/gyp/v8.gyp +21 -39
  211. data/vendor/v8/tools/js2c.py +3 -3
  212. data/vendor/v8/tools/jsmin.py +2 -2
  213. data/vendor/v8/tools/presubmit.py +2 -1
  214. data/vendor/v8/tools/test-wrapper-gypbuild.py +25 -11
  215. metadata +624 -612
@@ -446,6 +446,7 @@ class ProfileGenerator {
446
446
 
447
447
 
448
448
  class HeapEntry;
449
+ class HeapSnapshot;
449
450
 
450
451
  class HeapGraphEdge BASE_EMBEDDED {
451
452
  public:
@@ -460,9 +461,9 @@ class HeapGraphEdge BASE_EMBEDDED {
460
461
  };
461
462
 
462
463
  HeapGraphEdge() { }
463
- void Init(int child_index, Type type, const char* name, HeapEntry* to);
464
- void Init(int child_index, Type type, int index, HeapEntry* to);
465
- void Init(int child_index, int index, HeapEntry* to);
464
+ HeapGraphEdge(Type type, const char* name, int from, int to);
465
+ HeapGraphEdge(Type type, int index, int from, int to);
466
+ void ReplaceToIndexWithEntry(HeapSnapshot* snapshot);
466
467
 
467
468
  Type type() const { return static_cast<Type>(type_); }
468
469
  int index() const {
@@ -471,48 +472,34 @@ class HeapGraphEdge BASE_EMBEDDED {
471
472
  }
472
473
  const char* name() const {
473
474
  ASSERT(type_ == kContextVariable
474
- || type_ == kProperty
475
- || type_ == kInternal
476
- || type_ == kShortcut);
475
+ || type_ == kProperty
476
+ || type_ == kInternal
477
+ || type_ == kShortcut);
477
478
  return name_;
478
479
  }
479
- HeapEntry* to() const { return to_; }
480
480
  INLINE(HeapEntry* from() const);
481
+ HeapEntry* to() const { return to_entry_; }
481
482
 
482
483
  private:
483
- int child_index_ : 29;
484
+ INLINE(HeapSnapshot* snapshot() const);
485
+
484
486
  unsigned type_ : 3;
487
+ int from_index_ : 29;
488
+ union {
489
+ // During entries population |to_index_| is used for storing the index,
490
+ // afterwards it is replaced with a pointer to the entry.
491
+ int to_index_;
492
+ HeapEntry* to_entry_;
493
+ };
485
494
  union {
486
495
  int index_;
487
496
  const char* name_;
488
497
  };
489
- HeapEntry* to_;
490
-
491
- DISALLOW_COPY_AND_ASSIGN(HeapGraphEdge);
492
498
  };
493
499
 
494
500
 
495
- class HeapSnapshot;
496
-
497
501
  // HeapEntry instances represent an entity from the heap (or a special
498
- // virtual node, e.g. root). To make heap snapshots more compact,
499
- // HeapEntries has a special memory layout (no Vectors or Lists used):
500
- //
501
- // +-----------------+
502
- // HeapEntry
503
- // +-----------------+
504
- // HeapGraphEdge |
505
- // ... } children_count
506
- // HeapGraphEdge |
507
- // +-----------------+
508
- // HeapGraphEdge* |
509
- // ... } retainers_count
510
- // HeapGraphEdge* |
511
- // +-----------------+
512
- //
513
- // In a HeapSnapshot, all entries are hand-allocated in a continuous array
514
- // of raw bytes.
515
- //
502
+ // virtual node, e.g. root).
516
503
  class HeapEntry BASE_EMBEDDED {
517
504
  public:
518
505
  enum Type {
@@ -527,15 +514,14 @@ class HeapEntry BASE_EMBEDDED {
527
514
  kNative = v8::HeapGraphNode::kNative,
528
515
  kSynthetic = v8::HeapGraphNode::kSynthetic
529
516
  };
517
+ static const int kNoEntry;
530
518
 
531
519
  HeapEntry() { }
532
- void Init(HeapSnapshot* snapshot,
520
+ HeapEntry(HeapSnapshot* snapshot,
533
521
  Type type,
534
522
  const char* name,
535
523
  SnapshotObjectId id,
536
- int self_size,
537
- int children_count,
538
- int retainers_count);
524
+ int self_size);
539
525
 
540
526
  HeapSnapshot* snapshot() { return snapshot_; }
541
527
  Type type() { return static_cast<Type>(type_); }
@@ -543,80 +529,36 @@ class HeapEntry BASE_EMBEDDED {
543
529
  void set_name(const char* name) { name_ = name; }
544
530
  inline SnapshotObjectId id() { return id_; }
545
531
  int self_size() { return self_size_; }
546
- int retained_size() { return retained_size_; }
547
- void add_retained_size(int size) { retained_size_ += size; }
548
- void set_retained_size(int value) { retained_size_ = value; }
549
- int ordered_index() { return ordered_index_; }
550
- void set_ordered_index(int value) { ordered_index_ = value; }
551
- int entry_index() { return entry_index_; }
552
- void set_entry_index(int value) { entry_index_ = value; }
553
-
554
- Vector<HeapGraphEdge> children() {
555
- return Vector<HeapGraphEdge>(children_arr(), children_count_); }
556
- Vector<HeapGraphEdge*> retainers() {
557
- return Vector<HeapGraphEdge*>(retainers_arr(), retainers_count_); }
558
- HeapEntry* dominator() { return dominator_; }
559
- void set_dominator(HeapEntry* entry) {
560
- ASSERT(entry != NULL);
561
- dominator_ = entry;
562
- }
563
- void clear_paint() { painted_ = false; }
564
- bool painted() { return painted_; }
565
- void paint() { painted_ = true; }
566
- bool user_reachable() { return user_reachable_; }
567
- void set_user_reachable() { user_reachable_ = true; }
568
-
569
- void SetIndexedReference(HeapGraphEdge::Type type,
570
- int child_index,
571
- int index,
572
- HeapEntry* entry,
573
- int retainer_index);
574
- void SetNamedReference(HeapGraphEdge::Type type,
575
- int child_index,
576
- const char* name,
577
- HeapEntry* entry,
578
- int retainer_index);
579
- void SetUnidirElementReference(int child_index, int index, HeapEntry* entry);
580
-
581
- size_t EntrySize() {
582
- return EntriesSize(1, children_count_, retainers_count_);
532
+ INLINE(int index() const);
533
+ int children_count() const { return children_count_; }
534
+ INLINE(int set_children_index(int index));
535
+ void add_child(HeapGraphEdge* edge) {
536
+ children_arr()[children_count_++] = edge;
583
537
  }
538
+ Vector<HeapGraphEdge*> children() {
539
+ return Vector<HeapGraphEdge*>(children_arr(), children_count_); }
540
+
541
+ void SetIndexedReference(
542
+ HeapGraphEdge::Type type, int index, HeapEntry* entry);
543
+ void SetNamedReference(
544
+ HeapGraphEdge::Type type, const char* name, HeapEntry* entry);
584
545
 
585
546
  void Print(
586
547
  const char* prefix, const char* edge_name, int max_depth, int indent);
587
548
 
588
549
  Handle<HeapObject> GetHeapObject();
589
550
 
590
- static size_t EntriesSize(int entries_count,
591
- int children_count,
592
- int retainers_count);
593
-
594
551
  private:
595
- HeapGraphEdge* children_arr() {
596
- return reinterpret_cast<HeapGraphEdge*>(this + 1);
597
- }
598
- HeapGraphEdge** retainers_arr() {
599
- return reinterpret_cast<HeapGraphEdge**>(children_arr() + children_count_);
600
- }
552
+ INLINE(HeapGraphEdge** children_arr());
601
553
  const char* TypeAsString();
602
554
 
603
- unsigned painted_: 1;
604
- unsigned user_reachable_: 1;
605
555
  unsigned type_: 4;
606
- int children_count_: 26;
607
- int retainers_count_;
556
+ int children_count_: 28;
557
+ int children_index_;
608
558
  int self_size_;
609
- union {
610
- int ordered_index_; // Used during dominator tree building.
611
- int retained_size_; // At that moment, there is no retained size yet.
612
- };
613
- int entry_index_;
614
559
  SnapshotObjectId id_;
615
- HeapEntry* dominator_;
616
560
  HeapSnapshot* snapshot_;
617
561
  const char* name_;
618
-
619
- DISALLOW_COPY_AND_ASSIGN(HeapEntry);
620
562
  };
621
563
 
622
564
 
@@ -637,63 +579,55 @@ class HeapSnapshot {
637
579
  Type type,
638
580
  const char* title,
639
581
  unsigned uid);
640
- ~HeapSnapshot();
641
582
  void Delete();
642
583
 
643
584
  HeapSnapshotsCollection* collection() { return collection_; }
644
585
  Type type() { return type_; }
645
586
  const char* title() { return title_; }
646
587
  unsigned uid() { return uid_; }
647
- HeapEntry* root() { return root_entry_; }
648
- HeapEntry* gc_roots() { return gc_roots_entry_; }
649
- HeapEntry* natives_root() { return natives_root_entry_; }
650
- HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; }
651
- List<HeapEntry*>* entries() { return &entries_; }
652
- size_t raw_entries_size() { return raw_entries_size_; }
653
- int number_of_edges() { return number_of_edges_; }
588
+ size_t RawSnapshotSize() const;
589
+ HeapEntry* root() { return &entries_[root_index_]; }
590
+ HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; }
591
+ HeapEntry* natives_root() { return &entries_[natives_root_index_]; }
592
+ HeapEntry* gc_subroot(int index) {
593
+ return &entries_[gc_subroot_indexes_[index]];
594
+ }
595
+ List<HeapEntry>& entries() { return entries_; }
596
+ List<HeapGraphEdge>& edges() { return edges_; }
597
+ List<HeapGraphEdge*>& children() { return children_; }
654
598
  void RememberLastJSObjectId();
655
599
  SnapshotObjectId max_snapshot_js_object_id() const {
656
600
  return max_snapshot_js_object_id_;
657
601
  }
658
602
 
659
- void AllocateEntries(
660
- int entries_count, int children_count, int retainers_count);
661
603
  HeapEntry* AddEntry(HeapEntry::Type type,
662
604
  const char* name,
663
605
  SnapshotObjectId id,
664
- int size,
665
- int children_count,
666
- int retainers_count);
667
- HeapEntry* AddRootEntry(int children_count);
668
- HeapEntry* AddGcRootsEntry(int children_count, int retainers_count);
669
- HeapEntry* AddGcSubrootEntry(int tag,
670
- int children_count,
671
- int retainers_count);
672
- HeapEntry* AddNativesRootEntry(int children_count, int retainers_count);
673
- void ClearPaint();
606
+ int size);
607
+ HeapEntry* AddRootEntry();
608
+ HeapEntry* AddGcRootsEntry();
609
+ HeapEntry* AddGcSubrootEntry(int tag);
610
+ HeapEntry* AddNativesRootEntry();
674
611
  HeapEntry* GetEntryById(SnapshotObjectId id);
675
612
  List<HeapEntry*>* GetSortedEntriesList();
676
- void SetDominatorsToSelf();
613
+ void FillChildren();
677
614
 
678
615
  void Print(int max_depth);
679
616
  void PrintEntriesSize();
680
617
 
681
618
  private:
682
- HeapEntry* GetNextEntryToInit();
683
-
684
619
  HeapSnapshotsCollection* collection_;
685
620
  Type type_;
686
621
  const char* title_;
687
622
  unsigned uid_;
688
- HeapEntry* root_entry_;
689
- HeapEntry* gc_roots_entry_;
690
- HeapEntry* natives_root_entry_;
691
- HeapEntry* gc_subroot_entries_[VisitorSynchronization::kNumberOfSyncTags];
692
- char* raw_entries_;
693
- List<HeapEntry*> entries_;
623
+ int root_index_;
624
+ int gc_roots_index_;
625
+ int natives_root_index_;
626
+ int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags];
627
+ List<HeapEntry> entries_;
628
+ List<HeapGraphEdge> edges_;
629
+ List<HeapGraphEdge*> children_;
694
630
  List<HeapEntry*> sorted_entries_;
695
- size_t raw_entries_size_;
696
- int number_of_edges_;
697
631
  SnapshotObjectId max_snapshot_js_object_id_;
698
632
 
699
633
  friend class HeapSnapshotTester;
@@ -828,8 +762,7 @@ typedef void* HeapThing;
828
762
  class HeapEntriesAllocator {
829
763
  public:
830
764
  virtual ~HeapEntriesAllocator() { }
831
- virtual HeapEntry* AllocateEntry(
832
- HeapThing ptr, int children_count, int retainers_count) = 0;
765
+ virtual HeapEntry* AllocateEntry(HeapThing ptr) = 0;
833
766
  };
834
767
 
835
768
 
@@ -838,37 +771,11 @@ class HeapEntriesAllocator {
838
771
  class HeapEntriesMap {
839
772
  public:
840
773
  HeapEntriesMap();
841
- ~HeapEntriesMap();
842
-
843
- void AllocateEntries(HeapThing root_object);
844
- HeapEntry* Map(HeapThing thing);
845
- void Pair(HeapThing thing, HeapEntriesAllocator* allocator, HeapEntry* entry);
846
- void CountReference(HeapThing from, HeapThing to,
847
- int* prev_children_count = NULL,
848
- int* prev_retainers_count = NULL);
849
774
 
850
- int entries_count() { return entries_count_; }
851
- int total_children_count() { return total_children_count_; }
852
- int total_retainers_count() { return total_retainers_count_; }
853
-
854
- static HeapEntry* const kHeapEntryPlaceholder;
775
+ int Map(HeapThing thing);
776
+ void Pair(HeapThing thing, int entry);
855
777
 
856
778
  private:
857
- struct EntryInfo {
858
- EntryInfo(HeapEntry* entry, HeapEntriesAllocator* allocator)
859
- : entry(entry),
860
- allocator(allocator),
861
- children_count(0),
862
- retainers_count(0) {
863
- }
864
- HeapEntry* entry;
865
- HeapEntriesAllocator* allocator;
866
- int children_count;
867
- int retainers_count;
868
- };
869
-
870
- static inline void AllocateHeapEntryForMapEntry(HashMap::Entry* map_entry);
871
-
872
779
  static uint32_t Hash(HeapThing thing) {
873
780
  return ComputeIntegerHash(
874
781
  static_cast<uint32_t>(reinterpret_cast<uintptr_t>(thing)),
@@ -879,9 +786,6 @@ class HeapEntriesMap {
879
786
  }
880
787
 
881
788
  HashMap entries_;
882
- int entries_count_;
883
- int total_children_count_;
884
- int total_retainers_count_;
885
789
 
886
790
  friend class HeapObjectsSet;
887
791
 
@@ -916,26 +820,18 @@ class SnapshotFillerInterface {
916
820
  virtual HeapEntry* FindOrAddEntry(HeapThing ptr,
917
821
  HeapEntriesAllocator* allocator) = 0;
918
822
  virtual void SetIndexedReference(HeapGraphEdge::Type type,
919
- HeapThing parent_ptr,
920
- HeapEntry* parent_entry,
823
+ int parent_entry,
921
824
  int index,
922
- HeapThing child_ptr,
923
825
  HeapEntry* child_entry) = 0;
924
826
  virtual void SetIndexedAutoIndexReference(HeapGraphEdge::Type type,
925
- HeapThing parent_ptr,
926
- HeapEntry* parent_entry,
927
- HeapThing child_ptr,
827
+ int parent_entry,
928
828
  HeapEntry* child_entry) = 0;
929
829
  virtual void SetNamedReference(HeapGraphEdge::Type type,
930
- HeapThing parent_ptr,
931
- HeapEntry* parent_entry,
830
+ int parent_entry,
932
831
  const char* reference_name,
933
- HeapThing child_ptr,
934
832
  HeapEntry* child_entry) = 0;
935
833
  virtual void SetNamedAutoIndexReference(HeapGraphEdge::Type type,
936
- HeapThing parent_ptr,
937
- HeapEntry* parent_entry,
938
- HeapThing child_ptr,
834
+ int parent_entry,
939
835
  HeapEntry* child_entry) = 0;
940
836
  };
941
837
 
@@ -954,12 +850,10 @@ class V8HeapExplorer : public HeapEntriesAllocator {
954
850
  V8HeapExplorer(HeapSnapshot* snapshot,
955
851
  SnapshottingProgressReportingInterface* progress);
956
852
  virtual ~V8HeapExplorer();
957
- virtual HeapEntry* AllocateEntry(
958
- HeapThing ptr, int children_count, int retainers_count);
853
+ virtual HeapEntry* AllocateEntry(HeapThing ptr);
959
854
  void AddRootEntries(SnapshotFillerInterface* filler);
960
855
  int EstimateObjectsCount(HeapIterator* iterator);
961
856
  bool IterateAndExtractReferences(SnapshotFillerInterface* filler);
962
- bool IterateAndSetObjectNames(SnapshotFillerInterface* filler);
963
857
  void TagGlobalObjects();
964
858
 
965
859
  static String* GetConstructorName(JSObject* object);
@@ -967,81 +861,77 @@ class V8HeapExplorer : public HeapEntriesAllocator {
967
861
  static HeapObject* const kInternalRootObject;
968
862
 
969
863
  private:
970
- HeapEntry* AddEntry(
971
- HeapObject* object, int children_count, int retainers_count);
864
+ HeapEntry* AddEntry(HeapObject* object);
972
865
  HeapEntry* AddEntry(HeapObject* object,
973
866
  HeapEntry::Type type,
974
- const char* name,
975
- int children_count,
976
- int retainers_count);
867
+ const char* name);
977
868
  const char* GetSystemEntryName(HeapObject* object);
978
869
 
979
870
  void ExtractReferences(HeapObject* obj);
980
871
  void ExtractJSGlobalProxyReferences(JSGlobalProxy* proxy);
981
- void ExtractJSObjectReferences(HeapEntry* entry, JSObject* js_obj);
982
- void ExtractStringReferences(HeapEntry* entry, String* obj);
983
- void ExtractContextReferences(HeapEntry* entry, Context* context);
984
- void ExtractMapReferences(HeapEntry* entry, Map* map);
985
- void ExtractSharedFunctionInfoReferences(HeapEntry* entry,
872
+ void ExtractJSObjectReferences(int entry, JSObject* js_obj);
873
+ void ExtractStringReferences(int entry, String* obj);
874
+ void ExtractContextReferences(int entry, Context* context);
875
+ void ExtractMapReferences(int entry, Map* map);
876
+ void ExtractSharedFunctionInfoReferences(int entry,
986
877
  SharedFunctionInfo* shared);
987
- void ExtractScriptReferences(HeapEntry* entry, Script* script);
988
- void ExtractCodeCacheReferences(HeapEntry* entry, CodeCache* code_cache);
989
- void ExtractCodeReferences(HeapEntry* entry, Code* code);
990
- void ExtractJSGlobalPropertyCellReferences(HeapEntry* entry,
878
+ void ExtractScriptReferences(int entry, Script* script);
879
+ void ExtractCodeCacheReferences(int entry, CodeCache* code_cache);
880
+ void ExtractCodeReferences(int entry, Code* code);
881
+ void ExtractJSGlobalPropertyCellReferences(int entry,
991
882
  JSGlobalPropertyCell* cell);
992
- void ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry);
993
- void ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entry);
994
- void ExtractElementReferences(JSObject* js_obj, HeapEntry* entry);
995
- void ExtractInternalReferences(JSObject* js_obj, HeapEntry* entry);
883
+ void ExtractClosureReferences(JSObject* js_obj, int entry);
884
+ void ExtractPropertyReferences(JSObject* js_obj, int entry);
885
+ void ExtractElementReferences(JSObject* js_obj, int entry);
886
+ void ExtractInternalReferences(JSObject* js_obj, int entry);
996
887
  bool IsEssentialObject(Object* object);
997
888
  void SetClosureReference(HeapObject* parent_obj,
998
- HeapEntry* parent,
889
+ int parent,
999
890
  String* reference_name,
1000
891
  Object* child);
1001
892
  void SetNativeBindReference(HeapObject* parent_obj,
1002
- HeapEntry* parent,
893
+ int parent,
1003
894
  const char* reference_name,
1004
895
  Object* child);
1005
896
  void SetElementReference(HeapObject* parent_obj,
1006
- HeapEntry* parent,
897
+ int parent,
1007
898
  int index,
1008
899
  Object* child);
1009
900
  void SetInternalReference(HeapObject* parent_obj,
1010
- HeapEntry* parent,
901
+ int parent,
1011
902
  const char* reference_name,
1012
903
  Object* child,
1013
904
  int field_offset = -1);
1014
905
  void SetInternalReference(HeapObject* parent_obj,
1015
- HeapEntry* parent,
906
+ int parent,
1016
907
  int index,
1017
908
  Object* child,
1018
909
  int field_offset = -1);
1019
910
  void SetHiddenReference(HeapObject* parent_obj,
1020
- HeapEntry* parent,
911
+ int parent,
1021
912
  int index,
1022
913
  Object* child);
1023
914
  void SetWeakReference(HeapObject* parent_obj,
1024
- HeapEntry* parent_entry,
915
+ int parent,
1025
916
  int index,
1026
917
  Object* child_obj,
1027
918
  int field_offset);
1028
919
  void SetPropertyReference(HeapObject* parent_obj,
1029
- HeapEntry* parent,
920
+ int parent,
1030
921
  String* reference_name,
1031
922
  Object* child,
1032
923
  const char* name_format_string = NULL,
1033
924
  int field_offset = -1);
1034
925
  void SetPropertyShortcutReference(HeapObject* parent_obj,
1035
- HeapEntry* parent,
926
+ int parent,
1036
927
  String* reference_name,
1037
928
  Object* child);
1038
- void SetUserGlobalReference(Object* window);
929
+ void SetUserGlobalReference(Object* user_global);
1039
930
  void SetRootGcRootsReference();
1040
931
  void SetGcRootsReference(VisitorSynchronization::SyncTag tag);
1041
932
  void SetGcSubrootReference(
1042
933
  VisitorSynchronization::SyncTag tag, bool is_weak, Object* child);
1043
934
  const char* GetStrongGcSubrootName(Object* object);
1044
- void SetObjectName(HeapObject* object);
1045
935
  void TagObject(Object* obj, const char* tag);
1046
936
 
1047
937
  HeapEntry* GetEntry(Object* obj);
@@ -1136,17 +1026,9 @@ class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface {
1136
1026
  bool GenerateSnapshot();
1137
1027
 
1138
1028
  private:
1139
- bool BuildDominatorTree(const Vector<HeapEntry*>& entries,
1140
- Vector<int>* dominators);
1141
- bool CalculateRetainedSizes();
1142
- bool CountEntriesAndReferences();
1143
1029
  bool FillReferences();
1144
- void FillPostorderIndexes(Vector<HeapEntry*>* entries);
1145
- bool IsUserGlobalReference(const HeapGraphEdge& edge);
1146
- void MarkUserReachableObjects();
1147
1030
  void ProgressStep();
1148
1031
  bool ProgressReport(bool force = false);
1149
- bool SetEntriesDominators();
1150
1032
  void SetProgressTotal(int iterations_count);
1151
1033
 
1152
1034
  HeapSnapshot* snapshot_;
@@ -1186,20 +1068,21 @@ class HeapSnapshotJSONSerializer {
1186
1068
  v8::internal::kZeroHashSeed);
1187
1069
  }
1188
1070
 
1189
- void CalculateNodeIndexes(const List<HeapEntry*>& nodes);
1190
1071
  HeapSnapshot* CreateFakeSnapshot();
1191
1072
  int GetStringId(const char* s);
1073
+ int entry_index(HeapEntry* e) { return e->index() * kNodeFieldsCount; }
1192
1074
  void SerializeEdge(HeapGraphEdge* edge, bool first_edge);
1193
- void SerializeEdges(const List<HeapEntry*>& nodes);
1075
+ void SerializeEdges(const List<HeapEntry>& nodes);
1194
1076
  void SerializeImpl();
1195
1077
  void SerializeNode(HeapEntry* entry, int edges_index);
1196
- void SerializeNodes(const List<HeapEntry*>& nodes);
1078
+ void SerializeNodes(const List<HeapEntry>& nodes);
1197
1079
  void SerializeSnapshot();
1198
1080
  void SerializeString(const unsigned char* s);
1199
1081
  void SerializeStrings();
1200
1082
  void SortHashMap(HashMap* map, List<HashMap::Entry*>* sorted_entries);
1201
1083
 
1202
- static const int kMaxSerializableSnapshotRawSize;
1084
+ static const int kEdgeFieldsCount;
1085
+ static const int kNodeFieldsCount;
1203
1086
 
1204
1087
  HeapSnapshot* snapshot_;
1205
1088
  HashMap strings_;