| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 int CodeBreakIterator::GetModeMask(BreakLocatorType type) { | 187 int CodeBreakIterator::GetModeMask(BreakLocatorType type) { |
| 188 int mask = 0; | 188 int mask = 0; |
| 189 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); | 189 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); |
| 190 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_CALL); | 190 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_CALL); |
| 191 if (isolate()->is_tail_call_elimination_enabled()) { | 191 if (isolate()->is_tail_call_elimination_enabled()) { |
| 192 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL); | 192 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL); |
| 193 } | 193 } |
| 194 if (type == ALL_BREAK_LOCATIONS) { | 194 if (type == ALL_BREAK_LOCATIONS) { |
| 195 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); | 195 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); |
| 196 mask |= RelocInfo::ModeMask(RelocInfo::DEBUGGER_STATEMENT); | |
| 197 } | 196 } |
| 198 return mask; | 197 return mask; |
| 199 } | 198 } |
| 200 | 199 |
| 201 void CodeBreakIterator::Next() { | 200 void CodeBreakIterator::Next() { |
| 202 DisallowHeapAllocation no_gc; | 201 DisallowHeapAllocation no_gc; |
| 203 DCHECK(!Done()); | 202 DCHECK(!Done()); |
| 204 | 203 |
| 205 // Iterate through reloc info stopping at each breakable code target. | 204 // Iterate through reloc info stopping at each breakable code target. |
| 206 bool first = break_index_ == -1; | 205 bool first = break_index_ == -1; |
| 207 | 206 |
| 208 if (!first) reloc_iterator_.next(); | 207 if (!first) reloc_iterator_.next(); |
| 209 first = false; | 208 first = false; |
| 210 if (Done()) return; | 209 if (Done()) return; |
| 211 | 210 |
| 212 int offset = code_offset(); | 211 int offset = code_offset(); |
| 213 while (!source_position_iterator_.done() && | 212 while (!source_position_iterator_.done() && |
| 214 source_position_iterator_.code_offset() <= offset) { | 213 source_position_iterator_.code_offset() <= offset) { |
| 215 position_ = source_position_iterator_.source_position().ScriptOffset(); | 214 position_ = source_position_iterator_.source_position().ScriptOffset(); |
| 216 if (source_position_iterator_.is_statement()) { | 215 if (source_position_iterator_.is_statement()) { |
| 217 statement_position_ = position_; | 216 statement_position_ = position_; |
| 218 } | 217 } |
| 219 source_position_iterator_.Advance(); | 218 source_position_iterator_.Advance(); |
| 220 } | 219 } |
| 221 | 220 |
| 222 DCHECK(RelocInfo::IsDebugBreakSlot(rmode()) || | 221 DCHECK(RelocInfo::IsDebugBreakSlot(rmode())); |
| 223 RelocInfo::IsDebuggerStatement(rmode())); | |
| 224 break_index_++; | 222 break_index_++; |
| 225 } | 223 } |
| 226 | 224 |
| 227 DebugBreakType CodeBreakIterator::GetDebugBreakType() { | 225 DebugBreakType CodeBreakIterator::GetDebugBreakType() { |
| 228 if (RelocInfo::IsDebugBreakSlotAtReturn(rmode())) { | 226 if (RelocInfo::IsDebugBreakSlotAtReturn(rmode())) { |
| 229 return DEBUG_BREAK_SLOT_AT_RETURN; | 227 return DEBUG_BREAK_SLOT_AT_RETURN; |
| 230 } else if (RelocInfo::IsDebugBreakSlotAtCall(rmode())) { | 228 } else if (RelocInfo::IsDebugBreakSlotAtCall(rmode())) { |
| 231 return DEBUG_BREAK_SLOT_AT_CALL; | 229 return DEBUG_BREAK_SLOT_AT_CALL; |
| 232 } else if (RelocInfo::IsDebugBreakSlotAtTailCall(rmode())) { | 230 } else if (RelocInfo::IsDebugBreakSlotAtTailCall(rmode())) { |
| 233 return isolate()->is_tail_call_elimination_enabled() | 231 return isolate()->is_tail_call_elimination_enabled() |
| 234 ? DEBUG_BREAK_SLOT_AT_TAIL_CALL | 232 ? DEBUG_BREAK_SLOT_AT_TAIL_CALL |
| 235 : DEBUG_BREAK_SLOT_AT_CALL; | 233 : DEBUG_BREAK_SLOT_AT_CALL; |
| 236 } else if (RelocInfo::IsDebuggerStatement(rmode())) { | |
| 237 return DEBUGGER_STATEMENT; | |
| 238 } else if (RelocInfo::IsDebugBreakSlot(rmode())) { | 234 } else if (RelocInfo::IsDebugBreakSlot(rmode())) { |
| 239 return DEBUG_BREAK_SLOT; | 235 return DEBUG_BREAK_SLOT; |
| 240 } else { | 236 } else { |
| 241 return NOT_DEBUG_BREAK; | 237 return NOT_DEBUG_BREAK; |
| 242 } | 238 } |
| 243 } | 239 } |
| 244 | 240 |
| 245 void CodeBreakIterator::SkipToPosition(int position, | 241 void CodeBreakIterator::SkipToPosition(int position, |
| 246 BreakPositionAlignment alignment) { | 242 BreakPositionAlignment alignment) { |
| 247 CodeBreakIterator it(debug_info_, break_locator_type_); | 243 CodeBreakIterator it(debug_info_, break_locator_type_); |
| 248 SkipTo(it.BreakIndexFromPosition(position, alignment)); | 244 SkipTo(it.BreakIndexFromPosition(position, alignment)); |
| 249 } | 245 } |
| 250 | 246 |
| 251 void CodeBreakIterator::SetDebugBreak() { | 247 void CodeBreakIterator::SetDebugBreak() { |
| 252 DebugBreakType debug_break_type = GetDebugBreakType(); | 248 DebugBreakType debug_break_type = GetDebugBreakType(); |
| 253 if (debug_break_type == DEBUGGER_STATEMENT) return; | |
| 254 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); | 249 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); |
| 255 Builtins* builtins = isolate()->builtins(); | 250 Builtins* builtins = isolate()->builtins(); |
| 256 Handle<Code> target = debug_break_type == DEBUG_BREAK_SLOT_AT_RETURN | 251 Handle<Code> target = debug_break_type == DEBUG_BREAK_SLOT_AT_RETURN |
| 257 ? builtins->Return_DebugBreak() | 252 ? builtins->Return_DebugBreak() |
| 258 : builtins->Slot_DebugBreak(); | 253 : builtins->Slot_DebugBreak(); |
| 259 DebugCodegen::PatchDebugBreakSlot(isolate(), rinfo()->pc(), target); | 254 DebugCodegen::PatchDebugBreakSlot(isolate(), rinfo()->pc(), target); |
| 260 } | 255 } |
| 261 | 256 |
| 262 void CodeBreakIterator::ClearDebugBreak() { | 257 void CodeBreakIterator::ClearDebugBreak() { |
| 263 DebugBreakType debug_break_type = GetDebugBreakType(); | 258 DebugBreakType debug_break_type = GetDebugBreakType(); |
| 264 if (debug_break_type == DEBUGGER_STATEMENT) return; | |
| 265 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); | 259 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); |
| 266 DebugCodegen::ClearDebugBreakSlot(isolate(), rinfo()->pc()); | 260 DebugCodegen::ClearDebugBreakSlot(isolate(), rinfo()->pc()); |
| 267 } | 261 } |
| 268 | 262 |
| 269 bool CodeBreakIterator::IsDebugBreak() { | 263 bool CodeBreakIterator::IsDebugBreak() { |
| 270 DebugBreakType debug_break_type = GetDebugBreakType(); | 264 DebugBreakType debug_break_type = GetDebugBreakType(); |
| 271 if (debug_break_type == DEBUGGER_STATEMENT) return false; | |
| 272 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); | 265 DCHECK(debug_break_type >= DEBUG_BREAK_SLOT); |
| 273 return DebugCodegen::DebugBreakSlotIsPatched(rinfo()->pc()); | 266 return DebugCodegen::DebugBreakSlotIsPatched(rinfo()->pc()); |
| 274 } | 267 } |
| 275 | 268 |
| 276 BreakLocation CodeBreakIterator::GetBreakLocation() { | 269 BreakLocation CodeBreakIterator::GetBreakLocation() { |
| 277 Handle<AbstractCode> code(AbstractCode::cast(debug_info_->DebugCode())); | 270 Handle<AbstractCode> code(AbstractCode::cast(debug_info_->DebugCode())); |
| 278 return BreakLocation(code, GetDebugBreakType(), code_offset(), position_); | 271 return BreakLocation(code, GetDebugBreakType(), code_offset(), position_); |
| 279 } | 272 } |
| 280 | 273 |
| 281 BytecodeArrayBreakIterator::BytecodeArrayBreakIterator( | 274 BytecodeArrayBreakIterator::BytecodeArrayBreakIterator( |
| (...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 return v8::Utils::ToLocal(callback_data_); | 2327 return v8::Utils::ToLocal(callback_data_); |
| 2335 } | 2328 } |
| 2336 | 2329 |
| 2337 | 2330 |
| 2338 v8::Isolate* EventDetailsImpl::GetIsolate() const { | 2331 v8::Isolate* EventDetailsImpl::GetIsolate() const { |
| 2339 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); | 2332 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); |
| 2340 } | 2333 } |
| 2341 | 2334 |
| 2342 } // namespace internal | 2335 } // namespace internal |
| 2343 } // namespace v8 | 2336 } // namespace v8 |
| OLD | NEW |