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

Unified Diff: runtime/vm/profiler.cc

Issue 345713006: Make size of sample variable based on the profile depth flag (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | « runtime/vm/profiler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/profiler.cc
diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc
index 2545385532d77673de052c50ee76e814637eb9d1..016332e39ade7087970da3f6fb3124e1b5f2256f 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -46,6 +46,7 @@ void Profiler::InitOnce() {
// Place some sane restrictions on user controlled flags.
SetSamplePeriod(FLAG_profile_period);
SetSampleDepth(FLAG_profile_depth);
+ Sample::InitOnce();
if (!FLAG_profile) {
return;
}
@@ -70,7 +71,7 @@ void Profiler::Shutdown() {
void Profiler::SetSampleDepth(intptr_t depth) {
const int kMinimumDepth = 1;
- const int kMaximumDepth = kSampleFramesSize - 1;
+ const int kMaximumDepth = 255;
if (depth < kMinimumDepth) {
FLAG_profile_depth = kMinimumDepth;
} else if (depth > kMaximumDepth) {
@@ -1617,6 +1618,42 @@ void IsolateProfilerData::Unblock() {
}
+intptr_t Sample::pcs_length_ = 0;
+intptr_t Sample::instance_size_ = 0;
+
+
+void Sample::InitOnce() {
+ ASSERT(FLAG_profile_depth >= 1);
+ pcs_length_ = FLAG_profile_depth;
+ instance_size_ =
+ sizeof(Sample) + (sizeof(uword) * pcs_length_); // NOLINT.
+}
+
+
+uword* Sample::GetPCArray() const {
+ return reinterpret_cast<uword*>(
+ reinterpret_cast<uintptr_t>(this) + sizeof(*this));
+}
+
+
+SampleBuffer::SampleBuffer(intptr_t capacity) {
+ ASSERT(Sample::instance_size() > 0);
+ samples_ = reinterpret_cast<Sample*>(
+ calloc(capacity, Sample::instance_size()));
+ capacity_ = capacity;
+ cursor_ = 0;
+}
+
+
+Sample* SampleBuffer::At(intptr_t idx) const {
+ ASSERT(idx >= 0);
+ ASSERT(idx < capacity_);
+ intptr_t offset = idx * Sample::instance_size();
+ uint8_t* samples = reinterpret_cast<uint8_t*>(samples_);
+ return reinterpret_cast<Sample*>(samples + offset);
+}
+
+
Sample* SampleBuffer::ReserveSample() {
ASSERT(samples_ != NULL);
uintptr_t cursor = AtomicOperations::FetchAndIncrement(&cursor_);
« no previous file with comments | « runtime/vm/profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698