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 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 if (object->IsJSFunction()) { | 1651 if (object->IsJSFunction()) { |
1652 fun = JSFunction::cast(object); | 1652 fun = JSFunction::cast(object); |
1653 } else { | 1653 } else { |
1654 fun = JSGeneratorObject::cast(object)->function(); | 1654 fun = JSGeneratorObject::cast(object)->function(); |
1655 } | 1655 } |
1656 return isolate->heap()->ToBoolean(fun->shared()->IsSubjectToDebugging() || | 1656 return isolate->heap()->ToBoolean(fun->shared()->IsSubjectToDebugging() || |
1657 fun->shared()->bound()); | 1657 fun->shared()->bound()); |
1658 } | 1658 } |
1659 | 1659 |
1660 | 1660 |
1661 void FloodDebugSubjectWithOneShot(Debug* debug, Handle<JSFunction> function) { | |
1662 if (function->shared()->IsSubjectToDebugging() || | |
1663 function->shared()->bound()) { | |
1664 // When leaving the function, step out has been activated, but not performed | |
1665 // if we do not leave the builtin. To be able to step into the function | |
1666 // again, we need to clear the step out at this point. | |
1667 debug->ClearStepOut(); | |
1668 debug->FloodWithOneShotGeneric(function); | |
1669 } | |
1670 } | |
1671 | |
1672 | |
1673 // Set one shot breakpoints for the callback function that is passed to a | 1661 // Set one shot breakpoints for the callback function that is passed to a |
1674 // built-in function such as Array.forEach to enable stepping into the callback, | 1662 // built-in function such as Array.forEach to enable stepping into the callback, |
1675 // if we are indeed stepping and the callback is subject to debugging. | 1663 // if we are indeed stepping and the callback is subject to debugging. |
1676 RUNTIME_FUNCTION(Runtime_DebugPrepareStepInIfStepping) { | 1664 RUNTIME_FUNCTION(Runtime_DebugPrepareStepInIfStepping) { |
1677 DCHECK(args.length() == 1); | 1665 DCHECK(args.length() == 1); |
1678 Debug* debug = isolate->debug(); | 1666 Debug* debug = isolate->debug(); |
1679 if (!DebugStepInIsActive(debug)) return isolate->heap()->undefined_value(); | 1667 if (debug->in_debug_scope() || !DebugStepInIsActive(debug)) { |
| 1668 return isolate->heap()->undefined_value(); |
| 1669 } |
1680 | 1670 |
1681 HandleScope scope(isolate); | 1671 HandleScope scope(isolate); |
1682 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 1672 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
1683 RUNTIME_ASSERT(object->IsJSFunction() || object->IsJSGeneratorObject()); | 1673 RUNTIME_ASSERT(object->IsJSFunction() || object->IsJSGeneratorObject()); |
1684 Handle<JSFunction> fun; | 1674 Handle<JSFunction> fun; |
1685 if (object->IsJSFunction()) { | 1675 if (object->IsJSFunction()) { |
1686 fun = Handle<JSFunction>::cast(object); | 1676 fun = Handle<JSFunction>::cast(object); |
1687 } else { | 1677 } else { |
1688 fun = Handle<JSFunction>( | 1678 fun = Handle<JSFunction>( |
1689 Handle<JSGeneratorObject>::cast(object)->function(), isolate); | 1679 Handle<JSGeneratorObject>::cast(object)->function(), isolate); |
1690 } | 1680 } |
1691 | 1681 |
1692 FloodDebugSubjectWithOneShot(debug, fun); | 1682 debug->ClearStepOut(); |
| 1683 debug->FloodWithOneShotGeneric(fun); |
1693 return isolate->heap()->undefined_value(); | 1684 return isolate->heap()->undefined_value(); |
1694 } | 1685 } |
1695 | 1686 |
1696 | 1687 |
1697 RUNTIME_FUNCTION(Runtime_DebugPushPromise) { | 1688 RUNTIME_FUNCTION(Runtime_DebugPushPromise) { |
1698 DCHECK(args.length() == 3); | 1689 DCHECK(args.length() == 2); |
1699 HandleScope scope(isolate); | 1690 HandleScope scope(isolate); |
1700 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); | 1691 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); |
1701 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); | 1692 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); |
1702 CONVERT_ARG_HANDLE_CHECKED(Object, handler, 2); | |
1703 isolate->PushPromise(promise, function); | 1693 isolate->PushPromise(promise, function); |
1704 Debug* debug = isolate->debug(); | |
1705 if (handler->IsJSFunction() && DebugStepInIsActive(debug)) { | |
1706 FloodDebugSubjectWithOneShot(debug, Handle<JSFunction>::cast(handler)); | |
1707 } | |
1708 return isolate->heap()->undefined_value(); | 1694 return isolate->heap()->undefined_value(); |
1709 } | 1695 } |
1710 | 1696 |
1711 | 1697 |
1712 RUNTIME_FUNCTION(Runtime_DebugPopPromise) { | 1698 RUNTIME_FUNCTION(Runtime_DebugPopPromise) { |
1713 DCHECK(args.length() == 0); | 1699 DCHECK(args.length() == 0); |
1714 SealHandleScope shs(isolate); | 1700 SealHandleScope shs(isolate); |
1715 isolate->PopPromise(); | 1701 isolate->PopPromise(); |
1716 return isolate->heap()->undefined_value(); | 1702 return isolate->heap()->undefined_value(); |
1717 } | 1703 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 return *isolate->factory()->undefined_value(); | 1737 return *isolate->factory()->undefined_value(); |
1752 } | 1738 } |
1753 | 1739 |
1754 | 1740 |
1755 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1741 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
1756 UNIMPLEMENTED(); | 1742 UNIMPLEMENTED(); |
1757 return NULL; | 1743 return NULL; |
1758 } | 1744 } |
1759 } // namespace internal | 1745 } // namespace internal |
1760 } // namespace v8 | 1746 } // namespace v8 |
OLD | NEW |