| OLD | NEW |
| 1 // Copyright 2009-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2009-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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 387 |
| 388 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, | 388 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, |
| 389 int type, | 389 int type, |
| 390 v8::ActivityControl* control) { | 390 v8::ActivityControl* control) { |
| 391 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); | 391 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); |
| 392 HeapSnapshot* result = | 392 HeapSnapshot* result = |
| 393 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); | 393 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); |
| 394 bool generation_completed = true; | 394 bool generation_completed = true; |
| 395 switch (s_type) { | 395 switch (s_type) { |
| 396 case HeapSnapshot::kFull: { | 396 case HeapSnapshot::kFull: { |
| 397 Heap::CollectAllGarbage(true); | 397 Heap::CollectAllGarbage(Heap::kMakeHeapIterableMask); |
| 398 HeapSnapshotGenerator generator(result, control); | 398 HeapSnapshotGenerator generator(result, control); |
| 399 generation_completed = generator.GenerateSnapshot(); | 399 generation_completed = generator.GenerateSnapshot(); |
| 400 break; | 400 break; |
| 401 } | 401 } |
| 402 case HeapSnapshot::kAggregated: { | 402 case HeapSnapshot::kAggregated: { |
| 403 Heap::CollectAllGarbage(true); | 403 Heap::CollectAllGarbage(Heap::kMakeHeapIterableMask); |
| 404 AggregatedHeapSnapshot agg_snapshot; | 404 AggregatedHeapSnapshot agg_snapshot; |
| 405 AggregatedHeapSnapshotGenerator generator(&agg_snapshot); | 405 AggregatedHeapSnapshotGenerator generator(&agg_snapshot); |
| 406 generator.GenerateSnapshot(); | 406 generator.GenerateSnapshot(); |
| 407 generator.FillHeapSnapshot(result); | 407 generator.FillHeapSnapshot(result); |
| 408 break; | 408 break; |
| 409 } | 409 } |
| 410 default: | 410 default: |
| 411 UNREACHABLE(); | 411 UNREACHABLE(); |
| 412 } | 412 } |
| 413 if (!generation_completed) { | 413 if (!generation_completed) { |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 | 823 |
| 824 void AggregatedHeapSnapshotGenerator::CollectStats(HeapObject* obj) { | 824 void AggregatedHeapSnapshotGenerator::CollectStats(HeapObject* obj) { |
| 825 InstanceType type = obj->map()->instance_type(); | 825 InstanceType type = obj->map()->instance_type(); |
| 826 ASSERT(0 <= type && type <= LAST_TYPE); | 826 ASSERT(0 <= type && type <= LAST_TYPE); |
| 827 agg_snapshot_->info()[type].increment_number(1); | 827 agg_snapshot_->info()[type].increment_number(1); |
| 828 agg_snapshot_->info()[type].increment_bytes(obj->Size()); | 828 agg_snapshot_->info()[type].increment_bytes(obj->Size()); |
| 829 } | 829 } |
| 830 | 830 |
| 831 | 831 |
| 832 void AggregatedHeapSnapshotGenerator::GenerateSnapshot() { | 832 void AggregatedHeapSnapshotGenerator::GenerateSnapshot() { |
| 833 HeapIterator iterator(HeapIterator::kFilterUnreachable); | 833 HeapIterator iterator; |
| 834 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 834 for (HeapObject* obj = iterator.Next(); obj != NULL; obj = iterator.Next()) { |
| 835 CollectStats(obj); | 835 CollectStats(obj); |
| 836 agg_snapshot_->js_cons_profile()->CollectStats(obj); | 836 agg_snapshot_->js_cons_profile()->CollectStats(obj); |
| 837 agg_snapshot_->js_retainer_profile()->CollectStats(obj); | 837 agg_snapshot_->js_retainer_profile()->CollectStats(obj); |
| 838 } | 838 } |
| 839 CalculateStringsStats(); | 839 CalculateStringsStats(); |
| 840 agg_snapshot_->js_retainer_profile()->CoarseAndAggregate(); | 840 agg_snapshot_->js_retainer_profile()->CoarseAndAggregate(); |
| 841 } | 841 } |
| 842 | 842 |
| 843 | 843 |
| 844 class CountingConstructorHeapProfileIterator { | 844 class CountingConstructorHeapProfileIterator { |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 GlobalHandles::MakeWeak(handle.location(), | 1142 GlobalHandles::MakeWeak(handle.location(), |
| 1143 static_cast<void*>(stack.start()), | 1143 static_cast<void*>(stack.start()), |
| 1144 StackWeakReferenceCallback); | 1144 StackWeakReferenceCallback); |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 | 1147 |
| 1148 #endif // ENABLE_LOGGING_AND_PROFILING | 1148 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1149 | 1149 |
| 1150 | 1150 |
| 1151 } } // namespace v8::internal | 1151 } } // namespace v8::internal |
| OLD | NEW |