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); |
} |