| Index: test/cctest/test-heap-profiler.cc
|
| diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
|
| index ba6a97a4c6b11f366d24f2c65ba10194afb011bd..577d47e06641bc10feeb93587ae1ae15157640ce 100644
|
| --- a/test/cctest/test-heap-profiler.cc
|
| +++ b/test/cctest/test-heap-profiler.cc
|
| @@ -1832,3 +1832,45 @@ TEST(ManyLocalsInSharedContext) {
|
| CHECK_NE(NULL, f_object);
|
| }
|
| }
|
| +
|
| +
|
| +TEST(AllocationSitesAreVisible) {
|
| + LocalContext env;
|
| + v8::HandleScope scope(env->GetIsolate());
|
| + v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
|
| + CompileRun(
|
| + "fun = function () { var a = [3, 2, 1]; return a; }\n"
|
| + "fun();");
|
| + const v8::HeapSnapshot* snapshot =
|
| + heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
|
| +
|
| + const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
|
| + CHECK_NE(NULL, global);
|
| + const v8::HeapGraphNode* fun_code =
|
| + GetProperty(global, v8::HeapGraphEdge::kProperty, "fun");
|
| + CHECK_NE(NULL, fun_code);
|
| + const v8::HeapGraphNode* literals =
|
| + GetProperty(fun_code, v8::HeapGraphEdge::kInternal, "literals");
|
| + CHECK_NE(NULL, literals);
|
| + CHECK_EQ(v8::HeapGraphNode::kArray, literals->GetType());
|
| + CHECK_EQ(2, literals->GetChildrenCount());
|
| +
|
| + // The second value in the literals array should be the boilerplate,
|
| + // after an AllocationSite.
|
| + const v8::HeapGraphEdge* prop = literals->GetChild(1);
|
| + const v8::HeapGraphNode* allocation_site = prop->GetToNode();
|
| + v8::String::Utf8Value name(allocation_site->GetName());
|
| + CHECK_EQ("system / AllocationSite", *name);
|
| + const v8::HeapGraphNode* transition_info =
|
| + GetProperty(allocation_site, v8::HeapGraphEdge::kInternal,
|
| + "transition_info");
|
| + CHECK_NE(NULL, transition_info);
|
| + CHECK(transition_info->GetHeapValue()->IsArray());
|
| + v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(
|
| + transition_info->GetHeapValue());
|
| + // Verify the array is "a" in the code above.
|
| + CHECK_EQ(3, array->Length());
|
| + CHECK_EQ(v8::Integer::New(3), array->Get(v8::Integer::New(0)));
|
| + CHECK_EQ(v8::Integer::New(2), array->Get(v8::Integer::New(1)));
|
| + CHECK_EQ(v8::Integer::New(1), array->Get(v8::Integer::New(2)));
|
| +}
|
|
|