Chromium Code Reviews| Index: runtime/vm/profiler.h |
| diff --git a/runtime/vm/profiler.h b/runtime/vm/profiler.h |
| index ee87a31d954051b61af6a7a822b7f2bb78da23eb..f23dd065192eb066aa97fe845a38716e59e59740 100644 |
| --- a/runtime/vm/profiler.h |
| +++ b/runtime/vm/profiler.h |
| @@ -58,6 +58,7 @@ class Profiler : public AllStatic { |
| static void DumpStackTrace(); |
| static void SampleAllocation(Thread* thread, intptr_t cid); |
| + static Sample* SampleNativeAllocation(intptr_t skip_count); |
| // SampleThread is called from inside the signal handler and hence it is very |
| // critical that the implementation of SampleThread does not do any of the |
| @@ -91,7 +92,7 @@ class Profiler : public AllStatic { |
| class SampleVisitor : public ValueObject { |
| public: |
| - explicit SampleVisitor(Isolate* isolate) : isolate_(isolate), visited_(0) {} |
| + explicit SampleVisitor(Dart_Port port) : port_(port), visited_(0) {} |
| virtual ~SampleVisitor() {} |
| virtual void VisitSample(Sample* sample) = 0; |
| @@ -100,10 +101,10 @@ class SampleVisitor : public ValueObject { |
| void IncrementVisited() { visited_++; } |
| - Isolate* isolate() const { return isolate_; } |
| + Dart_Port port() const { return port_; } |
| private: |
| - Isolate* isolate_; |
| + Dart_Port port_; |
| intptr_t visited_; |
| DISALLOW_IMPLICIT_CONSTRUCTORS(SampleVisitor); |
| @@ -112,11 +113,11 @@ class SampleVisitor : public ValueObject { |
| class SampleFilter : public ValueObject { |
| public: |
| - SampleFilter(Isolate* isolate, |
| + SampleFilter(Dart_Port port, |
| intptr_t thread_task_mask, |
| int64_t time_origin_micros, |
| int64_t time_extent_micros) |
| - : isolate_(isolate), |
| + : port_(port), |
| thread_task_mask_(thread_task_mask), |
| time_origin_micros_(time_origin_micros), |
| time_extent_micros_(time_extent_micros) { |
| @@ -130,7 +131,7 @@ class SampleFilter : public ValueObject { |
| // Return |true| if |sample| passes the filter. |
| virtual bool FilterSample(Sample* sample) { return true; } |
| - Isolate* isolate() const { return isolate_; } |
| + Dart_Port port() const { return port_; } |
| // Returns |true| if |sample| passes the time filter. |
| bool TimeFilterSample(Sample* sample); |
| @@ -139,7 +140,7 @@ class SampleFilter : public ValueObject { |
| bool TaskFilterSample(Sample* sample); |
| private: |
| - Isolate* isolate_; |
| + Dart_Port port_; |
| intptr_t thread_task_mask_; |
| int64_t time_origin_micros_; |
| int64_t time_extent_micros_; |
| @@ -157,21 +158,20 @@ class ClearProfileVisitor : public SampleVisitor { |
| // Each Sample holds a stack trace from an isolate. |
| class Sample { |
| public: |
| - void Init(Isolate* isolate, int64_t timestamp, ThreadId tid) { |
| + void Init(Dart_Port port, int64_t timestamp, ThreadId tid) { |
| Clear(); |
| timestamp_ = timestamp; |
| tid_ = tid; |
| - isolate_ = isolate; |
| + port_ = port; |
| } |
| - // Isolate sample was taken from. |
| - Isolate* isolate() const { return isolate_; } |
| + Dart_Port port() const { return port_; } |
| // Thread sample was taken on. |
| ThreadId tid() const { return tid_; } |
| void Clear() { |
| - isolate_ = NULL; |
| + port_ = ILLEGAL_PORT; |
| pc_marker_ = 0; |
| for (intptr_t i = 0; i < kStackBufferSizeInWords; i++) { |
| stack_buffer_[i] = 0; |
| @@ -268,6 +268,15 @@ class Sample { |
| state_ = ClassAllocationSampleBit::update(allocation_sample, state_); |
| } |
| + bool is_native_allocation_sample() const { |
| + return NativeAllocationSampleBit::decode(state_); |
| + } |
| + |
| + void set_is_native_allocation_sample(bool native_allocation_sample) { |
| + state_ = |
| + NativeAllocationSampleBit::update(native_allocation_sample, state_); |
| + } |
| + |
| Thread::TaskKind thread_task() const { return ThreadTaskBit::decode(state_); } |
| void set_thread_task(Thread::TaskKind task) { |
| @@ -331,7 +340,8 @@ class Sample { |
| kClassAllocationSampleBit = 6, |
| kContinuationSampleBit = 7, |
| kThreadTaskBit = 8, // 5 bits. |
| - kNextFreeBit = 13, |
| + kNativeAllocationSampleBit = 13, |
| + kNextFreeBit = 14, |
| }; |
| class HeadSampleBit : public BitField<uword, bool, kHeadSampleBit, 1> {}; |
| class LeafFrameIsDart : public BitField<uword, bool, kLeafFrameIsDartBit, 1> { |
| @@ -344,6 +354,8 @@ class Sample { |
| : public BitField<uword, bool, kTruncatedTraceBit, 1> {}; |
| class ClassAllocationSampleBit |
| : public BitField<uword, bool, kClassAllocationSampleBit, 1> {}; |
| + class NativeAllocationSampleBit |
| + : public BitField<uword, bool, kNativeAllocationSampleBit, 1> {}; |
| class ContinuationSampleBit |
| : public BitField<uword, bool, kContinuationSampleBit, 1> {}; |
| class ThreadTaskBit |
| @@ -351,7 +363,7 @@ class Sample { |
| int64_t timestamp_; |
| ThreadId tid_; |
| - Isolate* isolate_; |
| + Dart_Port port_; |
| uword pc_marker_; |
| uword stack_buffer_[kStackBufferSizeInWords]; |
| uword vm_tag_; |
| @@ -474,7 +486,8 @@ class SampleBuffer { |
| // Bad sample. |
| continue; |
| } |
| - if (sample->isolate() != visitor->isolate()) { |
| + if ((sample->port() != visitor->port()) && |
|
Cutch
2017/02/21 18:53:35
It seems like native samples have a port of ILLEGA
bkonyi
2017/02/22 19:12:51
No, we don't. I've removed the code associated wit
|
| + !sample->is_native_allocation_sample()) { |
| // Another isolate. |
| continue; |
| } |