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

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
Index: runtime/vm/debugger.cc
===================================================================
--- runtime/vm/debugger.cc (revision 5364)
+++ runtime/vm/debugger.cc (working copy)
@@ -485,7 +485,24 @@
}
-void Debugger::InstrumentForStepping(const Function &target_function) {
+// 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) {
+ printf("Deoptimizing function %s\n",
srdjan 2012/03/13 17:11:35 OS::Print
hausner 2012/03/13 20:45:03 Done.
+ String::Handle(func.name()).ToCString());
+ }
+ func.set_usage_counter(0);
+ func.set_deoptimization_counter(func.deoptimization_counter() + 1);
srdjan 2012/03/13 17:11:35 Don't increase the counter otherwise setting and c
hausner 2012/03/13 20:45:03 Done.
+ Compiler::CompileFunction(func);
+ ASSERT(!func.HasOptimizedCode());
+ }
+}
+
+
+void Debugger::InstrumentForStepping(const Function& target_function) {
if (!target_function.HasCode()) {
Compiler::CompileFunction(target_function);
// If there were any errors, ignore them silently and return without
@@ -493,8 +510,9 @@
if (!target_function.HasCode()) {
return;
}
+ } else {
+ EnsureFunctionIsDeoptimized(target_function);
srdjan 2012/03/13 17:11:35 I rather think positive: if (target.HasCode()) {
hausner 2012/03/13 20:45:03 The glass is now half full. On 2012/03/13 17:11:3
}
- 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.

Powered by Google App Engine
This is Rietveld 408576698