OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2211 HeapEntry* child_entry = GetEntry(child_obj); | 2211 HeapEntry* child_entry = GetEntry(child_obj); |
2212 if (child_entry != NULL) { | 2212 if (child_entry != NULL) { |
2213 filler_->SetStrongRootReference(child_obj, child_entry); | 2213 filler_->SetStrongRootReference(child_obj, child_entry); |
2214 } | 2214 } |
2215 } | 2215 } |
2216 | 2216 |
2217 | 2217 |
2218 void HeapSnapshotGenerator::SetProgressTotal(int iterations_count) { | 2218 void HeapSnapshotGenerator::SetProgressTotal(int iterations_count) { |
2219 if (control_ == NULL) return; | 2219 if (control_ == NULL) return; |
2220 | 2220 |
2221 HeapIterator iterator(HeapIterator::kPreciseFiltering); | 2221 HeapIterator iterator(HeapIterator::kFilterUnreachable); |
2222 int objects_count = 0; | 2222 int objects_count = 0; |
2223 for (HeapObject* obj = iterator.next(); | 2223 for (HeapObject* obj = iterator.next(); |
2224 obj != NULL; | 2224 obj != NULL; |
2225 obj = iterator.next(), ++objects_count) {} | 2225 obj = iterator.next(), ++objects_count) {} |
2226 progress_total_ = objects_count * iterations_count; | 2226 progress_total_ = objects_count * iterations_count; |
2227 progress_counter_ = 0; | 2227 progress_counter_ = 0; |
2228 } | 2228 } |
2229 | 2229 |
2230 | 2230 |
2231 bool HeapSnapshotGenerator::CountEntriesAndReferences() { | 2231 bool HeapSnapshotGenerator::CountEntriesAndReferences() { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 bool HeapSnapshotGenerator::SetEntriesDominators() { | 2335 bool HeapSnapshotGenerator::SetEntriesDominators() { |
2336 // This array is used for maintaining reverse postorder of nodes. | 2336 // This array is used for maintaining reverse postorder of nodes. |
2337 ScopedVector<HeapEntry*> ordered_entries(snapshot_->entries()->length()); | 2337 ScopedVector<HeapEntry*> ordered_entries(snapshot_->entries()->length()); |
2338 FillReversePostorderIndexes(&ordered_entries); | 2338 FillReversePostorderIndexes(&ordered_entries); |
2339 ScopedVector<HeapEntry*> dominators(ordered_entries.length()); | 2339 ScopedVector<HeapEntry*> dominators(ordered_entries.length()); |
2340 if (!BuildDominatorTree(ordered_entries, &dominators)) return false; | 2340 if (!BuildDominatorTree(ordered_entries, &dominators)) return false; |
2341 for (int i = 0; i < ordered_entries.length(); ++i) { | 2341 for (int i = 0; i < ordered_entries.length(); ++i) { |
2342 ASSERT(dominators[i] != NULL); | 2342 ASSERT(dominators[i] != NULL); |
2343 ordered_entries[i]->set_dominator(dominators[i]); | 2343 ordered_entries[i]->set_dominator(dominators[i]); |
2344 } | 2344 } |
2345 // For nodes unreachable from root, set dominator to itself. | |
2346 snapshot_->SetDominatorsToSelf(); | |
2347 return true; | 2345 return true; |
2348 } | 2346 } |
2349 | 2347 |
2350 | 2348 |
2351 bool HeapSnapshotGenerator::ApproximateRetainedSizes() { | 2349 bool HeapSnapshotGenerator::ApproximateRetainedSizes() { |
2352 // As for the dominators tree we only know parent nodes, not | 2350 // As for the dominators tree we only know parent nodes, not |
2353 // children, to sum up total sizes we "bubble" node's self size | 2351 // children, to sum up total sizes we "bubble" node's self size |
2354 // adding it to all of its parents. | 2352 // adding it to all of its parents. |
2355 for (int i = 0; i < snapshot_->entries()->length(); ++i) { | 2353 for (int i = 0; i < snapshot_->entries()->length(); ++i) { |
2356 HeapEntry* entry = snapshot_->entries()->at(i); | 2354 HeapEntry* entry = snapshot_->entries()->at(i); |
2357 entry->set_retained_size(entry->self_size()); | 2355 entry->set_retained_size(entry->self_size()); |
2358 } | 2356 } |
2359 for (int i = 0; | 2357 for (int i = 0; |
2360 i < snapshot_->entries()->length(); | 2358 i < snapshot_->entries()->length(); |
2361 ++i, IncProgressCounter()) { | 2359 ++i, IncProgressCounter()) { |
2362 HeapEntry* entry = snapshot_->entries()->at(i); | 2360 HeapEntry* entry = snapshot_->entries()->at(i); |
2363 int entry_size = entry->self_size(); | 2361 int entry_size = entry->self_size(); |
2364 for (HeapEntry* dominator = entry->dominator(); | 2362 for (HeapEntry* dominator = entry->dominator(); |
2365 dominator != entry; | 2363 dominator != entry; |
2366 entry = dominator, dominator = entry->dominator()) { | 2364 entry = dominator, dominator = entry->dominator()) { |
2367 dominator->add_retained_size(entry_size); | 2365 dominator->add_retained_size(entry_size); |
2368 } | 2366 } |
2369 if (!ReportProgress()) return false; | 2367 if (!ReportProgress()) return false; |
2370 } | 2368 } |
2371 return true; | 2369 return true; |
2372 } | 2370 } |
2373 | 2371 |
2374 | 2372 |
2375 bool HeapSnapshotGenerator::IterateAndExtractReferences() { | 2373 bool HeapSnapshotGenerator::IterateAndExtractReferences() { |
2376 HeapIterator iterator(HeapIterator::kPreciseFiltering); | 2374 HeapIterator iterator(HeapIterator::kFilterUnreachable); |
2377 bool interrupted = false; | 2375 bool interrupted = false; |
2378 // Heap iteration with precise filtering must be finished in any case. | 2376 // Heap iteration with filtering must be finished in any case. |
2379 for (HeapObject* obj = iterator.next(); | 2377 for (HeapObject* obj = iterator.next(); |
2380 obj != NULL; | 2378 obj != NULL; |
2381 obj = iterator.next(), IncProgressCounter()) { | 2379 obj = iterator.next(), IncProgressCounter()) { |
2382 if (!interrupted) { | 2380 if (!interrupted) { |
2383 ExtractReferences(obj); | 2381 ExtractReferences(obj); |
2384 if (!ReportProgress()) interrupted = true; | 2382 if (!ReportProgress()) interrupted = true; |
2385 } | 2383 } |
2386 } | 2384 } |
2387 if (interrupted) return false; | 2385 if (interrupted) return false; |
2388 SetRootGcRootsReference(); | 2386 SetRootGcRootsReference(); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2835 | 2833 |
2836 | 2834 |
2837 String* GetConstructorNameForHeapProfile(JSObject* object) { | 2835 String* GetConstructorNameForHeapProfile(JSObject* object) { |
2838 if (object->IsJSFunction()) return Heap::closure_symbol(); | 2836 if (object->IsJSFunction()) return Heap::closure_symbol(); |
2839 return object->constructor_name(); | 2837 return object->constructor_name(); |
2840 } | 2838 } |
2841 | 2839 |
2842 } } // namespace v8::internal | 2840 } } // namespace v8::internal |
2843 | 2841 |
2844 #endif // ENABLE_LOGGING_AND_PROFILING | 2842 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |