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

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

Issue 23886002: remove Isolate::Current from most files starting with 'f' through 'i' (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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') | src/hydrogen-instructions.h » ('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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 static_cast<intptr_t>(HeapObjectsMap::kGcRootsFirstSubrootId)); 725 static_cast<intptr_t>(HeapObjectsMap::kGcRootsFirstSubrootId));
726 HeapObject* const V8HeapExplorer::kLastGcSubrootObject = 726 HeapObject* const V8HeapExplorer::kLastGcSubrootObject =
727 reinterpret_cast<HeapObject*>( 727 reinterpret_cast<HeapObject*>(
728 static_cast<intptr_t>(HeapObjectsMap::kFirstAvailableObjectId)); 728 static_cast<intptr_t>(HeapObjectsMap::kFirstAvailableObjectId));
729 729
730 730
731 V8HeapExplorer::V8HeapExplorer( 731 V8HeapExplorer::V8HeapExplorer(
732 HeapSnapshot* snapshot, 732 HeapSnapshot* snapshot,
733 SnapshottingProgressReportingInterface* progress, 733 SnapshottingProgressReportingInterface* progress,
734 v8::HeapProfiler::ObjectNameResolver* resolver) 734 v8::HeapProfiler::ObjectNameResolver* resolver)
735 : heap_(Isolate::Current()->heap()), 735 : heap_(snapshot->collection()->heap()),
736 snapshot_(snapshot), 736 snapshot_(snapshot),
737 collection_(snapshot_->collection()), 737 collection_(snapshot_->collection()),
738 progress_(progress), 738 progress_(progress),
739 filler_(NULL), 739 filler_(NULL),
740 global_object_name_resolver_(resolver) { 740 global_object_name_resolver_(resolver) {
741 } 741 }
742 742
743 743
744 V8HeapExplorer::~V8HeapExplorer() { 744 V8HeapExplorer::~V8HeapExplorer() {
745 } 745 }
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 int count() { return objects_.length(); } 1845 int count() { return objects_.length(); }
1846 Handle<JSGlobalObject>& at(int i) { return objects_[i]; } 1846 Handle<JSGlobalObject>& at(int i) { return objects_[i]; }
1847 1847
1848 private: 1848 private:
1849 List<Handle<JSGlobalObject> > objects_; 1849 List<Handle<JSGlobalObject> > objects_;
1850 }; 1850 };
1851 1851
1852 1852
1853 // Modifies heap. Must not be run during heap traversal. 1853 // Modifies heap. Must not be run during heap traversal.
1854 void V8HeapExplorer::TagGlobalObjects() { 1854 void V8HeapExplorer::TagGlobalObjects() {
1855 Isolate* isolate = Isolate::Current(); 1855 Isolate* isolate = heap_->isolate();
1856 HandleScope scope(isolate); 1856 HandleScope scope(isolate);
1857 GlobalObjectsEnumerator enumerator; 1857 GlobalObjectsEnumerator enumerator;
1858 isolate->global_handles()->IterateAllRoots(&enumerator); 1858 isolate->global_handles()->IterateAllRoots(&enumerator);
1859 const char** urls = NewArray<const char*>(enumerator.count()); 1859 const char** urls = NewArray<const char*>(enumerator.count());
1860 for (int i = 0, l = enumerator.count(); i < l; ++i) { 1860 for (int i = 0, l = enumerator.count(); i < l; ++i) {
1861 if (global_object_name_resolver_) { 1861 if (global_object_name_resolver_) {
1862 HandleScope scope(isolate); 1862 HandleScope scope(isolate);
1863 Handle<JSGlobalObject> global_obj = enumerator.at(i); 1863 Handle<JSGlobalObject> global_obj = enumerator.at(i);
1864 urls[i] = global_object_name_resolver_->GetName( 1864 urls[i] = global_object_name_resolver_->GetName(
1865 Utils::ToLocal(Handle<JSObject>::cast(global_obj))); 1865 Utils::ToLocal(Handle<JSObject>::cast(global_obj)));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 : collection_->names()->GetCopy(info->GetLabel()); 1920 : collection_->names()->GetCopy(info->GetLabel());
1921 return snapshot_->AddEntry( 1921 return snapshot_->AddEntry(
1922 entries_type_, 1922 entries_type_,
1923 name, 1923 name,
1924 HeapObjectsMap::GenerateId(info), 1924 HeapObjectsMap::GenerateId(info),
1925 size != -1 ? static_cast<int>(size) : 0); 1925 size != -1 ? static_cast<int>(size) : 0);
1926 } 1926 }
1927 1927
1928 1928
1929 NativeObjectsExplorer::NativeObjectsExplorer( 1929 NativeObjectsExplorer::NativeObjectsExplorer(
1930 HeapSnapshot* snapshot, SnapshottingProgressReportingInterface* progress) 1930 HeapSnapshot* snapshot,
1931 : snapshot_(snapshot), 1931 SnapshottingProgressReportingInterface* progress)
1932 : isolate_(snapshot->collection()->heap()->isolate()),
1933 snapshot_(snapshot),
1932 collection_(snapshot_->collection()), 1934 collection_(snapshot_->collection()),
1933 progress_(progress), 1935 progress_(progress),
1934 embedder_queried_(false), 1936 embedder_queried_(false),
1935 objects_by_info_(RetainedInfosMatch), 1937 objects_by_info_(RetainedInfosMatch),
1936 native_groups_(StringsMatch), 1938 native_groups_(StringsMatch),
1937 filler_(NULL) { 1939 filler_(NULL) {
1938 synthetic_entries_allocator_ = 1940 synthetic_entries_allocator_ =
1939 new BasicHeapEntriesAllocator(snapshot, HeapEntry::kSynthetic); 1941 new BasicHeapEntriesAllocator(snapshot, HeapEntry::kSynthetic);
1940 native_entries_allocator_ = 1942 native_entries_allocator_ =
1941 new BasicHeapEntriesAllocator(snapshot, HeapEntry::kNative); 1943 new BasicHeapEntriesAllocator(snapshot, HeapEntry::kNative);
(...skipping 24 matching lines...) Expand all
1966 1968
1967 1969
1968 int NativeObjectsExplorer::EstimateObjectsCount() { 1970 int NativeObjectsExplorer::EstimateObjectsCount() {
1969 FillRetainedObjects(); 1971 FillRetainedObjects();
1970 return objects_by_info_.occupancy(); 1972 return objects_by_info_.occupancy();
1971 } 1973 }
1972 1974
1973 1975
1974 void NativeObjectsExplorer::FillRetainedObjects() { 1976 void NativeObjectsExplorer::FillRetainedObjects() {
1975 if (embedder_queried_) return; 1977 if (embedder_queried_) return;
1976 Isolate* isolate = Isolate::Current(); 1978 Isolate* isolate = isolate_;
1977 const GCType major_gc_type = kGCTypeMarkSweepCompact; 1979 const GCType major_gc_type = kGCTypeMarkSweepCompact;
1978 // Record objects that are joined into ObjectGroups. 1980 // Record objects that are joined into ObjectGroups.
1979 isolate->heap()->CallGCPrologueCallbacks( 1981 isolate->heap()->CallGCPrologueCallbacks(
1980 major_gc_type, kGCCallbackFlagConstructRetainedObjectInfos); 1982 major_gc_type, kGCCallbackFlagConstructRetainedObjectInfos);
1981 List<ObjectGroup*>* groups = isolate->global_handles()->object_groups(); 1983 List<ObjectGroup*>* groups = isolate->global_handles()->object_groups();
1982 for (int i = 0; i < groups->length(); ++i) { 1984 for (int i = 0; i < groups->length(); ++i) {
1983 ObjectGroup* group = groups->at(i); 1985 ObjectGroup* group = groups->at(i);
1984 if (group->info == NULL) continue; 1986 if (group->info == NULL) continue;
1985 List<HeapObject*>* list = GetListMaybeDisposeInfo(group->info); 1987 List<HeapObject*>* list = GetListMaybeDisposeInfo(group->info);
1986 for (size_t j = 0; j < group->length; ++j) { 1988 for (size_t j = 0; j < group->length; ++j) {
1987 HeapObject* obj = HeapObject::cast(*group->objects[j]); 1989 HeapObject* obj = HeapObject::cast(*group->objects[j]);
1988 list->Add(obj); 1990 list->Add(obj);
1989 in_groups_.Insert(obj); 1991 in_groups_.Insert(obj);
1990 } 1992 }
1991 group->info = NULL; // Acquire info object ownership. 1993 group->info = NULL; // Acquire info object ownership.
1992 } 1994 }
1993 isolate->global_handles()->RemoveObjectGroups(); 1995 isolate->global_handles()->RemoveObjectGroups();
1994 isolate->heap()->CallGCEpilogueCallbacks(major_gc_type); 1996 isolate->heap()->CallGCEpilogueCallbacks(major_gc_type);
1995 // Record objects that are not in ObjectGroups, but have class ID. 1997 // Record objects that are not in ObjectGroups, but have class ID.
1996 GlobalHandlesExtractor extractor(this); 1998 GlobalHandlesExtractor extractor(this);
1997 isolate->global_handles()->IterateAllRootsWithClassIds(&extractor); 1999 isolate->global_handles()->IterateAllRootsWithClassIds(&extractor);
1998 embedder_queried_ = true; 2000 embedder_queried_ = true;
1999 } 2001 }
2000 2002
2001 2003
2002 void NativeObjectsExplorer::FillImplicitReferences() { 2004 void NativeObjectsExplorer::FillImplicitReferences() {
2003 Isolate* isolate = Isolate::Current(); 2005 Isolate* isolate = isolate_;
2004 List<ImplicitRefGroup*>* groups = 2006 List<ImplicitRefGroup*>* groups =
2005 isolate->global_handles()->implicit_ref_groups(); 2007 isolate->global_handles()->implicit_ref_groups();
2006 for (int i = 0; i < groups->length(); ++i) { 2008 for (int i = 0; i < groups->length(); ++i) {
2007 ImplicitRefGroup* group = groups->at(i); 2009 ImplicitRefGroup* group = groups->at(i);
2008 HeapObject* parent = *group->parent; 2010 HeapObject* parent = *group->parent;
2009 int parent_entry = 2011 int parent_entry =
2010 filler_->FindOrAddEntry(parent, native_entries_allocator_)->index(); 2012 filler_->FindOrAddEntry(parent, native_entries_allocator_)->index();
2011 ASSERT(parent_entry != HeapEntry::kNoEntry); 2013 ASSERT(parent_entry != HeapEntry::kNoEntry);
2012 Object*** children = group->children; 2014 Object*** children = group->children;
2013 for (size_t j = 0; j < group->length; ++j) { 2015 for (size_t j = 0; j < group->length; ++j) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 filler_->SetIndexedAutoIndexReference( 2152 filler_->SetIndexedAutoIndexReference(
2151 HeapGraphEdge::kElement, 2153 HeapGraphEdge::kElement,
2152 snapshot_->root()->index(), 2154 snapshot_->root()->index(),
2153 group_entry); 2155 group_entry);
2154 } 2156 }
2155 } 2157 }
2156 2158
2157 2159
2158 void NativeObjectsExplorer::VisitSubtreeWrapper(Object** p, uint16_t class_id) { 2160 void NativeObjectsExplorer::VisitSubtreeWrapper(Object** p, uint16_t class_id) {
2159 if (in_groups_.Contains(*p)) return; 2161 if (in_groups_.Contains(*p)) return;
2160 Isolate* isolate = Isolate::Current(); 2162 Isolate* isolate = isolate_;
2161 v8::RetainedObjectInfo* info = 2163 v8::RetainedObjectInfo* info =
2162 isolate->heap_profiler()->ExecuteWrapperClassCallback(class_id, p); 2164 isolate->heap_profiler()->ExecuteWrapperClassCallback(class_id, p);
2163 if (info == NULL) return; 2165 if (info == NULL) return;
2164 GetListMaybeDisposeInfo(info)->Add(HeapObject::cast(*p)); 2166 GetListMaybeDisposeInfo(info)->Add(HeapObject::cast(*p));
2165 } 2167 }
2166 2168
2167 2169
2168 class SnapshotFiller : public SnapshotFillerInterface { 2170 class SnapshotFiller : public SnapshotFillerInterface {
2169 public: 2171 public:
2170 explicit SnapshotFiller(HeapSnapshot* snapshot, HeapEntriesMap* entries) 2172 explicit SnapshotFiller(HeapSnapshot* snapshot, HeapEntriesMap* entries)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 } 2238 }
2237 2239
2238 2240
2239 bool HeapSnapshotGenerator::GenerateSnapshot() { 2241 bool HeapSnapshotGenerator::GenerateSnapshot() {
2240 v8_heap_explorer_.TagGlobalObjects(); 2242 v8_heap_explorer_.TagGlobalObjects();
2241 2243
2242 // TODO(1562) Profiler assumes that any object that is in the heap after 2244 // TODO(1562) Profiler assumes that any object that is in the heap after
2243 // full GC is reachable from the root when computing dominators. 2245 // full GC is reachable from the root when computing dominators.
2244 // This is not true for weakly reachable objects. 2246 // This is not true for weakly reachable objects.
2245 // As a temporary solution we call GC twice. 2247 // As a temporary solution we call GC twice.
2246 Isolate::Current()->heap()->CollectAllGarbage( 2248 heap_->CollectAllGarbage(
2247 Heap::kMakeHeapIterableMask, 2249 Heap::kMakeHeapIterableMask,
2248 "HeapSnapshotGenerator::GenerateSnapshot"); 2250 "HeapSnapshotGenerator::GenerateSnapshot");
2249 Isolate::Current()->heap()->CollectAllGarbage( 2251 heap_->CollectAllGarbage(
2250 Heap::kMakeHeapIterableMask, 2252 Heap::kMakeHeapIterableMask,
2251 "HeapSnapshotGenerator::GenerateSnapshot"); 2253 "HeapSnapshotGenerator::GenerateSnapshot");
2252 2254
2253 #ifdef VERIFY_HEAP 2255 #ifdef VERIFY_HEAP
2254 Heap* debug_heap = Isolate::Current()->heap(); 2256 Heap* debug_heap = heap_;
2255 CHECK(!debug_heap->old_data_space()->was_swept_conservatively()); 2257 CHECK(!debug_heap->old_data_space()->was_swept_conservatively());
2256 CHECK(!debug_heap->old_pointer_space()->was_swept_conservatively()); 2258 CHECK(!debug_heap->old_pointer_space()->was_swept_conservatively());
2257 CHECK(!debug_heap->code_space()->was_swept_conservatively()); 2259 CHECK(!debug_heap->code_space()->was_swept_conservatively());
2258 CHECK(!debug_heap->cell_space()->was_swept_conservatively()); 2260 CHECK(!debug_heap->cell_space()->was_swept_conservatively());
2259 CHECK(!debug_heap->property_cell_space()-> 2261 CHECK(!debug_heap->property_cell_space()->
2260 was_swept_conservatively()); 2262 was_swept_conservatively());
2261 CHECK(!debug_heap->map_space()->was_swept_conservatively()); 2263 CHECK(!debug_heap->map_space()->was_swept_conservatively());
2262 #endif 2264 #endif
2263 2265
2264 // The following code uses heap iterators, so we want the heap to be 2266 // The following code uses heap iterators, so we want the heap to be
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 2705
2704 2706
2705 void HeapSnapshotJSONSerializer::SortHashMap( 2707 void HeapSnapshotJSONSerializer::SortHashMap(
2706 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2708 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2707 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2709 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2708 sorted_entries->Add(p); 2710 sorted_entries->Add(p);
2709 sorted_entries->Sort(SortUsingEntryValue); 2711 sorted_entries->Sort(SortUsingEntryValue);
2710 } 2712 }
2711 2713
2712 } } // namespace v8::internal 2714 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698