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 "src/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 DCHECK_EQ(CALLS_AND_RETURNS, break_locator_type_); | 210 DCHECK_EQ(CALLS_AND_RETURNS, break_locator_type_); |
211 if (type == DEBUG_BREAK_SLOT_AT_CALL) break; | 211 if (type == DEBUG_BREAK_SLOT_AT_CALL) break; |
212 if (type == DEBUG_BREAK_SLOT_AT_RETURN) { | 212 if (type == DEBUG_BREAK_SLOT_AT_RETURN) { |
213 DCHECK_EQ(ReturnPosition(), position_); | 213 DCHECK_EQ(ReturnPosition(), position_); |
214 DCHECK_EQ(ReturnPosition(), statement_position_); | 214 DCHECK_EQ(ReturnPosition(), statement_position_); |
215 break; | 215 break; |
216 } | 216 } |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 namespace { | |
221 class BytecodePrefixHelper final { | |
rmcilroy
2016/03/16 11:55:54
As discussed offline, I think we could get rid of
oth
2016/03/17 13:48:38
Done.
| |
222 public: | |
223 BytecodePrefixHelper(BytecodeArray* bytecode_array, int offset) { | |
224 bytecode_ = interpreter::Bytecodes::FromByte(bytecode_array->get(offset)); | |
225 operand_scale_ = interpreter::Bytecodes::GetPrefixBytecodeScale(bytecode_); | |
226 if (operand_scale_ > 1) { | |
227 prefix_offset_ = 1; | |
228 bytecode_ = | |
229 interpreter::Bytecodes::FromByte(bytecode_array->get(offset + 1)); | |
230 } else { | |
231 prefix_offset_ = 0; | |
232 } | |
233 DCHECK(!interpreter::Bytecodes::IsPrefixScalingBytecode(bytecode_)); | |
234 } | |
235 | |
236 interpreter::Bytecode bytecode() const { return bytecode_; } | |
237 int operand_scale() const { return operand_scale_; } | |
238 int prefix_offset() const { return prefix_offset_; } | |
239 | |
240 private: | |
241 interpreter::Bytecode bytecode_; | |
242 int operand_scale_; | |
243 int prefix_offset_; | |
244 | |
245 DISALLOW_COPY_AND_ASSIGN(BytecodePrefixHelper); | |
246 }; | |
247 } // namespace | |
248 | |
220 BreakLocation::DebugBreakType | 249 BreakLocation::DebugBreakType |
221 BreakLocation::BytecodeArrayIterator::GetDebugBreakType() { | 250 BreakLocation::BytecodeArrayIterator::GetDebugBreakType() { |
222 BytecodeArray* bytecode_array = debug_info_->original_bytecode_array(); | 251 BytecodeArray* bytecode_array = debug_info_->original_bytecode_array(); |
223 interpreter::Bytecode bytecode = | 252 BytecodePrefixHelper bytecode_prefix_helper(bytecode_array, code_offset()); |
224 interpreter::Bytecodes::FromByte(bytecode_array->get(code_offset())); | 253 interpreter::Bytecode bytecode = bytecode_prefix_helper.bytecode(); |
225 | 254 |
226 if (bytecode == interpreter::Bytecode::kDebugger) { | 255 if (bytecode == interpreter::Bytecode::kDebugger) { |
227 return DEBUGGER_STATEMENT; | 256 return DEBUGGER_STATEMENT; |
228 } else if (bytecode == interpreter::Bytecode::kReturn) { | 257 } else if (bytecode == interpreter::Bytecode::kReturn) { |
229 return DEBUG_BREAK_SLOT_AT_RETURN; | 258 return DEBUG_BREAK_SLOT_AT_RETURN; |
230 } else if (interpreter::Bytecodes::IsCallOrNew(bytecode)) { | 259 } else if (interpreter::Bytecodes::IsCallOrNew(bytecode)) { |
231 return DEBUG_BREAK_SLOT_AT_CALL; | 260 return DEBUG_BREAK_SLOT_AT_CALL; |
232 } else if (source_position_iterator_.is_statement()) { | 261 } else if (source_position_iterator_.is_statement()) { |
233 return DEBUG_BREAK_SLOT; | 262 return DEBUG_BREAK_SLOT; |
234 } else { | 263 } else { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 if (abstract_code()->IsCode()) { | 426 if (abstract_code()->IsCode()) { |
398 Code* code = abstract_code()->GetCode(); | 427 Code* code = abstract_code()->GetCode(); |
399 DCHECK(code->kind() == Code::FUNCTION); | 428 DCHECK(code->kind() == Code::FUNCTION); |
400 Builtins* builtins = isolate()->builtins(); | 429 Builtins* builtins = isolate()->builtins(); |
401 Handle<Code> target = IsReturn() ? builtins->Return_DebugBreak() | 430 Handle<Code> target = IsReturn() ? builtins->Return_DebugBreak() |
402 : builtins->Slot_DebugBreak(); | 431 : builtins->Slot_DebugBreak(); |
403 Address pc = code->instruction_start() + code_offset(); | 432 Address pc = code->instruction_start() + code_offset(); |
404 DebugCodegen::PatchDebugBreakSlot(isolate(), pc, target); | 433 DebugCodegen::PatchDebugBreakSlot(isolate(), pc, target); |
405 } else { | 434 } else { |
406 BytecodeArray* bytecode_array = abstract_code()->GetBytecodeArray(); | 435 BytecodeArray* bytecode_array = abstract_code()->GetBytecodeArray(); |
407 interpreter::Bytecode bytecode = | 436 BytecodePrefixHelper bytecode_prefix_helper(bytecode_array, code_offset()); |
408 interpreter::Bytecodes::FromByte(bytecode_array->get(code_offset())); | 437 interpreter::Bytecode debugbreak = interpreter::Bytecodes::GetDebugBreak( |
409 interpreter::Bytecode debugbreak = | 438 bytecode_prefix_helper.bytecode(), |
410 interpreter::Bytecodes::GetDebugBreak(bytecode); | 439 bytecode_prefix_helper.operand_scale()); |
411 bytecode_array->set(code_offset(), | 440 bytecode_array->set(code_offset() + bytecode_prefix_helper.prefix_offset(), |
412 interpreter::Bytecodes::ToByte(debugbreak)); | 441 interpreter::Bytecodes::ToByte(debugbreak)); |
413 } | 442 } |
414 DCHECK(IsDebugBreak()); | 443 DCHECK(IsDebugBreak()); |
415 } | 444 } |
416 | 445 |
417 | 446 |
418 void BreakLocation::ClearDebugBreak() { | 447 void BreakLocation::ClearDebugBreak() { |
419 // Debugger statement always calls debugger. No need to modify it. | 448 // Debugger statement always calls debugger. No need to modify it. |
420 if (IsDebuggerStatement()) return; | 449 if (IsDebuggerStatement()) return; |
421 | 450 |
422 DCHECK(IsDebugBreakSlot()); | 451 DCHECK(IsDebugBreakSlot()); |
423 if (abstract_code()->IsCode()) { | 452 if (abstract_code()->IsCode()) { |
424 Code* code = abstract_code()->GetCode(); | 453 Code* code = abstract_code()->GetCode(); |
425 DCHECK(code->kind() == Code::FUNCTION); | 454 DCHECK(code->kind() == Code::FUNCTION); |
426 Address pc = code->instruction_start() + code_offset(); | 455 Address pc = code->instruction_start() + code_offset(); |
427 DebugCodegen::ClearDebugBreakSlot(isolate(), pc); | 456 DebugCodegen::ClearDebugBreakSlot(isolate(), pc); |
428 } else { | 457 } else { |
429 BytecodeArray* bytecode_array = abstract_code()->GetBytecodeArray(); | 458 BytecodeArray* bytecode_array = abstract_code()->GetBytecodeArray(); |
430 BytecodeArray* original = debug_info_->original_bytecode_array(); | 459 BytecodeArray* original = debug_info_->original_bytecode_array(); |
431 bytecode_array->set(code_offset(), original->get(code_offset())); | 460 BytecodePrefixHelper bytecode_prefix_helper(original, code_offset()); |
461 int offset = code_offset() + bytecode_prefix_helper.prefix_offset(); | |
462 bytecode_array->set(offset, original->get(offset)); | |
432 } | 463 } |
433 DCHECK(!IsDebugBreak()); | 464 DCHECK(!IsDebugBreak()); |
434 } | 465 } |
435 | 466 |
436 | 467 |
437 bool BreakLocation::IsDebugBreak() const { | 468 bool BreakLocation::IsDebugBreak() const { |
438 if (IsDebuggerStatement()) return false; | 469 if (IsDebuggerStatement()) return false; |
439 DCHECK(IsDebugBreakSlot()); | 470 DCHECK(IsDebugBreakSlot()); |
440 if (abstract_code()->IsCode()) { | 471 if (abstract_code()->IsCode()) { |
441 Code* code = abstract_code()->GetCode(); | 472 Code* code = abstract_code()->GetCode(); |
442 DCHECK(code->kind() == Code::FUNCTION); | 473 DCHECK(code->kind() == Code::FUNCTION); |
443 Address pc = code->instruction_start() + code_offset(); | 474 Address pc = code->instruction_start() + code_offset(); |
444 return DebugCodegen::DebugBreakSlotIsPatched(pc); | 475 return DebugCodegen::DebugBreakSlotIsPatched(pc); |
445 } else { | 476 } else { |
446 BytecodeArray* bytecode_array = abstract_code()->GetBytecodeArray(); | 477 BytecodeArray* bytecode_array = abstract_code()->GetBytecodeArray(); |
447 interpreter::Bytecode bytecode = | 478 BytecodePrefixHelper prefix_helper(bytecode_array, code_offset()); |
448 interpreter::Bytecodes::FromByte(bytecode_array->get(code_offset())); | 479 return interpreter::Bytecodes::IsDebugBreak(prefix_helper.bytecode()); |
449 return interpreter::Bytecodes::IsDebugBreak(bytecode); | |
450 } | 480 } |
451 } | 481 } |
452 | 482 |
453 | 483 |
454 Handle<Object> BreakLocation::BreakPointObjects() const { | 484 Handle<Object> BreakLocation::BreakPointObjects() const { |
455 return debug_info_->GetBreakPointObjects(code_offset_); | 485 return debug_info_->GetBreakPointObjects(code_offset_); |
456 } | 486 } |
457 | 487 |
458 void DebugFeatureTracker::Track(DebugFeatureTracker::Feature feature) { | 488 void DebugFeatureTracker::Track(DebugFeatureTracker::Feature feature) { |
459 uint32_t mask = 1 << feature; | 489 uint32_t mask = 1 << feature; |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1570 } | 1600 } |
1571 | 1601 |
1572 Object* Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { | 1602 Object* Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { |
1573 if (frame->is_interpreted()) { | 1603 if (frame->is_interpreted()) { |
1574 // Find the handler from the original bytecode array. | 1604 // Find the handler from the original bytecode array. |
1575 InterpretedFrame* interpreted_frame = | 1605 InterpretedFrame* interpreted_frame = |
1576 reinterpret_cast<InterpretedFrame*>(frame); | 1606 reinterpret_cast<InterpretedFrame*>(frame); |
1577 SharedFunctionInfo* shared = interpreted_frame->function()->shared(); | 1607 SharedFunctionInfo* shared = interpreted_frame->function()->shared(); |
1578 BytecodeArray* bytecode_array = shared->bytecode_array(); | 1608 BytecodeArray* bytecode_array = shared->bytecode_array(); |
1579 int bytecode_offset = interpreted_frame->GetBytecodeOffset(); | 1609 int bytecode_offset = interpreted_frame->GetBytecodeOffset(); |
1580 interpreter::Bytecode bytecode = | 1610 BytecodePrefixHelper prefix_helper(bytecode_array, bytecode_offset); |
1581 interpreter::Bytecodes::FromByte(bytecode_array->get(bytecode_offset)); | 1611 return isolate_->interpreter()->GetBytecodeHandler( |
1582 return isolate_->interpreter()->GetBytecodeHandler(bytecode); | 1612 prefix_helper.bytecode(), prefix_helper.operand_scale()); |
rmcilroy
2016/03/16 11:55:54
As discussed offline, I don't think this would wor
oth
2016/03/17 13:48:38
Done.
| |
1583 } else { | 1613 } else { |
1584 after_break_target_ = NULL; | 1614 after_break_target_ = NULL; |
1585 if (!LiveEdit::SetAfterBreakTarget(this)) { | 1615 if (!LiveEdit::SetAfterBreakTarget(this)) { |
1586 // Continue just after the slot. | 1616 // Continue just after the slot. |
1587 after_break_target_ = frame->pc(); | 1617 after_break_target_ = frame->pc(); |
1588 } | 1618 } |
1589 return isolate_->heap()->undefined_value(); | 1619 return isolate_->heap()->undefined_value(); |
1590 } | 1620 } |
1591 } | 1621 } |
1592 | 1622 |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2620 } | 2650 } |
2621 | 2651 |
2622 | 2652 |
2623 void LockingCommandMessageQueue::Clear() { | 2653 void LockingCommandMessageQueue::Clear() { |
2624 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2654 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2625 queue_.Clear(); | 2655 queue_.Clear(); |
2626 } | 2656 } |
2627 | 2657 |
2628 } // namespace internal | 2658 } // namespace internal |
2629 } // namespace v8 | 2659 } // namespace v8 |
OLD | NEW |