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

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

Issue 213673006: Show references from weak containers as weak in heap snapshots. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added a test. Created 6 years, 9 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 f1ccc571dabcfef9766da81c7f6a367cef469838..56c81defb4853d497ddc3528b5779e1d3b60cbff 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -2508,6 +2508,41 @@ TEST(BoxObject) {
}
+TEST(WeakContainers) {
+ i::FLAG_allow_natives_syntax = true;
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+ if (!CcTest::i_isolate()->use_crankshaft()) return;
+ v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
+ CompileRun(
+ "function foo(a) { return a.x; }\n"
+ "obj = {x : 123};\n"
+ "foo(obj);\n"
+ "foo(obj);\n"
+ "%OptimizeFunctionOnNextCall(foo);\n"
+ "foo(obj);\n");
+ const v8::HeapSnapshot* snapshot =
+ heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
+ CHECK(ValidateSnapshot(snapshot));
+ const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
+ const v8::HeapGraphNode* obj =
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "obj");
+ CHECK_NE(NULL, obj);
+ const v8::HeapGraphNode* map =
+ GetProperty(obj, v8::HeapGraphEdge::kInternal, "map");
+ CHECK_NE(NULL, map);
+ const v8::HeapGraphNode* dependent_code =
+ GetProperty(map, v8::HeapGraphEdge::kInternal, "dependent_code");
+ if (!dependent_code) return;
+ int count = dependent_code->GetChildrenCount();
+ CHECK_NE(0, count);
+ for (int i = 0; i < count; ++i) {
+ const v8::HeapGraphEdge* prop = dependent_code->GetChild(i);
+ CHECK_EQ(v8::HeapGraphEdge::kWeak, prop->GetType());
+ }
+}
+
+
static inline i::Address ToAddress(int n) {
return reinterpret_cast<i::Address>(n);
}
« 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