| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 bool BreakLocationIterator::IsStepInLocation(Isolate* isolate) { | 399 bool BreakLocationIterator::IsStepInLocation(Isolate* isolate) { |
| 400 if (RelocInfo::IsConstructCall(original_rmode())) { | 400 if (RelocInfo::IsConstructCall(original_rmode())) { |
| 401 return true; | 401 return true; |
| 402 } else if (RelocInfo::IsCodeTarget(rmode())) { | 402 } else if (RelocInfo::IsCodeTarget(rmode())) { |
| 403 HandleScope scope(debug_info_->GetIsolate()); | 403 HandleScope scope(debug_info_->GetIsolate()); |
| 404 Address target = original_rinfo()->target_address(); | 404 Address target = original_rinfo()->target_address(); |
| 405 Handle<Code> target_code(Code::GetCodeFromTargetAddress(target)); | 405 Handle<Code> target_code(Code::GetCodeFromTargetAddress(target)); |
| 406 if (target_code->kind() == Code::STUB) { | 406 if (target_code->kind() == Code::STUB) { |
| 407 return target_code->major_key() == CodeStub::CallFunction; | 407 return target_code->major_key() == CodeStub::CallFunction; |
| 408 } | 408 } |
| 409 return target_code->is_call_stub(); | |
| 410 } | 409 } |
| 411 return false; | 410 return false; |
| 412 } | 411 } |
| 413 | 412 |
| 414 | 413 |
| 415 void BreakLocationIterator::PrepareStepIn(Isolate* isolate) { | 414 void BreakLocationIterator::PrepareStepIn(Isolate* isolate) { |
| 416 #ifdef DEBUG | 415 #ifdef DEBUG |
| 417 HandleScope scope(isolate); | 416 HandleScope scope(isolate); |
| 418 // Step in can only be prepared if currently positioned on an IC call, | 417 // Step in can only be prepared if currently positioned on an IC call, |
| 419 // construct call or CallFunction stub call. | 418 // construct call or CallFunction stub call. |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 bool is_load_or_store = false; | 1418 bool is_load_or_store = false; |
| 1420 bool is_inline_cache_stub = false; | 1419 bool is_inline_cache_stub = false; |
| 1421 bool is_at_restarted_function = false; | 1420 bool is_at_restarted_function = false; |
| 1422 Handle<Code> call_function_stub; | 1421 Handle<Code> call_function_stub; |
| 1423 | 1422 |
| 1424 if (thread_local_.restarter_frame_function_pointer_ == NULL) { | 1423 if (thread_local_.restarter_frame_function_pointer_ == NULL) { |
| 1425 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { | 1424 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { |
| 1426 bool is_call_target = false; | 1425 bool is_call_target = false; |
| 1427 Address target = it.rinfo()->target_address(); | 1426 Address target = it.rinfo()->target_address(); |
| 1428 Code* code = Code::GetCodeFromTargetAddress(target); | 1427 Code* code = Code::GetCodeFromTargetAddress(target); |
| 1429 if (code->is_call_stub()) { | |
| 1430 is_call_target = true; | |
| 1431 } | |
| 1432 if (code->is_inline_cache_stub()) { | 1428 if (code->is_inline_cache_stub()) { |
| 1433 is_inline_cache_stub = true; | 1429 is_inline_cache_stub = true; |
| 1434 is_load_or_store = !is_call_target; | 1430 is_load_or_store = !is_call_target; |
| 1435 } | 1431 } |
| 1436 | 1432 |
| 1437 // Check if target code is CallFunction stub. | 1433 // Check if target code is CallFunction stub. |
| 1438 Code* maybe_call_function_stub = code; | 1434 Code* maybe_call_function_stub = code; |
| 1439 // If there is a breakpoint at this line look at the original code to | 1435 // If there is a breakpoint at this line look at the original code to |
| 1440 // check if it is a CallFunction stub. | 1436 // check if it is a CallFunction stub. |
| 1441 if (it.IsDebugBreak()) { | 1437 if (it.IsDebugBreak()) { |
| 1442 Address original_target = it.original_rinfo()->target_address(); | 1438 Address original_target = it.original_rinfo()->target_address(); |
| 1443 maybe_call_function_stub = | 1439 maybe_call_function_stub = |
| 1444 Code::GetCodeFromTargetAddress(original_target); | 1440 Code::GetCodeFromTargetAddress(original_target); |
| 1445 } | 1441 } |
| 1446 if ((maybe_call_function_stub->kind() == Code::STUB && | 1442 if (maybe_call_function_stub->kind() == Code::STUB && |
| 1447 maybe_call_function_stub->major_key() == CodeStub::CallFunction) || | 1443 maybe_call_function_stub->major_key() == CodeStub::CallFunction) { |
| 1448 maybe_call_function_stub->kind() == Code::CALL_IC) { | |
| 1449 // Save reference to the code as we may need it to find out arguments | 1444 // Save reference to the code as we may need it to find out arguments |
| 1450 // count for 'step in' later. | 1445 // count for 'step in' later. |
| 1451 call_function_stub = Handle<Code>(maybe_call_function_stub); | 1446 call_function_stub = Handle<Code>(maybe_call_function_stub); |
| 1452 } | 1447 } |
| 1453 } | 1448 } |
| 1454 } else { | 1449 } else { |
| 1455 is_at_restarted_function = true; | 1450 is_at_restarted_function = true; |
| 1456 } | 1451 } |
| 1457 | 1452 |
| 1458 // If this is the last break code target step out is the only possibility. | 1453 // If this is the last break code target step out is the only possibility. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 } else { | 1489 } else { |
| 1495 // If there's restarter frame on top of the stack, just get the pointer | 1490 // If there's restarter frame on top of the stack, just get the pointer |
| 1496 // to function which is going to be restarted. | 1491 // to function which is going to be restarted. |
| 1497 if (is_at_restarted_function) { | 1492 if (is_at_restarted_function) { |
| 1498 Handle<JSFunction> restarted_function( | 1493 Handle<JSFunction> restarted_function( |
| 1499 JSFunction::cast(*thread_local_.restarter_frame_function_pointer_)); | 1494 JSFunction::cast(*thread_local_.restarter_frame_function_pointer_)); |
| 1500 FloodWithOneShot(restarted_function); | 1495 FloodWithOneShot(restarted_function); |
| 1501 } else if (!call_function_stub.is_null()) { | 1496 } else if (!call_function_stub.is_null()) { |
| 1502 // If it's CallFunction stub ensure target function is compiled and flood | 1497 // If it's CallFunction stub ensure target function is compiled and flood |
| 1503 // it with one shot breakpoints. | 1498 // it with one shot breakpoints. |
| 1504 bool is_call_ic = call_function_stub->kind() == Code::CALL_IC; | |
| 1505 | 1499 |
| 1506 // Find out number of arguments from the stub minor key. | 1500 // Find out number of arguments from the stub minor key. |
| 1507 // Reverse lookup required as the minor key cannot be retrieved | 1501 // Reverse lookup required as the minor key cannot be retrieved |
| 1508 // from the code object. | 1502 // from the code object. |
| 1509 Handle<Object> obj( | 1503 Handle<Object> obj( |
| 1510 isolate_->heap()->code_stubs()->SlowReverseLookup( | 1504 isolate_->heap()->code_stubs()->SlowReverseLookup( |
| 1511 *call_function_stub), | 1505 *call_function_stub), |
| 1512 isolate_); | 1506 isolate_); |
| 1513 ASSERT(!obj.is_null()); | 1507 ASSERT(!obj.is_null()); |
| 1514 ASSERT(!(*obj)->IsUndefined()); | 1508 ASSERT(!(*obj)->IsUndefined()); |
| 1515 ASSERT(obj->IsSmi()); | 1509 ASSERT(obj->IsSmi()); |
| 1516 // Get the STUB key and extract major and minor key. | 1510 // Get the STUB key and extract major and minor key. |
| 1517 uint32_t key = Smi::cast(*obj)->value(); | 1511 uint32_t key = Smi::cast(*obj)->value(); |
| 1518 // Argc in the stub is the number of arguments passed - not the | 1512 // Argc in the stub is the number of arguments passed - not the |
| 1519 // expected arguments of the called function. | 1513 // expected arguments of the called function. |
| 1520 int call_function_arg_count = is_call_ic | 1514 int call_function_arg_count = |
| 1521 ? CallICStub::ExtractArgcFromMinorKey(CodeStub::MinorKeyFromKey(key)) | 1515 CallFunctionStub::ExtractArgcFromMinorKey( |
| 1522 : CallFunctionStub::ExtractArgcFromMinorKey( | |
| 1523 CodeStub::MinorKeyFromKey(key)); | 1516 CodeStub::MinorKeyFromKey(key)); |
| 1524 | 1517 ASSERT(call_function_stub->major_key() == |
| 1525 ASSERT(is_call_ic || | 1518 CodeStub::MajorKeyFromKey(key)); |
| 1526 call_function_stub->major_key() == CodeStub::MajorKeyFromKey(key)); | |
| 1527 | 1519 |
| 1528 // Find target function on the expression stack. | 1520 // Find target function on the expression stack. |
| 1529 // Expression stack looks like this (top to bottom): | 1521 // Expression stack looks like this (top to bottom): |
| 1530 // argN | 1522 // argN |
| 1531 // ... | 1523 // ... |
| 1532 // arg0 | 1524 // arg0 |
| 1533 // Receiver | 1525 // Receiver |
| 1534 // Function to call | 1526 // Function to call |
| 1535 int expressions_count = frame->ComputeExpressionsCount(); | 1527 int expressions_count = frame->ComputeExpressionsCount(); |
| 1536 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); | 1528 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 | 1636 |
| 1645 | 1637 |
| 1646 // Find the builtin to use for invoking the debug break | 1638 // Find the builtin to use for invoking the debug break |
| 1647 Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) { | 1639 Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) { |
| 1648 Isolate* isolate = code->GetIsolate(); | 1640 Isolate* isolate = code->GetIsolate(); |
| 1649 | 1641 |
| 1650 // Find the builtin debug break function matching the calling convention | 1642 // Find the builtin debug break function matching the calling convention |
| 1651 // used by the call site. | 1643 // used by the call site. |
| 1652 if (code->is_inline_cache_stub()) { | 1644 if (code->is_inline_cache_stub()) { |
| 1653 switch (code->kind()) { | 1645 switch (code->kind()) { |
| 1654 case Code::CALL_IC: | |
| 1655 return isolate->builtins()->CallICStub_DebugBreak(); | |
| 1656 | |
| 1657 case Code::LOAD_IC: | 1646 case Code::LOAD_IC: |
| 1658 return isolate->builtins()->LoadIC_DebugBreak(); | 1647 return isolate->builtins()->LoadIC_DebugBreak(); |
| 1659 | 1648 |
| 1660 case Code::STORE_IC: | 1649 case Code::STORE_IC: |
| 1661 return isolate->builtins()->StoreIC_DebugBreak(); | 1650 return isolate->builtins()->StoreIC_DebugBreak(); |
| 1662 | 1651 |
| 1663 case Code::KEYED_LOAD_IC: | 1652 case Code::KEYED_LOAD_IC: |
| 1664 return isolate->builtins()->KeyedLoadIC_DebugBreak(); | 1653 return isolate->builtins()->KeyedLoadIC_DebugBreak(); |
| 1665 | 1654 |
| 1666 case Code::KEYED_STORE_IC: | 1655 case Code::KEYED_STORE_IC: |
| 1667 return isolate->builtins()->KeyedStoreIC_DebugBreak(); | 1656 return isolate->builtins()->KeyedStoreIC_DebugBreak(); |
| 1668 | 1657 |
| 1669 case Code::COMPARE_NIL_IC: | 1658 case Code::COMPARE_NIL_IC: |
| 1670 return isolate->builtins()->CompareNilIC_DebugBreak(); | 1659 return isolate->builtins()->CompareNilIC_DebugBreak(); |
| 1671 | 1660 |
| 1672 default: | 1661 default: |
| 1673 UNREACHABLE(); | 1662 UNREACHABLE(); |
| 1674 } | 1663 } |
| 1675 } | 1664 } |
| 1676 if (RelocInfo::IsConstructCall(mode)) { | 1665 if (RelocInfo::IsConstructCall(mode)) { |
| 1677 if (code->has_function_cache()) { | 1666 if (code->has_function_cache()) { |
| 1678 return isolate->builtins()->CallConstructStub_Recording_DebugBreak(); | 1667 return isolate->builtins()->CallConstructStub_Recording_DebugBreak(); |
| 1679 } else { | 1668 } else { |
| 1680 return isolate->builtins()->CallConstructStub_DebugBreak(); | 1669 return isolate->builtins()->CallConstructStub_DebugBreak(); |
| 1681 } | 1670 } |
| 1682 } | 1671 } |
| 1683 if (code->kind() == Code::STUB) { | 1672 if (code->kind() == Code::STUB) { |
| 1684 ASSERT(code->major_key() == CodeStub::CallFunction); | 1673 ASSERT(code->major_key() == CodeStub::CallFunction); |
| 1685 return isolate->builtins()->CallFunctionStub_DebugBreak(); | 1674 if (code->has_function_cache()) { |
| 1675 return isolate->builtins()->CallFunctionStub_Recording_DebugBreak(); |
| 1676 } else { |
| 1677 return isolate->builtins()->CallFunctionStub_DebugBreak(); |
| 1678 } |
| 1686 } | 1679 } |
| 1687 | 1680 |
| 1688 UNREACHABLE(); | 1681 UNREACHABLE(); |
| 1689 return Handle<Code>::null(); | 1682 return Handle<Code>::null(); |
| 1690 } | 1683 } |
| 1691 | 1684 |
| 1692 | 1685 |
| 1693 // Simple function for returning the source positions for active break points. | 1686 // Simple function for returning the source positions for active break points. |
| 1694 Handle<Object> Debug::GetSourceBreakLocations( | 1687 Handle<Object> Debug::GetSourceBreakLocations( |
| 1695 Handle<SharedFunctionInfo> shared, | 1688 Handle<SharedFunctionInfo> shared, |
| (...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3818 { | 3811 { |
| 3819 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3812 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
| 3820 isolate_->debugger()->CallMessageDispatchHandler(); | 3813 isolate_->debugger()->CallMessageDispatchHandler(); |
| 3821 } | 3814 } |
| 3822 } | 3815 } |
| 3823 } | 3816 } |
| 3824 | 3817 |
| 3825 #endif // ENABLE_DEBUGGER_SUPPORT | 3818 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3826 | 3819 |
| 3827 } } // namespace v8::internal | 3820 } } // namespace v8::internal |
| OLD | NEW |