OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_PROFILER_H_ | 5 #ifndef VM_PROFILER_H_ |
6 #define VM_PROFILER_H_ | 6 #define VM_PROFILER_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/bitfield.h" | 9 #include "vm/bitfield.h" |
10 #include "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 class SampleBuffer; | 26 class SampleBuffer; |
27 | 27 |
28 class Profiler : public AllStatic { | 28 class Profiler : public AllStatic { |
29 public: | 29 public: |
30 static void InitOnce(); | 30 static void InitOnce(); |
31 static void Shutdown(); | 31 static void Shutdown(); |
32 | 32 |
33 static void SetSampleDepth(intptr_t depth); | 33 static void SetSampleDepth(intptr_t depth); |
34 static void SetSamplePeriod(intptr_t period); | 34 static void SetSamplePeriod(intptr_t period); |
35 | 35 |
| 36 static void InitProfilingForIsolate(Isolate* isolate, |
| 37 bool shared_buffer = true); |
| 38 static void ShutdownProfilingForIsolate(Isolate* isolate); |
| 39 |
| 40 static void BeginExecution(Isolate* isolate); |
| 41 static void EndExecution(Isolate* isolate); |
| 42 |
36 static SampleBuffer* sample_buffer() { | 43 static SampleBuffer* sample_buffer() { |
37 return sample_buffer_; | 44 return sample_buffer_; |
38 } | 45 } |
39 | 46 |
40 static void SampleAllocation(Thread* thread, intptr_t cid); | 47 static void RecordAllocation(Thread* thread, intptr_t cid); |
41 static void SampleThread(Thread* thread, | |
42 const InterruptedThreadState& state); | |
43 | 48 |
44 private: | 49 private: |
45 static bool initialized_; | 50 static bool initialized_; |
46 static Monitor* monitor_; | 51 static Monitor* monitor_; |
47 | 52 |
| 53 static void RecordSampleInterruptCallback(const InterruptedThreadState& state, |
| 54 void* data); |
| 55 |
48 static SampleBuffer* sample_buffer_; | 56 static SampleBuffer* sample_buffer_; |
49 | |
50 friend class Thread; | |
51 }; | 57 }; |
52 | 58 |
53 | 59 |
| 60 class IsolateProfilerData { |
| 61 public: |
| 62 IsolateProfilerData(SampleBuffer* sample_buffer, bool own_sample_buffer); |
| 63 ~IsolateProfilerData(); |
| 64 |
| 65 SampleBuffer* sample_buffer() const { return sample_buffer_; } |
| 66 |
| 67 void set_sample_buffer(SampleBuffer* sample_buffer) { |
| 68 sample_buffer_ = sample_buffer; |
| 69 } |
| 70 |
| 71 bool blocked() const { |
| 72 return block_count_ > 0; |
| 73 } |
| 74 |
| 75 void Block(); |
| 76 |
| 77 void Unblock(); |
| 78 |
| 79 private: |
| 80 SampleBuffer* sample_buffer_; |
| 81 bool own_sample_buffer_; |
| 82 intptr_t block_count_; |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(IsolateProfilerData); |
| 85 }; |
| 86 |
| 87 |
54 class SampleVisitor : public ValueObject { | 88 class SampleVisitor : public ValueObject { |
55 public: | 89 public: |
56 explicit SampleVisitor(Isolate* isolate) : isolate_(isolate), visited_(0) { } | 90 explicit SampleVisitor(Isolate* isolate) : isolate_(isolate), visited_(0) { } |
57 virtual ~SampleVisitor() {} | 91 virtual ~SampleVisitor() {} |
58 | 92 |
59 virtual void VisitSample(Sample* sample) = 0; | 93 virtual void VisitSample(Sample* sample) = 0; |
60 | 94 |
61 intptr_t visited() const { | 95 intptr_t visited() const { |
62 return visited_; | 96 return visited_; |
63 } | 97 } |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 556 |
523 private: | 557 private: |
524 ZoneGrowableArray<ProcessedSample*> samples_; | 558 ZoneGrowableArray<ProcessedSample*> samples_; |
525 | 559 |
526 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); | 560 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); |
527 }; | 561 }; |
528 | 562 |
529 } // namespace dart | 563 } // namespace dart |
530 | 564 |
531 #endif // VM_PROFILER_H_ | 565 #endif // VM_PROFILER_H_ |
OLD | NEW |