Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/heap-profiler.h

Issue 2822009: Heap profiler: publish API and add test. (Closed)
Patch Set: comments addressed Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/api.cc ('k') | src/heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_HEAP_PROFILER_H_ 28 #ifndef V8_HEAP_PROFILER_H_
29 #define V8_HEAP_PROFILER_H_ 29 #define V8_HEAP_PROFILER_H_
30 30
31 #include "zone.h" 31 #include "zone-inl.h"
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 #ifdef ENABLE_LOGGING_AND_PROFILING 36 #ifdef ENABLE_LOGGING_AND_PROFILING
37 37
38 class HeapSnapshot;
39 class HeapSnapshotsCollection;
40
38 // The HeapProfiler writes data to the log files, which can be postprocessed 41 // The HeapProfiler writes data to the log files, which can be postprocessed
39 // to generate .hp files for use by the GHC/Valgrind tool hp2ps. 42 // to generate .hp files for use by the GHC/Valgrind tool hp2ps.
40 class HeapProfiler { 43 class HeapProfiler {
41 public: 44 public:
45 static void Setup();
46 static void TearDown();
47 static HeapSnapshot* TakeSnapshot(const char* name);
48 static HeapSnapshot* TakeSnapshot(String* name);
49 static int GetSnapshotsCount();
50 static HeapSnapshot* GetSnapshot(int index);
51 static HeapSnapshot* FindSnapshot(unsigned uid);
52
53 // Obsolete interface.
42 // Write a single heap sample to the log file. 54 // Write a single heap sample to the log file.
43 static void WriteSample(); 55 static void WriteSample();
44 56
45 private: 57 private:
58 HeapProfiler();
59 ~HeapProfiler();
60 HeapSnapshot* TakeSnapshotImpl(const char* name);
61 HeapSnapshot* TakeSnapshotImpl(String* name);
62
63 // Obsolete interface.
46 // Update the array info with stats from obj. 64 // Update the array info with stats from obj.
47 static void CollectStats(HeapObject* obj, HistogramInfo* info); 65 static void CollectStats(HeapObject* obj, HistogramInfo* info);
66
67 HeapSnapshotsCollection* snapshots_;
68 unsigned next_snapshot_uid_;
69
70 static HeapProfiler* singleton_;
48 }; 71 };
49 72
50 73
51 // JSObjectsCluster describes a group of JS objects that are 74 // JSObjectsCluster describes a group of JS objects that are
52 // considered equivalent in terms of a particular profile. 75 // considered equivalent in terms of a particular profile.
53 class JSObjectsCluster BASE_EMBEDDED { 76 class JSObjectsCluster BASE_EMBEDDED {
54 public: 77 public:
55 // These special cases are used in retainer profile. 78 // These special cases are used in retainer profile.
56 enum SpecialCase { 79 enum SpecialCase {
57 ROOTS = 1, 80 ROOTS = 1,
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 private: 293 private:
271 static void DoRecordJSObjectAllocation(Object* obj); 294 static void DoRecordJSObjectAllocation(Object* obj);
272 static bool can_log_; 295 static bool can_log_;
273 }; 296 };
274 297
275 #endif // ENABLE_LOGGING_AND_PROFILING 298 #endif // ENABLE_LOGGING_AND_PROFILING
276 299
277 } } // namespace v8::internal 300 } } // namespace v8::internal
278 301
279 #endif // V8_HEAP_PROFILER_H_ 302 #endif // V8_HEAP_PROFILER_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698