Commit d9f797b4 authored by alexeif@chromium.org's avatar alexeif@chromium.org

Eliminate internal and hidden links to oddballs and other non-essential objects in heap snapshot.

Review URL: https://chromiumcodereview.appspot.com/10162005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11404 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d97aa5f5
......@@ -2480,6 +2480,20 @@ void V8HeapExplorer::SetObjectName(HeapObject* object) {
}
bool V8HeapExplorer::IsEssentialObject(Object* object) {
// We have to use raw_unchecked_* versions because checked versions
// would fail during iteration over object properties.
return object->IsHeapObject()
&& !object->IsOddball()
&& object != heap_->raw_unchecked_empty_byte_array()
&& object != heap_->raw_unchecked_empty_fixed_array()
&& object != heap_->raw_unchecked_empty_descriptor_array()
&& object != heap_->raw_unchecked_fixed_array_map()
&& object != heap_->raw_unchecked_global_property_cell_map()
&& object != heap_->raw_unchecked_shared_function_info_map();
}
void V8HeapExplorer::SetClosureReference(HeapObject* parent_obj,
HeapEntry* parent_entry,
String* reference_name,
......@@ -2535,10 +2549,7 @@ void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj,
int field_offset) {
HeapEntry* child_entry = GetEntry(child_obj);
if (child_entry == NULL) return;
// We have to use raw_unchecked_* version because when the
// empty_fixed_array itself is being processed all its inline properties
// are invalid and the check in empty_fixed_array() function fails.
if (child_obj != heap_->raw_unchecked_empty_fixed_array()) {
if (IsEssentialObject(child_obj)) {
filler_->SetNamedReference(HeapGraphEdge::kInternal,
parent_obj, parent_entry,
reference_name,
......@@ -2555,8 +2566,7 @@ void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj,
int field_offset) {
HeapEntry* child_entry = GetEntry(child_obj);
if (child_entry == NULL) return;
// See the comment regarding raw_unchecked_* above.
if (child_obj != heap_->raw_unchecked_empty_fixed_array()) {
if (IsEssentialObject(child_obj)) {
filler_->SetNamedReference(HeapGraphEdge::kInternal,
parent_obj, parent_entry,
collection_->names()->GetName(index),
......@@ -2571,7 +2581,7 @@ void V8HeapExplorer::SetHiddenReference(HeapObject* parent_obj,
int index,
Object* child_obj) {
HeapEntry* child_entry = GetEntry(child_obj);
if (child_entry != NULL) {
if (child_entry != NULL && IsEssentialObject(child_obj)) {
filler_->SetIndexedReference(HeapGraphEdge::kHidden,
parent_obj,
parent_entry,
......@@ -2711,11 +2721,7 @@ const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) {
void V8HeapExplorer::TagObject(Object* obj, const char* tag) {
if (obj->IsHeapObject() &&
!obj->IsOddball() &&
obj != heap_->raw_unchecked_empty_byte_array() &&
obj != heap_->raw_unchecked_empty_fixed_array() &&
obj != heap_->raw_unchecked_empty_descriptor_array()) {
if (IsEssentialObject(obj)) {
objects_tags_.SetTag(obj, tag);
}
}
......
......@@ -980,6 +980,7 @@ class V8HeapExplorer : public HeapEntriesAllocator {
void ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entry);
void ExtractElementReferences(JSObject* js_obj, HeapEntry* entry);
void ExtractInternalReferences(JSObject* js_obj, HeapEntry* entry);
bool IsEssentialObject(Object* object);
void SetClosureReference(HeapObject* parent_obj,
HeapEntry* parent,
String* reference_name,
......
......@@ -1645,3 +1645,22 @@ TEST(AllStrongGcRootsHaveNames) {
CHECK(isalpha(**name));
}
}
TEST(NoRefsToNonEssentialEntries) {
v8::HandleScope scope;
LocalContext env;
CompileRun("global_object = {};\n");
const v8::HeapSnapshot* snapshot =
v8::HeapProfiler::TakeSnapshot(v8_str("snapshot"));
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
const v8::HeapGraphNode* global_object =
GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object");
CHECK_NE(NULL, global_object);
const v8::HeapGraphNode* properties =
GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties");
CHECK_EQ(NULL, properties);
const v8::HeapGraphNode* elements =
GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements");
CHECK_EQ(NULL, elements);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment