Update V8 to r7427: Initial merge by git

As required by WebKit r82507

Change-Id: I7ae83ef3f689356043b4929255b7c1dd31d8c5df
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index ad242fe..141b42f 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -26,7 +26,7 @@
  public:
   ConstructorHeapProfileTestHelper()
     : i::ConstructorHeapProfile(),
-      f_name_(i::Factory::NewStringFromAscii(i::CStrVector("F"))),
+      f_name_(FACTORY->NewStringFromAscii(i::CStrVector("F"))),
       f_count_(0) {
   }
 
@@ -143,25 +143,25 @@
   i::ZoneScope zn_scope(i::DELETE_ON_EXIT);
 
   JSObjectsRetainerTree tree;
-  JSObjectsCluster function(i::Heap::function_class_symbol());
-  JSObjectsCluster a(*i::Factory::NewStringFromAscii(i::CStrVector("A")));
-  JSObjectsCluster b(*i::Factory::NewStringFromAscii(i::CStrVector("B")));
+  JSObjectsCluster function(HEAP->function_class_symbol());
+  JSObjectsCluster a(*FACTORY->NewStringFromAscii(i::CStrVector("A")));
+  JSObjectsCluster b(*FACTORY->NewStringFromAscii(i::CStrVector("B")));
 
   // o1 <- Function
   JSObjectsCluster o1 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x100, &function);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100, &function);
   // o2 <- Function
   JSObjectsCluster o2 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x200, &function);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x200, &function);
   // o3 <- A, B
   JSObjectsCluster o3 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x300, &a, &b);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x300, &a, &b);
   // o4 <- B, A
   JSObjectsCluster o4 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x400, &b, &a);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x400, &b, &a);
   // o5 <- A, B, Function
   JSObjectsCluster o5 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x500,
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x500,
                           &a, &b, &function);
 
   ClustersCoarser coarser;
@@ -181,20 +181,20 @@
   i::ZoneScope zn_scope(i::DELETE_ON_EXIT);
 
   JSObjectsRetainerTree tree;
-  JSObjectsCluster function(i::Heap::function_class_symbol());
+  JSObjectsCluster function(HEAP->function_class_symbol());
 
   // o1 <- Function
   JSObjectsCluster o1 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x100, &function);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100, &function);
   // a1 <- Function
   JSObjectsCluster a1 =
-      AddHeapObjectToTree(&tree, i::Heap::Array_symbol(), 0x1000, &function);
+      AddHeapObjectToTree(&tree, HEAP->Array_symbol(), 0x1000, &function);
   // o2 <- Function
   JSObjectsCluster o2 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x200, &function);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x200, &function);
   // a2 <- Function
   JSObjectsCluster a2 =
-      AddHeapObjectToTree(&tree, i::Heap::Array_symbol(), 0x2000, &function);
+      AddHeapObjectToTree(&tree, HEAP->Array_symbol(), 0x2000, &function);
 
   ClustersCoarser coarser;
   coarser.Process(&tree);
@@ -224,21 +224,21 @@
   // o21 ~ o22, and o11 ~ o12.
 
   JSObjectsCluster o =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x100);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100);
   JSObjectsCluster o11 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x110, &o);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x110, &o);
   JSObjectsCluster o12 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x120, &o);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x120, &o);
   JSObjectsCluster o21 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x210, &o11);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x210, &o11);
   JSObjectsCluster o22 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x220, &o12);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x220, &o12);
   JSObjectsCluster p =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x300, &o21);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x300, &o21);
   JSObjectsCluster q =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x310, &o21, &o22);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x310, &o21, &o22);
   JSObjectsCluster r =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x320, &o22);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x320, &o22);
 
   ClustersCoarser coarser;
   coarser.Process(&tree);
@@ -275,19 +275,19 @@
   // we expect that coarser will deduce equivalences: p ~ q ~ r, o1 ~ o2;
 
   JSObjectsCluster o =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x100);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100);
   JSObjectsCluster o1 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x110, &o);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x110, &o);
   JSObjectsCluster o2 =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x120, &o);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x120, &o);
   JSObjectsCluster p =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x300, &o1);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x300, &o1);
   AddSelfReferenceToTree(&tree, &p);
   JSObjectsCluster q =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x310, &o1, &o2);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x310, &o1, &o2);
   AddSelfReferenceToTree(&tree, &q);
   JSObjectsCluster r =
-      AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x320, &o2);
+      AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x320, &o2);
   AddSelfReferenceToTree(&tree, &r);
 
   ClustersCoarser coarser;
@@ -433,19 +433,6 @@
 }
 
 
-static bool IsNodeRetainedAs(const v8::HeapGraphNode* node,
-                             v8::HeapGraphEdge::Type type,
-                             const char* name) {
-  for (int i = 0, count = node->GetRetainersCount(); i < count; ++i) {
-    const v8::HeapGraphEdge* prop = node->GetRetainer(i);
-    v8::String::AsciiValue prop_name(prop->GetName());
-    if (prop->GetType() == type && strcmp(name, *prop_name) == 0)
-      return true;
-  }
-  return false;
-}
-
-
 static bool HasString(const v8::HeapGraphNode* node, const char* contents) {
   for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) {
     const v8::HeapGraphEdge* prop = node->GetChild(i);
@@ -496,56 +483,6 @@
   CHECK(det.has_A2);
   CHECK(det.has_B2);
   CHECK(det.has_C2);
-
-  /*
-    // Currently disabled. Too many retaining paths emerge, need to
-    // reduce the amount.
-
-  // Verify 'a2' object retainers. They are:
-  //  - (global object).a2
-  //  - c2.x1, c2.x2, c2[1]
-  //  - b2_1 and b2_2 closures: via 'x' variable
-  CHECK_EQ(6, a2_node->GetRetainingPathsCount());
-  bool has_global_obj_a2_ref = false;
-  bool has_c2_x1_ref = false, has_c2_x2_ref = false, has_c2_1_ref = false;
-  bool has_b2_1_x_ref = false, has_b2_2_x_ref = false;
-  for (int i = 0; i < a2_node->GetRetainingPathsCount(); ++i) {
-    const v8::HeapGraphPath* path = a2_node->GetRetainingPath(i);
-    const int edges_count = path->GetEdgesCount();
-    CHECK_GT(edges_count, 0);
-    const v8::HeapGraphEdge* last_edge = path->GetEdge(edges_count - 1);
-    v8::String::AsciiValue last_edge_name(last_edge->GetName());
-    if (strcmp("a2", *last_edge_name) == 0
-        && last_edge->GetType() == v8::HeapGraphEdge::kProperty) {
-      has_global_obj_a2_ref = true;
-      continue;
-    }
-    CHECK_GT(edges_count, 1);
-    const v8::HeapGraphEdge* prev_edge = path->GetEdge(edges_count - 2);
-    v8::String::AsciiValue prev_edge_name(prev_edge->GetName());
-    if (strcmp("x1", *last_edge_name) == 0
-        && last_edge->GetType() == v8::HeapGraphEdge::kProperty
-        && strcmp("c2", *prev_edge_name) == 0) has_c2_x1_ref = true;
-    if (strcmp("x2", *last_edge_name) == 0
-        && last_edge->GetType() == v8::HeapGraphEdge::kProperty
-        && strcmp("c2", *prev_edge_name) == 0) has_c2_x2_ref = true;
-    if (strcmp("1", *last_edge_name) == 0
-        && last_edge->GetType() == v8::HeapGraphEdge::kElement
-        && strcmp("c2", *prev_edge_name) == 0) has_c2_1_ref = true;
-    if (strcmp("x", *last_edge_name) == 0
-        && last_edge->GetType() == v8::HeapGraphEdge::kContextVariable
-        && strcmp("b2_1", *prev_edge_name) == 0) has_b2_1_x_ref = true;
-    if (strcmp("x", *last_edge_name) == 0
-        && last_edge->GetType() == v8::HeapGraphEdge::kContextVariable
-        && strcmp("b2_2", *prev_edge_name) == 0) has_b2_2_x_ref = true;
-  }
-  CHECK(has_global_obj_a2_ref);
-  CHECK(has_c2_x1_ref);
-  CHECK(has_c2_x2_ref);
-  CHECK(has_c2_1_ref);
-  CHECK(has_b2_1_x_ref);
-  CHECK(has_b2_2_x_ref);
-  */
 }
 
 
@@ -730,7 +667,7 @@
   const v8::HeapSnapshot* snapshot1 =
       v8::HeapProfiler::TakeSnapshot(v8::String::New("s1"));
 
-  i::Heap::CollectAllGarbage(true);  // Enforce compaction.
+  HEAP->CollectAllGarbage(true);  // Enforce compaction.
 
   const v8::HeapSnapshot* snapshot2 =
       v8::HeapProfiler::TakeSnapshot(v8::String::New("s2"));
@@ -774,76 +711,6 @@
 }
 
 
-TEST(HeapSnapshotsDiff) {
-  v8::HandleScope scope;
-  LocalContext env;
-
-  CompileRun(
-      "function A() {}\n"
-      "function B(x) { this.x = x; }\n"
-      "function A2(a) { for (var i = 0; i < a; ++i) this[i] = i; }\n"
-      "var a = new A();\n"
-      "var b = new B(a);");
-  const v8::HeapSnapshot* snapshot1 =
-      v8::HeapProfiler::TakeSnapshot(v8::String::New("s1"));
-
-  CompileRun(
-      "delete a;\n"
-      "b.x = null;\n"
-      "var a = new A2(20);\n"
-      "var b2 = new B(a);");
-  const v8::HeapSnapshot* snapshot2 =
-      v8::HeapProfiler::TakeSnapshot(v8::String::New("s2"));
-
-  const v8::HeapSnapshotsDiff* diff = snapshot1->CompareWith(snapshot2);
-
-  // Verify additions: ensure that addition of A and B was detected.
-  const v8::HeapGraphNode* additions_root = diff->GetAdditionsRoot();
-  bool found_A = false, found_B = false;
-  uint64_t s1_A_id = 0;
-  for (int i = 0, count = additions_root->GetChildrenCount(); i < count; ++i) {
-    const v8::HeapGraphEdge* prop = additions_root->GetChild(i);
-    const v8::HeapGraphNode* node = prop->GetToNode();
-    if (node->GetType() == v8::HeapGraphNode::kObject) {
-      v8::String::AsciiValue node_name(node->GetName());
-      if (strcmp(*node_name, "A2") == 0) {
-        CHECK(IsNodeRetainedAs(node, v8::HeapGraphEdge::kShortcut, "a"));
-        CHECK(!found_A);
-        found_A = true;
-        s1_A_id = node->GetId();
-      } else if (strcmp(*node_name, "B") == 0) {
-        CHECK(IsNodeRetainedAs(node, v8::HeapGraphEdge::kShortcut, "b2"));
-        CHECK(!found_B);
-        found_B = true;
-      }
-    }
-  }
-  CHECK(found_A);
-  CHECK(found_B);
-
-  // Verify deletions: ensure that deletion of A was detected.
-  const v8::HeapGraphNode* deletions_root = diff->GetDeletionsRoot();
-  bool found_A_del = false;
-  uint64_t s2_A_id = 0;
-  for (int i = 0, count = deletions_root->GetChildrenCount(); i < count; ++i) {
-    const v8::HeapGraphEdge* prop = deletions_root->GetChild(i);
-    const v8::HeapGraphNode* node = prop->GetToNode();
-    if (node->GetType() == v8::HeapGraphNode::kObject) {
-      v8::String::AsciiValue node_name(node->GetName());
-      if (strcmp(*node_name, "A") == 0) {
-        CHECK(IsNodeRetainedAs(node, v8::HeapGraphEdge::kShortcut, "a"));
-        CHECK(!found_A_del);
-        found_A_del = true;
-        s2_A_id = node->GetId();
-      }
-    }
-  }
-  CHECK(found_A_del);
-  CHECK_NE_UINT64_T(0, s1_A_id);
-  CHECK(s1_A_id != s2_A_id);
-}
-
-
 TEST(HeapSnapshotRootPreservedAfterSorting) {
   v8::HandleScope scope;
   LocalContext env;
@@ -1258,4 +1125,199 @@
   CHECK_GT(control.total(), 0);
 }
 
+
+namespace {
+
+class TestRetainedObjectInfo : public v8::RetainedObjectInfo {
+ public:
+  TestRetainedObjectInfo(int hash,
+                         const char* label,
+                         intptr_t element_count = -1,
+                         intptr_t size = -1)
+      : disposed_(false),
+        hash_(hash),
+        label_(label),
+        element_count_(element_count),
+        size_(size) {
+    instances.Add(this);
+  }
+  virtual ~TestRetainedObjectInfo() {}
+  virtual void Dispose() {
+    CHECK(!disposed_);
+    disposed_ = true;
+  }
+  virtual bool IsEquivalent(RetainedObjectInfo* other) {
+    return GetHash() == other->GetHash();
+  }
+  virtual intptr_t GetHash() { return hash_; }
+  virtual const char* GetLabel() { return label_; }
+  virtual intptr_t GetElementCount() { return element_count_; }
+  virtual intptr_t GetSizeInBytes() { return size_; }
+  bool disposed() { return disposed_; }
+
+  static v8::RetainedObjectInfo* WrapperInfoCallback(
+      uint16_t class_id, v8::Handle<v8::Value> wrapper) {
+    if (class_id == 1) {
+      if (wrapper->IsString()) {
+        v8::String::AsciiValue ascii(wrapper);
+        if (strcmp(*ascii, "AAA") == 0)
+          return new TestRetainedObjectInfo(1, "aaa", 100);
+        else if (strcmp(*ascii, "BBB") == 0)
+          return new TestRetainedObjectInfo(1, "aaa", 100);
+      }
+    } else if (class_id == 2) {
+      if (wrapper->IsString()) {
+        v8::String::AsciiValue ascii(wrapper);
+        if (strcmp(*ascii, "CCC") == 0)
+          return new TestRetainedObjectInfo(2, "ccc");
+      }
+    }
+    CHECK(false);
+    return NULL;
+  }
+
+  static i::List<TestRetainedObjectInfo*> instances;
+
+ private:
+  bool disposed_;
+  int category_;
+  int hash_;
+  const char* label_;
+  intptr_t element_count_;
+  intptr_t size_;
+};
+
+
+i::List<TestRetainedObjectInfo*> TestRetainedObjectInfo::instances;
+}
+
+
+static const v8::HeapGraphNode* GetNode(const v8::HeapGraphNode* parent,
+                                        v8::HeapGraphNode::Type type,
+                                        const char* name) {
+  for (int i = 0, count = parent->GetChildrenCount(); i < count; ++i) {
+    const v8::HeapGraphNode* node = parent->GetChild(i)->GetToNode();
+    if (node->GetType() == type && strcmp(name,
+               const_cast<i::HeapEntry*>(
+                   reinterpret_cast<const i::HeapEntry*>(node))->name()) == 0) {
+      return node;
+    }
+  }
+  return NULL;
+}
+
+
+TEST(HeapSnapshotRetainedObjectInfo) {
+  v8::HandleScope scope;
+  LocalContext env;
+
+  v8::HeapProfiler::DefineWrapperClass(
+      1, TestRetainedObjectInfo::WrapperInfoCallback);
+  v8::HeapProfiler::DefineWrapperClass(
+      2, TestRetainedObjectInfo::WrapperInfoCallback);
+  v8::Persistent<v8::String> p_AAA =
+      v8::Persistent<v8::String>::New(v8_str("AAA"));
+  p_AAA.SetWrapperClassId(1);
+  v8::Persistent<v8::String> p_BBB =
+      v8::Persistent<v8::String>::New(v8_str("BBB"));
+  p_BBB.SetWrapperClassId(1);
+  v8::Persistent<v8::String> p_CCC =
+      v8::Persistent<v8::String>::New(v8_str("CCC"));
+  p_CCC.SetWrapperClassId(2);
+  CHECK_EQ(0, TestRetainedObjectInfo::instances.length());
+  const v8::HeapSnapshot* snapshot =
+      v8::HeapProfiler::TakeSnapshot(v8::String::New("retained"));
+
+  CHECK_EQ(3, TestRetainedObjectInfo::instances.length());
+  for (int i = 0; i < TestRetainedObjectInfo::instances.length(); ++i) {
+    CHECK(TestRetainedObjectInfo::instances[i]->disposed());
+    delete TestRetainedObjectInfo::instances[i];
+  }
+
+  const v8::HeapGraphNode* natives = GetNode(
+      snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(Native objects)");
+  CHECK_NE(NULL, natives);
+  CHECK_EQ(2, natives->GetChildrenCount());
+  const v8::HeapGraphNode* aaa = GetNode(
+      natives, v8::HeapGraphNode::kNative, "aaa / 100 entries");
+  CHECK_NE(NULL, aaa);
+  const v8::HeapGraphNode* ccc = GetNode(
+      natives, v8::HeapGraphNode::kNative, "ccc");
+  CHECK_NE(NULL, ccc);
+
+  CHECK_EQ(2, aaa->GetChildrenCount());
+  const v8::HeapGraphNode* n_AAA = GetNode(
+      aaa, v8::HeapGraphNode::kString, "AAA");
+  CHECK_NE(NULL, n_AAA);
+  const v8::HeapGraphNode* n_BBB = GetNode(
+      aaa, v8::HeapGraphNode::kString, "BBB");
+  CHECK_NE(NULL, n_BBB);
+  CHECK_EQ(1, ccc->GetChildrenCount());
+  const v8::HeapGraphNode* n_CCC = GetNode(
+      ccc, v8::HeapGraphNode::kString, "CCC");
+  CHECK_NE(NULL, n_CCC);
+
+  CHECK_EQ(aaa, GetProperty(n_AAA, v8::HeapGraphEdge::kInternal, "Native"));
+  CHECK_EQ(aaa, GetProperty(n_BBB, v8::HeapGraphEdge::kInternal, "Native"));
+  CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "Native"));
+}
+
+
+TEST(DeleteAllHeapSnapshots) {
+  v8::HandleScope scope;
+  LocalContext env;
+
+  CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+  v8::HeapProfiler::DeleteAllSnapshots();
+  CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+  CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("1")));
+  CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
+  v8::HeapProfiler::DeleteAllSnapshots();
+  CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+  CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("1")));
+  CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("2")));
+  CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount());
+  v8::HeapProfiler::DeleteAllSnapshots();
+  CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+}
+
+
+TEST(DeleteHeapSnapshot) {
+  v8::HandleScope scope;
+  LocalContext env;
+
+  CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+  const v8::HeapSnapshot* s1 =
+      v8::HeapProfiler::TakeSnapshot(v8::String::New("1"));
+  CHECK_NE(NULL, s1);
+  CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
+  unsigned uid1 = s1->GetUid();
+  CHECK_EQ(s1, v8::HeapProfiler::FindSnapshot(uid1));
+  const_cast<v8::HeapSnapshot*>(s1)->Delete();
+  CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+  CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid1));
+
+  const v8::HeapSnapshot* s2 =
+      v8::HeapProfiler::TakeSnapshot(v8::String::New("2"));
+  CHECK_NE(NULL, s2);
+  CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
+  unsigned uid2 = s2->GetUid();
+  CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
+  CHECK_EQ(s2, v8::HeapProfiler::FindSnapshot(uid2));
+  const v8::HeapSnapshot* s3 =
+      v8::HeapProfiler::TakeSnapshot(v8::String::New("3"));
+  CHECK_NE(NULL, s3);
+  CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount());
+  unsigned uid3 = s3->GetUid();
+  CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
+  CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3));
+  const_cast<v8::HeapSnapshot*>(s2)->Delete();
+  CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount());
+  CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2));
+  CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3));
+  const_cast<v8::HeapSnapshot*>(s3)->Delete();
+  CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
+  CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3));
+}
+
 #endif  // ENABLE_LOGGING_AND_PROFILING