| 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-evaluate.h" | 8 #include "src/debug/debug-evaluate.h" |
| 9 #include "src/debug/debug-frames.h" | 9 #include "src/debug/debug-frames.h" |
| 10 #include "src/debug/debug-scopes.h" | 10 #include "src/debug/debug-scopes.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 // Adds a JavaScript function as a debug event listener. | 75 // Adds a JavaScript function as a debug event listener. |
| 76 // args[0]: debug event listener function to set or null or undefined for | 76 // args[0]: debug event listener function to set or null or undefined for |
| 77 // clearing the event listener function | 77 // clearing the event listener function |
| 78 // args[1]: object supplied during callback | 78 // args[1]: object supplied during callback |
| 79 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { | 79 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { |
| 80 SealHandleScope shs(isolate); | 80 SealHandleScope shs(isolate); |
| 81 DCHECK(args.length() == 2); | 81 DCHECK(args.length() == 2); |
| 82 RUNTIME_ASSERT(args[0]->IsJSFunction() || args[0]->IsUndefined(isolate) || | 82 CHECK(args[0]->IsJSFunction() || args[0]->IsUndefined(isolate) || |
| 83 args[0]->IsNull(isolate)); | 83 args[0]->IsNull(isolate)); |
| 84 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); | 84 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); |
| 85 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); | 85 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); |
| 86 isolate->debug()->SetEventListener(callback, data); | 86 isolate->debug()->SetEventListener(callback, data); |
| 87 | 87 |
| 88 return isolate->heap()->undefined_value(); | 88 return isolate->heap()->undefined_value(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 RUNTIME_FUNCTION(Runtime_ScheduleBreak) { | 92 RUNTIME_FUNCTION(Runtime_ScheduleBreak) { |
| 93 SealHandleScope shs(isolate); | 93 SealHandleScope shs(isolate); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 DCHECK(args.length() == 1); | 430 DCHECK(args.length() == 1); |
| 431 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 431 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
| 432 return Smi::FromInt(static_cast<int>(details.attributes())); | 432 return Smi::FromInt(static_cast<int>(details.attributes())); |
| 433 } | 433 } |
| 434 | 434 |
| 435 | 435 |
| 436 RUNTIME_FUNCTION(Runtime_CheckExecutionState) { | 436 RUNTIME_FUNCTION(Runtime_CheckExecutionState) { |
| 437 SealHandleScope shs(isolate); | 437 SealHandleScope shs(isolate); |
| 438 DCHECK(args.length() == 1); | 438 DCHECK(args.length() == 1); |
| 439 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 439 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 440 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 440 CHECK(isolate->debug()->CheckExecutionState(break_id)); |
| 441 return isolate->heap()->true_value(); | 441 return isolate->heap()->true_value(); |
| 442 } | 442 } |
| 443 | 443 |
| 444 | 444 |
| 445 RUNTIME_FUNCTION(Runtime_GetFrameCount) { | 445 RUNTIME_FUNCTION(Runtime_GetFrameCount) { |
| 446 HandleScope scope(isolate); | 446 HandleScope scope(isolate); |
| 447 DCHECK(args.length() == 1); | 447 DCHECK(args.length() == 1); |
| 448 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 448 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 449 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 449 CHECK(isolate->debug()->CheckExecutionState(break_id)); |
| 450 | 450 |
| 451 // Count all frames which are relevant to debugging stack trace. | 451 // Count all frames which are relevant to debugging stack trace. |
| 452 int n = 0; | 452 int n = 0; |
| 453 StackFrame::Id id = isolate->debug()->break_frame_id(); | 453 StackFrame::Id id = isolate->debug()->break_frame_id(); |
| 454 if (id == StackFrame::NO_ID) { | 454 if (id == StackFrame::NO_ID) { |
| 455 // If there is no JavaScript stack frame count is 0. | 455 // If there is no JavaScript stack frame count is 0. |
| 456 return Smi::FromInt(0); | 456 return Smi::FromInt(0); |
| 457 } | 457 } |
| 458 | 458 |
| 459 for (StackTraceFrameIterator it(isolate, id); !it.done(); it.Advance()) { | 459 for (StackTraceFrameIterator it(isolate, id); !it.done(); it.Advance()) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // 7: Constructor call | 499 // 7: Constructor call |
| 500 // 8: Is at return | 500 // 8: Is at return |
| 501 // 9: Flags | 501 // 9: Flags |
| 502 // Arguments name, value | 502 // Arguments name, value |
| 503 // Locals name, value | 503 // Locals name, value |
| 504 // Return value if any | 504 // Return value if any |
| 505 RUNTIME_FUNCTION(Runtime_GetFrameDetails) { | 505 RUNTIME_FUNCTION(Runtime_GetFrameDetails) { |
| 506 HandleScope scope(isolate); | 506 HandleScope scope(isolate); |
| 507 DCHECK(args.length() == 2); | 507 DCHECK(args.length() == 2); |
| 508 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 508 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 509 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 509 CHECK(isolate->debug()->CheckExecutionState(break_id)); |
| 510 | 510 |
| 511 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 511 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
| 512 Heap* heap = isolate->heap(); | 512 Heap* heap = isolate->heap(); |
| 513 | 513 |
| 514 // Find the relevant frame with the requested index. | 514 // Find the relevant frame with the requested index. |
| 515 StackFrame::Id id = isolate->debug()->break_frame_id(); | 515 StackFrame::Id id = isolate->debug()->break_frame_id(); |
| 516 if (id == StackFrame::NO_ID) { | 516 if (id == StackFrame::NO_ID) { |
| 517 // If there are no JavaScript stack frames return undefined. | 517 // If there are no JavaScript stack frames return undefined. |
| 518 return heap->undefined_value(); | 518 return heap->undefined_value(); |
| 519 } | 519 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 | 590 |
| 591 // Handle JavaScript frames. | 591 // Handle JavaScript frames. |
| 592 bool is_optimized = it.frame()->is_optimized(); | 592 bool is_optimized = it.frame()->is_optimized(); |
| 593 | 593 |
| 594 // Check for constructor frame. | 594 // Check for constructor frame. |
| 595 bool constructor = frame_inspector.IsConstructor(); | 595 bool constructor = frame_inspector.IsConstructor(); |
| 596 | 596 |
| 597 // Get scope info and read from it for local variable information. | 597 // Get scope info and read from it for local variable information. |
| 598 Handle<JSFunction> function = | 598 Handle<JSFunction> function = |
| 599 Handle<JSFunction>::cast(frame_inspector.GetFunction()); | 599 Handle<JSFunction>::cast(frame_inspector.GetFunction()); |
| 600 RUNTIME_ASSERT(function->shared()->IsSubjectToDebugging()); | 600 CHECK(function->shared()->IsSubjectToDebugging()); |
| 601 Handle<SharedFunctionInfo> shared(function->shared()); | 601 Handle<SharedFunctionInfo> shared(function->shared()); |
| 602 Handle<ScopeInfo> scope_info(shared->scope_info()); | 602 Handle<ScopeInfo> scope_info(shared->scope_info()); |
| 603 DCHECK(*scope_info != ScopeInfo::Empty(isolate)); | 603 DCHECK(*scope_info != ScopeInfo::Empty(isolate)); |
| 604 | 604 |
| 605 // Get the locals names and values into a temporary array. | 605 // Get the locals names and values into a temporary array. |
| 606 int local_count = scope_info->LocalCount(); | 606 int local_count = scope_info->LocalCount(); |
| 607 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { | 607 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { |
| 608 // Hide compiler-introduced temporary variables, whether on the stack or on | 608 // Hide compiler-introduced temporary variables, whether on the stack or on |
| 609 // the context. | 609 // the context. |
| 610 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(slot))) { | 610 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(slot))) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 770 |
| 771 DCHECK_EQ(details_size, details_index); | 771 DCHECK_EQ(details_size, details_index); |
| 772 return *isolate->factory()->NewJSArrayWithElements(details); | 772 return *isolate->factory()->NewJSArrayWithElements(details); |
| 773 } | 773 } |
| 774 | 774 |
| 775 | 775 |
| 776 RUNTIME_FUNCTION(Runtime_GetScopeCount) { | 776 RUNTIME_FUNCTION(Runtime_GetScopeCount) { |
| 777 HandleScope scope(isolate); | 777 HandleScope scope(isolate); |
| 778 DCHECK(args.length() == 2); | 778 DCHECK(args.length() == 2); |
| 779 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 779 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 780 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 780 CHECK(isolate->debug()->CheckExecutionState(break_id)); |
| 781 | 781 |
| 782 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 782 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 783 | 783 |
| 784 // Get the frame where the debugging is performed. | 784 // Get the frame where the debugging is performed. |
| 785 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); | 785 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); |
| 786 JavaScriptFrameIterator it(isolate, id); | 786 JavaScriptFrameIterator it(isolate, id); |
| 787 JavaScriptFrame* frame = it.frame(); | 787 JavaScriptFrame* frame = it.frame(); |
| 788 FrameInspector frame_inspector(frame, 0, isolate); | 788 FrameInspector frame_inspector(frame, 0, isolate); |
| 789 | 789 |
| 790 // Count the visible scopes. | 790 // Count the visible scopes. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 803 // args[2]: number: inlined frame index | 803 // args[2]: number: inlined frame index |
| 804 // args[3]: number: scope index | 804 // args[3]: number: scope index |
| 805 // | 805 // |
| 806 // The array returned contains the following information: | 806 // The array returned contains the following information: |
| 807 // 0: Scope type | 807 // 0: Scope type |
| 808 // 1: Scope object | 808 // 1: Scope object |
| 809 RUNTIME_FUNCTION(Runtime_GetScopeDetails) { | 809 RUNTIME_FUNCTION(Runtime_GetScopeDetails) { |
| 810 HandleScope scope(isolate); | 810 HandleScope scope(isolate); |
| 811 DCHECK(args.length() == 4); | 811 DCHECK(args.length() == 4); |
| 812 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 812 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 813 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 813 CHECK(isolate->debug()->CheckExecutionState(break_id)); |
| 814 | 814 |
| 815 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 815 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 816 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 816 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
| 817 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 817 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
| 818 | 818 |
| 819 // Get the frame where the debugging is performed. | 819 // Get the frame where the debugging is performed. |
| 820 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); | 820 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); |
| 821 JavaScriptFrameIterator frame_it(isolate, id); | 821 JavaScriptFrameIterator frame_it(isolate, id); |
| 822 JavaScriptFrame* frame = frame_it.frame(); | 822 JavaScriptFrame* frame = frame_it.frame(); |
| 823 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 823 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 841 // args[2]: number: inlined frame index | 841 // args[2]: number: inlined frame index |
| 842 // args[3]: boolean: ignore nested scopes | 842 // args[3]: boolean: ignore nested scopes |
| 843 // | 843 // |
| 844 // The array returned contains arrays with the following information: | 844 // The array returned contains arrays with the following information: |
| 845 // 0: Scope type | 845 // 0: Scope type |
| 846 // 1: Scope object | 846 // 1: Scope object |
| 847 RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) { | 847 RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) { |
| 848 HandleScope scope(isolate); | 848 HandleScope scope(isolate); |
| 849 DCHECK(args.length() == 3 || args.length() == 4); | 849 DCHECK(args.length() == 3 || args.length() == 4); |
| 850 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 850 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 851 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 851 CHECK(isolate->debug()->CheckExecutionState(break_id)); |
| 852 | 852 |
| 853 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 853 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 854 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 854 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
| 855 | 855 |
| 856 ScopeIterator::Option option = ScopeIterator::DEFAULT; | 856 ScopeIterator::Option option = ScopeIterator::DEFAULT; |
| 857 if (args.length() == 4) { | 857 if (args.length() == 4) { |
| 858 CONVERT_BOOLEAN_ARG_CHECKED(flag, 3); | 858 CONVERT_BOOLEAN_ARG_CHECKED(flag, 3); |
| 859 if (flag) option = ScopeIterator::IGNORE_NESTED_SCOPES; | 859 if (flag) option = ScopeIterator::IGNORE_NESTED_SCOPES; |
| 860 } | 860 } |
| 861 | 861 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 DCHECK(args.length() == 6); | 951 DCHECK(args.length() == 6); |
| 952 | 952 |
| 953 // Check arguments. | 953 // Check arguments. |
| 954 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 954 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
| 955 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); | 955 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); |
| 956 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); | 956 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); |
| 957 | 957 |
| 958 bool res; | 958 bool res; |
| 959 if (args[0]->IsNumber()) { | 959 if (args[0]->IsNumber()) { |
| 960 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 960 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 961 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 961 CHECK(isolate->debug()->CheckExecutionState(break_id)); |
| 962 | 962 |
| 963 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 963 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 964 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 964 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
| 965 | 965 |
| 966 // Get the frame where the debugging is performed. | 966 // Get the frame where the debugging is performed. |
| 967 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); | 967 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); |
| 968 JavaScriptFrameIterator frame_it(isolate, id); | 968 JavaScriptFrameIterator frame_it(isolate, id); |
| 969 JavaScriptFrame* frame = frame_it.frame(); | 969 JavaScriptFrame* frame = frame_it.frame(); |
| 970 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 970 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
| 971 | 971 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 | 1011 |
| 1012 | 1012 |
| 1013 static bool IsPositionAlignmentCodeCorrect(int alignment) { | 1013 static bool IsPositionAlignmentCodeCorrect(int alignment) { |
| 1014 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED; | 1014 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED; |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 | 1017 |
| 1018 RUNTIME_FUNCTION(Runtime_GetBreakLocations) { | 1018 RUNTIME_FUNCTION(Runtime_GetBreakLocations) { |
| 1019 HandleScope scope(isolate); | 1019 HandleScope scope(isolate); |
| 1020 DCHECK(args.length() == 2); | 1020 DCHECK(args.length() == 2); |
| 1021 RUNTIME_ASSERT(isolate->debug()->is_active()); | 1021 CHECK(isolate->debug()->is_active()); |
| 1022 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 1022 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
| 1023 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]); | 1023 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]); |
| 1024 | 1024 |
| 1025 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { | 1025 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { |
| 1026 return isolate->ThrowIllegalOperation(); | 1026 return isolate->ThrowIllegalOperation(); |
| 1027 } | 1027 } |
| 1028 BreakPositionAlignment alignment = | 1028 BreakPositionAlignment alignment = |
| 1029 static_cast<BreakPositionAlignment>(statement_aligned_code); | 1029 static_cast<BreakPositionAlignment>(statement_aligned_code); |
| 1030 | 1030 |
| 1031 Handle<SharedFunctionInfo> shared(fun->shared()); | 1031 Handle<SharedFunctionInfo> shared(fun->shared()); |
| 1032 // Find the number of break points | 1032 // Find the number of break points |
| 1033 Handle<Object> break_locations = | 1033 Handle<Object> break_locations = |
| 1034 Debug::GetSourceBreakLocations(shared, alignment); | 1034 Debug::GetSourceBreakLocations(shared, alignment); |
| 1035 if (break_locations->IsUndefined(isolate)) { | 1035 if (break_locations->IsUndefined(isolate)) { |
| 1036 return isolate->heap()->undefined_value(); | 1036 return isolate->heap()->undefined_value(); |
| 1037 } | 1037 } |
| 1038 // Return array as JS array | 1038 // Return array as JS array |
| 1039 return *isolate->factory()->NewJSArrayWithElements( | 1039 return *isolate->factory()->NewJSArrayWithElements( |
| 1040 Handle<FixedArray>::cast(break_locations)); | 1040 Handle<FixedArray>::cast(break_locations)); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 | 1043 |
| 1044 // Set a break point in a function. | 1044 // Set a break point in a function. |
| 1045 // args[0]: function | 1045 // args[0]: function |
| 1046 // args[1]: number: break source position (within the function source) | 1046 // args[1]: number: break source position (within the function source) |
| 1047 // args[2]: number: break point object | 1047 // args[2]: number: break point object |
| 1048 RUNTIME_FUNCTION(Runtime_SetFunctionBreakPoint) { | 1048 RUNTIME_FUNCTION(Runtime_SetFunctionBreakPoint) { |
| 1049 HandleScope scope(isolate); | 1049 HandleScope scope(isolate); |
| 1050 DCHECK(args.length() == 3); | 1050 DCHECK(args.length() == 3); |
| 1051 RUNTIME_ASSERT(isolate->debug()->is_active()); | 1051 CHECK(isolate->debug()->is_active()); |
| 1052 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 1052 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 1053 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 1053 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
| 1054 RUNTIME_ASSERT(source_position >= function->shared()->start_position() && | 1054 CHECK(source_position >= function->shared()->start_position() && |
| 1055 source_position <= function->shared()->end_position()); | 1055 source_position <= function->shared()->end_position()); |
| 1056 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2); | 1056 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2); |
| 1057 | 1057 |
| 1058 // Set break point. | 1058 // Set break point. |
| 1059 RUNTIME_ASSERT(isolate->debug()->SetBreakPoint( | 1059 CHECK(isolate->debug()->SetBreakPoint(function, break_point_object_arg, |
| 1060 function, break_point_object_arg, &source_position)); | 1060 &source_position)); |
| 1061 | 1061 |
| 1062 return Smi::FromInt(source_position); | 1062 return Smi::FromInt(source_position); |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 | 1065 |
| 1066 // Changes the state of a break point in a script and returns source position | 1066 // Changes the state of a break point in a script and returns source position |
| 1067 // where break point was set. NOTE: Regarding performance see the NOTE for | 1067 // where break point was set. NOTE: Regarding performance see the NOTE for |
| 1068 // GetScriptFromScriptData. | 1068 // GetScriptFromScriptData. |
| 1069 // args[0]: script to set break point in | 1069 // args[0]: script to set break point in |
| 1070 // args[1]: number: break source position (within the script source) | 1070 // args[1]: number: break source position (within the script source) |
| 1071 // args[2]: number, breakpoint position alignment | 1071 // args[2]: number, breakpoint position alignment |
| 1072 // args[3]: number: break point object | 1072 // args[3]: number: break point object |
| 1073 RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) { | 1073 RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) { |
| 1074 HandleScope scope(isolate); | 1074 HandleScope scope(isolate); |
| 1075 DCHECK(args.length() == 4); | 1075 DCHECK(args.length() == 4); |
| 1076 RUNTIME_ASSERT(isolate->debug()->is_active()); | 1076 CHECK(isolate->debug()->is_active()); |
| 1077 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); | 1077 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); |
| 1078 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 1078 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
| 1079 RUNTIME_ASSERT(source_position >= 0); | 1079 CHECK(source_position >= 0); |
| 1080 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); | 1080 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); |
| 1081 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3); | 1081 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3); |
| 1082 | 1082 |
| 1083 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { | 1083 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { |
| 1084 return isolate->ThrowIllegalOperation(); | 1084 return isolate->ThrowIllegalOperation(); |
| 1085 } | 1085 } |
| 1086 BreakPositionAlignment alignment = | 1086 BreakPositionAlignment alignment = |
| 1087 static_cast<BreakPositionAlignment>(statement_aligned_code); | 1087 static_cast<BreakPositionAlignment>(statement_aligned_code); |
| 1088 | 1088 |
| 1089 // Get the script from the script wrapper. | 1089 // Get the script from the script wrapper. |
| 1090 RUNTIME_ASSERT(wrapper->value()->IsScript()); | 1090 CHECK(wrapper->value()->IsScript()); |
| 1091 Handle<Script> script(Script::cast(wrapper->value())); | 1091 Handle<Script> script(Script::cast(wrapper->value())); |
| 1092 | 1092 |
| 1093 // Set break point. | 1093 // Set break point. |
| 1094 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg, | 1094 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg, |
| 1095 &source_position, alignment)) { | 1095 &source_position, alignment)) { |
| 1096 return isolate->heap()->undefined_value(); | 1096 return isolate->heap()->undefined_value(); |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 return Smi::FromInt(source_position); | 1099 return Smi::FromInt(source_position); |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 | 1102 |
| 1103 // Clear a break point | 1103 // Clear a break point |
| 1104 // args[0]: number: break point object | 1104 // args[0]: number: break point object |
| 1105 RUNTIME_FUNCTION(Runtime_ClearBreakPoint) { | 1105 RUNTIME_FUNCTION(Runtime_ClearBreakPoint) { |
| 1106 HandleScope scope(isolate); | 1106 HandleScope scope(isolate); |
| 1107 DCHECK(args.length() == 1); | 1107 DCHECK(args.length() == 1); |
| 1108 RUNTIME_ASSERT(isolate->debug()->is_active()); | 1108 CHECK(isolate->debug()->is_active()); |
| 1109 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0); | 1109 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0); |
| 1110 | 1110 |
| 1111 // Clear break point. | 1111 // Clear break point. |
| 1112 isolate->debug()->ClearBreakPoint(break_point_object_arg); | 1112 isolate->debug()->ClearBreakPoint(break_point_object_arg); |
| 1113 | 1113 |
| 1114 return isolate->heap()->undefined_value(); | 1114 return isolate->heap()->undefined_value(); |
| 1115 } | 1115 } |
| 1116 | 1116 |
| 1117 | 1117 |
| 1118 // Change the state of break on exceptions. | 1118 // Change the state of break on exceptions. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1148 | 1148 |
| 1149 // Prepare for stepping | 1149 // Prepare for stepping |
| 1150 // args[0]: break id for checking execution state | 1150 // args[0]: break id for checking execution state |
| 1151 // args[1]: step action from the enumeration StepAction | 1151 // args[1]: step action from the enumeration StepAction |
| 1152 // args[2]: number of times to perform the step, for step out it is the number | 1152 // args[2]: number of times to perform the step, for step out it is the number |
| 1153 // of frames to step down. | 1153 // of frames to step down. |
| 1154 RUNTIME_FUNCTION(Runtime_PrepareStep) { | 1154 RUNTIME_FUNCTION(Runtime_PrepareStep) { |
| 1155 HandleScope scope(isolate); | 1155 HandleScope scope(isolate); |
| 1156 DCHECK(args.length() == 2); | 1156 DCHECK(args.length() == 2); |
| 1157 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 1157 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 1158 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 1158 CHECK(isolate->debug()->CheckExecutionState(break_id)); |
| 1159 | 1159 |
| 1160 if (!args[1]->IsNumber()) { | 1160 if (!args[1]->IsNumber()) { |
| 1161 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 1161 return isolate->Throw(isolate->heap()->illegal_argument_string()); |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 // Get the step action and check validity. | 1164 // Get the step action and check validity. |
| 1165 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); | 1165 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); |
| 1166 if (step_action != StepIn && step_action != StepNext && | 1166 if (step_action != StepIn && step_action != StepNext && |
| 1167 step_action != StepOut && step_action != StepFrame) { | 1167 step_action != StepOut && step_action != StepFrame) { |
| 1168 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 1168 return isolate->Throw(isolate->heap()->illegal_argument_string()); |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 // Clear all current stepping setup. | 1171 // Clear all current stepping setup. |
| 1172 isolate->debug()->ClearStepping(); | 1172 isolate->debug()->ClearStepping(); |
| 1173 | 1173 |
| 1174 // Prepare step. | 1174 // Prepare step. |
| 1175 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action)); | 1175 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action)); |
| 1176 return isolate->heap()->undefined_value(); | 1176 return isolate->heap()->undefined_value(); |
| 1177 } | 1177 } |
| 1178 | 1178 |
| 1179 | 1179 |
| 1180 // Clear all stepping set by PrepareStep. | 1180 // Clear all stepping set by PrepareStep. |
| 1181 RUNTIME_FUNCTION(Runtime_ClearStepping) { | 1181 RUNTIME_FUNCTION(Runtime_ClearStepping) { |
| 1182 HandleScope scope(isolate); | 1182 HandleScope scope(isolate); |
| 1183 DCHECK(args.length() == 0); | 1183 DCHECK(args.length() == 0); |
| 1184 RUNTIME_ASSERT(isolate->debug()->is_active()); | 1184 CHECK(isolate->debug()->is_active()); |
| 1185 isolate->debug()->ClearStepping(); | 1185 isolate->debug()->ClearStepping(); |
| 1186 return isolate->heap()->undefined_value(); | 1186 return isolate->heap()->undefined_value(); |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 | 1189 |
| 1190 RUNTIME_FUNCTION(Runtime_DebugEvaluate) { | 1190 RUNTIME_FUNCTION(Runtime_DebugEvaluate) { |
| 1191 HandleScope scope(isolate); | 1191 HandleScope scope(isolate); |
| 1192 | 1192 |
| 1193 // Check the execution state and decode arguments frame and source to be | 1193 // Check the execution state and decode arguments frame and source to be |
| 1194 // evaluated. | 1194 // evaluated. |
| 1195 DCHECK(args.length() == 6); | 1195 DCHECK(args.length() == 6); |
| 1196 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 1196 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 1197 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 1197 CHECK(isolate->debug()->CheckExecutionState(break_id)); |
| 1198 | 1198 |
| 1199 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 1199 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 1200 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 1200 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
| 1201 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); | 1201 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); |
| 1202 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); | 1202 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); |
| 1203 CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 5); | 1203 CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 5); |
| 1204 | 1204 |
| 1205 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); | 1205 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); |
| 1206 | 1206 |
| 1207 RETURN_RESULT_OR_FAILURE( | 1207 RETURN_RESULT_OR_FAILURE( |
| 1208 isolate, DebugEvaluate::Local(isolate, id, inlined_jsframe_index, source, | 1208 isolate, DebugEvaluate::Local(isolate, id, inlined_jsframe_index, source, |
| 1209 disable_break, context_extension)); | 1209 disable_break, context_extension)); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 | 1212 |
| 1213 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { | 1213 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { |
| 1214 HandleScope scope(isolate); | 1214 HandleScope scope(isolate); |
| 1215 | 1215 |
| 1216 // Check the execution state and decode arguments frame and source to be | 1216 // Check the execution state and decode arguments frame and source to be |
| 1217 // evaluated. | 1217 // evaluated. |
| 1218 DCHECK(args.length() == 4); | 1218 DCHECK(args.length() == 4); |
| 1219 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 1219 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 1220 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 1220 CHECK(isolate->debug()->CheckExecutionState(break_id)); |
| 1221 | 1221 |
| 1222 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 1222 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 1223 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); | 1223 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); |
| 1224 CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 3); | 1224 CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 3); |
| 1225 | 1225 |
| 1226 RETURN_RESULT_OR_FAILURE( | 1226 RETURN_RESULT_OR_FAILURE( |
| 1227 isolate, | 1227 isolate, |
| 1228 DebugEvaluate::Global(isolate, source, disable_break, context_extension)); | 1228 DebugEvaluate::Global(isolate, source, disable_break, context_extension)); |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 | 1231 |
| 1232 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { | 1232 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { |
| 1233 HandleScope scope(isolate); | 1233 HandleScope scope(isolate); |
| 1234 DCHECK(args.length() == 0); | 1234 DCHECK(args.length() == 0); |
| 1235 RUNTIME_ASSERT(isolate->debug()->is_active()); | 1235 |
| 1236 // This runtime function is used by the debugger to determine whether the |
| 1237 // debugger is active or not. Hence we fail gracefully here and don't crash. |
| 1238 if (!isolate->debug()->is_active()) return isolate->ThrowIllegalOperation(); |
| 1236 | 1239 |
| 1237 Handle<FixedArray> instances; | 1240 Handle<FixedArray> instances; |
| 1238 { | 1241 { |
| 1239 DebugScope debug_scope(isolate->debug()); | 1242 DebugScope debug_scope(isolate->debug()); |
| 1240 if (debug_scope.failed()) { | 1243 if (debug_scope.failed()) { |
| 1241 DCHECK(isolate->has_pending_exception()); | 1244 DCHECK(isolate->has_pending_exception()); |
| 1242 return isolate->heap()->exception(); | 1245 return isolate->heap()->exception(); |
| 1243 } | 1246 } |
| 1244 // Fill the script objects. | 1247 // Fill the script objects. |
| 1245 instances = isolate->debug()->GetLoadedScripts(); | 1248 instances = isolate->debug()->GetLoadedScripts(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1275 | 1278 |
| 1276 // Scan the heap for objects with direct references to an object | 1279 // Scan the heap for objects with direct references to an object |
| 1277 // args[0]: the object to find references to | 1280 // args[0]: the object to find references to |
| 1278 // args[1]: constructor function for instances to exclude (Mirror) | 1281 // args[1]: constructor function for instances to exclude (Mirror) |
| 1279 // args[2]: the the maximum number of objects to return | 1282 // args[2]: the the maximum number of objects to return |
| 1280 RUNTIME_FUNCTION(Runtime_DebugReferencedBy) { | 1283 RUNTIME_FUNCTION(Runtime_DebugReferencedBy) { |
| 1281 HandleScope scope(isolate); | 1284 HandleScope scope(isolate); |
| 1282 DCHECK(args.length() == 3); | 1285 DCHECK(args.length() == 3); |
| 1283 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); | 1286 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); |
| 1284 CONVERT_ARG_HANDLE_CHECKED(Object, filter, 1); | 1287 CONVERT_ARG_HANDLE_CHECKED(Object, filter, 1); |
| 1285 RUNTIME_ASSERT(filter->IsUndefined(isolate) || filter->IsJSObject()); | 1288 CHECK(filter->IsUndefined(isolate) || filter->IsJSObject()); |
| 1286 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); | 1289 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); |
| 1287 RUNTIME_ASSERT(max_references >= 0); | 1290 CHECK(max_references >= 0); |
| 1288 | 1291 |
| 1289 List<Handle<JSObject> > instances; | 1292 List<Handle<JSObject> > instances; |
| 1290 Heap* heap = isolate->heap(); | 1293 Heap* heap = isolate->heap(); |
| 1291 { | 1294 { |
| 1292 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable); | 1295 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable); |
| 1293 // Get the constructor function for context extension and arguments array. | 1296 // Get the constructor function for context extension and arguments array. |
| 1294 Object* arguments_fun = isolate->sloppy_arguments_map()->GetConstructor(); | 1297 Object* arguments_fun = isolate->sloppy_arguments_map()->GetConstructor(); |
| 1295 HeapObject* heap_obj; | 1298 HeapObject* heap_obj; |
| 1296 while ((heap_obj = iterator.next())) { | 1299 while ((heap_obj = iterator.next())) { |
| 1297 if (!heap_obj->IsJSObject()) continue; | 1300 if (!heap_obj->IsJSObject()) continue; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 | 1335 |
| 1333 | 1336 |
| 1334 // Scan the heap for objects constructed by a specific function. | 1337 // Scan the heap for objects constructed by a specific function. |
| 1335 // args[0]: the constructor to find instances of | 1338 // args[0]: the constructor to find instances of |
| 1336 // args[1]: the the maximum number of objects to return | 1339 // args[1]: the the maximum number of objects to return |
| 1337 RUNTIME_FUNCTION(Runtime_DebugConstructedBy) { | 1340 RUNTIME_FUNCTION(Runtime_DebugConstructedBy) { |
| 1338 HandleScope scope(isolate); | 1341 HandleScope scope(isolate); |
| 1339 DCHECK(args.length() == 2); | 1342 DCHECK(args.length() == 2); |
| 1340 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); | 1343 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); |
| 1341 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); | 1344 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); |
| 1342 RUNTIME_ASSERT(max_references >= 0); | 1345 CHECK(max_references >= 0); |
| 1343 | 1346 |
| 1344 List<Handle<JSObject> > instances; | 1347 List<Handle<JSObject> > instances; |
| 1345 Heap* heap = isolate->heap(); | 1348 Heap* heap = isolate->heap(); |
| 1346 { | 1349 { |
| 1347 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable); | 1350 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable); |
| 1348 HeapObject* heap_obj; | 1351 HeapObject* heap_obj; |
| 1349 while ((heap_obj = iterator.next())) { | 1352 while ((heap_obj = iterator.next())) { |
| 1350 if (!heap_obj->IsJSObject()) continue; | 1353 if (!heap_obj->IsJSObject()) continue; |
| 1351 JSObject* obj = JSObject::cast(heap_obj); | 1354 JSObject* obj = JSObject::cast(heap_obj); |
| 1352 if (obj->map()->GetConstructor() != *constructor) continue; | 1355 if (obj->map()->GetConstructor() != *constructor) continue; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1378 | 1381 |
| 1379 | 1382 |
| 1380 // Patches script source (should be called upon BeforeCompile event). | 1383 // Patches script source (should be called upon BeforeCompile event). |
| 1381 RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) { | 1384 RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) { |
| 1382 HandleScope scope(isolate); | 1385 HandleScope scope(isolate); |
| 1383 DCHECK(args.length() == 2); | 1386 DCHECK(args.length() == 2); |
| 1384 | 1387 |
| 1385 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); | 1388 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); |
| 1386 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 1389 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 1387 | 1390 |
| 1388 RUNTIME_ASSERT(script_wrapper->value()->IsScript()); | 1391 CHECK(script_wrapper->value()->IsScript()); |
| 1389 Handle<Script> script(Script::cast(script_wrapper->value())); | 1392 Handle<Script> script(Script::cast(script_wrapper->value())); |
| 1390 | 1393 |
| 1391 int compilation_state = script->compilation_state(); | 1394 // The following condition is not guaranteed to hold and a failure is also |
| 1392 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); | 1395 // propagated to callers. Hence we fail gracefully here and don't crash. |
| 1396 if (script->compilation_state() != Script::COMPILATION_STATE_INITIAL) { |
| 1397 return isolate->ThrowIllegalOperation(); |
| 1398 } |
| 1399 |
| 1393 script->set_source(*source); | 1400 script->set_source(*source); |
| 1394 | 1401 |
| 1395 return isolate->heap()->undefined_value(); | 1402 return isolate->heap()->undefined_value(); |
| 1396 } | 1403 } |
| 1397 | 1404 |
| 1398 | 1405 |
| 1399 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { | 1406 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { |
| 1400 SealHandleScope shs(isolate); | 1407 SealHandleScope shs(isolate); |
| 1401 DCHECK_EQ(1, args.length()); | 1408 DCHECK_EQ(1, args.length()); |
| 1402 | 1409 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 | 1518 |
| 1512 if (found.is_null()) return isolate->heap()->undefined_value(); | 1519 if (found.is_null()) return isolate->heap()->undefined_value(); |
| 1513 return *Script::GetWrapper(found); | 1520 return *Script::GetWrapper(found); |
| 1514 } | 1521 } |
| 1515 | 1522 |
| 1516 RUNTIME_FUNCTION(Runtime_ScriptLineCount) { | 1523 RUNTIME_FUNCTION(Runtime_ScriptLineCount) { |
| 1517 HandleScope scope(isolate); | 1524 HandleScope scope(isolate); |
| 1518 DCHECK(args.length() == 1); | 1525 DCHECK(args.length() == 1); |
| 1519 CONVERT_ARG_CHECKED(JSValue, script, 0); | 1526 CONVERT_ARG_CHECKED(JSValue, script, 0); |
| 1520 | 1527 |
| 1521 RUNTIME_ASSERT(script->value()->IsScript()); | 1528 CHECK(script->value()->IsScript()); |
| 1522 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 1529 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
| 1523 | 1530 |
| 1524 Script::InitLineEnds(script_handle); | 1531 Script::InitLineEnds(script_handle); |
| 1525 | 1532 |
| 1526 FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends()); | 1533 FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends()); |
| 1527 return Smi::FromInt(line_ends_array->length()); | 1534 return Smi::FromInt(line_ends_array->length()); |
| 1528 } | 1535 } |
| 1529 | 1536 |
| 1530 RUNTIME_FUNCTION(Runtime_ScriptLineStartPosition) { | 1537 RUNTIME_FUNCTION(Runtime_ScriptLineStartPosition) { |
| 1531 HandleScope scope(isolate); | 1538 HandleScope scope(isolate); |
| 1532 DCHECK(args.length() == 2); | 1539 DCHECK(args.length() == 2); |
| 1533 CONVERT_ARG_CHECKED(JSValue, script, 0); | 1540 CONVERT_ARG_CHECKED(JSValue, script, 0); |
| 1534 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]); | 1541 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]); |
| 1535 | 1542 |
| 1536 RUNTIME_ASSERT(script->value()->IsScript()); | 1543 CHECK(script->value()->IsScript()); |
| 1537 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 1544 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
| 1538 | 1545 |
| 1539 Script::InitLineEnds(script_handle); | 1546 Script::InitLineEnds(script_handle); |
| 1540 | 1547 |
| 1541 FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends()); | 1548 FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends()); |
| 1542 const int line_count = line_ends_array->length(); | 1549 const int line_count = line_ends_array->length(); |
| 1543 | 1550 |
| 1544 // If line == line_count, we return the first position beyond the last line. | 1551 // If line == line_count, we return the first position beyond the last line. |
| 1545 if (line < 0 || line > line_count) { | 1552 if (line < 0 || line > line_count) { |
| 1546 return Smi::FromInt(-1); | 1553 return Smi::FromInt(-1); |
| 1547 } else if (line == 0) { | 1554 } else if (line == 0) { |
| 1548 return Smi::FromInt(0); | 1555 return Smi::FromInt(0); |
| 1549 } else { | 1556 } else { |
| 1550 DCHECK(0 < line && line <= line_count); | 1557 DCHECK(0 < line && line <= line_count); |
| 1551 const int pos = Smi::cast(line_ends_array->get(line - 1))->value() + 1; | 1558 const int pos = Smi::cast(line_ends_array->get(line - 1))->value() + 1; |
| 1552 return Smi::FromInt(pos); | 1559 return Smi::FromInt(pos); |
| 1553 } | 1560 } |
| 1554 } | 1561 } |
| 1555 | 1562 |
| 1556 RUNTIME_FUNCTION(Runtime_ScriptLineEndPosition) { | 1563 RUNTIME_FUNCTION(Runtime_ScriptLineEndPosition) { |
| 1557 HandleScope scope(isolate); | 1564 HandleScope scope(isolate); |
| 1558 DCHECK(args.length() == 2); | 1565 DCHECK(args.length() == 2); |
| 1559 CONVERT_ARG_CHECKED(JSValue, script, 0); | 1566 CONVERT_ARG_CHECKED(JSValue, script, 0); |
| 1560 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]); | 1567 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]); |
| 1561 | 1568 |
| 1562 RUNTIME_ASSERT(script->value()->IsScript()); | 1569 CHECK(script->value()->IsScript()); |
| 1563 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 1570 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
| 1564 | 1571 |
| 1565 Script::InitLineEnds(script_handle); | 1572 Script::InitLineEnds(script_handle); |
| 1566 | 1573 |
| 1567 FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends()); | 1574 FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends()); |
| 1568 const int line_count = line_ends_array->length(); | 1575 const int line_count = line_ends_array->length(); |
| 1569 | 1576 |
| 1570 if (line < 0 || line >= line_count) { | 1577 if (line < 0 || line >= line_count) { |
| 1571 return Smi::FromInt(-1); | 1578 return Smi::FromInt(-1); |
| 1572 } else { | 1579 } else { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 // used to find a source position in a function based on a line and column in | 1618 // used to find a source position in a function based on a line and column in |
| 1612 // the source for the function alone. The offset passed will then be the | 1619 // the source for the function alone. The offset passed will then be the |
| 1613 // start position of the source for the function within the full script source. | 1620 // start position of the source for the function within the full script source. |
| 1614 // Note that incoming line and column parameters may be undefined, and are | 1621 // Note that incoming line and column parameters may be undefined, and are |
| 1615 // assumed to be passed *with* offsets. | 1622 // assumed to be passed *with* offsets. |
| 1616 RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine) { | 1623 RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine) { |
| 1617 HandleScope scope(isolate); | 1624 HandleScope scope(isolate); |
| 1618 DCHECK(args.length() == 4); | 1625 DCHECK(args.length() == 4); |
| 1619 CONVERT_ARG_CHECKED(JSValue, script, 0); | 1626 CONVERT_ARG_CHECKED(JSValue, script, 0); |
| 1620 | 1627 |
| 1621 RUNTIME_ASSERT(script->value()->IsScript()); | 1628 CHECK(script->value()->IsScript()); |
| 1622 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 1629 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
| 1623 | 1630 |
| 1624 // Line and column are possibly undefined and we need to handle these cases, | 1631 // Line and column are possibly undefined and we need to handle these cases, |
| 1625 // additionally subtracting corresponding offsets. | 1632 // additionally subtracting corresponding offsets. |
| 1626 | 1633 |
| 1627 int32_t line; | 1634 int32_t line; |
| 1628 if (args[1]->IsNull(isolate) || args[1]->IsUndefined(isolate)) { | 1635 if (args[1]->IsNull(isolate) || args[1]->IsUndefined(isolate)) { |
| 1629 line = 0; | 1636 line = 0; |
| 1630 } else { | 1637 } else { |
| 1631 RUNTIME_ASSERT(args[1]->IsNumber()); | 1638 CHECK(args[1]->IsNumber()); |
| 1632 line = NumberToInt32(args[1]) - script_handle->line_offset(); | 1639 line = NumberToInt32(args[1]) - script_handle->line_offset(); |
| 1633 } | 1640 } |
| 1634 | 1641 |
| 1635 int32_t column; | 1642 int32_t column; |
| 1636 if (args[2]->IsNull(isolate) || args[2]->IsUndefined(isolate)) { | 1643 if (args[2]->IsNull(isolate) || args[2]->IsUndefined(isolate)) { |
| 1637 column = 0; | 1644 column = 0; |
| 1638 } else { | 1645 } else { |
| 1639 RUNTIME_ASSERT(args[2]->IsNumber()); | 1646 CHECK(args[2]->IsNumber()); |
| 1640 column = NumberToInt32(args[2]); | 1647 column = NumberToInt32(args[2]); |
| 1641 if (line == 0) column -= script_handle->column_offset(); | 1648 if (line == 0) column -= script_handle->column_offset(); |
| 1642 } | 1649 } |
| 1643 | 1650 |
| 1644 CONVERT_NUMBER_CHECKED(int32_t, offset_position, Int32, args[3]); | 1651 CONVERT_NUMBER_CHECKED(int32_t, offset_position, Int32, args[3]); |
| 1645 | 1652 |
| 1646 if (line < 0 || column < 0 || offset_position < 0) { | 1653 if (line < 0 || column < 0 || offset_position < 0) { |
| 1647 return isolate->heap()->null_value(); | 1654 return isolate->heap()->null_value(); |
| 1648 } | 1655 } |
| 1649 | 1656 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1675 isolate); | 1682 isolate); |
| 1676 } | 1683 } |
| 1677 | 1684 |
| 1678 RUNTIME_FUNCTION(Runtime_ScriptPositionInfo) { | 1685 RUNTIME_FUNCTION(Runtime_ScriptPositionInfo) { |
| 1679 HandleScope scope(isolate); | 1686 HandleScope scope(isolate); |
| 1680 DCHECK(args.length() == 3); | 1687 DCHECK(args.length() == 3); |
| 1681 CONVERT_ARG_CHECKED(JSValue, script, 0); | 1688 CONVERT_ARG_CHECKED(JSValue, script, 0); |
| 1682 CONVERT_NUMBER_CHECKED(int32_t, position, Int32, args[1]); | 1689 CONVERT_NUMBER_CHECKED(int32_t, position, Int32, args[1]); |
| 1683 CONVERT_BOOLEAN_ARG_CHECKED(with_offset, 2); | 1690 CONVERT_BOOLEAN_ARG_CHECKED(with_offset, 2); |
| 1684 | 1691 |
| 1685 RUNTIME_ASSERT(script->value()->IsScript()); | 1692 CHECK(script->value()->IsScript()); |
| 1686 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 1693 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
| 1687 | 1694 |
| 1688 const Script::OffsetFlag offset_flag = | 1695 const Script::OffsetFlag offset_flag = |
| 1689 with_offset ? Script::WITH_OFFSET : Script::NO_OFFSET; | 1696 with_offset ? Script::WITH_OFFSET : Script::NO_OFFSET; |
| 1690 return *GetJSPositionInfo(script_handle, position, offset_flag, isolate); | 1697 return *GetJSPositionInfo(script_handle, position, offset_flag, isolate); |
| 1691 } | 1698 } |
| 1692 | 1699 |
| 1693 // Returns the given line as a string, or null if line is out of bounds. | 1700 // Returns the given line as a string, or null if line is out of bounds. |
| 1694 // The parameter line is expected to include the script's line offset. | 1701 // The parameter line is expected to include the script's line offset. |
| 1695 RUNTIME_FUNCTION(Runtime_ScriptSourceLine) { | 1702 RUNTIME_FUNCTION(Runtime_ScriptSourceLine) { |
| 1696 HandleScope scope(isolate); | 1703 HandleScope scope(isolate); |
| 1697 DCHECK(args.length() == 2); | 1704 DCHECK(args.length() == 2); |
| 1698 CONVERT_ARG_CHECKED(JSValue, script, 0); | 1705 CONVERT_ARG_CHECKED(JSValue, script, 0); |
| 1699 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]); | 1706 CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]); |
| 1700 | 1707 |
| 1701 RUNTIME_ASSERT(script->value()->IsScript()); | 1708 CHECK(script->value()->IsScript()); |
| 1702 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 1709 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
| 1703 | 1710 |
| 1704 Script::InitLineEnds(script_handle); | 1711 Script::InitLineEnds(script_handle); |
| 1705 | 1712 |
| 1706 FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends()); | 1713 FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends()); |
| 1707 const int line_count = line_ends_array->length(); | 1714 const int line_count = line_ends_array->length(); |
| 1708 | 1715 |
| 1709 line -= script_handle->line_offset(); | 1716 line -= script_handle->line_offset(); |
| 1710 if (line < 0 || line_count <= line) { | 1717 if (line < 0 || line_count <= line) { |
| 1711 return isolate->heap()->null_value(); | 1718 return isolate->heap()->null_value(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1793 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
| 1787 UNIMPLEMENTED(); | 1794 UNIMPLEMENTED(); |
| 1788 return NULL; | 1795 return NULL; |
| 1789 } | 1796 } |
| 1790 | 1797 |
| 1791 RUNTIME_FUNCTION(Runtime_GetWasmFunctionOffsetTable) { | 1798 RUNTIME_FUNCTION(Runtime_GetWasmFunctionOffsetTable) { |
| 1792 DCHECK(args.length() == 1); | 1799 DCHECK(args.length() == 1); |
| 1793 HandleScope scope(isolate); | 1800 HandleScope scope(isolate); |
| 1794 CONVERT_ARG_CHECKED(JSValue, script_val, 0); | 1801 CONVERT_ARG_CHECKED(JSValue, script_val, 0); |
| 1795 | 1802 |
| 1796 RUNTIME_ASSERT(script_val->value()->IsScript()); | 1803 CHECK(script_val->value()->IsScript()); |
| 1797 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); | 1804 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); |
| 1798 | 1805 |
| 1799 Handle<wasm::WasmDebugInfo> debug_info( | 1806 Handle<wasm::WasmDebugInfo> debug_info( |
| 1800 wasm::GetDebugInfo(script->wasm_object()), isolate); | 1807 wasm::GetDebugInfo(script->wasm_object()), isolate); |
| 1801 Handle<FixedArray> elements = wasm::WasmDebugInfo::GetFunctionOffsetTable( | 1808 Handle<FixedArray> elements = wasm::WasmDebugInfo::GetFunctionOffsetTable( |
| 1802 debug_info, script->wasm_function_index()); | 1809 debug_info, script->wasm_function_index()); |
| 1803 return *isolate->factory()->NewJSArrayWithElements(elements); | 1810 return *isolate->factory()->NewJSArrayWithElements(elements); |
| 1804 } | 1811 } |
| 1805 | 1812 |
| 1806 RUNTIME_FUNCTION(Runtime_DisassembleWasmFunction) { | 1813 RUNTIME_FUNCTION(Runtime_DisassembleWasmFunction) { |
| 1807 DCHECK(args.length() == 1); | 1814 DCHECK(args.length() == 1); |
| 1808 HandleScope scope(isolate); | 1815 HandleScope scope(isolate); |
| 1809 CONVERT_ARG_CHECKED(JSValue, script_val, 0); | 1816 CONVERT_ARG_CHECKED(JSValue, script_val, 0); |
| 1810 | 1817 |
| 1811 RUNTIME_ASSERT(script_val->value()->IsScript()); | 1818 CHECK(script_val->value()->IsScript()); |
| 1812 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); | 1819 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); |
| 1813 | 1820 |
| 1814 Handle<wasm::WasmDebugInfo> debug_info( | 1821 Handle<wasm::WasmDebugInfo> debug_info( |
| 1815 wasm::GetDebugInfo(script->wasm_object()), isolate); | 1822 wasm::GetDebugInfo(script->wasm_object()), isolate); |
| 1816 return *wasm::WasmDebugInfo::DisassembleFunction( | 1823 return *wasm::WasmDebugInfo::DisassembleFunction( |
| 1817 debug_info, script->wasm_function_index()); | 1824 debug_info, script->wasm_function_index()); |
| 1818 } | 1825 } |
| 1819 | 1826 |
| 1820 } // namespace internal | 1827 } // namespace internal |
| 1821 } // namespace v8 | 1828 } // namespace v8 |
| OLD | NEW |