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

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

Issue 2636913002: [liveedit] reimplement frame restarting. (Closed)
Patch Set: Created 3 years, 11 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
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/compiler.h" 8 #include "src/compiler.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"
11 #include "src/debug/debug-scopes.h" 11 #include "src/debug/debug-scopes.h"
12 #include "src/debug/debug.h" 12 #include "src/debug/debug.h"
13 #include "src/debug/liveedit.h" 13 #include "src/debug/liveedit.h"
14 #include "src/frames-inl.h" 14 #include "src/frames-inl.h"
15 #include "src/globals.h" 15 #include "src/globals.h"
16 #include "src/interpreter/bytecodes.h" 16 #include "src/interpreter/bytecodes.h"
17 #include "src/interpreter/interpreter.h" 17 #include "src/interpreter/interpreter.h"
18 #include "src/isolate-inl.h" 18 #include "src/isolate-inl.h"
19 #include "src/runtime/runtime.h" 19 #include "src/runtime/runtime.h"
20 #include "src/wasm/wasm-module.h" 20 #include "src/wasm/wasm-module.h"
21 #include "src/wasm/wasm-objects.h" 21 #include "src/wasm/wasm-objects.h"
22 22
23 namespace v8 { 23 namespace v8 {
24 namespace internal { 24 namespace internal {
25 25
26 RUNTIME_FUNCTION(Runtime_DebugBreak) { 26 RUNTIME_FUNCTION(Runtime_DebugBreak) {
27 SealHandleScope shs(isolate); 27 SealHandleScope shs(isolate);
28 DCHECK_EQ(1, args.length()); 28 DCHECK_EQ(1, args.length());
29 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); 29 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
30 isolate->debug()->set_return_value(value); 30 isolate->debug()->set_return_value(*value);
31 31
32 // Get the top-most JavaScript frame. 32 // Get the top-most JavaScript frame.
33 JavaScriptFrameIterator it(isolate); 33 JavaScriptFrameIterator it(isolate);
34 isolate->debug()->Break(it.frame()); 34 isolate->debug()->Break(it.frame());
35 35 return isolate->debug()->return_value();
36 isolate->debug()->SetAfterBreakTarget(it.frame());
37 return *isolate->debug()->return_value();
38 } 36 }
39 37
40 RUNTIME_FUNCTION(Runtime_DebugBreakOnBytecode) { 38 RUNTIME_FUNCTION(Runtime_DebugBreakOnBytecode) {
41 SealHandleScope shs(isolate); 39 SealHandleScope shs(isolate);
42 DCHECK_EQ(1, args.length()); 40 DCHECK_EQ(1, args.length());
43 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); 41 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
44 isolate->debug()->set_return_value(value); 42 isolate->debug()->set_return_value(*value);
45 43
46 // Get the top-most JavaScript frame. 44 // Get the top-most JavaScript frame.
47 JavaScriptFrameIterator it(isolate); 45 JavaScriptFrameIterator it(isolate);
48 isolate->debug()->Break(it.frame()); 46 isolate->debug()->Break(it.frame());
49 47
50 // If live-edit has dropped frames, we are not going back to dispatch.
51 if (LiveEdit::SetAfterBreakTarget(isolate->debug())) return Smi::kZero;
52
53 // Return the handler from the original bytecode array. 48 // Return the handler from the original bytecode array.
54 DCHECK(it.frame()->is_interpreted()); 49 DCHECK(it.frame()->is_interpreted());
55 InterpretedFrame* interpreted_frame = 50 InterpretedFrame* interpreted_frame =
56 reinterpret_cast<InterpretedFrame*>(it.frame()); 51 reinterpret_cast<InterpretedFrame*>(it.frame());
57 SharedFunctionInfo* shared = interpreted_frame->function()->shared(); 52 SharedFunctionInfo* shared = interpreted_frame->function()->shared();
58 BytecodeArray* bytecode_array = shared->bytecode_array(); 53 BytecodeArray* bytecode_array = shared->bytecode_array();
59 int bytecode_offset = interpreted_frame->GetBytecodeOffset(); 54 int bytecode_offset = interpreted_frame->GetBytecodeOffset();
60 interpreter::Bytecode bytecode = 55 interpreter::Bytecode bytecode =
61 interpreter::Bytecodes::FromByte(bytecode_array->get(bytecode_offset)); 56 interpreter::Bytecodes::FromByte(bytecode_array->get(bytecode_offset));
62 return isolate->interpreter()->GetBytecodeHandler( 57 return isolate->interpreter()->GetBytecodeHandler(
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 // frame or if the frame is optimized it cannot be at a return. 620 // frame or if the frame is optimized it cannot be at a return.
626 bool at_return = false; 621 bool at_return = false;
627 if (!is_optimized && index == 0) { 622 if (!is_optimized && index == 0) {
628 at_return = isolate->debug()->IsBreakAtReturn(it.javascript_frame()); 623 at_return = isolate->debug()->IsBreakAtReturn(it.javascript_frame());
629 } 624 }
630 625
631 // If positioned just before return find the value to be returned and add it 626 // If positioned just before return find the value to be returned and add it
632 // to the frame information. 627 // to the frame information.
633 Handle<Object> return_value = isolate->factory()->undefined_value(); 628 Handle<Object> return_value = isolate->factory()->undefined_value();
634 if (at_return) { 629 if (at_return) {
635 return_value = isolate->debug()->return_value(); 630 return_value = handle(isolate->debug()->return_value(), isolate);
636 } 631 }
637 632
638 // Now advance to the arguments adapter frame (if any). It contains all 633 // Now advance to the arguments adapter frame (if any). It contains all
639 // the provided parameters whereas the function frame always have the number 634 // the provided parameters whereas the function frame always have the number
640 // of arguments matching the functions parameters. The rest of the 635 // of arguments matching the functions parameters. The rest of the
641 // information (except for what is collected above) is the same. 636 // information (except for what is collected above) is the same.
642 if ((inlined_frame_index == 0) && 637 if ((inlined_frame_index == 0) &&
643 it.javascript_frame()->has_adapted_arguments()) { 638 it.javascript_frame()->has_adapted_arguments()) {
644 it.AdvanceToArgumentsFrame(); 639 it.AdvanceToArgumentsFrame();
645 frame_inspector.SetArgumentsFrame(it.frame()); 640 frame_inspector.SetArgumentsFrame(it.frame());
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 if (function->IsJSBoundFunction()) { 1440 if (function->IsJSBoundFunction()) {
1446 RETURN_RESULT_OR_FAILURE( 1441 RETURN_RESULT_OR_FAILURE(
1447 isolate, JSBoundFunction::GetName( 1442 isolate, JSBoundFunction::GetName(
1448 isolate, Handle<JSBoundFunction>::cast(function))); 1443 isolate, Handle<JSBoundFunction>::cast(function)));
1449 } else { 1444 } else {
1450 return *JSFunction::GetDebugName(Handle<JSFunction>::cast(function)); 1445 return *JSFunction::GetDebugName(Handle<JSFunction>::cast(function));
1451 } 1446 }
1452 } 1447 }
1453 1448
1454 1449
1455 // Calls specified function with or without entering the debugger.
1456 // This is used in unit tests to run code as if debugger is entered or simply
1457 // to have a stack with C++ frame in the middle.
1458 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) {
1459 HandleScope scope(isolate);
1460 DCHECK_EQ(1, args.length());
1461 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
1462
1463 DebugScope debug_scope(isolate->debug());
1464 if (debug_scope.failed()) {
1465 DCHECK(isolate->has_pending_exception());
1466 return isolate->heap()->exception();
1467 }
1468
1469 RETURN_RESULT_OR_FAILURE(
1470 isolate, Execution::Call(isolate, function,
1471 handle(function->global_proxy()), 0, NULL));
1472 }
1473
1474
1475 RUNTIME_FUNCTION(Runtime_GetDebugContext) { 1450 RUNTIME_FUNCTION(Runtime_GetDebugContext) {
1476 HandleScope scope(isolate); 1451 HandleScope scope(isolate);
1477 DCHECK_EQ(0, args.length()); 1452 DCHECK_EQ(0, args.length());
1478 Handle<Context> context; 1453 Handle<Context> context;
1479 { 1454 {
1480 DebugScope debug_scope(isolate->debug()); 1455 DebugScope debug_scope(isolate->debug());
1481 if (debug_scope.failed()) { 1456 if (debug_scope.failed()) {
1482 DCHECK(isolate->has_pending_exception()); 1457 DCHECK(isolate->has_pending_exception());
1483 return isolate->heap()->exception(); 1458 return isolate->heap()->exception();
1484 } 1459 }
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 } 1891 }
1917 1892
1918 1893
1919 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { 1894 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
1920 UNIMPLEMENTED(); 1895 UNIMPLEMENTED();
1921 return NULL; 1896 return NULL;
1922 } 1897 }
1923 1898
1924 } // namespace internal 1899 } // namespace internal
1925 } // namespace v8 1900 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698