| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 v8::ActivityControl* control); | 61 v8::ActivityControl* control); |
| 62 static HeapSnapshot* TakeSnapshot(String* name, | 62 static HeapSnapshot* TakeSnapshot(String* name, |
| 63 int type, | 63 int type, |
| 64 v8::ActivityControl* control); | 64 v8::ActivityControl* control); |
| 65 static int GetSnapshotsCount(); | 65 static int GetSnapshotsCount(); |
| 66 static HeapSnapshot* GetSnapshot(int index); | 66 static HeapSnapshot* GetSnapshot(int index); |
| 67 static HeapSnapshot* FindSnapshot(unsigned uid); | 67 static HeapSnapshot* FindSnapshot(unsigned uid); |
| 68 | 68 |
| 69 static void ObjectMoveEvent(Address from, Address to); | 69 static void ObjectMoveEvent(Address from, Address to); |
| 70 | 70 |
| 71 static void DefineWrapperClass( |
| 72 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback); |
| 73 static v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id, |
| 74 Object** wrapper); |
| 75 |
| 71 static INLINE(bool is_profiling()) { | 76 static INLINE(bool is_profiling()) { |
| 72 return singleton_ != NULL && singleton_->snapshots_->is_tracking_objects(); | 77 return singleton_ != NULL && singleton_->snapshots_->is_tracking_objects(); |
| 73 } | 78 } |
| 74 | 79 |
| 75 // Obsolete interface. | 80 // Obsolete interface. |
| 76 // Write a single heap sample to the log file. | 81 // Write a single heap sample to the log file. |
| 77 static void WriteSample(); | 82 static void WriteSample(); |
| 78 | 83 |
| 79 private: | 84 private: |
| 80 HeapProfiler(); | 85 HeapProfiler(); |
| 81 ~HeapProfiler(); | 86 ~HeapProfiler(); |
| 82 HeapSnapshot* TakeSnapshotImpl(const char* name, | 87 HeapSnapshot* TakeSnapshotImpl(const char* name, |
| 83 int type, | 88 int type, |
| 84 v8::ActivityControl* control); | 89 v8::ActivityControl* control); |
| 85 HeapSnapshot* TakeSnapshotImpl(String* name, | 90 HeapSnapshot* TakeSnapshotImpl(String* name, |
| 86 int type, | 91 int type, |
| 87 v8::ActivityControl* control); | 92 v8::ActivityControl* control); |
| 88 | 93 |
| 89 HeapSnapshotsCollection* snapshots_; | 94 HeapSnapshotsCollection* snapshots_; |
| 90 unsigned next_snapshot_uid_; | 95 unsigned next_snapshot_uid_; |
| 96 List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_; |
| 91 | 97 |
| 92 static HeapProfiler* singleton_; | 98 static HeapProfiler* singleton_; |
| 93 #endif // ENABLE_LOGGING_AND_PROFILING | 99 #endif // ENABLE_LOGGING_AND_PROFILING |
| 94 }; | 100 }; |
| 95 | 101 |
| 96 | 102 |
| 97 #ifdef ENABLE_LOGGING_AND_PROFILING | 103 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 98 | 104 |
| 99 // JSObjectsCluster describes a group of JS objects that are | 105 // JSObjectsCluster describes a group of JS objects that are |
| 100 // considered equivalent in terms of a particular profile. | 106 // considered equivalent in terms of a particular profile. |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 RetainerHeapProfile* js_retainer_profile() { return &js_retainer_profile_; } | 339 RetainerHeapProfile* js_retainer_profile() { return &js_retainer_profile_; } |
| 334 | 340 |
| 335 private: | 341 private: |
| 336 HistogramInfo* info_; | 342 HistogramInfo* info_; |
| 337 ConstructorHeapProfile js_cons_profile_; | 343 ConstructorHeapProfile js_cons_profile_; |
| 338 RetainerHeapProfile js_retainer_profile_; | 344 RetainerHeapProfile js_retainer_profile_; |
| 339 }; | 345 }; |
| 340 | 346 |
| 341 | 347 |
| 342 class HeapEntriesMap; | 348 class HeapEntriesMap; |
| 349 class HeapEntriesAllocator; |
| 343 class HeapSnapshot; | 350 class HeapSnapshot; |
| 344 | 351 |
| 345 class AggregatedHeapSnapshotGenerator { | 352 class AggregatedHeapSnapshotGenerator { |
| 346 public: | 353 public: |
| 347 explicit AggregatedHeapSnapshotGenerator(AggregatedHeapSnapshot* snapshot); | 354 explicit AggregatedHeapSnapshotGenerator(AggregatedHeapSnapshot* snapshot); |
| 348 void GenerateSnapshot(); | 355 void GenerateSnapshot(); |
| 349 void FillHeapSnapshot(HeapSnapshot* snapshot); | 356 void FillHeapSnapshot(HeapSnapshot* snapshot); |
| 350 | 357 |
| 351 static const int kAllStringsType = LAST_TYPE + 1; | 358 static const int kAllStringsType = LAST_TYPE + 1; |
| 352 | 359 |
| 353 private: | 360 private: |
| 354 void CalculateStringsStats(); | 361 void CalculateStringsStats(); |
| 355 void CollectStats(HeapObject* obj); | 362 void CollectStats(HeapObject* obj); |
| 356 template<class Iterator> | 363 template<class Iterator> |
| 357 void IterateRetainers(HeapEntriesMap* entries_map); | 364 void IterateRetainers( |
| 365 HeapEntriesAllocator* allocator, HeapEntriesMap* entries_map); |
| 358 | 366 |
| 359 AggregatedHeapSnapshot* agg_snapshot_; | 367 AggregatedHeapSnapshot* agg_snapshot_; |
| 360 }; | 368 }; |
| 361 | 369 |
| 362 | 370 |
| 363 class ProducerHeapProfile : public AllStatic { | 371 class ProducerHeapProfile : public AllStatic { |
| 364 public: | 372 public: |
| 365 static void Setup(); | 373 static void Setup(); |
| 366 static void RecordJSObjectAllocation(Object* obj) { | 374 static void RecordJSObjectAllocation(Object* obj) { |
| 367 if (FLAG_log_producers) DoRecordJSObjectAllocation(obj); | 375 if (FLAG_log_producers) DoRecordJSObjectAllocation(obj); |
| 368 } | 376 } |
| 369 | 377 |
| 370 private: | 378 private: |
| 371 static void DoRecordJSObjectAllocation(Object* obj); | 379 static void DoRecordJSObjectAllocation(Object* obj); |
| 372 static bool can_log_; | 380 static bool can_log_; |
| 373 }; | 381 }; |
| 374 | 382 |
| 375 #endif // ENABLE_LOGGING_AND_PROFILING | 383 #endif // ENABLE_LOGGING_AND_PROFILING |
| 376 | 384 |
| 377 } } // namespace v8::internal | 385 } } // namespace v8::internal |
| 378 | 386 |
| 379 #endif // V8_HEAP_PROFILER_H_ | 387 #endif // V8_HEAP_PROFILER_H_ |
| OLD | NEW |