| 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 if (id == StackFrame::NO_ID) { | 444 if (id == StackFrame::NO_ID) { |
| 445 // If there is no JavaScript stack frame count is 0. | 445 // If there is no JavaScript stack frame count is 0. |
| 446 return Smi::FromInt(0); | 446 return Smi::FromInt(0); |
| 447 } | 447 } |
| 448 | 448 |
| 449 for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) { | 449 for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) { |
| 450 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 450 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
| 451 it.frame()->Summarize(&frames); | 451 it.frame()->Summarize(&frames); |
| 452 for (int i = frames.length() - 1; i >= 0; i--) { | 452 for (int i = frames.length() - 1; i >= 0; i--) { |
| 453 // Omit functions from native and extension scripts. | 453 // Omit functions from native and extension scripts. |
| 454 if (frames[i].function()->IsSubjectToDebugging()) n++; | 454 if (frames[i].function()->shared()->IsSubjectToDebugging()) n++; |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 return Smi::FromInt(n); | 457 return Smi::FromInt(n); |
| 458 } | 458 } |
| 459 | 459 |
| 460 | 460 |
| 461 static const int kFrameDetailsFrameIdIndex = 0; | 461 static const int kFrameDetailsFrameIdIndex = 0; |
| 462 static const int kFrameDetailsReceiverIndex = 1; | 462 static const int kFrameDetailsReceiverIndex = 1; |
| 463 static const int kFrameDetailsFunctionIndex = 2; | 463 static const int kFrameDetailsFunctionIndex = 2; |
| 464 static const int kFrameDetailsArgumentCountIndex = 3; | 464 static const int kFrameDetailsArgumentCountIndex = 3; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 isolate); | 522 isolate); |
| 523 | 523 |
| 524 // Find source position in unoptimized code. | 524 // Find source position in unoptimized code. |
| 525 int position = frame_inspector.GetSourcePosition(); | 525 int position = frame_inspector.GetSourcePosition(); |
| 526 | 526 |
| 527 // Check for constructor frame. | 527 // Check for constructor frame. |
| 528 bool constructor = frame_inspector.IsConstructor(); | 528 bool constructor = frame_inspector.IsConstructor(); |
| 529 | 529 |
| 530 // Get scope info and read from it for local variable information. | 530 // Get scope info and read from it for local variable information. |
| 531 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 531 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); |
| 532 RUNTIME_ASSERT(function->IsSubjectToDebugging()); | 532 RUNTIME_ASSERT(function->shared()->IsSubjectToDebugging()); |
| 533 Handle<SharedFunctionInfo> shared(function->shared()); | 533 Handle<SharedFunctionInfo> shared(function->shared()); |
| 534 Handle<ScopeInfo> scope_info(shared->scope_info()); | 534 Handle<ScopeInfo> scope_info(shared->scope_info()); |
| 535 DCHECK(*scope_info != ScopeInfo::Empty(isolate)); | 535 DCHECK(*scope_info != ScopeInfo::Empty(isolate)); |
| 536 | 536 |
| 537 // Get the locals names and values into a temporary array. | 537 // Get the locals names and values into a temporary array. |
| 538 int local_count = scope_info->LocalCount(); | 538 int local_count = scope_info->LocalCount(); |
| 539 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { | 539 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { |
| 540 // Hide compiler-introduced temporary variables, whether on the stack or on | 540 // Hide compiler-introduced temporary variables, whether on the stack or on |
| 541 // the context. | 541 // the context. |
| 542 if (scope_info->LocalIsSynthetic(slot)) local_count--; | 542 if (scope_info->LocalIsSynthetic(slot)) local_count--; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 details->set(details_index++, locals->get(i)); | 698 details->set(details_index++, locals->get(i)); |
| 699 } | 699 } |
| 700 | 700 |
| 701 // Add the value being returned. | 701 // Add the value being returned. |
| 702 if (at_return) { | 702 if (at_return) { |
| 703 details->set(details_index++, *return_value); | 703 details->set(details_index++, *return_value); |
| 704 } | 704 } |
| 705 | 705 |
| 706 // Add the receiver (same as in function frame). | 706 // Add the receiver (same as in function frame). |
| 707 Handle<Object> receiver(it.frame()->receiver(), isolate); | 707 Handle<Object> receiver(it.frame()->receiver(), isolate); |
| 708 DCHECK(!function->IsBuiltin()); | 708 DCHECK(!function->shared()->IsBuiltin()); |
| 709 if (!receiver->IsJSObject() && is_sloppy(shared->language_mode())) { | 709 if (!receiver->IsJSObject() && is_sloppy(shared->language_mode())) { |
| 710 // If the receiver is not a JSObject and the function is not a builtin or | 710 // If the receiver is not a JSObject and the function is not a builtin or |
| 711 // strict-mode we have hit an optimization where a value object is not | 711 // strict-mode we have hit an optimization where a value object is not |
| 712 // converted into a wrapped JS objects. To hide this optimization from the | 712 // converted into a wrapped JS objects. To hide this optimization from the |
| 713 // debugger, we wrap the receiver by creating correct wrapper object based | 713 // debugger, we wrap the receiver by creating correct wrapper object based |
| 714 // on the function's native context. | 714 // on the function's native context. |
| 715 // See ECMA-262 6.0, 9.2.1.2, 6 b iii. | 715 // See ECMA-262 6.0, 9.2.1.2, 6 b iii. |
| 716 if (receiver->IsUndefined()) { | 716 if (receiver->IsUndefined()) { |
| 717 receiver = handle(function->global_proxy()); | 717 receiver = handle(function->global_proxy()); |
| 718 } else { | 718 } else { |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 CONVERT_ARG_CHECKED(Object, object, 0); | 1631 CONVERT_ARG_CHECKED(Object, object, 0); |
| 1632 RUNTIME_ASSERT(object->IsJSFunction() || object->IsJSGeneratorObject()); | 1632 RUNTIME_ASSERT(object->IsJSFunction() || object->IsJSGeneratorObject()); |
| 1633 // We do not step into the callback if it's a builtin other than a bound, | 1633 // We do not step into the callback if it's a builtin other than a bound, |
| 1634 // or not even a function. | 1634 // or not even a function. |
| 1635 JSFunction* fun; | 1635 JSFunction* fun; |
| 1636 if (object->IsJSFunction()) { | 1636 if (object->IsJSFunction()) { |
| 1637 fun = JSFunction::cast(object); | 1637 fun = JSFunction::cast(object); |
| 1638 } else { | 1638 } else { |
| 1639 fun = JSGeneratorObject::cast(object)->function(); | 1639 fun = JSGeneratorObject::cast(object)->function(); |
| 1640 } | 1640 } |
| 1641 return isolate->heap()->ToBoolean(fun->IsSubjectToDebugging() || | 1641 return isolate->heap()->ToBoolean(fun->shared()->IsSubjectToDebugging() || |
| 1642 fun->shared()->bound()); | 1642 fun->shared()->bound()); |
| 1643 } | 1643 } |
| 1644 | 1644 |
| 1645 | 1645 |
| 1646 void FloodDebugSubjectWithOneShot(Debug* debug, Handle<JSFunction> function) { | 1646 void FloodDebugSubjectWithOneShot(Debug* debug, Handle<JSFunction> function) { |
| 1647 if (function->IsSubjectToDebugging() || function->shared()->bound()) { | 1647 if (function->shared()->IsSubjectToDebugging() || |
| 1648 function->shared()->bound()) { |
| 1648 // When leaving the function, step out has been activated, but not performed | 1649 // When leaving the function, step out has been activated, but not performed |
| 1649 // if we do not leave the builtin. To be able to step into the function | 1650 // if we do not leave the builtin. To be able to step into the function |
| 1650 // again, we need to clear the step out at this point. | 1651 // again, we need to clear the step out at this point. |
| 1651 debug->ClearStepOut(); | 1652 debug->ClearStepOut(); |
| 1652 debug->FloodWithOneShotGeneric(function); | 1653 debug->FloodWithOneShotGeneric(function); |
| 1653 } | 1654 } |
| 1654 } | 1655 } |
| 1655 | 1656 |
| 1656 | 1657 |
| 1657 // Set one shot breakpoints for the callback function that is passed to a | 1658 // Set one shot breakpoints for the callback function that is passed to a |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 return *isolate->factory()->undefined_value(); | 1736 return *isolate->factory()->undefined_value(); |
| 1736 } | 1737 } |
| 1737 | 1738 |
| 1738 | 1739 |
| 1739 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1740 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
| 1740 UNIMPLEMENTED(); | 1741 UNIMPLEMENTED(); |
| 1741 return NULL; | 1742 return NULL; |
| 1742 } | 1743 } |
| 1743 } // namespace internal | 1744 } // namespace internal |
| 1744 } // namespace v8 | 1745 } // namespace v8 |
| OLD | NEW |