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 RUNTIME_VM_PROFILER_H_ | 5 #ifndef RUNTIME_VM_PROFILER_H_ |
6 #define RUNTIME_VM_PROFILER_H_ | 6 #define RUNTIME_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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 | 51 |
52 static void SetSampleDepth(intptr_t depth); | 52 static void SetSampleDepth(intptr_t depth); |
53 static void SetSamplePeriod(intptr_t period); | 53 static void SetSamplePeriod(intptr_t period); |
54 | 54 |
55 static SampleBuffer* sample_buffer() { return sample_buffer_; } | 55 static SampleBuffer* sample_buffer() { return sample_buffer_; } |
56 | 56 |
57 static void DumpStackTrace(void* context); | 57 static void DumpStackTrace(void* context); |
58 static void DumpStackTrace(); | 58 static void DumpStackTrace(); |
59 | 59 |
60 static void SampleAllocation(Thread* thread, intptr_t cid); | 60 static void SampleAllocation(Thread* thread, intptr_t cid); |
61 static Sample* NativeSampleAllocation(); | |
Cutch
2017/02/08 00:28:54
SampleNativeAllocation
bkonyi
2017/02/08 01:37:05
Done.
| |
61 | 62 |
62 // SampleThread is called from inside the signal handler and hence it is very | 63 // SampleThread is called from inside the signal handler and hence it is very |
63 // critical that the implementation of SampleThread does not do any of the | 64 // critical that the implementation of SampleThread does not do any of the |
64 // following: | 65 // following: |
65 // * Accessing TLS -- Because on Windows the callback will be running in a | 66 // * Accessing TLS -- Because on Windows the callback will be running in a |
66 // different thread. | 67 // different thread. |
67 // * Allocating memory -- Because this takes locks which may already be | 68 // * Allocating memory -- Because this takes locks which may already be |
68 // held, resulting in a dead lock. | 69 // held, resulting in a dead lock. |
69 // * Taking a lock -- See above. | 70 // * Taking a lock -- See above. |
70 static void SampleThread(Thread* thread, const InterruptedThreadState& state); | 71 static void SampleThread(Thread* thread, const InterruptedThreadState& state); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 } | 262 } |
262 | 263 |
263 bool is_allocation_sample() const { | 264 bool is_allocation_sample() const { |
264 return ClassAllocationSampleBit::decode(state_); | 265 return ClassAllocationSampleBit::decode(state_); |
265 } | 266 } |
266 | 267 |
267 void set_is_allocation_sample(bool allocation_sample) { | 268 void set_is_allocation_sample(bool allocation_sample) { |
268 state_ = ClassAllocationSampleBit::update(allocation_sample, state_); | 269 state_ = ClassAllocationSampleBit::update(allocation_sample, state_); |
269 } | 270 } |
270 | 271 |
272 bool is_native_allocation_sample() const { | |
273 return NativeAllocationSampleBit::decode(state_); | |
274 } | |
275 | |
276 void set_is_native_allocation_sample(bool native_allocation_sample) { | |
277 state_ = | |
278 NativeAllocationSampleBit::update(native_allocation_sample, state_); | |
279 } | |
280 | |
271 Thread::TaskKind thread_task() const { return ThreadTaskBit::decode(state_); } | 281 Thread::TaskKind thread_task() const { return ThreadTaskBit::decode(state_); } |
272 | 282 |
273 void set_thread_task(Thread::TaskKind task) { | 283 void set_thread_task(Thread::TaskKind task) { |
274 state_ = ThreadTaskBit::update(task, state_); | 284 state_ = ThreadTaskBit::update(task, state_); |
275 } | 285 } |
276 | 286 |
277 bool is_continuation_sample() const { | 287 bool is_continuation_sample() const { |
278 return ContinuationSampleBit::decode(state_); | 288 return ContinuationSampleBit::decode(state_); |
279 } | 289 } |
280 | 290 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 enum StateBits { | 334 enum StateBits { |
325 kHeadSampleBit = 0, | 335 kHeadSampleBit = 0, |
326 kLeafFrameIsDartBit = 1, | 336 kLeafFrameIsDartBit = 1, |
327 kIgnoreBit = 2, | 337 kIgnoreBit = 2, |
328 kExitFrameBit = 3, | 338 kExitFrameBit = 3, |
329 kMissingFrameInsertedBit = 4, | 339 kMissingFrameInsertedBit = 4, |
330 kTruncatedTraceBit = 5, | 340 kTruncatedTraceBit = 5, |
331 kClassAllocationSampleBit = 6, | 341 kClassAllocationSampleBit = 6, |
332 kContinuationSampleBit = 7, | 342 kContinuationSampleBit = 7, |
333 kThreadTaskBit = 8, // 5 bits. | 343 kThreadTaskBit = 8, // 5 bits. |
334 kNextFreeBit = 13, | 344 kNativeAllocationSampleBit = 13, |
345 kNextFreeBit = 14, | |
335 }; | 346 }; |
336 class HeadSampleBit : public BitField<uword, bool, kHeadSampleBit, 1> {}; | 347 class HeadSampleBit : public BitField<uword, bool, kHeadSampleBit, 1> {}; |
337 class LeafFrameIsDart : public BitField<uword, bool, kLeafFrameIsDartBit, 1> { | 348 class LeafFrameIsDart : public BitField<uword, bool, kLeafFrameIsDartBit, 1> { |
338 }; | 349 }; |
339 class IgnoreBit : public BitField<uword, bool, kIgnoreBit, 1> {}; | 350 class IgnoreBit : public BitField<uword, bool, kIgnoreBit, 1> {}; |
340 class ExitFrameBit : public BitField<uword, bool, kExitFrameBit, 1> {}; | 351 class ExitFrameBit : public BitField<uword, bool, kExitFrameBit, 1> {}; |
341 class MissingFrameInsertedBit | 352 class MissingFrameInsertedBit |
342 : public BitField<uword, bool, kMissingFrameInsertedBit, 1> {}; | 353 : public BitField<uword, bool, kMissingFrameInsertedBit, 1> {}; |
343 class TruncatedTraceBit | 354 class TruncatedTraceBit |
344 : public BitField<uword, bool, kTruncatedTraceBit, 1> {}; | 355 : public BitField<uword, bool, kTruncatedTraceBit, 1> {}; |
345 class ClassAllocationSampleBit | 356 class ClassAllocationSampleBit |
346 : public BitField<uword, bool, kClassAllocationSampleBit, 1> {}; | 357 : public BitField<uword, bool, kClassAllocationSampleBit, 1> {}; |
358 class NativeAllocationSampleBit | |
359 : public BitField<uword, bool, kNativeAllocationSampleBit, 1> {}; | |
347 class ContinuationSampleBit | 360 class ContinuationSampleBit |
348 : public BitField<uword, bool, kContinuationSampleBit, 1> {}; | 361 : public BitField<uword, bool, kContinuationSampleBit, 1> {}; |
349 class ThreadTaskBit | 362 class ThreadTaskBit |
350 : public BitField<uword, Thread::TaskKind, kThreadTaskBit, 5> {}; | 363 : public BitField<uword, Thread::TaskKind, kThreadTaskBit, 5> {}; |
351 | 364 |
352 int64_t timestamp_; | 365 int64_t timestamp_; |
353 ThreadId tid_; | 366 ThreadId tid_; |
354 Isolate* isolate_; | 367 Isolate* isolate_; |
355 uword pc_marker_; | 368 uword pc_marker_; |
356 uword stack_buffer_[kStackBufferSizeInWords]; | 369 uword stack_buffer_[kStackBufferSizeInWords]; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 private: | 622 private: |
610 ZoneGrowableArray<ProcessedSample*> samples_; | 623 ZoneGrowableArray<ProcessedSample*> samples_; |
611 CodeLookupTable* code_lookup_table_; | 624 CodeLookupTable* code_lookup_table_; |
612 | 625 |
613 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); | 626 DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer); |
614 }; | 627 }; |
615 | 628 |
616 } // namespace dart | 629 } // namespace dart |
617 | 630 |
618 #endif // RUNTIME_VM_PROFILER_H_ | 631 #endif // RUNTIME_VM_PROFILER_H_ |
OLD | NEW |