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

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

Issue 1834733002: Revert of [Interpreter] Adds support to fetch return value on break at return. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months 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') | test/mjsunit/mjsunit.status » ('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-evaluate.h" 9 #include "src/debug/debug-evaluate.h"
9 #include "src/debug/debug-frames.h" 10 #include "src/debug/debug-frames.h"
10 #include "src/debug/debug-scopes.h" 11 #include "src/debug/debug-scopes.h"
11 #include "src/debug/debug.h"
12 #include "src/frames-inl.h" 12 #include "src/frames-inl.h"
13 #include "src/interpreter/bytecodes.h"
14 #include "src/interpreter/interpreter.h"
15 #include "src/isolate-inl.h" 13 #include "src/isolate-inl.h"
16 #include "src/runtime/runtime.h" 14 #include "src/runtime/runtime.h"
17 15
18 namespace v8 { 16 namespace v8 {
19 namespace internal { 17 namespace internal {
20 18
21 RUNTIME_FUNCTION(Runtime_DebugBreak) { 19 RUNTIME_FUNCTION(Runtime_DebugBreak) {
22 SealHandleScope shs(isolate); 20 SealHandleScope shs(isolate);
23 DCHECK(args.length() == 1); 21 DCHECK(args.length() == 0);
24 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
25 isolate->debug()->set_return_value(value);
26
27 // Get the top-most JavaScript frame. 22 // Get the top-most JavaScript frame.
28 JavaScriptFrameIterator it(isolate); 23 JavaScriptFrameIterator it(isolate);
29 isolate->debug()->Break(it.frame()); 24 isolate->debug()->Break(args, it.frame());
30 25 return isolate->debug()->SetAfterBreakTarget(it.frame());
31 isolate->debug()->SetAfterBreakTarget(it.frame());
32 return *isolate->debug()->return_value();
33 }
34
35 RUNTIME_FUNCTION(Runtime_DebugBreakOnBytecode) {
36 SealHandleScope shs(isolate);
37 DCHECK(args.length() == 1);
38 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
39 isolate->debug()->set_return_value(value);
40
41 // Get the top-most JavaScript frame.
42 JavaScriptFrameIterator it(isolate);
43 isolate->debug()->Break(it.frame());
44
45 // Return the handler from the original bytecode array.
46 DCHECK(it.frame()->is_interpreted());
47 InterpretedFrame* interpreted_frame =
48 reinterpret_cast<InterpretedFrame*>(it.frame());
49 SharedFunctionInfo* shared = interpreted_frame->function()->shared();
50 BytecodeArray* bytecode_array = shared->bytecode_array();
51 int bytecode_offset = interpreted_frame->GetBytecodeOffset();
52 interpreter::Bytecode bytecode =
53 interpreter::Bytecodes::FromByte(bytecode_array->get(bytecode_offset));
54 return isolate->interpreter()->GetBytecodeHandler(
55 bytecode, interpreter::OperandScale::kSingle);
56 } 26 }
57 27
58 28
59 RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) { 29 RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) {
60 SealHandleScope shs(isolate); 30 SealHandleScope shs(isolate);
61 DCHECK(args.length() == 0); 31 DCHECK(args.length() == 0);
62 if (isolate->debug()->break_points_active()) { 32 if (isolate->debug()->break_points_active()) {
63 isolate->debug()->HandleDebugBreak(); 33 isolate->debug()->HandleDebugBreak();
64 } 34 }
65 return isolate->heap()->undefined_value(); 35 return isolate->heap()->undefined_value();
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // frame or if the frame is optimized it cannot be at a return. 584 // frame or if the frame is optimized it cannot be at a return.
615 bool at_return = false; 585 bool at_return = false;
616 if (!is_optimized && index == 0) { 586 if (!is_optimized && index == 0) {
617 at_return = isolate->debug()->IsBreakAtReturn(it.frame()); 587 at_return = isolate->debug()->IsBreakAtReturn(it.frame());
618 } 588 }
619 589
620 // If positioned just before return find the value to be returned and add it 590 // If positioned just before return find the value to be returned and add it
621 // to the frame information. 591 // to the frame information.
622 Handle<Object> return_value = isolate->factory()->undefined_value(); 592 Handle<Object> return_value = isolate->factory()->undefined_value();
623 if (at_return) { 593 if (at_return) {
624 return_value = isolate->debug()->return_value(); 594 StackFrameIterator it2(isolate);
595 Address internal_frame_sp = NULL;
596 while (!it2.done()) {
597 if (it2.frame()->is_internal()) {
598 internal_frame_sp = it2.frame()->sp();
599 } else {
600 if (it2.frame()->is_java_script()) {
601 if (it2.frame()->id() == it.frame()->id()) {
602 // The internal frame just before the JavaScript frame contains the
603 // value to return on top. A debug break at return will create an
604 // internal frame to store the return value (eax/rax/r0) before
605 // entering the debug break exit frame.
606 if (internal_frame_sp != NULL) {
607 return_value =
608 Handle<Object>(Memory::Object_at(internal_frame_sp), isolate);
609 break;
610 }
611 }
612 }
613
614 // Indicate that the previous frame was not an internal frame.
615 internal_frame_sp = NULL;
616 }
617 it2.Advance();
618 }
625 } 619 }
626 620
627 // Now advance to the arguments adapter frame (if any). It contains all 621 // Now advance to the arguments adapter frame (if any). It contains all
628 // the provided parameters whereas the function frame always have the number 622 // the provided parameters whereas the function frame always have the number
629 // of arguments matching the functions parameters. The rest of the 623 // of arguments matching the functions parameters. The rest of the
630 // information (except for what is collected above) is the same. 624 // information (except for what is collected above) is the same.
631 if ((inlined_jsframe_index == 0) && it.frame()->has_adapted_arguments()) { 625 if ((inlined_jsframe_index == 0) && it.frame()->has_adapted_arguments()) {
632 it.AdvanceToArgumentsFrame(); 626 it.AdvanceToArgumentsFrame();
633 frame_inspector.SetArgumentsFrame(it.frame()); 627 frame_inspector.SetArgumentsFrame(it.frame());
634 } 628 }
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 return Smi::FromInt(isolate->debug()->is_active()); 1652 return Smi::FromInt(isolate->debug()->is_active());
1659 } 1653 }
1660 1654
1661 1655
1662 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { 1656 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
1663 UNIMPLEMENTED(); 1657 UNIMPLEMENTED();
1664 return NULL; 1658 return NULL;
1665 } 1659 }
1666 } // namespace internal 1660 } // namespace internal
1667 } // namespace v8 1661 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698