| 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, |   59   static HeapSnapshot* TakeSnapshot(const char* name, int type); | 
|   60                                     int type, |   60   static HeapSnapshot* TakeSnapshot(String* name, int type); | 
|   61                                     v8::ActivityControl* control); |  | 
|   62   static HeapSnapshot* TakeSnapshot(String* name, |  | 
|   63                                     int type, |  | 
|   64                                     v8::ActivityControl* control); |  | 
|   65   static int GetSnapshotsCount(); |   61   static int GetSnapshotsCount(); | 
|   66   static HeapSnapshot* GetSnapshot(int index); |   62   static HeapSnapshot* GetSnapshot(int index); | 
|   67   static HeapSnapshot* FindSnapshot(unsigned uid); |   63   static HeapSnapshot* FindSnapshot(unsigned uid); | 
|   68  |   64  | 
|   69   static void ObjectMoveEvent(Address from, Address to); |   65   static void ObjectMoveEvent(Address from, Address to); | 
|   70  |   66  | 
|   71   static INLINE(bool is_profiling()) { |   67   static INLINE(bool is_profiling()) { | 
|   72     return singleton_ != NULL && singleton_->snapshots_->is_tracking_objects(); |   68     return singleton_ != NULL && singleton_->snapshots_->is_tracking_objects(); | 
|   73   } |   69   } | 
|   74  |   70  | 
|   75   // Obsolete interface. |   71   // Obsolete interface. | 
|   76   // Write a single heap sample to the log file. |   72   // Write a single heap sample to the log file. | 
|   77   static void WriteSample(); |   73   static void WriteSample(); | 
|   78  |   74  | 
|   79  private: |   75  private: | 
|   80   HeapProfiler(); |   76   HeapProfiler(); | 
|   81   ~HeapProfiler(); |   77   ~HeapProfiler(); | 
|   82   HeapSnapshot* TakeSnapshotImpl(const char* name, |   78   HeapSnapshot* TakeSnapshotImpl(const char* name, int type); | 
|   83                                  int type, |   79   HeapSnapshot* TakeSnapshotImpl(String* name, int type); | 
|   84                                  v8::ActivityControl* control); |  | 
|   85   HeapSnapshot* TakeSnapshotImpl(String* name, |  | 
|   86                                  int type, |  | 
|   87                                  v8::ActivityControl* control); |  | 
|   88  |   80  | 
|   89   HeapSnapshotsCollection* snapshots_; |   81   HeapSnapshotsCollection* snapshots_; | 
|   90   unsigned next_snapshot_uid_; |   82   unsigned next_snapshot_uid_; | 
|   91  |   83  | 
|   92   static HeapProfiler* singleton_; |   84   static HeapProfiler* singleton_; | 
|   93 #endif  // ENABLE_LOGGING_AND_PROFILING |   85 #endif  // ENABLE_LOGGING_AND_PROFILING | 
|   94 }; |   86 }; | 
|   95  |   87  | 
|   96  |   88  | 
|   97 #ifdef ENABLE_LOGGING_AND_PROFILING |   89 #ifdef ENABLE_LOGGING_AND_PROFILING | 
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  370  private: |  362  private: | 
|  371   static void DoRecordJSObjectAllocation(Object* obj); |  363   static void DoRecordJSObjectAllocation(Object* obj); | 
|  372   static bool can_log_; |  364   static bool can_log_; | 
|  373 }; |  365 }; | 
|  374  |  366  | 
|  375 #endif  // ENABLE_LOGGING_AND_PROFILING |  367 #endif  // ENABLE_LOGGING_AND_PROFILING | 
|  376  |  368  | 
|  377 } }  // namespace v8::internal |  369 } }  // namespace v8::internal | 
|  378  |  370  | 
|  379 #endif  // V8_HEAP_PROFILER_H_ |  371 #endif  // V8_HEAP_PROFILER_H_ | 
| OLD | NEW |