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

Unified Diff: runtime/vm/profiler.h

Issue 1202943002: Begin transition to ProcessedSample in Profiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/profiler.h
diff --git a/runtime/vm/profiler.h b/runtime/vm/profiler.h
index 8b4d06adbdcee94c08f0a0a57f8ce7012a2da9ce..cea7bd5b1fce26b9e22851c327c3bd683890104f 100644
--- a/runtime/vm/profiler.h
+++ b/runtime/vm/profiler.h
@@ -9,6 +9,7 @@
#include "vm/bitfield.h"
#include "vm/code_observers.h"
#include "vm/globals.h"
+#include "vm/growable_array.h"
#include "vm/tags.h"
#include "vm/thread_interrupter.h"
@@ -18,10 +19,12 @@
namespace dart {
// Forward declarations.
+class ProcessedSample;
+class ProcessedSampleBuffer;
+
class Sample;
class SampleBuffer;
-
class Profiler : public AllStatic {
public:
static void InitOnce();
@@ -107,24 +110,23 @@ class SampleVisitor : public ValueObject {
};
-class PreprocessVisitor : public SampleVisitor {
+class SampleFilter : public ValueObject {
public:
- explicit PreprocessVisitor(Isolate* isolate);
-
- virtual void VisitSample(Sample* sample);
-
- private:
- void CheckForMissingDartFrame(const Code& code, Sample* sample) const;
-
- bool ContainedInDartCodeHeaps(uword pc) const;
+ explicit SampleFilter(Isolate* isolate) : isolate_(isolate) { }
+ virtual ~SampleFilter() { }
- Isolate* vm_isolate() const {
- return vm_isolate_;
+ // Override this function.
+ // Return |true| if |sample| passes the filter.
+ virtual bool FilterSample(Sample* sample) {
+ return true;
}
- RawCode* FindCodeForPC(uword pc) const;
+ Isolate* isolate() const {
+ return isolate_;
+ }
- Isolate* vm_isolate_;
+ private:
+ Isolate* isolate_;
};
@@ -406,7 +408,12 @@ class SampleBuffer {
}
}
+ ProcessedSampleBuffer* BuildProcessedSampleBuffer(SampleFilter* filter);
+
private:
+ ProcessedSample* BuildProcessedSample(Sample* sample);
+ Sample* Next(Sample* sample);
+
Sample* samples_;
intptr_t capacity_;
uintptr_t cursor_;
@@ -415,6 +422,115 @@ class SampleBuffer {
};
+// A |ProcessedSample| is a combination of 1 (or more) |Sample|(s) that have
+// been merged into a logical sample. The raw data may have been processed to
+// improve the quality of the stack trace.
+class ProcessedSample : public ZoneAllocated {
+ public:
+ ProcessedSample();
+
+ // Add |pc| to stack trace.
+ void Add(uword pc) {
+ pcs_.Add(pc);
+ }
+
+ // Insert |pc| at |index|.
+ void InsertAt(intptr_t index, uword pc) {
+ pcs_.InsertAt(index, pc);
+ }
+
+ // Number of pcs in stack trace.
+ intptr_t length() const { return pcs_.length(); }
+
+ // Get |pc| at |index|.
+ uword At(intptr_t index) const {
+ ASSERT(index >= 0);
+ ASSERT(index < length());
+ return pcs_[index];
+ }
+
+ // Timestamp sample was taken at.
+ int64_t timestamp() const { return timestamp_; }
+ void set_timestamp(int64_t timestamp) { timestamp_ = timestamp; }
+
+ // The VM tag.
+ uword vm_tag() const { return vm_tag_; }
+ void set_vm_tag(uword tag) { vm_tag_ = tag; }
+
+ // The user tag.
+ uword user_tag() const { return user_tag_; }
+ void set_user_tag(uword tag) { user_tag_ = tag; }
+
+ // The class id if this is an allocation profile sample. -1 otherwise.
+ intptr_t allocation_cid() const { return allocation_cid_; }
+ void set_allocation_cid(intptr_t cid) { allocation_cid_ = cid; }
+
+ // Was the stack trace truncated?
+ bool truncated() const { return truncated_; }
+ void set_truncated(bool truncated) { truncated_ = truncated; }
+
+ // Was the first frame in the stack trace executing?
+ bool first_frame_executing() const { return first_frame_executing_; }
+ void set_first_frame_executing(bool first_frame_executing) {
+ first_frame_executing_ = first_frame_executing;
+ }
+
+ private:
+ void FixupCaller(Isolate* isolate,
+ Isolate* vm_isolate,
+ uword pc_marker,
+ uword* stack_buffer);
+
+ void CheckForMissingDartFrame(Isolate* isolate,
+ Isolate* vm_isolate,
+ const Code& code,
+ uword pc_marker,
+ uword* stack_buffer);
+
+ static RawCode* FindCodeForPC(Isolate* isolate,
+ Isolate* vm_isolate,
+ uword pc);
+
+ static bool ContainedInDartCodeHeaps(Isolate* isolate,
+ Isolate* vm_isolate,
+ uword pc);
+
+ ZoneGrowableArray<uword> pcs_;
+ int64_t timestamp_;
+ uword vm_tag_;
+ uword user_tag_;
+ intptr_t allocation_cid_;
+ bool truncated_;
+ bool first_frame_executing_;
+
+ friend class SampleBuffer;
+ DISALLOW_COPY_AND_ASSIGN(ProcessedSample);
+};
+
+
+// A collection of |ProcessedSample|s.
+class ProcessedSampleBuffer : public ZoneAllocated {
+ public:
+ ProcessedSampleBuffer();
+
+ void Add(ProcessedSample* sample) {
+ samples_.Add(sample);
+ }
+
+ intptr_t length() const {
+ return samples_.length();
+ }
+
+ ProcessedSample* At(intptr_t index) {
+ return samples_.At(index);
+ }
+
+ private:
+ ZoneGrowableArray<ProcessedSample*> samples_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProcessedSampleBuffer);
+};
+
} // namespace dart
#endif // VM_PROFILER_H_
« no previous file with comments | « no previous file | runtime/vm/profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698