| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #endif // ENABLE_LOGGING_AND_PROFILING | 49 #endif // ENABLE_LOGGING_AND_PROFILING |
| 50 | 50 |
| 51 // The HeapProfiler writes data to the log files, which can be postprocessed | 51 // The HeapProfiler writes data to the log files, which can be postprocessed |
| 52 // to generate .hp files for use by the GHC/Valgrind tool hp2ps. | 52 // to generate .hp files for use by the GHC/Valgrind tool hp2ps. |
| 53 class HeapProfiler { | 53 class HeapProfiler { |
| 54 public: | 54 public: |
| 55 static void Setup(); | 55 static void Setup(); |
| 56 static void TearDown(); | 56 static void TearDown(); |
| 57 | 57 |
| 58 #ifdef ENABLE_LOGGING_AND_PROFILING | 58 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 59 static HeapSnapshot* TakeSnapshot(const char* name, int type); | 59 static HeapSnapshot* TakeSnapshot(const char* name, |
| 60 static HeapSnapshot* TakeSnapshot(String* name, int type); | 60 int type, |
| 61 v8::ActivityControl* control); |
| 62 static HeapSnapshot* TakeSnapshot(String* name, |
| 63 int type, |
| 64 v8::ActivityControl* control); |
| 61 static int GetSnapshotsCount(); | 65 static int GetSnapshotsCount(); |
| 62 static HeapSnapshot* GetSnapshot(int index); | 66 static HeapSnapshot* GetSnapshot(int index); |
| 63 static HeapSnapshot* FindSnapshot(unsigned uid); | 67 static HeapSnapshot* FindSnapshot(unsigned uid); |
| 64 | 68 |
| 65 static void ObjectMoveEvent(Address from, Address to); | 69 static void ObjectMoveEvent(Address from, Address to); |
| 66 | 70 |
| 67 static INLINE(bool is_profiling()) { | 71 static INLINE(bool is_profiling()) { |
| 68 return singleton_ != NULL && singleton_->snapshots_->is_tracking_objects(); | 72 return singleton_ != NULL && singleton_->snapshots_->is_tracking_objects(); |
| 69 } | 73 } |
| 70 | 74 |
| 71 // Obsolete interface. | 75 // Obsolete interface. |
| 72 // Write a single heap sample to the log file. | 76 // Write a single heap sample to the log file. |
| 73 static void WriteSample(); | 77 static void WriteSample(); |
| 74 | 78 |
| 75 private: | 79 private: |
| 76 HeapProfiler(); | 80 HeapProfiler(); |
| 77 ~HeapProfiler(); | 81 ~HeapProfiler(); |
| 78 HeapSnapshot* TakeSnapshotImpl(const char* name, int type); | 82 HeapSnapshot* TakeSnapshotImpl(const char* name, |
| 79 HeapSnapshot* TakeSnapshotImpl(String* name, int type); | 83 int type, |
| 84 v8::ActivityControl* control); |
| 85 HeapSnapshot* TakeSnapshotImpl(String* name, |
| 86 int type, |
| 87 v8::ActivityControl* control); |
| 80 | 88 |
| 81 HeapSnapshotsCollection* snapshots_; | 89 HeapSnapshotsCollection* snapshots_; |
| 82 unsigned next_snapshot_uid_; | 90 unsigned next_snapshot_uid_; |
| 83 | 91 |
| 84 static HeapProfiler* singleton_; | 92 static HeapProfiler* singleton_; |
| 85 #endif // ENABLE_LOGGING_AND_PROFILING | 93 #endif // ENABLE_LOGGING_AND_PROFILING |
| 86 }; | 94 }; |
| 87 | 95 |
| 88 | 96 |
| 89 #ifdef ENABLE_LOGGING_AND_PROFILING | 97 #ifdef ENABLE_LOGGING_AND_PROFILING |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 private: | 370 private: |
| 363 static void DoRecordJSObjectAllocation(Object* obj); | 371 static void DoRecordJSObjectAllocation(Object* obj); |
| 364 static bool can_log_; | 372 static bool can_log_; |
| 365 }; | 373 }; |
| 366 | 374 |
| 367 #endif // ENABLE_LOGGING_AND_PROFILING | 375 #endif // ENABLE_LOGGING_AND_PROFILING |
| 368 | 376 |
| 369 } } // namespace v8::internal | 377 } } // namespace v8::internal |
| 370 | 378 |
| 371 #endif // V8_HEAP_PROFILER_H_ | 379 #endif // V8_HEAP_PROFILER_H_ |
| OLD | NEW |