| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/debug/debug.h" | 5 #include "src/debug/debug.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 DCHECK(!Done()); | 176 DCHECK(!Done()); |
| 177 Next(); | 177 Next(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 int CodeBreakIterator::GetModeMask() { | 180 int CodeBreakIterator::GetModeMask() { |
| 181 int mask = 0; | 181 int mask = 0; |
| 182 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); | 182 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); |
| 183 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_CALL); | 183 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_CALL); |
| 184 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL); | 184 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL); |
| 185 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); | 185 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); |
| 186 mask |= RelocInfo::ModeMask(RelocInfo::DEBUGGER_STATEMENT); | |
| 187 return mask; | 186 return mask; |
| 188 } | 187 } |
| 189 | 188 |
| 190 void CodeBreakIterator::Next() { | 189 void CodeBreakIterator::Next() { |
| 191 DisallowHeapAllocation no_gc; | 190 DisallowHeapAllocation no_gc; |
| 192 DCHECK(!Done()); | 191 DCHECK(!Done()); |
| 193 | 192 |
| 194 // Iterate through reloc info stopping at each breakable code target. | 193 // Iterate through reloc info stopping at each breakable code target. |
| 195 bool first = break_index_ == -1; | 194 bool first = break_index_ == -1; |
| 196 | 195 |
| 197 if (!first) reloc_iterator_.next(); | 196 if (!first) reloc_iterator_.next(); |
| 198 first = false; | 197 first = false; |
| 199 if (Done()) return; | 198 if (Done()) return; |
| 200 | 199 |
| 201 int offset = code_offset(); | 200 int offset = code_offset(); |
| 202 while (!source_position_iterator_.done() && | 201 while (!source_position_iterator_.done() && |
| 203 source_position_iterator_.code_offset() <= offset) { | 202 source_position_iterator_.code_offset() <= offset) { |
| 204 position_ = source_position_iterator_.source_position().ScriptOffset(); | 203 position_ = source_position_iterator_.source_position().ScriptOffset(); |
| 205 if (source_position_iterator_.is_statement()) { | 204 if (source_position_iterator_.is_statement()) { |
| 206 statement_position_ = position_; | 205 statement_position_ = position_; |
| 207 } | 206 } |
| 208 source_position_iterator_.Advance(); | 207 source_position_iterator_.Advance(); |
| 209 } | 208 } |
| 210 | 209 |
| 211 DCHECK(RelocInfo::IsDebugBreakSlot(rmode()) || | 210 DCHECK(RelocInfo::IsDebugBreakSlot(rmode())); |
| 212 RelocInfo::IsDebuggerStatement(rmode())); | |
| 213 break_index_++; | 211 break_index_++; |
| 214 } | 212 } |
| 215 | 213 |
| 216 DebugBreakType CodeBreakIterator::GetDebugBreakType() { | 214 DebugBreakType CodeBreakIterator::GetDebugBreakType() { |
| 217 if (RelocInfo::IsDebugBreakSlotAtReturn(rmode())) { | 215 if (RelocInfo::IsDebugBreakSlotAtReturn(rmode())) { |
| 218 return DEBUG_BREAK_SLOT_AT_RETURN; | 216 return DEBUG_BREAK_SLOT_AT_RETURN; |
| 219 } else if (RelocInfo::IsDebugBreakSlotAtCall(rmode())) { | 217 } else if (RelocInfo::IsDebugBreakSlotAtCall(rmode())) { |
| 220 return DEBUG_BREAK_SLOT_AT_CALL; | 218 return DEBUG_BREAK_SLOT_AT_CALL; |
| 221 } else if (RelocInfo::IsDebugBreakSlotAtTailCall(rmode())) { | 219 } else if (RelocInfo::IsDebugBreakSlotAtTailCall(rmode())) { |
| 222 return isolate()->is_tail_call_elimination_enabled() | 220 return isolate()->is_tail_call_elimination_enabled() |
| 223 ? DEBUG_BREAK_SLOT_AT_TAIL_CALL | 221 ? DEBUG_BREAK_SLOT_AT_TAIL_CALL |
| 224 : DEBUG_BREAK_SLOT_AT_CALL; | 222 : DEBUG_BREAK_SLOT_AT_CALL; |
| 225 } else if (RelocInfo::IsDebuggerStatement(rmode())) { | |
| 226 return DEBUGGER_STATEMENT; | |
| 227 } else if (RelocInfo::IsDebugBreakSlot(rmode())) { | 223 } else if (RelocInfo::IsDebugBreakSlot(rmode())) { |
| 228 return DEBUG_BREAK_SLOT; | 224 return DEBUG_BREAK_SLOT; |
| 229 } else { | 225 } else { |
| 230 return NOT_DEBUG_BREAK; | 226 return NOT_DEBUG_BREAK; |
| 231 } | 227 } |
| 232 } | 228 } |
| 233 | 229 |
| 234 void CodeBreakIterator::SkipToPosition(int position, | 230 void CodeBreakIterator::SkipToPosition(int position, |
| 235 BreakPositionAlignment alignment) { | 231 BreakPositionAlignment alignment) { |
| 236 CodeBreakIterator it(debug_info_); | 232 CodeBreakIterator it(debug_info_); |
| 237 SkipTo(it.BreakIndexFromPosition(position, alignment)); | 233 SkipTo(it.BreakIndexFromPosition(position, alignment)); |
| 238 } | 234 } |
| 239 | 235 |
| 240 void CodeBreakIterator::SetDebugBreak() { | 236 void CodeBreakIterator::SetDebugBreak() { |
| 241 DebugBreakType debug_break_type = GetDebugBreakType(); | 237 DebugBreakType debug_break_type = GetDebugBreakType(); |
| 242 if (debug_break_type == DEBUGGER_STATEMENT) return; | |
| 243 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); | 238 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); |
| 244 Builtins* builtins = isolate()->builtins(); | 239 Builtins* builtins = isolate()->builtins(); |
| 245 Handle<Code> target = debug_break_type == DEBUG_BREAK_SLOT_AT_RETURN | 240 Handle<Code> target = debug_break_type == DEBUG_BREAK_SLOT_AT_RETURN |
| 246 ? builtins->Return_DebugBreak() | 241 ? builtins->Return_DebugBreak() |
| 247 : builtins->Slot_DebugBreak(); | 242 : builtins->Slot_DebugBreak(); |
| 248 DebugCodegen::PatchDebugBreakSlot(isolate(), rinfo()->pc(), target); | 243 DebugCodegen::PatchDebugBreakSlot(isolate(), rinfo()->pc(), target); |
| 249 } | 244 } |
| 250 | 245 |
| 251 void CodeBreakIterator::ClearDebugBreak() { | 246 void CodeBreakIterator::ClearDebugBreak() { |
| 252 DebugBreakType debug_break_type = GetDebugBreakType(); | 247 DCHECK(GetDebugBreakType() >= DEBUG_BREAK_SLOT); |
| 253 if (debug_break_type == DEBUGGER_STATEMENT) return; | |
| 254 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); | |
| 255 DebugCodegen::ClearDebugBreakSlot(isolate(), rinfo()->pc()); | 248 DebugCodegen::ClearDebugBreakSlot(isolate(), rinfo()->pc()); |
| 256 } | 249 } |
| 257 | 250 |
| 258 bool CodeBreakIterator::IsDebugBreak() { | 251 bool CodeBreakIterator::IsDebugBreak() { |
| 259 DebugBreakType debug_break_type = GetDebugBreakType(); | 252 DCHECK(GetDebugBreakType() >= DEBUG_BREAK_SLOT); |
| 260 if (debug_break_type == DEBUGGER_STATEMENT) return false; | |
| 261 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); | |
| 262 return DebugCodegen::DebugBreakSlotIsPatched(rinfo()->pc()); | 253 return DebugCodegen::DebugBreakSlotIsPatched(rinfo()->pc()); |
| 263 } | 254 } |
| 264 | 255 |
| 265 BreakLocation CodeBreakIterator::GetBreakLocation() { | 256 BreakLocation CodeBreakIterator::GetBreakLocation() { |
| 266 Handle<AbstractCode> code(AbstractCode::cast(debug_info_->DebugCode())); | 257 Handle<AbstractCode> code(AbstractCode::cast(debug_info_->DebugCode())); |
| 267 return BreakLocation(code, GetDebugBreakType(), code_offset(), position_); | 258 return BreakLocation(code, GetDebugBreakType(), code_offset(), position_); |
| 268 } | 259 } |
| 269 | 260 |
| 270 BytecodeArrayBreakIterator::BytecodeArrayBreakIterator( | 261 BytecodeArrayBreakIterator::BytecodeArrayBreakIterator( |
| 271 Handle<DebugInfo> debug_info) | 262 Handle<DebugInfo> debug_info) |
| (...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2417 isolate_->Throw(*isolate_->factory()->NewEvalError( | 2408 isolate_->Throw(*isolate_->factory()->NewEvalError( |
| 2418 MessageTemplate::kNoSideEffectDebugEvaluate)); | 2409 MessageTemplate::kNoSideEffectDebugEvaluate)); |
| 2419 } | 2410 } |
| 2420 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); | 2411 isolate_->set_needs_side_effect_check(old_needs_side_effect_check_); |
| 2421 isolate_->debug()->UpdateHookOnFunctionCall(); | 2412 isolate_->debug()->UpdateHookOnFunctionCall(); |
| 2422 isolate_->debug()->side_effect_check_failed_ = false; | 2413 isolate_->debug()->side_effect_check_failed_ = false; |
| 2423 } | 2414 } |
| 2424 | 2415 |
| 2425 } // namespace internal | 2416 } // namespace internal |
| 2426 } // namespace v8 | 2417 } // namespace v8 |
| OLD | NEW |