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

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
Index: runtime/vm/profiler.cc
diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc
index da856e2844ba9f3dd8efcd6f961407a9533460b5..8d37ebc90edd78a4403394e3b5fabfcd9d033e42 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()));
+
+ intptr_t size = Utils::RoundUp(capacity * Sample::instance_size(),
zra 2017/06/23 04:43:41 const
rmacnak 2017/06/23 21:05:52 Done.
+ 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') | runtime/vm/zone.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698