Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: test/cctest/test-heap-profiler.cc

Issue 294163005: Support ES6 weak collections in heap profiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap-profiler.cc
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index dbef127b6e011ca44600a3c78d371aa869a68c36..a515a22bdf051f4a982627904438c3b09451e195 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -495,6 +495,70 @@ TEST(HeapSnapshotSymbol) {
}
+TEST(HeapSnapshotWeakCollection) {
+ i::FLAG_harmony_collections = true;
+
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+
+ CompileRun("k = {}; v = {};\n"
+ "ws = new WeakSet(); ws.add(k); ws.add(v);\n"
+ "wm = new WeakMap(); wm.set(k, v);\n");
+ const v8::HeapSnapshot* snapshot =
+ heap_profiler->TakeHeapSnapshot(v8_str("WeakCollections"));
+ CHECK(ValidateSnapshot(snapshot));
+ const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
+ const v8::HeapGraphNode* k =
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "k");
+ CHECK_NE(NULL, k);
+ const v8::HeapGraphNode* v =
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "v");
+ CHECK_NE(NULL, v);
+
+ const v8::HeapGraphNode* ws =
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "ws");
+ CHECK_NE(NULL, ws);
+ CHECK_EQ(v8::HeapGraphNode::kObject, ws->GetType());
+ CHECK_EQ(v8_str("WeakSet"), ws->GetName());
+
+ const v8::HeapGraphNode* ws_table =
+ GetProperty(ws, v8::HeapGraphEdge::kInternal, "table");
+ CHECK_EQ(v8::HeapGraphNode::kArray, ws_table->GetType());
+ CHECK_GT(ws_table->GetChildrenCount(), 0);
+ int weak_entries = 0;
+ for (int i = 0, count = ws_table->GetChildrenCount(); i < count; ++i) {
+ const v8::HeapGraphEdge* prop = ws_table->GetChild(i);
+ if (prop->GetType() != v8::HeapGraphEdge::kWeak) continue;
+ if (k->GetId() == prop->GetToNode()->GetId()) {
+ ++weak_entries;
+ }
+ }
+ CHECK_EQ(1, weak_entries);
+
+ const v8::HeapGraphNode* wm =
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "wm");
+ CHECK_NE(NULL, wm);
+ CHECK_EQ(v8::HeapGraphNode::kObject, wm->GetType());
+ CHECK_EQ(v8_str("WeakMap"), wm->GetName());
+
+ const v8::HeapGraphNode* wm_table =
+ GetProperty(wm, v8::HeapGraphEdge::kInternal, "table");
+ CHECK_EQ(v8::HeapGraphNode::kArray, wm_table->GetType());
+ CHECK_GT(wm_table->GetChildrenCount(), 0);
+ weak_entries = 0;
+ for (int i = 0, count = wm_table->GetChildrenCount(); i < count; ++i) {
+ const v8::HeapGraphEdge* prop = wm_table->GetChild(i);
+ if (prop->GetType() != v8::HeapGraphEdge::kWeak) continue;
+ const v8::SnapshotObjectId to_node_id = prop->GetToNode()->GetId();
+ if (to_node_id == k->GetId() || to_node_id == v->GetId()) {
+ ++weak_entries;
+ }
+ }
+ CHECK_EQ(2, weak_entries);
+}
+
+
TEST(HeapSnapshotInternalReferences) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698