Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: src/runtime/runtime-debug.cc

Issue 1463803002: [debugger] flood function for stepping before calling it. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 return *Script::GetWrapper(found); 1626 return *Script::GetWrapper(found);
1627 } 1627 }
1628 1628
1629 1629
1630 bool DebugStepInIsActive(Debug* debug) { 1630 bool DebugStepInIsActive(Debug* debug) {
1631 return debug->is_active() && debug->IsStepping() && 1631 return debug->is_active() && debug->IsStepping() &&
1632 debug->last_step_action() == StepIn; 1632 debug->last_step_action() == StepIn;
1633 } 1633 }
1634 1634
1635 1635
1636 // Check whether debugger is about to step into the callback that is passed
1637 // to a built-in function such as Array.forEach. This check is done before
1638 // %DebugPrepareStepInIfStepping and is not strictly necessary. However, if it
1639 // returns false, we can skip %DebugPrepareStepInIfStepping, useful in loops.
1640 RUNTIME_FUNCTION(Runtime_DebugCallbackSupportsStepping) {
1641 SealHandleScope shs(isolate);
1642 DCHECK(args.length() == 1);
1643 if (!DebugStepInIsActive(isolate->debug())) {
1644 return isolate->heap()->false_value();
1645 }
1646 CONVERT_ARG_CHECKED(Object, object, 0);
1647 RUNTIME_ASSERT(object->IsJSFunction() || object->IsJSGeneratorObject());
1648 // We do not step into the callback if it's a builtin other than a bound,
1649 // or not even a function.
1650 JSFunction* fun;
1651 if (object->IsJSFunction()) {
1652 fun = JSFunction::cast(object);
1653 } else {
1654 fun = JSGeneratorObject::cast(object)->function();
1655 }
1656 return isolate->heap()->ToBoolean(fun->shared()->IsSubjectToDebugging() ||
1657 fun->shared()->bound());
1658 }
1659
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 1636 // 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, 1637 // 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. 1638 // if we are indeed stepping and the callback is subject to debugging.
1676 RUNTIME_FUNCTION(Runtime_DebugPrepareStepInIfStepping) { 1639 RUNTIME_FUNCTION(Runtime_DebugPrepareStepInIfStepping) {
1677 DCHECK(args.length() == 1); 1640 DCHECK(args.length() == 1);
1678 Debug* debug = isolate->debug(); 1641 Debug* debug = isolate->debug();
1679 if (!DebugStepInIsActive(debug)) return isolate->heap()->undefined_value(); 1642 if (debug->in_debug_scope() || !DebugStepInIsActive(debug)) {
1643 return isolate->heap()->undefined_value();
1644 }
1680 1645
1681 HandleScope scope(isolate); 1646 HandleScope scope(isolate);
1682 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 1647 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
1683 RUNTIME_ASSERT(object->IsJSFunction() || object->IsJSGeneratorObject()); 1648 RUNTIME_ASSERT(object->IsJSFunction() || object->IsJSGeneratorObject());
1684 Handle<JSFunction> fun; 1649 Handle<JSFunction> fun;
1685 if (object->IsJSFunction()) { 1650 if (object->IsJSFunction()) {
1686 fun = Handle<JSFunction>::cast(object); 1651 fun = Handle<JSFunction>::cast(object);
1687 } else { 1652 } else {
1688 fun = Handle<JSFunction>( 1653 fun = Handle<JSFunction>(
1689 Handle<JSGeneratorObject>::cast(object)->function(), isolate); 1654 Handle<JSGeneratorObject>::cast(object)->function(), isolate);
1690 } 1655 }
1691 1656
1692 FloodDebugSubjectWithOneShot(debug, fun); 1657 debug->ClearStepOut();
1658 debug->FloodWithOneShotGeneric(fun);
1693 return isolate->heap()->undefined_value(); 1659 return isolate->heap()->undefined_value();
1694 } 1660 }
1695 1661
1696 1662
1697 RUNTIME_FUNCTION(Runtime_DebugPushPromise) { 1663 RUNTIME_FUNCTION(Runtime_DebugPushPromise) {
1698 DCHECK(args.length() == 3); 1664 DCHECK(args.length() == 2);
1699 HandleScope scope(isolate); 1665 HandleScope scope(isolate);
1700 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); 1666 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
1701 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); 1667 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1);
1702 CONVERT_ARG_HANDLE_CHECKED(Object, handler, 2);
1703 isolate->PushPromise(promise, function); 1668 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(); 1669 return isolate->heap()->undefined_value();
1709 } 1670 }
1710 1671
1711 1672
1712 RUNTIME_FUNCTION(Runtime_DebugPopPromise) { 1673 RUNTIME_FUNCTION(Runtime_DebugPopPromise) {
1713 DCHECK(args.length() == 0); 1674 DCHECK(args.length() == 0);
1714 SealHandleScope shs(isolate); 1675 SealHandleScope shs(isolate);
1715 isolate->PopPromise(); 1676 isolate->PopPromise();
1716 return isolate->heap()->undefined_value(); 1677 return isolate->heap()->undefined_value();
1717 } 1678 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 return *isolate->factory()->undefined_value(); 1712 return *isolate->factory()->undefined_value();
1752 } 1713 }
1753 1714
1754 1715
1755 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { 1716 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
1756 UNIMPLEMENTED(); 1717 UNIMPLEMENTED();
1757 return NULL; 1718 return NULL;
1758 } 1719 }
1759 } // namespace internal 1720 } // namespace internal
1760 } // namespace v8 1721 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698