Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1164)

Side by Side Diff: src/profile-generator.cc

Issue 10096016: Remove Debug object from the user roots in heap profiler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 16 matching lines...) Expand all
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "profile-generator-inl.h" 30 #include "profile-generator-inl.h"
31 31
32 #include "global-handles.h" 32 #include "global-handles.h"
33 #include "heap-profiler.h" 33 #include "heap-profiler.h"
34 #include "scopeinfo.h" 34 #include "scopeinfo.h"
35 #include "unicode.h" 35 #include "unicode.h"
36 #include "zone-inl.h" 36 #include "zone-inl.h"
37 #include "debug.h"
37 38
38 namespace v8 { 39 namespace v8 {
39 namespace internal { 40 namespace internal {
40 41
41 42
42 TokenEnumerator::TokenEnumerator() 43 TokenEnumerator::TokenEnumerator()
43 : token_locations_(4), 44 : token_locations_(4),
44 token_removed_(4) { 45 token_removed_(4) {
45 } 46 }
46 47
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 void HeapEntry::Init(HeapSnapshot* snapshot, 961 void HeapEntry::Init(HeapSnapshot* snapshot,
961 Type type, 962 Type type,
962 const char* name, 963 const char* name,
963 SnapshotObjectId id, 964 SnapshotObjectId id,
964 int self_size, 965 int self_size,
965 int children_count, 966 int children_count,
966 int retainers_count) { 967 int retainers_count) {
967 snapshot_ = snapshot; 968 snapshot_ = snapshot;
968 type_ = type; 969 type_ = type;
969 painted_ = false; 970 painted_ = false;
970 reachable_from_window_ = false; 971 user_reachable_ = false;
971 name_ = name; 972 name_ = name;
972 self_size_ = self_size; 973 self_size_ = self_size;
973 retained_size_ = 0; 974 retained_size_ = 0;
974 entry_index_ = -1; 975 entry_index_ = -1;
975 children_count_ = children_count; 976 children_count_ = children_count;
976 retainers_count_ = retainers_count; 977 retainers_count_ = retainers_count;
977 dominator_ = NULL; 978 dominator_ = NULL;
978 id_ = id; 979 id_ = id;
979 } 980 }
980 981
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 void V8HeapExplorer::ExtractReferences(HeapObject* obj) { 1980 void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
1980 HeapEntry* entry = GetEntry(obj); 1981 HeapEntry* entry = GetEntry(obj);
1981 if (entry == NULL) return; // No interest in this object. 1982 if (entry == NULL) return; // No interest in this object.
1982 1983
1983 bool extract_indexed_refs = true; 1984 bool extract_indexed_refs = true;
1984 if (obj->IsJSGlobalProxy()) { 1985 if (obj->IsJSGlobalProxy()) {
1985 // We need to reference JS global objects from snapshot's root. 1986 // We need to reference JS global objects from snapshot's root.
1986 // We use JSGlobalProxy because this is what embedder (e.g. browser) 1987 // We use JSGlobalProxy because this is what embedder (e.g. browser)
1987 // uses for the global object. 1988 // uses for the global object.
1988 JSGlobalProxy* proxy = JSGlobalProxy::cast(obj); 1989 JSGlobalProxy* proxy = JSGlobalProxy::cast(obj);
1989 SetWindowReference(proxy->map()->prototype()); 1990 Object* object = proxy->map()->prototype();
1991 bool is_debug_object = false;
1992 #ifdef ENABLE_DEBUGGER_SUPPORT
1993 is_debug_object = object->IsGlobalObject() &&
1994 Isolate::Current()->debug()->IsDebugGlobal(GlobalObject::cast(object));
1995 #endif
1996 if (!is_debug_object) {
1997 SetUserGlobalReference(object);
1998 }
1990 } else if (obj->IsJSObject()) { 1999 } else if (obj->IsJSObject()) {
1991 JSObject* js_obj = JSObject::cast(obj); 2000 JSObject* js_obj = JSObject::cast(obj);
1992 ExtractClosureReferences(js_obj, entry); 2001 ExtractClosureReferences(js_obj, entry);
1993 ExtractPropertyReferences(js_obj, entry); 2002 ExtractPropertyReferences(js_obj, entry);
1994 ExtractElementReferences(js_obj, entry); 2003 ExtractElementReferences(js_obj, entry);
1995 ExtractInternalReferences(js_obj, entry); 2004 ExtractInternalReferences(js_obj, entry);
1996 SetPropertyReference( 2005 SetPropertyReference(
1997 obj, entry, heap_->Proto_symbol(), js_obj->GetPrototype()); 2006 obj, entry, heap_->Proto_symbol(), js_obj->GetPrototype());
1998 if (obj->IsJSFunction()) { 2007 if (obj->IsJSFunction()) {
1999 JSFunction* js_fun = JSFunction::cast(js_obj); 2008 JSFunction* js_fun = JSFunction::cast(js_obj);
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 2633
2625 2634
2626 void V8HeapExplorer::SetRootGcRootsReference() { 2635 void V8HeapExplorer::SetRootGcRootsReference() {
2627 filler_->SetIndexedAutoIndexReference( 2636 filler_->SetIndexedAutoIndexReference(
2628 HeapGraphEdge::kElement, 2637 HeapGraphEdge::kElement,
2629 kInternalRootObject, snapshot_->root(), 2638 kInternalRootObject, snapshot_->root(),
2630 kGcRootsObject, snapshot_->gc_roots()); 2639 kGcRootsObject, snapshot_->gc_roots());
2631 } 2640 }
2632 2641
2633 2642
2634 void V8HeapExplorer::SetWindowReference(Object* child_obj) { 2643 void V8HeapExplorer::SetUserGlobalReference(Object* child_obj) {
2635 HeapEntry* child_entry = GetEntry(child_obj); 2644 HeapEntry* child_entry = GetEntry(child_obj);
2636 ASSERT(child_entry != NULL); 2645 ASSERT(child_entry != NULL);
2637 filler_->SetNamedAutoIndexReference( 2646 filler_->SetNamedAutoIndexReference(
2638 HeapGraphEdge::kShortcut, 2647 HeapGraphEdge::kShortcut,
2639 kInternalRootObject, snapshot_->root(), 2648 kInternalRootObject, snapshot_->root(),
2640 child_obj, child_entry); 2649 child_obj, child_entry);
2641 } 2650 }
2642 2651
2643 2652
2644 void V8HeapExplorer::SetGcRootsReference(VisitorSynchronization::SyncTag tag) { 2653 void V8HeapExplorer::SetGcRootsReference(VisitorSynchronization::SyncTag tag) {
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 // in turn may relocate objects in property maps thus changing the heap 3269 // in turn may relocate objects in property maps thus changing the heap
3261 // layout and affecting retainer counts. This is not acceptable because 3270 // layout and affecting retainer counts. This is not acceptable because
3262 // number of retainers must not change between count and fill passes. 3271 // number of retainers must not change between count and fill passes.
3263 // To avoid this there's a separate postpass that set object names. 3272 // To avoid this there's a separate postpass that set object names.
3264 return v8_heap_explorer_.IterateAndExtractReferences(&filler) 3273 return v8_heap_explorer_.IterateAndExtractReferences(&filler)
3265 && dom_explorer_.IterateAndExtractReferences(&filler) 3274 && dom_explorer_.IterateAndExtractReferences(&filler)
3266 && v8_heap_explorer_.IterateAndSetObjectNames(&filler); 3275 && v8_heap_explorer_.IterateAndSetObjectNames(&filler);
3267 } 3276 }
3268 3277
3269 3278
3270 bool HeapSnapshotGenerator::IsWindowReference(const HeapGraphEdge& edge) { 3279 bool HeapSnapshotGenerator::IsUserGlobalReference(const HeapGraphEdge& edge) {
3271 ASSERT(edge.from() == snapshot_->root()); 3280 ASSERT(edge.from() == snapshot_->root());
3272 return edge.type() == HeapGraphEdge::kShortcut; 3281 return edge.type() == HeapGraphEdge::kShortcut;
3273 } 3282 }
3274 3283
3275 3284
3276 void HeapSnapshotGenerator::MarkWindowReachableObjects() { 3285 void HeapSnapshotGenerator::MarkUserReachableObjects() {
3277 List<HeapEntry*> worklist; 3286 List<HeapEntry*> worklist;
3278 3287
3279 Vector<HeapGraphEdge> children = snapshot_->root()->children(); 3288 Vector<HeapGraphEdge> children = snapshot_->root()->children();
3280 for (int i = 0; i < children.length(); ++i) { 3289 for (int i = 0; i < children.length(); ++i) {
3281 if (IsWindowReference(children[i])) { 3290 if (IsUserGlobalReference(children[i])) {
3282 worklist.Add(children[i].to()); 3291 worklist.Add(children[i].to());
3283 } 3292 }
3284 } 3293 }
3285 3294
3286 while (!worklist.is_empty()) { 3295 while (!worklist.is_empty()) {
3287 HeapEntry* entry = worklist.RemoveLast(); 3296 HeapEntry* entry = worklist.RemoveLast();
3288 if (entry->reachable_from_window()) continue; 3297 if (entry->user_reachable()) continue;
3289 entry->set_reachable_from_window(); 3298 entry->set_user_reachable();
3290 Vector<HeapGraphEdge> children = entry->children(); 3299 Vector<HeapGraphEdge> children = entry->children();
3291 for (int i = 0; i < children.length(); ++i) { 3300 for (int i = 0; i < children.length(); ++i) {
3292 HeapEntry* child = children[i].to(); 3301 HeapEntry* child = children[i].to();
3293 if (!child->reachable_from_window()) { 3302 if (!child->user_reachable()) {
3294 worklist.Add(child); 3303 worklist.Add(child);
3295 } 3304 }
3296 } 3305 }
3297 } 3306 }
3298 } 3307 }
3299 3308
3300 3309
3301 static bool IsRetainingEdge(HeapGraphEdge* edge) { 3310 static bool IsRetainingEdge(HeapGraphEdge* edge) {
3302 if (edge->type() == HeapGraphEdge::kShortcut) return false; 3311 if (edge->type() == HeapGraphEdge::kShortcut) return false;
3303 // The edge is not retaining if it goes from system domain 3312 // The edge is not retaining if it goes from system domain
3304 // (i.e. an object not reachable from window) to the user domain 3313 // (i.e. an object not reachable from window) to the user domain
3305 // (i.e. a reachable object). 3314 // (i.e. a reachable object).
3306 return edge->from()->reachable_from_window() 3315 return edge->from()->user_reachable()
3307 || !edge->to()->reachable_from_window(); 3316 || !edge->to()->user_reachable();
3308 } 3317 }
3309 3318
3310 3319
3311 void HeapSnapshotGenerator::FillPostorderIndexes( 3320 void HeapSnapshotGenerator::FillPostorderIndexes(
3312 Vector<HeapEntry*>* entries) { 3321 Vector<HeapEntry*>* entries) {
3313 snapshot_->ClearPaint(); 3322 snapshot_->ClearPaint();
3314 int current_entry = 0; 3323 int current_entry = 0;
3315 List<HeapEntry*> nodes_to_visit; 3324 List<HeapEntry*> nodes_to_visit;
3316 HeapEntry* root = snapshot_->root(); 3325 HeapEntry* root = snapshot_->root();
3317 nodes_to_visit.Add(root); 3326 nodes_to_visit.Add(root);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 affected[children[j].to()->ordered_index()] = true; 3414 affected[children[j].to()->ordered_index()] = true;
3406 } 3415 }
3407 } 3416 }
3408 } 3417 }
3409 } 3418 }
3410 return true; 3419 return true;
3411 } 3420 }
3412 3421
3413 3422
3414 bool HeapSnapshotGenerator::SetEntriesDominators() { 3423 bool HeapSnapshotGenerator::SetEntriesDominators() {
3415 MarkWindowReachableObjects(); 3424 MarkUserReachableObjects();
3416 // This array is used for maintaining postorder of nodes. 3425 // This array is used for maintaining postorder of nodes.
3417 ScopedVector<HeapEntry*> ordered_entries(snapshot_->entries()->length()); 3426 ScopedVector<HeapEntry*> ordered_entries(snapshot_->entries()->length());
3418 FillPostorderIndexes(&ordered_entries); 3427 FillPostorderIndexes(&ordered_entries);
3419 ScopedVector<int> dominators(ordered_entries.length()); 3428 ScopedVector<int> dominators(ordered_entries.length());
3420 if (!BuildDominatorTree(ordered_entries, &dominators)) return false; 3429 if (!BuildDominatorTree(ordered_entries, &dominators)) return false;
3421 for (int i = 0; i < ordered_entries.length(); ++i) { 3430 for (int i = 0; i < ordered_entries.length(); ++i) {
3422 ASSERT(dominators[i] >= 0); 3431 ASSERT(dominators[i] >= 0);
3423 ordered_entries[i]->set_dominator(ordered_entries[dominators[i]]); 3432 ordered_entries[i]->set_dominator(ordered_entries[dominators[i]]);
3424 } 3433 }
3425 return true; 3434 return true;
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
3899 3908
3900 3909
3901 void HeapSnapshotJSONSerializer::SortHashMap( 3910 void HeapSnapshotJSONSerializer::SortHashMap(
3902 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3911 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3903 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3912 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3904 sorted_entries->Add(p); 3913 sorted_entries->Add(p);
3905 sorted_entries->Sort(SortUsingEntryValue); 3914 sorted_entries->Sort(SortUsingEntryValue);
3906 } 3915 }
3907 3916
3908 } } // namespace v8::internal 3917 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698