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

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

Issue 3301008: [Isolates] Add heap pointer to all maps and use map->heap() more. (Closed)
Patch Set: even more Created 10 years, 3 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
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 21 matching lines...) Expand all
32 #include "zone-inl.h" 32 #include "zone-inl.h"
33 33
34 namespace v8 { 34 namespace v8 {
35 namespace internal { 35 namespace internal {
36 36
37 #ifdef ENABLE_LOGGING_AND_PROFILING 37 #ifdef ENABLE_LOGGING_AND_PROFILING
38 38
39 class HeapSnapshot; 39 class HeapSnapshot;
40 class HeapSnapshotsCollection; 40 class HeapSnapshotsCollection;
41 41
42 #define HEAP_PROFILE(Call) \ 42 #define HEAP_PROFILE(heap, call) \
43 do { \ 43 do { \
44 if (v8::internal::HeapProfiler::is_profiling()) { \ 44 v8::internal::HeapProfiler* profiler = heap->isolate()->heap_profiler(); \
45 v8::internal::HeapProfiler::Call; \ 45 if (profiler && profiler->is_profiling()) { \
Vitaly Repeshko 2010/09/10 12:35:25 nit: Use explicit != NULL comparison.
46 } \ 46 profiler->call; \
47 } \
47 } while (false) 48 } while (false)
48 #else 49 #else
49 #define HEAP_PROFILE(Call) ((void) 0) 50 #define HEAP_PROFILE(heap, call) ((void) 0)
50 #endif // ENABLE_LOGGING_AND_PROFILING 51 #endif // ENABLE_LOGGING_AND_PROFILING
51 52
52 // The HeapProfiler writes data to the log files, which can be postprocessed 53 // The HeapProfiler writes data to the log files, which can be postprocessed
53 // to generate .hp files for use by the GHC/Valgrind tool hp2ps. 54 // to generate .hp files for use by the GHC/Valgrind tool hp2ps.
54 class HeapProfiler { 55 class HeapProfiler {
55 public: 56 public:
56 static void Setup(); 57 static void Setup();
57 static void TearDown(); 58 static void TearDown();
58 59
59 #ifdef ENABLE_LOGGING_AND_PROFILING 60 #ifdef ENABLE_LOGGING_AND_PROFILING
60 static HeapSnapshot* TakeSnapshot(const char* name, int type); 61 static HeapSnapshot* TakeSnapshot(const char* name, int type);
61 static HeapSnapshot* TakeSnapshot(String* name, int type); 62 static HeapSnapshot* TakeSnapshot(String* name, int type);
62 static int GetSnapshotsCount(); 63 static int GetSnapshotsCount();
63 static HeapSnapshot* GetSnapshot(int index); 64 static HeapSnapshot* GetSnapshot(int index);
64 static HeapSnapshot* FindSnapshot(unsigned uid); 65 static HeapSnapshot* FindSnapshot(unsigned uid);
65 66
66 static void ObjectMoveEvent(Address from, Address to); 67 void ObjectMoveEvent(Address from, Address to);
67 68
68 static INLINE(bool is_profiling()) { 69 INLINE(bool is_profiling()) {
69 HeapProfiler* profiler = Isolate::Current()->heap_profiler(); 70 return snapshots_->is_tracking_objects();
70 return profiler != NULL && profiler->snapshots_->is_tracking_objects();
71 } 71 }
72 72
73 // Obsolete interface. 73 // Obsolete interface.
74 // Write a single heap sample to the log file. 74 // Write a single heap sample to the log file.
75 static void WriteSample(); 75 static void WriteSample();
76 76
77 private: 77 private:
78 HeapProfiler(); 78 HeapProfiler();
79 ~HeapProfiler(); 79 ~HeapProfiler();
80 HeapSnapshot* TakeSnapshotImpl(const char* name, int type); 80 HeapSnapshot* TakeSnapshotImpl(const char* name, int type);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 friend class Isolate; 370 friend class Isolate;
371 371
372 DISALLOW_COPY_AND_ASSIGN(ProducerHeapProfile); 372 DISALLOW_COPY_AND_ASSIGN(ProducerHeapProfile);
373 }; 373 };
374 374
375 #endif // ENABLE_LOGGING_AND_PROFILING 375 #endif // ENABLE_LOGGING_AND_PROFILING
376 376
377 } } // namespace v8::internal 377 } } // namespace v8::internal
378 378
379 #endif // V8_HEAP_PROFILER_H_ 379 #endif // V8_HEAP_PROFILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698