| 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(); |
| 409 } | 410 } |
| 410 return false; | 411 return false; |
| 411 } | 412 } |
| 412 | 413 |
| 413 | 414 |
| 414 void BreakLocationIterator::PrepareStepIn(Isolate* isolate) { | 415 void BreakLocationIterator::PrepareStepIn(Isolate* isolate) { |
| 415 #ifdef DEBUG | 416 #ifdef DEBUG |
| 416 HandleScope scope(isolate); | 417 HandleScope scope(isolate); |
| 417 // Step in can only be prepared if currently positioned on an IC call, | 418 // Step in can only be prepared if currently positioned on an IC call, |
| 418 // construct call or CallFunction stub call. | 419 // construct call or CallFunction stub call. |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 bool is_load_or_store = false; | 1414 bool is_load_or_store = false; |
| 1414 bool is_inline_cache_stub = false; | 1415 bool is_inline_cache_stub = false; |
| 1415 bool is_at_restarted_function = false; | 1416 bool is_at_restarted_function = false; |
| 1416 Handle<Code> call_function_stub; | 1417 Handle<Code> call_function_stub; |
| 1417 | 1418 |
| 1418 if (thread_local_.restarter_frame_function_pointer_ == NULL) { | 1419 if (thread_local_.restarter_frame_function_pointer_ == NULL) { |
| 1419 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { | 1420 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { |
| 1420 bool is_call_target = false; | 1421 bool is_call_target = false; |
| 1421 Address target = it.rinfo()->target_address(); | 1422 Address target = it.rinfo()->target_address(); |
| 1422 Code* code = Code::GetCodeFromTargetAddress(target); | 1423 Code* code = Code::GetCodeFromTargetAddress(target); |
| 1424 if (code->is_call_stub()) { |
| 1425 is_call_target = true; |
| 1426 } |
| 1423 if (code->is_inline_cache_stub()) { | 1427 if (code->is_inline_cache_stub()) { |
| 1424 is_inline_cache_stub = true; | 1428 is_inline_cache_stub = true; |
| 1425 is_load_or_store = !is_call_target; | 1429 is_load_or_store = !is_call_target; |
| 1426 } | 1430 } |
| 1427 | 1431 |
| 1428 // Check if target code is CallFunction stub. | 1432 // Check if target code is CallFunction stub. |
| 1429 Code* maybe_call_function_stub = code; | 1433 Code* maybe_call_function_stub = code; |
| 1430 // If there is a breakpoint at this line look at the original code to | 1434 // If there is a breakpoint at this line look at the original code to |
| 1431 // check if it is a CallFunction stub. | 1435 // check if it is a CallFunction stub. |
| 1432 if (it.IsDebugBreak()) { | 1436 if (it.IsDebugBreak()) { |
| 1433 Address original_target = it.original_rinfo()->target_address(); | 1437 Address original_target = it.original_rinfo()->target_address(); |
| 1434 maybe_call_function_stub = | 1438 maybe_call_function_stub = |
| 1435 Code::GetCodeFromTargetAddress(original_target); | 1439 Code::GetCodeFromTargetAddress(original_target); |
| 1436 } | 1440 } |
| 1437 if (maybe_call_function_stub->kind() == Code::STUB && | 1441 if ((maybe_call_function_stub->kind() == Code::STUB && |
| 1438 maybe_call_function_stub->major_key() == CodeStub::CallFunction) { | 1442 maybe_call_function_stub->major_key() == CodeStub::CallFunction) || |
| 1443 maybe_call_function_stub->kind() == Code::CALL_IC) { |
| 1439 // 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 |
| 1440 // count for 'step in' later. | 1445 // count for 'step in' later. |
| 1441 call_function_stub = Handle<Code>(maybe_call_function_stub); | 1446 call_function_stub = Handle<Code>(maybe_call_function_stub); |
| 1442 } | 1447 } |
| 1443 } | 1448 } |
| 1444 } else { | 1449 } else { |
| 1445 is_at_restarted_function = true; | 1450 is_at_restarted_function = true; |
| 1446 } | 1451 } |
| 1447 | 1452 |
| 1448 // 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... |
| 1484 } else { | 1489 } else { |
| 1485 // 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 |
| 1486 // to function which is going to be restarted. | 1491 // to function which is going to be restarted. |
| 1487 if (is_at_restarted_function) { | 1492 if (is_at_restarted_function) { |
| 1488 Handle<JSFunction> restarted_function( | 1493 Handle<JSFunction> restarted_function( |
| 1489 JSFunction::cast(*thread_local_.restarter_frame_function_pointer_)); | 1494 JSFunction::cast(*thread_local_.restarter_frame_function_pointer_)); |
| 1490 FloodWithOneShot(restarted_function); | 1495 FloodWithOneShot(restarted_function); |
| 1491 } else if (!call_function_stub.is_null()) { | 1496 } else if (!call_function_stub.is_null()) { |
| 1492 // 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 |
| 1493 // it with one shot breakpoints. | 1498 // it with one shot breakpoints. |
| 1499 bool is_call_ic = call_function_stub->kind() == Code::CALL_IC; |
| 1494 | 1500 |
| 1495 // Find out number of arguments from the stub minor key. | 1501 // Find out number of arguments from the stub minor key. |
| 1496 // Reverse lookup required as the minor key cannot be retrieved | 1502 // Reverse lookup required as the minor key cannot be retrieved |
| 1497 // from the code object. | 1503 // from the code object. |
| 1498 Handle<Object> obj( | 1504 Handle<Object> obj( |
| 1499 isolate_->heap()->code_stubs()->SlowReverseLookup( | 1505 isolate_->heap()->code_stubs()->SlowReverseLookup( |
| 1500 *call_function_stub), | 1506 *call_function_stub), |
| 1501 isolate_); | 1507 isolate_); |
| 1502 ASSERT(!obj.is_null()); | 1508 ASSERT(!obj.is_null()); |
| 1503 ASSERT(!(*obj)->IsUndefined()); | 1509 ASSERT(!(*obj)->IsUndefined()); |
| 1504 ASSERT(obj->IsSmi()); | 1510 ASSERT(obj->IsSmi()); |
| 1505 // Get the STUB key and extract major and minor key. | 1511 // Get the STUB key and extract major and minor key. |
| 1506 uint32_t key = Smi::cast(*obj)->value(); | 1512 uint32_t key = Smi::cast(*obj)->value(); |
| 1507 // Argc in the stub is the number of arguments passed - not the | 1513 // Argc in the stub is the number of arguments passed - not the |
| 1508 // expected arguments of the called function. | 1514 // expected arguments of the called function. |
| 1509 int call_function_arg_count = | 1515 int call_function_arg_count = is_call_ic |
| 1510 CallFunctionStub::ExtractArgcFromMinorKey( | 1516 ? CallICStub::ExtractArgcFromMinorKey(CodeStub::MinorKeyFromKey(key)) |
| 1517 : CallFunctionStub::ExtractArgcFromMinorKey( |
| 1511 CodeStub::MinorKeyFromKey(key)); | 1518 CodeStub::MinorKeyFromKey(key)); |
| 1512 ASSERT(call_function_stub->major_key() == | 1519 |
| 1513 CodeStub::MajorKeyFromKey(key)); | 1520 ASSERT(is_call_ic || |
| 1521 call_function_stub->major_key() == CodeStub::MajorKeyFromKey(key)); |
| 1514 | 1522 |
| 1515 // Find target function on the expression stack. | 1523 // Find target function on the expression stack. |
| 1516 // Expression stack looks like this (top to bottom): | 1524 // Expression stack looks like this (top to bottom): |
| 1517 // argN | 1525 // argN |
| 1518 // ... | 1526 // ... |
| 1519 // arg0 | 1527 // arg0 |
| 1520 // Receiver | 1528 // Receiver |
| 1521 // Function to call | 1529 // Function to call |
| 1522 int expressions_count = frame->ComputeExpressionsCount(); | 1530 int expressions_count = frame->ComputeExpressionsCount(); |
| 1523 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); | 1531 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 | 1639 |
| 1632 | 1640 |
| 1633 // Find the builtin to use for invoking the debug break | 1641 // Find the builtin to use for invoking the debug break |
| 1634 Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) { | 1642 Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) { |
| 1635 Isolate* isolate = code->GetIsolate(); | 1643 Isolate* isolate = code->GetIsolate(); |
| 1636 | 1644 |
| 1637 // Find the builtin debug break function matching the calling convention | 1645 // Find the builtin debug break function matching the calling convention |
| 1638 // used by the call site. | 1646 // used by the call site. |
| 1639 if (code->is_inline_cache_stub()) { | 1647 if (code->is_inline_cache_stub()) { |
| 1640 switch (code->kind()) { | 1648 switch (code->kind()) { |
| 1649 case Code::CALL_IC: |
| 1650 return isolate->builtins()->CallICStub_DebugBreak(); |
| 1651 |
| 1641 case Code::LOAD_IC: | 1652 case Code::LOAD_IC: |
| 1642 return isolate->builtins()->LoadIC_DebugBreak(); | 1653 return isolate->builtins()->LoadIC_DebugBreak(); |
| 1643 | 1654 |
| 1644 case Code::STORE_IC: | 1655 case Code::STORE_IC: |
| 1645 return isolate->builtins()->StoreIC_DebugBreak(); | 1656 return isolate->builtins()->StoreIC_DebugBreak(); |
| 1646 | 1657 |
| 1647 case Code::KEYED_LOAD_IC: | 1658 case Code::KEYED_LOAD_IC: |
| 1648 return isolate->builtins()->KeyedLoadIC_DebugBreak(); | 1659 return isolate->builtins()->KeyedLoadIC_DebugBreak(); |
| 1649 | 1660 |
| 1650 case Code::KEYED_STORE_IC: | 1661 case Code::KEYED_STORE_IC: |
| 1651 return isolate->builtins()->KeyedStoreIC_DebugBreak(); | 1662 return isolate->builtins()->KeyedStoreIC_DebugBreak(); |
| 1652 | 1663 |
| 1653 case Code::COMPARE_NIL_IC: | 1664 case Code::COMPARE_NIL_IC: |
| 1654 return isolate->builtins()->CompareNilIC_DebugBreak(); | 1665 return isolate->builtins()->CompareNilIC_DebugBreak(); |
| 1655 | 1666 |
| 1656 default: | 1667 default: |
| 1657 UNREACHABLE(); | 1668 UNREACHABLE(); |
| 1658 } | 1669 } |
| 1659 } | 1670 } |
| 1660 if (RelocInfo::IsConstructCall(mode)) { | 1671 if (RelocInfo::IsConstructCall(mode)) { |
| 1661 if (code->has_function_cache()) { | 1672 if (code->has_function_cache()) { |
| 1662 return isolate->builtins()->CallConstructStub_Recording_DebugBreak(); | 1673 return isolate->builtins()->CallConstructStub_Recording_DebugBreak(); |
| 1663 } else { | 1674 } else { |
| 1664 return isolate->builtins()->CallConstructStub_DebugBreak(); | 1675 return isolate->builtins()->CallConstructStub_DebugBreak(); |
| 1665 } | 1676 } |
| 1666 } | 1677 } |
| 1667 if (code->kind() == Code::STUB) { | 1678 if (code->kind() == Code::STUB) { |
| 1668 ASSERT(code->major_key() == CodeStub::CallFunction); | 1679 ASSERT(code->major_key() == CodeStub::CallFunction); |
| 1669 if (code->has_function_cache()) { | 1680 return isolate->builtins()->CallFunctionStub_DebugBreak(); |
| 1670 return isolate->builtins()->CallFunctionStub_Recording_DebugBreak(); | |
| 1671 } else { | |
| 1672 return isolate->builtins()->CallFunctionStub_DebugBreak(); | |
| 1673 } | |
| 1674 } | 1681 } |
| 1675 | 1682 |
| 1676 UNREACHABLE(); | 1683 UNREACHABLE(); |
| 1677 return Handle<Code>::null(); | 1684 return Handle<Code>::null(); |
| 1678 } | 1685 } |
| 1679 | 1686 |
| 1680 | 1687 |
| 1681 // Simple function for returning the source positions for active break points. | 1688 // Simple function for returning the source positions for active break points. |
| 1682 Handle<Object> Debug::GetSourceBreakLocations( | 1689 Handle<Object> Debug::GetSourceBreakLocations( |
| 1683 Handle<SharedFunctionInfo> shared, | 1690 Handle<SharedFunctionInfo> shared, |
| (...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3735 { | 3742 { |
| 3736 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3743 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
| 3737 isolate_->debugger()->CallMessageDispatchHandler(); | 3744 isolate_->debugger()->CallMessageDispatchHandler(); |
| 3738 } | 3745 } |
| 3739 } | 3746 } |
| 3740 } | 3747 } |
| 3741 | 3748 |
| 3742 #endif // ENABLE_DEBUGGER_SUPPORT | 3749 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3743 | 3750 |
| 3744 } } // namespace v8::internal | 3751 } } // namespace v8::internal |
| OLD | NEW |