| 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 370 |
| 371 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, | 371 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, |
| 372 int type, | 372 int type, |
| 373 v8::ActivityControl* control) { | 373 v8::ActivityControl* control) { |
| 374 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); | 374 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); |
| 375 HeapSnapshot* result = | 375 HeapSnapshot* result = |
| 376 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); | 376 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); |
| 377 bool generation_completed = true; | 377 bool generation_completed = true; |
| 378 switch (s_type) { | 378 switch (s_type) { |
| 379 case HeapSnapshot::kFull: { | 379 case HeapSnapshot::kFull: { |
| 380 HEAP->CollectAllGarbage(true); |
| 380 HeapSnapshotGenerator generator(result, control); | 381 HeapSnapshotGenerator generator(result, control); |
| 381 generation_completed = generator.GenerateSnapshot(); | 382 generation_completed = generator.GenerateSnapshot(); |
| 382 break; | 383 break; |
| 383 } | 384 } |
| 384 case HeapSnapshot::kAggregated: { | 385 case HeapSnapshot::kAggregated: { |
| 385 HEAP->CollectAllGarbage(true); | 386 HEAP->CollectAllGarbage(true); |
| 386 AggregatedHeapSnapshot agg_snapshot; | 387 AggregatedHeapSnapshot agg_snapshot; |
| 387 AggregatedHeapSnapshotGenerator generator(&agg_snapshot); | 388 AggregatedHeapSnapshotGenerator generator(&agg_snapshot); |
| 388 generator.GenerateSnapshot(); | 389 generator.GenerateSnapshot(); |
| 389 generator.FillHeapSnapshot(result); | 390 generator.FillHeapSnapshot(result); |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 | 809 |
| 809 void AggregatedHeapSnapshotGenerator::CollectStats(HeapObject* obj) { | 810 void AggregatedHeapSnapshotGenerator::CollectStats(HeapObject* obj) { |
| 810 InstanceType type = obj->map()->instance_type(); | 811 InstanceType type = obj->map()->instance_type(); |
| 811 ASSERT(0 <= type && type <= LAST_TYPE); | 812 ASSERT(0 <= type && type <= LAST_TYPE); |
| 812 agg_snapshot_->info()[type].increment_number(1); | 813 agg_snapshot_->info()[type].increment_number(1); |
| 813 agg_snapshot_->info()[type].increment_bytes(obj->Size()); | 814 agg_snapshot_->info()[type].increment_bytes(obj->Size()); |
| 814 } | 815 } |
| 815 | 816 |
| 816 | 817 |
| 817 void AggregatedHeapSnapshotGenerator::GenerateSnapshot() { | 818 void AggregatedHeapSnapshotGenerator::GenerateSnapshot() { |
| 818 HeapIterator iterator(HeapIterator::kFilterFreeListNodes); | 819 HeapIterator iterator(HeapIterator::kFilterUnreachable); |
| 819 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 820 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
| 820 CollectStats(obj); | 821 CollectStats(obj); |
| 821 agg_snapshot_->js_cons_profile()->CollectStats(obj); | 822 agg_snapshot_->js_cons_profile()->CollectStats(obj); |
| 822 agg_snapshot_->js_retainer_profile()->CollectStats(obj); | 823 agg_snapshot_->js_retainer_profile()->CollectStats(obj); |
| 823 } | 824 } |
| 824 CalculateStringsStats(); | 825 CalculateStringsStats(); |
| 825 agg_snapshot_->js_retainer_profile()->CoarseAndAggregate(); | 826 agg_snapshot_->js_retainer_profile()->CoarseAndAggregate(); |
| 826 } | 827 } |
| 827 | 828 |
| 828 | 829 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 isolate_->global_handles()->MakeWeak(handle.location(), | 1115 isolate_->global_handles()->MakeWeak(handle.location(), |
| 1115 static_cast<void*>(stack.start()), | 1116 static_cast<void*>(stack.start()), |
| 1116 StackWeakReferenceCallback); | 1117 StackWeakReferenceCallback); |
| 1117 } | 1118 } |
| 1118 | 1119 |
| 1119 | 1120 |
| 1120 #endif // ENABLE_LOGGING_AND_PROFILING | 1121 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1121 | 1122 |
| 1122 | 1123 |
| 1123 } } // namespace v8::internal | 1124 } } // namespace v8::internal |
| OLD | NEW |