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

Side by Side Diff: src/heap-snapshot-generator.cc

Issue 17881005: Heap snapshot: Update user roots definition. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix a typo Created 7 years, 5 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/heap-snapshot-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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 }; 954 };
955 955
956 956
957 void V8HeapExplorer::ExtractReferences(HeapObject* obj) { 957 void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
958 HeapEntry* heap_entry = GetEntry(obj); 958 HeapEntry* heap_entry = GetEntry(obj);
959 if (heap_entry == NULL) return; // No interest in this object. 959 if (heap_entry == NULL) return; // No interest in this object.
960 int entry = heap_entry->index(); 960 int entry = heap_entry->index();
961 961
962 bool extract_indexed_refs = true; 962 bool extract_indexed_refs = true;
963 if (obj->IsJSGlobalProxy()) { 963 if (obj->IsJSGlobalProxy()) {
964 ExtractJSGlobalProxyReferences(JSGlobalProxy::cast(obj)); 964 ExtractJSGlobalProxyReferences(entry, JSGlobalProxy::cast(obj));
965 } else if (obj->IsJSObject()) { 965 } else if (obj->IsJSObject()) {
966 ExtractJSObjectReferences(entry, JSObject::cast(obj)); 966 ExtractJSObjectReferences(entry, JSObject::cast(obj));
967 } else if (obj->IsString()) { 967 } else if (obj->IsString()) {
968 ExtractStringReferences(entry, String::cast(obj)); 968 ExtractStringReferences(entry, String::cast(obj));
969 } else if (obj->IsContext()) { 969 } else if (obj->IsContext()) {
970 ExtractContextReferences(entry, Context::cast(obj)); 970 ExtractContextReferences(entry, Context::cast(obj));
971 } else if (obj->IsMap()) { 971 } else if (obj->IsMap()) {
972 ExtractMapReferences(entry, Map::cast(obj)); 972 ExtractMapReferences(entry, Map::cast(obj));
973 } else if (obj->IsSharedFunctionInfo()) { 973 } else if (obj->IsSharedFunctionInfo()) {
974 ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj)); 974 ExtractSharedFunctionInfoReferences(entry, SharedFunctionInfo::cast(obj));
(...skipping 14 matching lines...) Expand all
989 extract_indexed_refs = false; 989 extract_indexed_refs = false;
990 } 990 }
991 if (extract_indexed_refs) { 991 if (extract_indexed_refs) {
992 SetInternalReference(obj, entry, "map", obj->map(), HeapObject::kMapOffset); 992 SetInternalReference(obj, entry, "map", obj->map(), HeapObject::kMapOffset);
993 IndexedReferencesExtractor refs_extractor(this, obj, entry); 993 IndexedReferencesExtractor refs_extractor(this, obj, entry);
994 obj->Iterate(&refs_extractor); 994 obj->Iterate(&refs_extractor);
995 } 995 }
996 } 996 }
997 997
998 998
999 void V8HeapExplorer::ExtractJSGlobalProxyReferences(JSGlobalProxy* proxy) { 999 void V8HeapExplorer::ExtractJSGlobalProxyReferences(
1000 // We need to reference JS global objects from snapshot's root. 1000 int entry, JSGlobalProxy* proxy) {
1001 // We use JSGlobalProxy because this is what embedder (e.g. browser) 1001 SetInternalReference(proxy, entry,
1002 // uses for the global object. 1002 "native_context", proxy->native_context(),
1003 Object* object = proxy->map()->prototype(); 1003 JSGlobalProxy::kNativeContextOffset);
1004 bool is_debug_object = false;
1005 #ifdef ENABLE_DEBUGGER_SUPPORT
1006 is_debug_object = object->IsGlobalObject() &&
1007 Isolate::Current()->debug()->IsDebugGlobal(GlobalObject::cast(object));
1008 #endif
1009 if (!is_debug_object) {
1010 SetUserGlobalReference(object);
1011 }
1012 } 1004 }
1013 1005
1014 1006
1015 void V8HeapExplorer::ExtractJSObjectReferences( 1007 void V8HeapExplorer::ExtractJSObjectReferences(
1016 int entry, JSObject* js_obj) { 1008 int entry, JSObject* js_obj) {
1017 HeapObject* obj = js_obj; 1009 HeapObject* obj = js_obj;
1018 ExtractClosureReferences(js_obj, entry); 1010 ExtractClosureReferences(js_obj, entry);
1019 ExtractPropertyReferences(js_obj, entry); 1011 ExtractPropertyReferences(js_obj, entry);
1020 ExtractElementReferences(js_obj, entry); 1012 ExtractElementReferences(js_obj, entry);
1021 ExtractInternalReferences(js_obj, entry); 1013 ExtractInternalReferences(js_obj, entry);
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 HeapGraphEdge::kInternal, 1763 HeapGraphEdge::kInternal,
1772 snapshot_->gc_subroot(tag)->index(), 1764 snapshot_->gc_subroot(tag)->index(),
1773 name, 1765 name,
1774 child_entry); 1766 child_entry);
1775 } else { 1767 } else {
1776 filler_->SetIndexedAutoIndexReference( 1768 filler_->SetIndexedAutoIndexReference(
1777 is_weak ? HeapGraphEdge::kWeak : HeapGraphEdge::kElement, 1769 is_weak ? HeapGraphEdge::kWeak : HeapGraphEdge::kElement,
1778 snapshot_->gc_subroot(tag)->index(), 1770 snapshot_->gc_subroot(tag)->index(),
1779 child_entry); 1771 child_entry);
1780 } 1772 }
1773
1774 // Add a shortcut to JS global object reference at snapshot root.
1775 if (child_obj->IsNativeContext()) {
1776 Context* context = Context::cast(child_obj);
1777 GlobalObject* global = context->global_object();
1778 if (global->IsJSGlobalObject()) {
1779 bool is_debug_object = false;
1780 #ifdef ENABLE_DEBUGGER_SUPPORT
1781 is_debug_object = heap_->isolate()->debug()->IsDebugGlobal(global);
1782 #endif
1783 if (!is_debug_object && !user_roots_.Contains(global)) {
1784 user_roots_.Insert(global);
1785 SetUserGlobalReference(global);
1786 }
1787 }
1788 }
1781 } 1789 }
1782 } 1790 }
1783 1791
1784 1792
1785 const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) { 1793 const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) {
1786 if (strong_gc_subroot_names_.is_empty()) { 1794 if (strong_gc_subroot_names_.is_empty()) {
1787 #define NAME_ENTRY(name) strong_gc_subroot_names_.SetTag(heap_->name(), #name); 1795 #define NAME_ENTRY(name) strong_gc_subroot_names_.SetTag(heap_->name(), #name);
1788 #define ROOT_NAME(type, name, camel_name) NAME_ENTRY(name) 1796 #define ROOT_NAME(type, name, camel_name) NAME_ENTRY(name)
1789 STRONG_ROOT_LIST(ROOT_NAME) 1797 STRONG_ROOT_LIST(ROOT_NAME)
1790 #undef ROOT_NAME 1798 #undef ROOT_NAME
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 2694
2687 2695
2688 void HeapSnapshotJSONSerializer::SortHashMap( 2696 void HeapSnapshotJSONSerializer::SortHashMap(
2689 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2697 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2690 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2698 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2691 sorted_entries->Add(p); 2699 sorted_entries->Add(p);
2692 sorted_entries->Sort(SortUsingEntryValue); 2700 sorted_entries->Sort(SortUsingEntryValue);
2693 } 2701 }
2694 2702
2695 } } // namespace v8::internal 2703 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698