Reviewers: Toon Verwaest, machenbach,
Message:
Here is the CL we discussed, thanks!
--Michael
Description:
Bugfix: AllocationSite objects need to be walkable by the heap snapshot
generator.
BUG=
Please review this at https://codereview.chromium.org/18584007/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/heap-snapshot-generator.h
M src/heap-snapshot-generator.cc
M test/cctest/test-heap-profiler.cc
Index: src/heap-snapshot-generator.cc
diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index
d65b8140039e43eb1e7c9d76747c54e6c3d0c1da..c5ec6f4917283d632df5e133755f74b63f928c0d
100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -958,6 +958,9 @@ void V8HeapExplorer::ExtractReferences(HeapObject* obj)
{
ExtractPropertyCellReferences(
entry, PropertyCell::cast(obj));
extract_indexed_refs = false;
+ } else if (obj->IsAllocationSite()) {
+ ExtractAllocationSiteReferences(entry, AllocationSite::cast(obj));
+ extract_indexed_refs = false;
}
if (extract_indexed_refs) {
SetInternalReference(obj, entry, "map", obj->map(),
HeapObject::kMapOffset);
@@ -1264,6 +1267,12 @@ void
V8HeapExplorer::ExtractPropertyCellReferences(int entry,
}
+void V8HeapExplorer::ExtractAllocationSiteReferences(int entry,
+ AllocationSite* site)
{
+ SetInternalReference(site, entry, "transition_info",
site->transition_info());
+}
+
+
void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry)
{
if (!js_obj->IsJSFunction()) return;
Index: src/heap-snapshot-generator.h
diff --git a/src/heap-snapshot-generator.h b/src/heap-snapshot-generator.h
index
70881ef642891023c8190d44fd31ee35dae41931..31d808856d180e7d4f2c67b7d172d58ff850a897
100644
--- a/src/heap-snapshot-generator.h
+++ b/src/heap-snapshot-generator.h
@@ -460,6 +460,7 @@ class V8HeapExplorer : public HeapEntriesAllocator {
void ExtractCodeReferences(int entry, Code* code);
void ExtractCellReferences(int entry, Cell* cell);
void ExtractPropertyCellReferences(int entry, PropertyCell* cell);
+ void ExtractAllocationSiteReferences(int entry, AllocationSite* site);
void ExtractClosureReferences(JSObject* js_obj, int entry);
void ExtractPropertyReferences(JSObject* js_obj, int entry);
bool ExtractAccessorPairProperty(JSObject* js_obj, int entry,
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)));
+}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.