Commit 2ec3e594 authored by alexeif@chromium.org's avatar alexeif@chromium.org

Remove Debug object from the user roots in heap profiler.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11358 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent bf630e23
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "scopeinfo.h" #include "scopeinfo.h"
#include "unicode.h" #include "unicode.h"
#include "zone-inl.h" #include "zone-inl.h"
#include "debug.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -967,7 +968,7 @@ void HeapEntry::Init(HeapSnapshot* snapshot, ...@@ -967,7 +968,7 @@ void HeapEntry::Init(HeapSnapshot* snapshot,
snapshot_ = snapshot; snapshot_ = snapshot;
type_ = type; type_ = type;
painted_ = false; painted_ = false;
reachable_from_window_ = false; user_reachable_ = false;
name_ = name; name_ = name;
self_size_ = self_size; self_size_ = self_size;
retained_size_ = 0; retained_size_ = 0;
...@@ -1981,7 +1982,15 @@ void V8HeapExplorer::ExtractReferences(HeapObject* obj) { ...@@ -1981,7 +1982,15 @@ void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
// We use JSGlobalProxy because this is what embedder (e.g. browser) // We use JSGlobalProxy because this is what embedder (e.g. browser)
// uses for the global object. // uses for the global object.
JSGlobalProxy* proxy = JSGlobalProxy::cast(obj); JSGlobalProxy* proxy = JSGlobalProxy::cast(obj);
SetWindowReference(proxy->map()->prototype()); Object* object = proxy->map()->prototype();
bool is_debug_object = false;
#ifdef ENABLE_DEBUGGER_SUPPORT
is_debug_object = object->IsGlobalObject() &&
Isolate::Current()->debug()->IsDebugGlobal(GlobalObject::cast(object));
#endif
if (!is_debug_object) {
SetUserGlobalReference(object);
}
} else if (obj->IsJSObject()) { } else if (obj->IsJSObject()) {
JSObject* js_obj = JSObject::cast(obj); JSObject* js_obj = JSObject::cast(obj);
ExtractClosureReferences(js_obj, entry); ExtractClosureReferences(js_obj, entry);
...@@ -2626,7 +2635,7 @@ void V8HeapExplorer::SetRootGcRootsReference() { ...@@ -2626,7 +2635,7 @@ void V8HeapExplorer::SetRootGcRootsReference() {
} }
void V8HeapExplorer::SetWindowReference(Object* child_obj) { void V8HeapExplorer::SetUserGlobalReference(Object* child_obj) {
HeapEntry* child_entry = GetEntry(child_obj); HeapEntry* child_entry = GetEntry(child_obj);
ASSERT(child_entry != NULL); ASSERT(child_entry != NULL);
filler_->SetNamedAutoIndexReference( filler_->SetNamedAutoIndexReference(
...@@ -3262,30 +3271,30 @@ bool HeapSnapshotGenerator::FillReferences() { ...@@ -3262,30 +3271,30 @@ bool HeapSnapshotGenerator::FillReferences() {
} }
bool HeapSnapshotGenerator::IsWindowReference(const HeapGraphEdge& edge) { bool HeapSnapshotGenerator::IsUserGlobalReference(const HeapGraphEdge& edge) {
ASSERT(edge.from() == snapshot_->root()); ASSERT(edge.from() == snapshot_->root());
return edge.type() == HeapGraphEdge::kShortcut; return edge.type() == HeapGraphEdge::kShortcut;
} }
void HeapSnapshotGenerator::MarkWindowReachableObjects() { void HeapSnapshotGenerator::MarkUserReachableObjects() {
List<HeapEntry*> worklist; List<HeapEntry*> worklist;
Vector<HeapGraphEdge> children = snapshot_->root()->children(); Vector<HeapGraphEdge> children = snapshot_->root()->children();
for (int i = 0; i < children.length(); ++i) { for (int i = 0; i < children.length(); ++i) {
if (IsWindowReference(children[i])) { if (IsUserGlobalReference(children[i])) {
worklist.Add(children[i].to()); worklist.Add(children[i].to());
} }
} }
while (!worklist.is_empty()) { while (!worklist.is_empty()) {
HeapEntry* entry = worklist.RemoveLast(); HeapEntry* entry = worklist.RemoveLast();
if (entry->reachable_from_window()) continue; if (entry->user_reachable()) continue;
entry->set_reachable_from_window(); entry->set_user_reachable();
Vector<HeapGraphEdge> children = entry->children(); Vector<HeapGraphEdge> children = entry->children();
for (int i = 0; i < children.length(); ++i) { for (int i = 0; i < children.length(); ++i) {
HeapEntry* child = children[i].to(); HeapEntry* child = children[i].to();
if (!child->reachable_from_window()) { if (!child->user_reachable()) {
worklist.Add(child); worklist.Add(child);
} }
} }
...@@ -3298,8 +3307,8 @@ static bool IsRetainingEdge(HeapGraphEdge* edge) { ...@@ -3298,8 +3307,8 @@ static bool IsRetainingEdge(HeapGraphEdge* edge) {
// The edge is not retaining if it goes from system domain // The edge is not retaining if it goes from system domain
// (i.e. an object not reachable from window) to the user domain // (i.e. an object not reachable from window) to the user domain
// (i.e. a reachable object). // (i.e. a reachable object).
return edge->from()->reachable_from_window() return edge->from()->user_reachable()
|| !edge->to()->reachable_from_window(); || !edge->to()->user_reachable();
} }
...@@ -3407,7 +3416,7 @@ bool HeapSnapshotGenerator::BuildDominatorTree( ...@@ -3407,7 +3416,7 @@ bool HeapSnapshotGenerator::BuildDominatorTree(
bool HeapSnapshotGenerator::SetEntriesDominators() { bool HeapSnapshotGenerator::SetEntriesDominators() {
MarkWindowReachableObjects(); MarkUserReachableObjects();
// This array is used for maintaining postorder of nodes. // This array is used for maintaining postorder of nodes.
ScopedVector<HeapEntry*> ordered_entries(snapshot_->entries()->length()); ScopedVector<HeapEntry*> ordered_entries(snapshot_->entries()->length());
FillPostorderIndexes(&ordered_entries); FillPostorderIndexes(&ordered_entries);
......
...@@ -563,8 +563,8 @@ class HeapEntry BASE_EMBEDDED { ...@@ -563,8 +563,8 @@ class HeapEntry BASE_EMBEDDED {
void clear_paint() { painted_ = false; } void clear_paint() { painted_ = false; }
bool painted() { return painted_; } bool painted() { return painted_; }
void paint() { painted_ = true; } void paint() { painted_ = true; }
bool reachable_from_window() { return reachable_from_window_; } bool user_reachable() { return user_reachable_; }
void set_reachable_from_window() { reachable_from_window_ = true; } void set_user_reachable() { user_reachable_ = true; }
void SetIndexedReference(HeapGraphEdge::Type type, void SetIndexedReference(HeapGraphEdge::Type type,
int child_index, int child_index,
...@@ -601,7 +601,7 @@ class HeapEntry BASE_EMBEDDED { ...@@ -601,7 +601,7 @@ class HeapEntry BASE_EMBEDDED {
const char* TypeAsString(); const char* TypeAsString();
unsigned painted_: 1; unsigned painted_: 1;
unsigned reachable_from_window_: 1; unsigned user_reachable_: 1;
unsigned type_: 4; unsigned type_: 4;
int children_count_: 26; int children_count_: 26;
int retainers_count_; int retainers_count_;
...@@ -1020,7 +1020,7 @@ class V8HeapExplorer : public HeapEntriesAllocator { ...@@ -1020,7 +1020,7 @@ class V8HeapExplorer : public HeapEntriesAllocator {
HeapEntry* parent, HeapEntry* parent,
String* reference_name, String* reference_name,
Object* child); Object* child);
void SetWindowReference(Object* window); void SetUserGlobalReference(Object* window);
void SetRootGcRootsReference(); void SetRootGcRootsReference();
void SetGcRootsReference(VisitorSynchronization::SyncTag tag); void SetGcRootsReference(VisitorSynchronization::SyncTag tag);
void SetGcSubrootReference( void SetGcSubrootReference(
...@@ -1125,8 +1125,8 @@ class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { ...@@ -1125,8 +1125,8 @@ class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface {
bool CountEntriesAndReferences(); bool CountEntriesAndReferences();
bool FillReferences(); bool FillReferences();
void FillPostorderIndexes(Vector<HeapEntry*>* entries); void FillPostorderIndexes(Vector<HeapEntry*>* entries);
bool IsWindowReference(const HeapGraphEdge& edge); bool IsUserGlobalReference(const HeapGraphEdge& edge);
void MarkWindowReachableObjects(); void MarkUserReachableObjects();
void ProgressStep(); void ProgressStep();
bool ProgressReport(bool force = false); bool ProgressReport(bool force = false);
bool SetEntriesDominators(); bool SetEntriesDominators();
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "cctest.h" #include "cctest.h"
#include "heap-profiler.h" #include "heap-profiler.h"
#include "snapshot.h" #include "snapshot.h"
#include "debug.h"
#include "utils-inl.h" #include "utils-inl.h"
#include "../include/v8-profiler.h" #include "../include/v8-profiler.h"
...@@ -1564,6 +1565,30 @@ TEST(SfiAndJsFunctionWeakRefs) { ...@@ -1564,6 +1565,30 @@ TEST(SfiAndJsFunctionWeakRefs) {
} }
TEST(NoDebugObjectInSnapshot) {
v8::HandleScope scope;
LocalContext env;
v8::internal::Isolate::Current()->debug()->Load();
CompileRun("foo = {};");
const v8::HeapSnapshot* snapshot =
v8::HeapProfiler::TakeSnapshot(v8_str("snapshot"));
const v8::HeapGraphNode* root = snapshot->GetRoot();
int globals_count = 0;
for (int i = 0; i < root->GetChildrenCount(); ++i) {
const v8::HeapGraphEdge* edge = root->GetChild(i);
if (edge->GetType() == v8::HeapGraphEdge::kShortcut) {
++globals_count;
const v8::HeapGraphNode* global = edge->GetToNode();
const v8::HeapGraphNode* foo =
GetProperty(global, v8::HeapGraphEdge::kProperty, "foo");
CHECK_NE(NULL, foo);
}
}
CHECK_EQ(1, globals_count);
}
TEST(PersistentHandleCount) { TEST(PersistentHandleCount) {
v8::HandleScope scope; v8::HandleScope scope;
LocalContext env; LocalContext env;
......
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