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