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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 ScopedVector<char> data(s->Utf8Length() + 1); | 79 ScopedVector<char> data(s->Utf8Length() + 1); |
80 if (data.start() == NULL) { | 80 if (data.start() == NULL) { |
81 V8::FatalProcessOutOfMemory("PrintLn"); | 81 V8::FatalProcessOutOfMemory("PrintLn"); |
82 return; | 82 return; |
83 } | 83 } |
84 s->WriteUtf8(data.start()); | 84 s->WriteUtf8(data.start()); |
85 PrintF("%s\n", data.start()); | 85 PrintF("%s\n", data.start()); |
86 } | 86 } |
87 | 87 |
88 | 88 |
89 static Handle<Code> ComputeCallDebugPrepareStepIn(Isolate* isolate, | |
90 int argc, | |
91 Code::Kind kind) { | |
92 return isolate->stub_cache()->ComputeCallDebugPrepareStepIn(argc, kind); | |
93 } | |
94 | |
95 | |
96 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) { | 89 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) { |
97 Handle<Context> context = isolate->debug()->debugger_entry()->GetContext(); | 90 Handle<Context> context = isolate->debug()->debugger_entry()->GetContext(); |
98 // Isolate::context() may have been NULL when "script collected" event | 91 // Isolate::context() may have been NULL when "script collected" event |
99 // occured. | 92 // occured. |
100 if (context.is_null()) return v8::Local<v8::Context>(); | 93 if (context.is_null()) return v8::Local<v8::Context>(); |
101 Handle<Context> native_context(context->native_context()); | 94 Handle<Context> native_context(context->native_context()); |
102 return v8::Utils::ToLocal(native_context); | 95 return v8::Utils::ToLocal(native_context); |
103 } | 96 } |
104 | 97 |
105 | 98 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 bool BreakLocationIterator::IsStepInLocation(Isolate* isolate) { | 399 bool BreakLocationIterator::IsStepInLocation(Isolate* isolate) { |
407 if (RelocInfo::IsConstructCall(original_rmode())) { | 400 if (RelocInfo::IsConstructCall(original_rmode())) { |
408 return true; | 401 return true; |
409 } else if (RelocInfo::IsCodeTarget(rmode())) { | 402 } else if (RelocInfo::IsCodeTarget(rmode())) { |
410 HandleScope scope(debug_info_->GetIsolate()); | 403 HandleScope scope(debug_info_->GetIsolate()); |
411 Address target = original_rinfo()->target_address(); | 404 Address target = original_rinfo()->target_address(); |
412 Handle<Code> target_code(Code::GetCodeFromTargetAddress(target)); | 405 Handle<Code> target_code(Code::GetCodeFromTargetAddress(target)); |
413 if (target_code->kind() == Code::STUB) { | 406 if (target_code->kind() == Code::STUB) { |
414 return target_code->major_key() == CodeStub::CallFunction; | 407 return target_code->major_key() == CodeStub::CallFunction; |
415 } | 408 } |
416 return target_code->is_call_stub() || target_code->is_keyed_call_stub(); | |
417 } else { | |
418 return false; | |
419 } | 409 } |
| 410 return false; |
420 } | 411 } |
421 | 412 |
422 | 413 |
423 void BreakLocationIterator::PrepareStepIn(Isolate* isolate) { | 414 void BreakLocationIterator::PrepareStepIn(Isolate* isolate) { |
| 415 #ifdef DEBUG |
424 HandleScope scope(isolate); | 416 HandleScope scope(isolate); |
425 | |
426 // 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, |
427 // construct call or CallFunction stub call. | 418 // construct call or CallFunction stub call. |
428 Address target = rinfo()->target_address(); | 419 Address target = rinfo()->target_address(); |
429 Handle<Code> target_code(Code::GetCodeFromTargetAddress(target)); | 420 Handle<Code> target_code(Code::GetCodeFromTargetAddress(target)); |
430 if (target_code->is_call_stub() || target_code->is_keyed_call_stub()) { | 421 // All the following stuff is needed only for assertion checks so the code |
431 // Step in through IC call is handled by the runtime system. Therefore make | 422 // is wrapped in ifdef. |
432 // sure that the any current IC is cleared and the runtime system is | 423 Handle<Code> maybe_call_function_stub = target_code; |
433 // called. If the executing code has a debug break at the location change | 424 if (IsDebugBreak()) { |
434 // the call in the original code as it is the code there that will be | 425 Address original_target = original_rinfo()->target_address(); |
435 // executed in place of the debug break call. | 426 maybe_call_function_stub = |
436 Handle<Code> stub = ComputeCallDebugPrepareStepIn( | 427 Handle<Code>(Code::GetCodeFromTargetAddress(original_target)); |
437 isolate, target_code->arguments_count(), target_code->kind()); | 428 } |
438 if (IsDebugBreak()) { | 429 bool is_call_function_stub = |
439 original_rinfo()->set_target_address(stub->entry()); | 430 (maybe_call_function_stub->kind() == Code::STUB && |
440 } else { | 431 maybe_call_function_stub->major_key() == CodeStub::CallFunction); |
441 rinfo()->set_target_address(stub->entry()); | |
442 } | |
443 } else { | |
444 #ifdef DEBUG | |
445 // All the following stuff is needed only for assertion checks so the code | |
446 // is wrapped in ifdef. | |
447 Handle<Code> maybe_call_function_stub = target_code; | |
448 if (IsDebugBreak()) { | |
449 Address original_target = original_rinfo()->target_address(); | |
450 maybe_call_function_stub = | |
451 Handle<Code>(Code::GetCodeFromTargetAddress(original_target)); | |
452 } | |
453 bool is_call_function_stub = | |
454 (maybe_call_function_stub->kind() == Code::STUB && | |
455 maybe_call_function_stub->major_key() == CodeStub::CallFunction); | |
456 | 432 |
457 // Step in through construct call requires no changes to the running code. | 433 // Step in through construct call requires no changes to the running code. |
458 // Step in through getters/setters should already be prepared as well | 434 // Step in through getters/setters should already be prepared as well |
459 // because caller of this function (Debug::PrepareStep) is expected to | 435 // because caller of this function (Debug::PrepareStep) is expected to |
460 // flood the top frame's function with one shot breakpoints. | 436 // flood the top frame's function with one shot breakpoints. |
461 // Step in through CallFunction stub should also be prepared by caller of | 437 // Step in through CallFunction stub should also be prepared by caller of |
462 // this function (Debug::PrepareStep) which should flood target function | 438 // this function (Debug::PrepareStep) which should flood target function |
463 // with breakpoints. | 439 // with breakpoints. |
464 ASSERT(RelocInfo::IsConstructCall(rmode()) || | 440 ASSERT(RelocInfo::IsConstructCall(rmode()) || |
465 target_code->is_inline_cache_stub() || | 441 target_code->is_inline_cache_stub() || |
466 is_call_function_stub); | 442 is_call_function_stub); |
467 #endif | 443 #endif |
468 } | |
469 } | 444 } |
470 | 445 |
471 | 446 |
472 // Check whether the break point is at a position which will exit the function. | 447 // Check whether the break point is at a position which will exit the function. |
473 bool BreakLocationIterator::IsExit() const { | 448 bool BreakLocationIterator::IsExit() const { |
474 return (RelocInfo::IsJSReturn(rmode())); | 449 return (RelocInfo::IsJSReturn(rmode())); |
475 } | 450 } |
476 | 451 |
477 | 452 |
478 bool BreakLocationIterator::HasBreakPoint() { | 453 bool BreakLocationIterator::HasBreakPoint() { |
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 bool is_load_or_store = false; | 1418 bool is_load_or_store = false; |
1444 bool is_inline_cache_stub = false; | 1419 bool is_inline_cache_stub = false; |
1445 bool is_at_restarted_function = false; | 1420 bool is_at_restarted_function = false; |
1446 Handle<Code> call_function_stub; | 1421 Handle<Code> call_function_stub; |
1447 | 1422 |
1448 if (thread_local_.restarter_frame_function_pointer_ == NULL) { | 1423 if (thread_local_.restarter_frame_function_pointer_ == NULL) { |
1449 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { | 1424 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { |
1450 bool is_call_target = false; | 1425 bool is_call_target = false; |
1451 Address target = it.rinfo()->target_address(); | 1426 Address target = it.rinfo()->target_address(); |
1452 Code* code = Code::GetCodeFromTargetAddress(target); | 1427 Code* code = Code::GetCodeFromTargetAddress(target); |
1453 if (code->is_call_stub() || code->is_keyed_call_stub()) { | |
1454 is_call_target = true; | |
1455 } | |
1456 if (code->is_inline_cache_stub()) { | 1428 if (code->is_inline_cache_stub()) { |
1457 is_inline_cache_stub = true; | 1429 is_inline_cache_stub = true; |
1458 is_load_or_store = !is_call_target; | 1430 is_load_or_store = !is_call_target; |
1459 } | 1431 } |
1460 | 1432 |
1461 // Check if target code is CallFunction stub. | 1433 // Check if target code is CallFunction stub. |
1462 Code* maybe_call_function_stub = code; | 1434 Code* maybe_call_function_stub = code; |
1463 // 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 |
1464 // check if it is a CallFunction stub. | 1436 // check if it is a CallFunction stub. |
1465 if (it.IsDebugBreak()) { | 1437 if (it.IsDebugBreak()) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 // Expression stack looks like this (top to bottom): | 1521 // Expression stack looks like this (top to bottom): |
1550 // argN | 1522 // argN |
1551 // ... | 1523 // ... |
1552 // arg0 | 1524 // arg0 |
1553 // Receiver | 1525 // Receiver |
1554 // Function to call | 1526 // Function to call |
1555 int expressions_count = frame->ComputeExpressionsCount(); | 1527 int expressions_count = frame->ComputeExpressionsCount(); |
1556 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); | 1528 ASSERT(expressions_count - 2 - call_function_arg_count >= 0); |
1557 Object* fun = frame->GetExpression( | 1529 Object* fun = frame->GetExpression( |
1558 expressions_count - 2 - call_function_arg_count); | 1530 expressions_count - 2 - call_function_arg_count); |
| 1531 |
| 1532 // Flood the actual target of call/apply. |
| 1533 if (fun->IsJSFunction()) { |
| 1534 Isolate* isolate = JSFunction::cast(fun)->GetIsolate(); |
| 1535 Code* apply = isolate->builtins()->builtin(Builtins::kFunctionApply); |
| 1536 Code* call = isolate->builtins()->builtin(Builtins::kFunctionCall); |
| 1537 while (fun->IsJSFunction()) { |
| 1538 Code* code = JSFunction::cast(fun)->shared()->code(); |
| 1539 if (code != apply && code != call) break; |
| 1540 fun = frame->GetExpression( |
| 1541 expressions_count - 1 - call_function_arg_count); |
| 1542 } |
| 1543 } |
| 1544 |
1559 if (fun->IsJSFunction()) { | 1545 if (fun->IsJSFunction()) { |
1560 Handle<JSFunction> js_function(JSFunction::cast(fun)); | 1546 Handle<JSFunction> js_function(JSFunction::cast(fun)); |
1561 if (js_function->shared()->bound()) { | 1547 if (js_function->shared()->bound()) { |
1562 Debug::FloodBoundFunctionWithOneShot(js_function); | 1548 Debug::FloodBoundFunctionWithOneShot(js_function); |
1563 } else if (!js_function->IsBuiltin()) { | 1549 } else if (!js_function->IsBuiltin()) { |
1564 // Don't step into builtins. | 1550 // Don't step into builtins. |
1565 // It will also compile target function if it's not compiled yet. | 1551 // It will also compile target function if it's not compiled yet. |
1566 FloodWithOneShot(js_function); | 1552 FloodWithOneShot(js_function); |
1567 } | 1553 } |
1568 } | 1554 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1650 | 1636 |
1651 | 1637 |
1652 // Find the builtin to use for invoking the debug break | 1638 // Find the builtin to use for invoking the debug break |
1653 Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) { | 1639 Handle<Code> Debug::FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode) { |
1654 Isolate* isolate = code->GetIsolate(); | 1640 Isolate* isolate = code->GetIsolate(); |
1655 | 1641 |
1656 // Find the builtin debug break function matching the calling convention | 1642 // Find the builtin debug break function matching the calling convention |
1657 // used by the call site. | 1643 // used by the call site. |
1658 if (code->is_inline_cache_stub()) { | 1644 if (code->is_inline_cache_stub()) { |
1659 switch (code->kind()) { | 1645 switch (code->kind()) { |
1660 case Code::CALL_IC: | |
1661 case Code::KEYED_CALL_IC: | |
1662 return isolate->stub_cache()->ComputeCallDebugBreak( | |
1663 code->arguments_count(), code->kind()); | |
1664 | |
1665 case Code::LOAD_IC: | 1646 case Code::LOAD_IC: |
1666 return isolate->builtins()->LoadIC_DebugBreak(); | 1647 return isolate->builtins()->LoadIC_DebugBreak(); |
1667 | 1648 |
1668 case Code::STORE_IC: | 1649 case Code::STORE_IC: |
1669 return isolate->builtins()->StoreIC_DebugBreak(); | 1650 return isolate->builtins()->StoreIC_DebugBreak(); |
1670 | 1651 |
1671 case Code::KEYED_LOAD_IC: | 1652 case Code::KEYED_LOAD_IC: |
1672 return isolate->builtins()->KeyedLoadIC_DebugBreak(); | 1653 return isolate->builtins()->KeyedLoadIC_DebugBreak(); |
1673 | 1654 |
1674 case Code::KEYED_STORE_IC: | 1655 case Code::KEYED_STORE_IC: |
(...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3823 { | 3804 { |
3824 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3805 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
3825 isolate_->debugger()->CallMessageDispatchHandler(); | 3806 isolate_->debugger()->CallMessageDispatchHandler(); |
3826 } | 3807 } |
3827 } | 3808 } |
3828 } | 3809 } |
3829 | 3810 |
3830 #endif // ENABLE_DEBUGGER_SUPPORT | 3811 #endif // ENABLE_DEBUGGER_SUPPORT |
3831 | 3812 |
3832 } } // namespace v8::internal | 3813 } } // namespace v8::internal |
OLD | NEW |