Index: runtime/vm/debugger_dbc.cc |
diff --git a/runtime/vm/debugger_dbc.cc b/runtime/vm/debugger_dbc.cc |
index 5f82cd5368a10a3456def0225c9684c30ca2cadf..b4b6c1f059f85e3019f9aa94e08208906cef6e96 100644 |
--- a/runtime/vm/debugger_dbc.cc |
+++ b/runtime/vm/debugger_dbc.cc |
@@ -25,6 +25,11 @@ static Instr* CallInstructionFromReturnAddress(uword pc) { |
} |
+static Instr* FastSmiInstructionFromReturnAddress(uword pc) { |
+ return reinterpret_cast<Instr*>(pc) - 2; |
+} |
+ |
+ |
void CodeBreakpoint::PatchCode() { |
ASSERT(!is_enabled_); |
const Code& code = Code::Handle(code_); |
@@ -54,6 +59,17 @@ void CodeBreakpoint::PatchCode() { |
default: |
UNREACHABLE(); |
} |
+ |
+ // If this call is the fall-through for a fast Smi op, also disable the fast |
+ // Smi op. |
+ if ((Bytecode::DecodeOpcode(saved_value_) == Bytecode::kInstanceCall2) && |
+ Bytecode::IsFastSmiOpcode(*FastSmiInstructionFromReturnAddress(pc_))) { |
+ saved_value_fastsmi_ = *FastSmiInstructionFromReturnAddress(pc_); |
+ *FastSmiInstructionFromReturnAddress(pc_) = |
+ Bytecode::Encode(Bytecode::kNop, 0, 0, 0); |
+ } else { |
+ saved_value_fastsmi_ = Bytecode::kTrap; |
+ } |
} |
is_enabled_ = true; |
} |
@@ -75,6 +91,12 @@ void CodeBreakpoint::RestoreCode() { |
default: |
UNREACHABLE(); |
} |
+ |
+ if (saved_value_fastsmi_ != Bytecode::kTrap) { |
+ Instr current_instr = *FastSmiInstructionFromReturnAddress(pc_); |
+ ASSERT(Bytecode::DecodeOpcode(current_instr) == Bytecode::kNop); |
+ *FastSmiInstructionFromReturnAddress(pc_) = saved_value_fastsmi_; |
+ } |
} |
is_enabled_ = false; |
} |