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

Unified Diff: runtime/vm/profiler.cc

Issue 1211633002: Introduce mechanism to record an allocation of a class (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 | « runtime/vm/profiler.h ('k') | runtime/vm/profiler_test.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 e6d7341e201d576c39cafc1a0fd2c9918202cd10..b674952c42fdb22f89c94cddca4d18967a8a0734 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -820,6 +820,58 @@ static void CollectSample(Isolate* isolate,
}
+void Profiler::RecordAllocation(Isolate* isolate, intptr_t cid) {
+ if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) {
+ // No isolate.
+ return;
+ }
+ ASSERT(isolate != Dart::vm_isolate());
+
+ const bool exited_dart_code = (isolate->stub_code() != NULL) &&
+ (isolate->top_exit_frame_info() != 0) &&
+ (isolate->vm_tag() != VMTag::kDartTagId);
+
+ if (!exited_dart_code) {
+ // No Dart frames on stack.
+ // TODO(johnmccutchan): Support collecting native stack.
+ return;
+ }
+
+ IsolateProfilerData* profiler_data = isolate->profiler_data();
+ if (profiler_data == NULL) {
+ // Profiler not initialized.
+ return;
+ }
+
+ SampleBuffer* sample_buffer = profiler_data->sample_buffer();
+ if (sample_buffer == NULL) {
+ // Profiler not initialized.
+ return;
+ }
+
+ const ThreadId thread_id = OSThread::GetCurrentThreadId();
+ // Setup sample.
+ Sample* sample = sample_buffer->ReserveSample();
+ sample->Init(isolate, OS::GetCurrentTimeMicros(), thread_id);
+ uword vm_tag = isolate->vm_tag();
+ #if defined(USING_SIMULATOR)
+ // When running in the simulator, the runtime entry function address
+ // (stored as the vm tag) is the address of a redirect function.
+ // Attempt to find the real runtime entry function address and use that.
+ uword redirect_vm_tag = Simulator::FunctionForRedirect(vm_tag);
+ if (redirect_vm_tag != 0) {
+ vm_tag = redirect_vm_tag;
+ }
+ #endif
+ sample->set_vm_tag(vm_tag);
+ sample->set_user_tag(isolate->user_tag());
+ sample->SetAllocationCid(cid);
+
+ ProfilerDartExitStackWalker dart_exit_stack_walker(isolate, sample);
+ dart_exit_stack_walker.walk();
+}
+
+
void Profiler::RecordSampleInterruptCallback(
const InterruptedThreadState& state,
void* data) {
« no previous file with comments | « runtime/vm/profiler.h ('k') | runtime/vm/profiler_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698