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

Unified Diff: runtime/vm/profiler.cc

Issue 2955493002: Allocate the profiler sample buffer and zone segments with virtual memory instead of malloc. (Closed)
Patch Set: . Created 3 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') | runtime/vm/virtual_memory_fuchsia.cc » ('j') | 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 da856e2844ba9f3dd8efcd6f961407a9533460b5..b416aeb5095f7de3cee46e1c4e3a521c57c5e33a 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -129,16 +129,29 @@ uword* Sample::GetPCArray() const {
SampleBuffer::SampleBuffer(intptr_t capacity) {
ASSERT(Sample::instance_size() > 0);
- samples_ =
- reinterpret_cast<Sample*>(calloc(capacity, Sample::instance_size()));
+
+ const intptr_t size = Utils::RoundUp(capacity * Sample::instance_size(),
+ VirtualMemory::PageSize());
+ const bool kNotExecutable = false;
+ memory_ = VirtualMemory::Reserve(size);
+ if ((memory_ == NULL) || !memory_->Commit(kNotExecutable, "dart-profiler")) {
+ OUT_OF_MEMORY();
+ }
+
+ samples_ = reinterpret_cast<Sample*>(memory_->address());
+ capacity_ = capacity;
+ cursor_ = 0;
+
if (FLAG_trace_profiler) {
OS::Print("Profiler holds %" Pd " samples\n", capacity);
OS::Print("Profiler sample is %" Pd " bytes\n", Sample::instance_size());
- OS::Print("Profiler memory usage = %" Pd " bytes\n",
- capacity * Sample::instance_size());
+ OS::Print("Profiler memory usage = %" Pd " bytes\n", size);
}
- capacity_ = capacity;
- cursor_ = 0;
+}
+
+
+SampleBuffer::~SampleBuffer() {
+ delete memory_;
}
« no previous file with comments | « runtime/vm/profiler.h ('k') | runtime/vm/virtual_memory_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698