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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 366 |
367 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, | 367 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, |
368 int type, | 368 int type, |
369 v8::ActivityControl* control) { | 369 v8::ActivityControl* control) { |
370 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); | 370 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); |
371 HeapSnapshot* result = | 371 HeapSnapshot* result = |
372 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); | 372 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); |
373 bool generation_completed = true; | 373 bool generation_completed = true; |
374 switch (s_type) { | 374 switch (s_type) { |
375 case HeapSnapshot::kFull: { | 375 case HeapSnapshot::kFull: { |
| 376 Heap::CollectAllGarbage(true); |
376 HeapSnapshotGenerator generator(result, control); | 377 HeapSnapshotGenerator generator(result, control); |
377 generation_completed = generator.GenerateSnapshot(); | 378 generation_completed = generator.GenerateSnapshot(); |
378 break; | 379 break; |
379 } | 380 } |
380 case HeapSnapshot::kAggregated: { | 381 case HeapSnapshot::kAggregated: { |
381 Heap::CollectAllGarbage(true); | 382 Heap::CollectAllGarbage(true); |
382 AggregatedHeapSnapshot agg_snapshot; | 383 AggregatedHeapSnapshot agg_snapshot; |
383 AggregatedHeapSnapshotGenerator generator(&agg_snapshot); | 384 AggregatedHeapSnapshotGenerator generator(&agg_snapshot); |
384 generator.GenerateSnapshot(); | 385 generator.GenerateSnapshot(); |
385 generator.FillHeapSnapshot(result); | 386 generator.FillHeapSnapshot(result); |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 | 802 |
802 void AggregatedHeapSnapshotGenerator::CollectStats(HeapObject* obj) { | 803 void AggregatedHeapSnapshotGenerator::CollectStats(HeapObject* obj) { |
803 InstanceType type = obj->map()->instance_type(); | 804 InstanceType type = obj->map()->instance_type(); |
804 ASSERT(0 <= type && type <= LAST_TYPE); | 805 ASSERT(0 <= type && type <= LAST_TYPE); |
805 agg_snapshot_->info()[type].increment_number(1); | 806 agg_snapshot_->info()[type].increment_number(1); |
806 agg_snapshot_->info()[type].increment_bytes(obj->Size()); | 807 agg_snapshot_->info()[type].increment_bytes(obj->Size()); |
807 } | 808 } |
808 | 809 |
809 | 810 |
810 void AggregatedHeapSnapshotGenerator::GenerateSnapshot() { | 811 void AggregatedHeapSnapshotGenerator::GenerateSnapshot() { |
811 HeapIterator iterator(HeapIterator::kFilterFreeListNodes); | 812 HeapIterator iterator(HeapIterator::kFilterUnreachable); |
812 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 813 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
813 CollectStats(obj); | 814 CollectStats(obj); |
814 agg_snapshot_->js_cons_profile()->CollectStats(obj); | 815 agg_snapshot_->js_cons_profile()->CollectStats(obj); |
815 agg_snapshot_->js_retainer_profile()->CollectStats(obj); | 816 agg_snapshot_->js_retainer_profile()->CollectStats(obj); |
816 } | 817 } |
817 CalculateStringsStats(); | 818 CalculateStringsStats(); |
818 agg_snapshot_->js_retainer_profile()->CoarseAndAggregate(); | 819 agg_snapshot_->js_retainer_profile()->CoarseAndAggregate(); |
819 } | 820 } |
820 | 821 |
821 | 822 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 GlobalHandles::MakeWeak(handle.location(), | 1110 GlobalHandles::MakeWeak(handle.location(), |
1110 static_cast<void*>(stack.start()), | 1111 static_cast<void*>(stack.start()), |
1111 StackWeakReferenceCallback); | 1112 StackWeakReferenceCallback); |
1112 } | 1113 } |
1113 | 1114 |
1114 | 1115 |
1115 #endif // ENABLE_LOGGING_AND_PROFILING | 1116 #endif // ENABLE_LOGGING_AND_PROFILING |
1116 | 1117 |
1117 | 1118 |
1118 } } // namespace v8::internal | 1119 } } // namespace v8::internal |
OLD | NEW |