| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/debug/debug-evaluate.h" | 9 #include "src/debug/debug-evaluate.h" |
| 10 #include "src/debug/debug-frames.h" | 10 #include "src/debug/debug-frames.h" |
| (...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1619 break; | 1619 break; |
| 1620 } | 1620 } |
| 1621 } | 1621 } |
| 1622 } | 1622 } |
| 1623 | 1623 |
| 1624 if (found.is_null()) return isolate->heap()->undefined_value(); | 1624 if (found.is_null()) return isolate->heap()->undefined_value(); |
| 1625 return *Script::GetWrapper(found); | 1625 return *Script::GetWrapper(found); |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 | 1628 |
| 1629 bool DebugStepInIsActive(Debug* debug) { | |
| 1630 return debug->is_active() && debug->IsStepping() && | |
| 1631 debug->last_step_action() == StepIn; | |
| 1632 } | |
| 1633 | |
| 1634 | |
| 1635 // Set one shot breakpoints for the callback function that is passed to a | 1629 // Set one shot breakpoints for the callback function that is passed to a |
| 1636 // built-in function such as Array.forEach to enable stepping into the callback, | 1630 // built-in function such as Array.forEach to enable stepping into the callback, |
| 1637 // if we are indeed stepping and the callback is subject to debugging. | 1631 // if we are indeed stepping and the callback is subject to debugging. |
| 1638 RUNTIME_FUNCTION(Runtime_DebugPrepareStepInIfStepping) { | 1632 RUNTIME_FUNCTION(Runtime_DebugPrepareStepInIfStepping) { |
| 1639 DCHECK(args.length() == 1); | 1633 DCHECK(args.length() == 1); |
| 1640 Debug* debug = isolate->debug(); | |
| 1641 if (debug->in_debug_scope() || !DebugStepInIsActive(debug)) { | |
| 1642 return isolate->heap()->undefined_value(); | |
| 1643 } | |
| 1644 | |
| 1645 HandleScope scope(isolate); | 1634 HandleScope scope(isolate); |
| 1646 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 1635 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 1647 RUNTIME_ASSERT(object->IsJSFunction() || object->IsJSGeneratorObject()); | 1636 RUNTIME_ASSERT(object->IsJSFunction() || object->IsJSGeneratorObject()); |
| 1648 Handle<JSFunction> fun; | 1637 Handle<JSFunction> fun; |
| 1649 if (object->IsJSFunction()) { | 1638 if (object->IsJSFunction()) { |
| 1650 fun = Handle<JSFunction>::cast(object); | 1639 fun = Handle<JSFunction>::cast(object); |
| 1651 } else { | 1640 } else { |
| 1652 fun = Handle<JSFunction>( | 1641 fun = Handle<JSFunction>( |
| 1653 Handle<JSGeneratorObject>::cast(object)->function(), isolate); | 1642 Handle<JSGeneratorObject>::cast(object)->function(), isolate); |
| 1654 } | 1643 } |
| 1655 | 1644 |
| 1656 debug->ClearStepOut(); | 1645 isolate->debug()->PrepareStepIn(fun); |
| 1657 debug->FloodWithOneShotGeneric(fun); | |
| 1658 return isolate->heap()->undefined_value(); | 1646 return isolate->heap()->undefined_value(); |
| 1659 } | 1647 } |
| 1660 | 1648 |
| 1661 | 1649 |
| 1662 RUNTIME_FUNCTION(Runtime_DebugPushPromise) { | 1650 RUNTIME_FUNCTION(Runtime_DebugPushPromise) { |
| 1663 DCHECK(args.length() == 2); | 1651 DCHECK(args.length() == 2); |
| 1664 HandleScope scope(isolate); | 1652 HandleScope scope(isolate); |
| 1665 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); | 1653 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); |
| 1666 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); | 1654 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); |
| 1667 isolate->PushPromise(promise, function); | 1655 isolate->PushPromise(promise, function); |
| 1656 // If we are in step-in mode, flood the handler. |
| 1657 isolate->debug()->EnableStepIn(); |
| 1668 return isolate->heap()->undefined_value(); | 1658 return isolate->heap()->undefined_value(); |
| 1669 } | 1659 } |
| 1670 | 1660 |
| 1671 | 1661 |
| 1672 RUNTIME_FUNCTION(Runtime_DebugPopPromise) { | 1662 RUNTIME_FUNCTION(Runtime_DebugPopPromise) { |
| 1673 DCHECK(args.length() == 0); | 1663 DCHECK(args.length() == 0); |
| 1674 SealHandleScope shs(isolate); | 1664 SealHandleScope shs(isolate); |
| 1675 isolate->PopPromise(); | 1665 isolate->PopPromise(); |
| 1676 return isolate->heap()->undefined_value(); | 1666 return isolate->heap()->undefined_value(); |
| 1677 } | 1667 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1694 return isolate->heap()->undefined_value(); | 1684 return isolate->heap()->undefined_value(); |
| 1695 } | 1685 } |
| 1696 | 1686 |
| 1697 | 1687 |
| 1698 RUNTIME_FUNCTION(Runtime_DebugIsActive) { | 1688 RUNTIME_FUNCTION(Runtime_DebugIsActive) { |
| 1699 SealHandleScope shs(isolate); | 1689 SealHandleScope shs(isolate); |
| 1700 return Smi::FromInt(isolate->debug()->is_active()); | 1690 return Smi::FromInt(isolate->debug()->is_active()); |
| 1701 } | 1691 } |
| 1702 | 1692 |
| 1703 | 1693 |
| 1704 RUNTIME_FUNCTION(Runtime_DebugHandleStepIntoAccessor) { | |
| 1705 HandleScope scope(isolate); | |
| 1706 DCHECK(args.length() == 2); | |
| 1707 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | |
| 1708 Debug* debug = isolate->debug(); | |
| 1709 // Handle stepping into constructors if step into is active. | |
| 1710 if (debug->StepInActive()) debug->HandleStepIn(function); | |
| 1711 return *isolate->factory()->undefined_value(); | |
| 1712 } | |
| 1713 | |
| 1714 | |
| 1715 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1694 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
| 1716 UNIMPLEMENTED(); | 1695 UNIMPLEMENTED(); |
| 1717 return NULL; | 1696 return NULL; |
| 1718 } | 1697 } |
| 1719 } // namespace internal | 1698 } // namespace internal |
| 1720 } // namespace v8 | 1699 } // namespace v8 |
| OLD | NEW |