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

Unified Diff: runtime/vm/debugger.cc

Issue 9696020: Deoptimize functions before setting breakpoints (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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/debugger.h ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debugger.cc
===================================================================
--- runtime/vm/debugger.cc (revision 5412)
+++ runtime/vm/debugger.cc (working copy)
@@ -485,8 +485,27 @@
}
-void Debugger::InstrumentForStepping(const Function &target_function) {
- if (!target_function.HasCode()) {
+// Deoptimize function if necessary. Does not patch return addresses on the
+// stack. If there are activation frames of this function on the stack,
+// the optimized code will be executed when the callee returns.
+void Debugger::EnsureFunctionIsDeoptimized(const Function& func) {
+ if (func.HasOptimizedCode()) {
+ if (verbose) {
+ OS::Print("Deoptimizing function %s\n",
+ String::Handle(func.name()).ToCString());
+ }
+ func.set_usage_counter(0);
+ func.set_deoptimization_counter(func.deoptimization_counter() + 1);
+ Compiler::CompileFunction(func);
+ ASSERT(!func.HasOptimizedCode());
+ }
+}
+
+
+void Debugger::InstrumentForStepping(const Function& target_function) {
+ if (target_function.HasCode()) {
+ EnsureFunctionIsDeoptimized(target_function);
+ } else {
Compiler::CompileFunction(target_function);
// If there were any errors, ignore them silently and return without
// adding breakpoints to target.
@@ -494,7 +513,6 @@
return;
}
}
- ASSERT(!target_function.HasOptimizedCode());
Code& code = Code::Handle(target_function.unoptimized_code());
ASSERT(!code.IsNull());
PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
@@ -563,6 +581,7 @@
// The given token position is not within the target function.
return NULL;
}
+ EnsureFunctionIsDeoptimized(target_function);
SourceBreakpoint* bpt = GetSourceBreakpoint(target_function, token_index);
if (bpt != NULL) {
// A breakpoint for this location already exists, return it.
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698