Index: runtime/vm/deopt_instructions.cc |
diff --git a/runtime/vm/deopt_instructions.cc b/runtime/vm/deopt_instructions.cc |
index 0acf361fb8ad0c09aad7ea14bf984cd080e54266..211cb78e6ea475c094424bc0880754c07371dd78 100644 |
--- a/runtime/vm/deopt_instructions.cc |
+++ b/runtime/vm/deopt_instructions.cc |
@@ -12,6 +12,7 @@ |
#include "vm/parser.h" |
#include "vm/stack_frame.h" |
#include "vm/thread.h" |
+#include "vm/timeline.h" |
namespace dart { |
@@ -41,6 +42,7 @@ DeoptContext::DeoptContext(const StackFrame* frame, |
deopt_reason_(ICData::kDeoptUnknown), |
deopt_flags_(0), |
thread_(Thread::Current()), |
+ timeline_event_(NULL), |
deferred_slots_(NULL), |
deferred_objects_count_(0), |
deferred_objects_(NULL) { |
@@ -92,6 +94,19 @@ DeoptContext::DeoptContext(const StackFrame* frame, |
dest_frame_is_allocated_ = true; |
} |
+ if (dest_options != kDestIsAllocated) { |
+ // kDestIsAllocated is used by the debugger to generate a stack trace |
+ // and does not signal a real deopt. |
+ Isolate* isolate = Isolate::Current(); |
+ TimelineStream* compiler_stream = isolate->GetCompilerStream(); |
+ ASSERT(compiler_stream != NULL); |
+ timeline_event_ = compiler_stream->RecordEvent(); |
+ if (timeline_event_ != NULL) { |
+ timeline_event_->DurationBegin(compiler_stream, "Deoptimize"); |
+ timeline_event_->SetNumArguments(3); |
+ } |
+ } |
+ |
if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { |
OS::PrintErr( |
"Deoptimizing (reason %d '%s') at pc %#" Px " '%s' (count %d)\n", |
@@ -126,6 +141,24 @@ DeoptContext::~DeoptContext() { |
delete[] deferred_objects_; |
deferred_objects_ = NULL; |
deferred_objects_count_ = 0; |
+ if (timeline_event_ != NULL) { |
+ const Code& code = Code::Handle(zone(), code_); |
+ const Function& function = Function::Handle(zone(), code.function()); |
+ timeline_event_->CopyArgument( |
+ 0, |
+ "function", |
+ const_cast<char*>(function.QualifiedUserVisibleNameCString())); |
+ timeline_event_->CopyArgument( |
+ 1, |
+ "reason", |
+ const_cast<char*>(DeoptReasonToCString(deopt_reason()))); |
+ timeline_event_->FormatArgument( |
+ 2, |
+ "deoptimizationCount", |
+ "%d", |
+ function.deoptimization_counter()); |
+ timeline_event_->DurationEnd(); |
+ } |
} |