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

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: 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 12 matching lines...) Expand all
987 extract_indexed_refs = false; 987 extract_indexed_refs = false;
988 } 988 }
989 if (extract_indexed_refs) { 989 if (extract_indexed_refs) {
990 SetInternalReference(obj, entry, "map", obj->map(), HeapObject::kMapOffset); 990 SetInternalReference(obj, entry, "map", obj->map(), HeapObject::kMapOffset);
991 IndexedReferencesExtractor refs_extractor(this, obj, entry); 991 IndexedReferencesExtractor refs_extractor(this, obj, entry);
992 obj->Iterate(&refs_extractor); 992 obj->Iterate(&refs_extractor);
993 } 993 }
994 } 994 }
995 995
996 996
997 void V8HeapExplorer::ExtractJSGlobalProxyReferences(JSGlobalProxy* proxy) { 997 void V8HeapExplorer::ExtractJSGlobalProxyReferences(
998 // We need to reference JS global objects from snapshot's root. 998 int entry, JSGlobalProxy* proxy) {
999 // We use JSGlobalProxy because this is what embedder (e.g. browser) 999 SetInternalReference(proxy, entry,
1000 // uses for the global object. 1000 "native_context", proxy->native_context(),
yurys 2013/06/27 16:26:00 Can we have a test for this? As far as I understa
alph 2013/06/28 11:58:04 Don't think checking that we've reported this the
1001 Object* object = proxy->map()->prototype(); 1001 JSGlobalProxy::kNativeContextOffset);
1002 bool is_debug_object = false;
1003 #ifdef ENABLE_DEBUGGER_SUPPORT
1004 is_debug_object = object->IsGlobalObject() &&
1005 Isolate::Current()->debug()->IsDebugGlobal(GlobalObject::cast(object));
1006 #endif
1007 if (!is_debug_object) {
1008 SetUserGlobalReference(object);
1009 }
1010 } 1002 }
1011 1003
1012 1004
1013 void V8HeapExplorer::ExtractJSObjectReferences( 1005 void V8HeapExplorer::ExtractJSObjectReferences(
1014 int entry, JSObject* js_obj) { 1006 int entry, JSObject* js_obj) {
1015 HeapObject* obj = js_obj; 1007 HeapObject* obj = js_obj;
1016 ExtractClosureReferences(js_obj, entry); 1008 ExtractClosureReferences(js_obj, entry);
1017 ExtractPropertyReferences(js_obj, entry); 1009 ExtractPropertyReferences(js_obj, entry);
1018 ExtractElementReferences(js_obj, entry); 1010 ExtractElementReferences(js_obj, entry);
1019 ExtractInternalReferences(js_obj, entry); 1011 ExtractInternalReferences(js_obj, entry);
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 HeapGraphEdge::kInternal, 1745 HeapGraphEdge::kInternal,
1754 snapshot_->gc_subroot(tag)->index(), 1746 snapshot_->gc_subroot(tag)->index(),
1755 name, 1747 name,
1756 child_entry); 1748 child_entry);
1757 } else { 1749 } else {
1758 filler_->SetIndexedAutoIndexReference( 1750 filler_->SetIndexedAutoIndexReference(
1759 is_weak ? HeapGraphEdge::kWeak : HeapGraphEdge::kElement, 1751 is_weak ? HeapGraphEdge::kWeak : HeapGraphEdge::kElement,
1760 snapshot_->gc_subroot(tag)->index(), 1752 snapshot_->gc_subroot(tag)->index(),
1761 child_entry); 1753 child_entry);
1762 } 1754 }
1755
1756 // Add a shortcut to JS global object reference at snapshot root.
1757 if (child_obj->IsNativeContext()) {
1758 Context* context = Context::cast(child_obj);
1759 JSObject* proxy = context->global_proxy();
1760 if (proxy->IsJSGlobalProxy()) {
1761 // We use JSGlobalProxy because that's what embedder (e.g. browser)
1762 // uses for the global object.
1763 // TODO(alph): consider extracting it as just proxy->global_object()
1764 Object* object = proxy->map()->prototype();
1765 if (object->IsJSGlobalObject()) {
1766 JSGlobalObject* global = JSGlobalObject::cast(object);
1767 CHECK(global == context->global_object());
yurys 2013/06/28 09:42:18 Ok, I looked more closely at how we setup global o
alph 2013/06/28 11:58:04 Done.
1768 bool is_debug_object = false;
1769 #ifdef ENABLE_DEBUGGER_SUPPORT
1770 is_debug_object = Isolate::Current()->debug()->IsDebugGlobal(global);
yurys 2013/06/27 16:26:00 Please use heap_->isolate() instead of Isolate::Cu
alph 2013/06/28 11:58:04 Done.
1771 #endif
1772 if (!is_debug_object && !user_roots_.Contains(global)) {
1773 user_roots_.Insert(global);
1774 SetUserGlobalReference(global);
1775 }
1776 }
1777 }
1778 }
1763 } 1779 }
1764 } 1780 }
1765 1781
1766 1782
1767 const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) { 1783 const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) {
1768 if (strong_gc_subroot_names_.is_empty()) { 1784 if (strong_gc_subroot_names_.is_empty()) {
1769 #define NAME_ENTRY(name) strong_gc_subroot_names_.SetTag(heap_->name(), #name); 1785 #define NAME_ENTRY(name) strong_gc_subroot_names_.SetTag(heap_->name(), #name);
1770 #define ROOT_NAME(type, name, camel_name) NAME_ENTRY(name) 1786 #define ROOT_NAME(type, name, camel_name) NAME_ENTRY(name)
1771 STRONG_ROOT_LIST(ROOT_NAME) 1787 STRONG_ROOT_LIST(ROOT_NAME)
1772 #undef ROOT_NAME 1788 #undef ROOT_NAME
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
2668 2684
2669 2685
2670 void HeapSnapshotJSONSerializer::SortHashMap( 2686 void HeapSnapshotJSONSerializer::SortHashMap(
2671 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2687 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2672 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2688 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2673 sorted_entries->Add(p); 2689 sorted_entries->Add(p);
2674 sorted_entries->Sort(SortUsingEntryValue); 2690 sorted_entries->Sort(SortUsingEntryValue);
2675 } 2691 }
2676 2692
2677 } } // namespace v8::internal 2693 } } // 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