The detailed heap snapshot generator was slightly adjusted for tracking sliced strings.

BUG=v8:1779
TEST=cctest/test-heap-profiler/HeapSnapshotSlicedString

Review URL: http://codereview.chromium.org/8362028
Patch from Ilya Tikhonovsky <loislo@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9742 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mikhail.naganov@gmail.com 2011-10-21 13:05:37 +00:00
parent ae6e6a689c
commit fa0d4ecf43
2 changed files with 26 additions and 0 deletions

View File

@ -1951,6 +1951,10 @@ void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
SetInternalReference(obj, entry, 1, cs->first());
SetInternalReference(obj, entry, 2, cs->second());
}
if (obj->IsSlicedString()) {
SlicedString* ss = SlicedString::cast(obj);
SetInternalReference(obj, entry, "parent", ss->parent());
}
extract_indexed_refs = false;
} else if (obj->IsGlobalContext()) {
Context* context = Context::cast(obj);

View File

@ -252,6 +252,28 @@ TEST(HeapSnapshotHeapNumbers) {
CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType());
}
TEST(HeapSnapshotSlicedString) {
v8::HandleScope scope;
LocalContext env;
CompileRun(
"parent_string = \"123456789.123456789.123456789.123456789.123456789."
"123456789.123456789.123456789.123456789.123456789."
"123456789.123456789.123456789.123456789.123456789."
"123456789.123456789.123456789.123456789.123456789.\";"
"child_string = parent_string.slice(100);");
const v8::HeapSnapshot* snapshot =
v8::HeapProfiler::TakeSnapshot(v8_str("strings"));
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
const v8::HeapGraphNode* parent_string =
GetProperty(global, v8::HeapGraphEdge::kShortcut, "parent_string");
CHECK_NE(NULL, parent_string);
const v8::HeapGraphNode* child_string =
GetProperty(global, v8::HeapGraphEdge::kShortcut, "child_string");
CHECK_NE(NULL, child_string);
const v8::HeapGraphNode* parent =
GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent");
CHECK_EQ(parent_string, parent);
}
TEST(HeapSnapshotInternalReferences) {
v8::HandleScope scope;