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

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

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/heap-inl.h ('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-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 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 "isolate.h"
31 #include "zone-inl.h" 32 #include "zone-inl.h"
32 33
33 namespace v8 { 34 namespace v8 {
34 namespace internal { 35 namespace internal {
35 36
36 #ifdef ENABLE_LOGGING_AND_PROFILING 37 #ifdef ENABLE_LOGGING_AND_PROFILING
37 38
38 class HeapSnapshot; 39 class HeapSnapshot;
39 class HeapSnapshotsCollection; 40 class HeapSnapshotsCollection;
40 41
41 #define HEAP_PROFILE(Call) \ 42 #define HEAP_PROFILE(heap, call) \
42 do { \ 43 do { \
43 if (v8::internal::HeapProfiler::is_profiling()) { \ 44 v8::internal::HeapProfiler* profiler = heap->isolate()->heap_profiler(); \
44 v8::internal::HeapProfiler::Call; \ 45 if (profiler != NULL && profiler->is_profiling()) { \
45 } \ 46 profiler->call; \
47 } \
46 } while (false) 48 } while (false)
47 #else 49 #else
48 #define HEAP_PROFILE(Call) ((void) 0) 50 #define HEAP_PROFILE(heap, call) ((void) 0)
49 #endif // ENABLE_LOGGING_AND_PROFILING 51 #endif // ENABLE_LOGGING_AND_PROFILING
50 52
51 // 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
52 // 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.
53 class HeapProfiler { 55 class HeapProfiler {
54 public: 56 public:
55 static void Setup(); 57 static void Setup();
56 static void TearDown(); 58 static void TearDown();
57 59
58 #ifdef ENABLE_LOGGING_AND_PROFILING 60 #ifdef ENABLE_LOGGING_AND_PROFILING
59 static HeapSnapshot* TakeSnapshot(const char* name, 61 static HeapSnapshot* TakeSnapshot(const char* name,
60 int type, 62 int type,
61 v8::ActivityControl* control); 63 v8::ActivityControl* control);
62 static HeapSnapshot* TakeSnapshot(String* name, 64 static HeapSnapshot* TakeSnapshot(String* name,
63 int type, 65 int type,
64 v8::ActivityControl* control); 66 v8::ActivityControl* control);
65 static int GetSnapshotsCount(); 67 static int GetSnapshotsCount();
66 static HeapSnapshot* GetSnapshot(int index); 68 static HeapSnapshot* GetSnapshot(int index);
67 static HeapSnapshot* FindSnapshot(unsigned uid); 69 static HeapSnapshot* FindSnapshot(unsigned uid);
68 70
69 static void ObjectMoveEvent(Address from, Address to); 71 void ObjectMoveEvent(Address from, Address to);
70 72
71 static void DefineWrapperClass( 73 void DefineWrapperClass(
72 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback); 74 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback);
73 static v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id,
74 Object** wrapper);
75 75
76 static INLINE(bool is_profiling()) { 76 v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id,
77 return singleton_ != NULL && singleton_->snapshots_->is_tracking_objects(); 77 Object** wrapper);
78 INLINE(bool is_profiling()) {
79 return snapshots_->is_tracking_objects();
78 } 80 }
79 81
80 // Obsolete interface. 82 // Obsolete interface.
81 // Write a single heap sample to the log file. 83 // Write a single heap sample to the log file.
82 static void WriteSample(); 84 static void WriteSample();
83 85
84 private: 86 private:
85 HeapProfiler(); 87 HeapProfiler();
86 ~HeapProfiler(); 88 ~HeapProfiler();
87 HeapSnapshot* TakeSnapshotImpl(const char* name, 89 HeapSnapshot* TakeSnapshotImpl(const char* name,
88 int type, 90 int type,
89 v8::ActivityControl* control); 91 v8::ActivityControl* control);
90 HeapSnapshot* TakeSnapshotImpl(String* name, 92 HeapSnapshot* TakeSnapshotImpl(String* name,
91 int type, 93 int type,
92 v8::ActivityControl* control); 94 v8::ActivityControl* control);
93 95
94 HeapSnapshotsCollection* snapshots_; 96 HeapSnapshotsCollection* snapshots_;
95 unsigned next_snapshot_uid_; 97 unsigned next_snapshot_uid_;
96 List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_; 98 List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_;
97 99
98 static HeapProfiler* singleton_;
99 #endif // ENABLE_LOGGING_AND_PROFILING 100 #endif // ENABLE_LOGGING_AND_PROFILING
100 }; 101 };
101 102
102 103
103 #ifdef ENABLE_LOGGING_AND_PROFILING 104 #ifdef ENABLE_LOGGING_AND_PROFILING
104 105
105 // JSObjectsCluster describes a group of JS objects that are 106 // JSObjectsCluster describes a group of JS objects that are
106 // considered equivalent in terms of a particular profile. 107 // considered equivalent in terms of a particular profile.
107 class JSObjectsCluster BASE_EMBEDDED { 108 class JSObjectsCluster BASE_EMBEDDED {
108 public: 109 public:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 const char* GetSpecialCaseName() const; 148 const char* GetSpecialCaseName() const;
148 void Print(StringStream* accumulator) const; 149 void Print(StringStream* accumulator) const;
149 // Allows null clusters to be printed. 150 // Allows null clusters to be printed.
150 void DebugPrint(StringStream* accumulator) const; 151 void DebugPrint(StringStream* accumulator) const;
151 152
152 private: 153 private:
153 static String* FromSpecialCase(SpecialCase special) { 154 static String* FromSpecialCase(SpecialCase special) {
154 // We use symbols that are illegal JS identifiers to identify special cases. 155 // We use symbols that are illegal JS identifiers to identify special cases.
155 // Their actual value is irrelevant for us. 156 // Their actual value is irrelevant for us.
156 switch (special) { 157 switch (special) {
157 case ROOTS: return Heap::result_symbol(); 158 case ROOTS: return HEAP->result_symbol();
158 case GLOBAL_PROPERTY: return Heap::code_symbol(); 159 case GLOBAL_PROPERTY: return HEAP->code_symbol();
159 case CODE: return Heap::arguments_shadow_symbol(); 160 case CODE: return HEAP->arguments_shadow_symbol();
160 case SELF: return Heap::catch_var_symbol(); 161 case SELF: return HEAP->catch_var_symbol();
161 default: 162 default:
162 UNREACHABLE(); 163 UNREACHABLE();
163 return NULL; 164 return NULL;
164 } 165 }
165 } 166 }
166 167
167 String* constructor_; 168 String* constructor_;
168 Object* instance_; 169 Object* instance_;
169 }; 170 };
170 171
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 341
341 private: 342 private:
342 HistogramInfo* info_; 343 HistogramInfo* info_;
343 ConstructorHeapProfile js_cons_profile_; 344 ConstructorHeapProfile js_cons_profile_;
344 RetainerHeapProfile js_retainer_profile_; 345 RetainerHeapProfile js_retainer_profile_;
345 }; 346 };
346 347
347 348
348 class HeapEntriesMap; 349 class HeapEntriesMap;
349 class HeapEntriesAllocator; 350 class HeapEntriesAllocator;
350 class HeapSnapshot;
351 351
352 class AggregatedHeapSnapshotGenerator { 352 class AggregatedHeapSnapshotGenerator {
353 public: 353 public:
354 explicit AggregatedHeapSnapshotGenerator(AggregatedHeapSnapshot* snapshot); 354 explicit AggregatedHeapSnapshotGenerator(AggregatedHeapSnapshot* snapshot);
355 void GenerateSnapshot(); 355 void GenerateSnapshot();
356 void FillHeapSnapshot(HeapSnapshot* snapshot); 356 void FillHeapSnapshot(HeapSnapshot* snapshot);
357 357
358 static const int kAllStringsType = LAST_TYPE + 1; 358 static const int kAllStringsType = LAST_TYPE + 1;
359 359
360 private: 360 private:
361 void CalculateStringsStats(); 361 void CalculateStringsStats();
362 void CollectStats(HeapObject* obj); 362 void CollectStats(HeapObject* obj);
363 template<class Iterator> 363 template<class Iterator>
364 void IterateRetainers( 364 void IterateRetainers(
365 HeapEntriesAllocator* allocator, HeapEntriesMap* entries_map); 365 HeapEntriesAllocator* allocator, HeapEntriesMap* entries_map);
366 366
367 AggregatedHeapSnapshot* agg_snapshot_; 367 AggregatedHeapSnapshot* agg_snapshot_;
368 }; 368 };
369 369
370 370
371 class ProducerHeapProfile : public AllStatic { 371 class ProducerHeapProfile {
372 public: 372 public:
373 static void Setup(); 373 void Setup();
374 static void RecordJSObjectAllocation(Object* obj) { 374 void RecordJSObjectAllocation(Object* obj) {
375 if (FLAG_log_producers) DoRecordJSObjectAllocation(obj); 375 if (FLAG_log_producers) DoRecordJSObjectAllocation(obj);
376 } 376 }
377 377
378 private: 378 private:
379 static void DoRecordJSObjectAllocation(Object* obj); 379 ProducerHeapProfile() : can_log_(false) { }
380 static bool can_log_; 380
381 void DoRecordJSObjectAllocation(Object* obj);
382 Isolate* isolate_;
383 bool can_log_;
384
385 friend class Isolate;
386
387 DISALLOW_COPY_AND_ASSIGN(ProducerHeapProfile);
381 }; 388 };
382 389
383 #endif // ENABLE_LOGGING_AND_PROFILING 390 #endif // ENABLE_LOGGING_AND_PROFILING
384 391
385 } } // namespace v8::internal 392 } } // namespace v8::internal
386 393
387 #endif // V8_HEAP_PROFILER_H_ 394 #endif // V8_HEAP_PROFILER_H_
OLDNEW
« no previous file with comments | « src/heap-inl.h ('k') | src/heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698