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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // Count all frames which are relevant to debugging stack trace. | 450 // Count all frames which are relevant to debugging stack trace. |
451 int n = 0; | 451 int n = 0; |
452 StackFrame::Id id = isolate->debug()->break_frame_id(); | 452 StackFrame::Id id = isolate->debug()->break_frame_id(); |
453 if (id == StackFrame::NO_ID) { | 453 if (id == StackFrame::NO_ID) { |
454 // If there is no JavaScript stack frame count is 0. | 454 // If there is no JavaScript stack frame count is 0. |
455 return Smi::FromInt(0); | 455 return Smi::FromInt(0); |
456 } | 456 } |
457 | 457 |
458 for (StackTraceFrameIterator it(isolate, id); !it.done(); it.Advance()) { | 458 for (StackTraceFrameIterator it(isolate, id); !it.done(); it.Advance()) { |
459 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 459 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
460 if (it.is_wasm()) { | 460 it.frame()->Summarize(&frames); |
461 n++; | 461 for (int i = frames.length() - 1; i >= 0; i--) { |
462 } else { | 462 // Omit functions from native and extension scripts. |
463 it.javascript_frame()->Summarize(&frames); | 463 if (frames[i].is_subject_to_debugging()) n++; |
464 for (int i = frames.length() - 1; i >= 0; i--) { | |
465 // Omit functions from native and extension scripts. | |
466 if (frames[i].function()->shared()->IsSubjectToDebugging()) n++; | |
467 } | |
468 } | 464 } |
469 } | 465 } |
470 return Smi::FromInt(n); | 466 return Smi::FromInt(n); |
471 } | 467 } |
472 | 468 |
473 | 469 |
474 static const int kFrameDetailsFrameIdIndex = 0; | 470 static const int kFrameDetailsFrameIdIndex = 0; |
475 static const int kFrameDetailsReceiverIndex = 1; | 471 static const int kFrameDetailsReceiverIndex = 1; |
476 static const int kFrameDetailsFunctionIndex = 2; | 472 static const int kFrameDetailsFunctionIndex = 2; |
477 static const int kFrameDetailsScriptIndex = 3; | 473 static const int kFrameDetailsScriptIndex = 3; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 | 508 |
513 // Find the relevant frame with the requested index. | 509 // Find the relevant frame with the requested index. |
514 StackFrame::Id id = isolate->debug()->break_frame_id(); | 510 StackFrame::Id id = isolate->debug()->break_frame_id(); |
515 if (id == StackFrame::NO_ID) { | 511 if (id == StackFrame::NO_ID) { |
516 // If there are no JavaScript stack frames return undefined. | 512 // If there are no JavaScript stack frames return undefined. |
517 return heap->undefined_value(); | 513 return heap->undefined_value(); |
518 } | 514 } |
519 | 515 |
520 StackTraceFrameIterator it(isolate, id); | 516 StackTraceFrameIterator it(isolate, id); |
521 // Inlined frame index in optimized frame, starting from outer function. | 517 // Inlined frame index in optimized frame, starting from outer function. |
522 int inlined_jsframe_index = | 518 int inlined_frame_index = |
523 DebugFrameHelper::FindIndexedNonNativeFrame(&it, index); | 519 DebugFrameHelper::FindIndexedNonNativeFrame(&it, index); |
524 if (inlined_jsframe_index == -1) return heap->undefined_value(); | 520 if (inlined_frame_index == -1) return heap->undefined_value(); |
525 | 521 |
526 FrameInspector frame_inspector(it.frame(), inlined_jsframe_index, isolate); | 522 FrameInspector frame_inspector(it.frame(), inlined_frame_index, isolate); |
527 | 523 |
528 // Traverse the saved contexts chain to find the active context for the | 524 // Traverse the saved contexts chain to find the active context for the |
529 // selected frame. | 525 // selected frame. |
530 SaveContext* save = | 526 SaveContext* save = |
531 DebugFrameHelper::FindSavedContextForFrame(isolate, it.frame()); | 527 DebugFrameHelper::FindSavedContextForFrame(isolate, it.frame()); |
532 | 528 |
533 // Get the frame id. | 529 // Get the frame id. |
534 Handle<Object> frame_id(DebugFrameHelper::WrapFrameId(it.frame()->id()), | 530 Handle<Object> frame_id(DebugFrameHelper::WrapFrameId(it.frame()->id()), |
535 isolate); | 531 isolate); |
536 | 532 |
537 // Find source position in unoptimized code. | 533 // Find source position in unoptimized code. |
538 int position = frame_inspector.GetSourcePosition(); | 534 int position = frame_inspector.GetSourcePosition(); |
539 | 535 |
540 if (it.is_wasm()) { | 536 if (it.is_wasm()) { |
541 // Create the details array (no dynamic information for wasm). | 537 // Create the details array (no dynamic information for wasm). |
542 Handle<FixedArray> details = | 538 Handle<FixedArray> details = |
543 isolate->factory()->NewFixedArray(kFrameDetailsFirstDynamicIndex); | 539 isolate->factory()->NewFixedArray(kFrameDetailsFirstDynamicIndex); |
544 | 540 |
545 // Add the frame id. | 541 // Add the frame id. |
546 details->set(kFrameDetailsFrameIdIndex, *frame_id); | 542 details->set(kFrameDetailsFrameIdIndex, *frame_id); |
547 | 543 |
548 // Add the function name. | 544 // Add the function name. |
549 Handle<Object> wasm_obj(it.wasm_frame()->wasm_obj(), isolate); | 545 details->set(kFrameDetailsFunctionIndex, |
550 int func_index = it.wasm_frame()->function_index(); | 546 *frame_inspector.GetFunctionName()); |
551 Handle<String> func_name = | |
552 wasm::GetWasmFunctionName(isolate, wasm_obj, func_index); | |
553 details->set(kFrameDetailsFunctionIndex, *func_name); | |
554 | 547 |
555 // Add the script wrapper | 548 // Add the script wrapper |
556 Handle<Object> script_wrapper = | 549 Handle<Object> script_wrapper = |
557 Script::GetWrapper(frame_inspector.GetScript()); | 550 Script::GetWrapper(frame_inspector.GetScript()); |
558 details->set(kFrameDetailsScriptIndex, *script_wrapper); | 551 details->set(kFrameDetailsScriptIndex, *script_wrapper); |
559 | 552 |
560 // Add the arguments count. | 553 // Add the arguments count. |
561 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(0)); | 554 details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(0)); |
562 | 555 |
563 // Add the locals count | 556 // Add the locals count |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 // to the frame information. | 654 // to the frame information. |
662 Handle<Object> return_value = isolate->factory()->undefined_value(); | 655 Handle<Object> return_value = isolate->factory()->undefined_value(); |
663 if (at_return) { | 656 if (at_return) { |
664 return_value = isolate->debug()->return_value(); | 657 return_value = isolate->debug()->return_value(); |
665 } | 658 } |
666 | 659 |
667 // Now advance to the arguments adapter frame (if any). It contains all | 660 // Now advance to the arguments adapter frame (if any). It contains all |
668 // the provided parameters whereas the function frame always have the number | 661 // the provided parameters whereas the function frame always have the number |
669 // of arguments matching the functions parameters. The rest of the | 662 // of arguments matching the functions parameters. The rest of the |
670 // information (except for what is collected above) is the same. | 663 // information (except for what is collected above) is the same. |
671 if ((inlined_jsframe_index == 0) && | 664 if ((inlined_frame_index == 0) && |
672 it.javascript_frame()->has_adapted_arguments()) { | 665 it.javascript_frame()->has_adapted_arguments()) { |
673 it.AdvanceToArgumentsFrame(); | 666 it.AdvanceToArgumentsFrame(); |
674 frame_inspector.SetArgumentsFrame(it.frame()); | 667 frame_inspector.SetArgumentsFrame(it.frame()); |
675 } | 668 } |
676 | 669 |
677 // Find the number of arguments to fill. At least fill the number of | 670 // Find the number of arguments to fill. At least fill the number of |
678 // parameters for the function and fill more if more parameters are provided. | 671 // parameters for the function and fill more if more parameters are provided. |
679 int argument_count = scope_info->ParameterCount(); | 672 int argument_count = scope_info->ParameterCount(); |
680 if (argument_count < frame_inspector.GetParametersCount()) { | 673 if (argument_count < frame_inspector.GetParametersCount()) { |
681 argument_count = frame_inspector.GetParametersCount(); | 674 argument_count = frame_inspector.GetParametersCount(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(constructor)); | 707 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(constructor)); |
715 | 708 |
716 // Add the at return information. | 709 // Add the at return information. |
717 details->set(kFrameDetailsAtReturnIndex, heap->ToBoolean(at_return)); | 710 details->set(kFrameDetailsAtReturnIndex, heap->ToBoolean(at_return)); |
718 | 711 |
719 // Add flags to indicate information on whether this frame is | 712 // Add flags to indicate information on whether this frame is |
720 // bit 0: invoked in the debugger context. | 713 // bit 0: invoked in the debugger context. |
721 // bit 1: optimized frame. | 714 // bit 1: optimized frame. |
722 // bit 2: inlined in optimized frame | 715 // bit 2: inlined in optimized frame |
723 int flags = 0; | 716 int flags = 0; |
724 if (*save->context() == *isolate->debug()->debug_context()) { | 717 if (!save->context().is_null() && |
| 718 *save->context() == *isolate->debug()->debug_context()) { |
725 flags |= 1 << 0; | 719 flags |= 1 << 0; |
726 } | 720 } |
727 if (is_optimized) { | 721 if (is_optimized) { |
728 flags |= 1 << 1; | 722 flags |= 1 << 1; |
729 flags |= inlined_jsframe_index << 2; | 723 flags |= inlined_frame_index << 2; |
730 } | 724 } |
731 details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags)); | 725 details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags)); |
732 | 726 |
733 // Fill the dynamic part. | 727 // Fill the dynamic part. |
734 int details_index = kFrameDetailsFirstDynamicIndex; | 728 int details_index = kFrameDetailsFirstDynamicIndex; |
735 | 729 |
736 // Add arguments name and value. | 730 // Add arguments name and value. |
737 for (int i = 0; i < argument_count; i++) { | 731 for (int i = 0; i < argument_count; i++) { |
738 // Name of the argument. | 732 // Name of the argument. |
739 if (i < scope_info->ParameterCount()) { | 733 if (i < scope_info->ParameterCount()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 // The array returned contains the following information: | 799 // The array returned contains the following information: |
806 // 0: Scope type | 800 // 0: Scope type |
807 // 1: Scope object | 801 // 1: Scope object |
808 RUNTIME_FUNCTION(Runtime_GetScopeDetails) { | 802 RUNTIME_FUNCTION(Runtime_GetScopeDetails) { |
809 HandleScope scope(isolate); | 803 HandleScope scope(isolate); |
810 DCHECK(args.length() == 4); | 804 DCHECK(args.length() == 4); |
811 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 805 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
812 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 806 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); |
813 | 807 |
814 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 808 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
815 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 809 CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); |
816 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 810 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
817 | 811 |
818 // Get the frame where the debugging is performed. | 812 // Get the frame where the debugging is performed. |
819 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); | 813 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); |
820 JavaScriptFrameIterator frame_it(isolate, id); | 814 JavaScriptFrameIterator frame_it(isolate, id); |
821 JavaScriptFrame* frame = frame_it.frame(); | 815 JavaScriptFrame* frame = frame_it.frame(); |
822 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 816 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); |
823 | 817 |
824 // Find the requested scope. | 818 // Find the requested scope. |
825 int n = 0; | 819 int n = 0; |
826 ScopeIterator it(isolate, &frame_inspector); | 820 ScopeIterator it(isolate, &frame_inspector); |
827 for (; !it.Done() && n < index; it.Next()) { | 821 for (; !it.Done() && n < index; it.Next()) { |
828 n++; | 822 n++; |
829 } | 823 } |
830 if (it.Done()) { | 824 if (it.Done()) { |
831 return isolate->heap()->undefined_value(); | 825 return isolate->heap()->undefined_value(); |
832 } | 826 } |
(...skipping 10 matching lines...) Expand all Loading... |
843 // The array returned contains arrays with the following information: | 837 // The array returned contains arrays with the following information: |
844 // 0: Scope type | 838 // 0: Scope type |
845 // 1: Scope object | 839 // 1: Scope object |
846 RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) { | 840 RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) { |
847 HandleScope scope(isolate); | 841 HandleScope scope(isolate); |
848 DCHECK(args.length() == 3 || args.length() == 4); | 842 DCHECK(args.length() == 3 || args.length() == 4); |
849 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 843 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
850 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 844 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); |
851 | 845 |
852 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 846 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
853 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 847 CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); |
854 | 848 |
855 ScopeIterator::Option option = ScopeIterator::DEFAULT; | 849 ScopeIterator::Option option = ScopeIterator::DEFAULT; |
856 if (args.length() == 4) { | 850 if (args.length() == 4) { |
857 CONVERT_BOOLEAN_ARG_CHECKED(flag, 3); | 851 CONVERT_BOOLEAN_ARG_CHECKED(flag, 3); |
858 if (flag) option = ScopeIterator::IGNORE_NESTED_SCOPES; | 852 if (flag) option = ScopeIterator::IGNORE_NESTED_SCOPES; |
859 } | 853 } |
860 | 854 |
861 // Get the frame where the debugging is performed. | 855 // Get the frame where the debugging is performed. |
862 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); | 856 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); |
863 StackTraceFrameIterator frame_it(isolate, id); | 857 StackTraceFrameIterator frame_it(isolate, id); |
864 StandardFrame* frame = frame_it.frame(); | 858 StandardFrame* frame = frame_it.frame(); |
865 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 859 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); |
866 | 860 |
867 List<Handle<JSObject> > result(4); | 861 List<Handle<JSObject> > result(4); |
868 ScopeIterator it(isolate, &frame_inspector, option); | 862 ScopeIterator it(isolate, &frame_inspector, option); |
869 for (; !it.Done(); it.Next()) { | 863 for (; !it.Done(); it.Next()) { |
870 Handle<JSObject> details; | 864 Handle<JSObject> details; |
871 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details, | 865 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details, |
872 it.MaterializeScopeDetails()); | 866 it.MaterializeScopeDetails()); |
873 result.Add(details); | 867 result.Add(details); |
874 } | 868 } |
875 | 869 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 947 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
954 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); | 948 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); |
955 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); | 949 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); |
956 | 950 |
957 bool res; | 951 bool res; |
958 if (args[0]->IsNumber()) { | 952 if (args[0]->IsNumber()) { |
959 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 953 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
960 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 954 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); |
961 | 955 |
962 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 956 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
963 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 957 CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); |
964 | 958 |
965 // Get the frame where the debugging is performed. | 959 // Get the frame where the debugging is performed. |
966 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); | 960 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); |
967 JavaScriptFrameIterator frame_it(isolate, id); | 961 JavaScriptFrameIterator frame_it(isolate, id); |
968 JavaScriptFrame* frame = frame_it.frame(); | 962 JavaScriptFrame* frame = frame_it.frame(); |
969 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 963 FrameInspector frame_inspector(frame, inlined_frame_index, isolate); |
970 | 964 |
971 ScopeIterator it(isolate, &frame_inspector); | 965 ScopeIterator it(isolate, &frame_inspector); |
972 res = SetScopeVariableValue(&it, index, variable_name, new_value); | 966 res = SetScopeVariableValue(&it, index, variable_name, new_value); |
973 } else { | 967 } else { |
974 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 968 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
975 ScopeIterator it(isolate, fun); | 969 ScopeIterator it(isolate, fun); |
976 res = SetScopeVariableValue(&it, index, variable_name, new_value); | 970 res = SetScopeVariableValue(&it, index, variable_name, new_value); |
977 } | 971 } |
978 | 972 |
979 return isolate->heap()->ToBoolean(res); | 973 return isolate->heap()->ToBoolean(res); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 RUNTIME_FUNCTION(Runtime_DebugEvaluate) { | 1183 RUNTIME_FUNCTION(Runtime_DebugEvaluate) { |
1190 HandleScope scope(isolate); | 1184 HandleScope scope(isolate); |
1191 | 1185 |
1192 // Check the execution state and decode arguments frame and source to be | 1186 // Check the execution state and decode arguments frame and source to be |
1193 // evaluated. | 1187 // evaluated. |
1194 DCHECK(args.length() == 6); | 1188 DCHECK(args.length() == 6); |
1195 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 1189 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
1196 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 1190 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); |
1197 | 1191 |
1198 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 1192 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
1199 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 1193 CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); |
1200 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); | 1194 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); |
1201 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); | 1195 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); |
1202 CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 5); | 1196 CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 5); |
1203 | 1197 |
1204 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); | 1198 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); |
1205 | 1199 |
1206 RETURN_RESULT_OR_FAILURE( | 1200 RETURN_RESULT_OR_FAILURE( |
1207 isolate, DebugEvaluate::Local(isolate, id, inlined_jsframe_index, source, | 1201 isolate, DebugEvaluate::Local(isolate, id, inlined_frame_index, source, |
1208 disable_break, context_extension)); | 1202 disable_break, context_extension)); |
1209 } | 1203 } |
1210 | 1204 |
1211 | 1205 |
1212 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { | 1206 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { |
1213 HandleScope scope(isolate); | 1207 HandleScope scope(isolate); |
1214 | 1208 |
1215 // Check the execution state and decode arguments frame and source to be | 1209 // Check the execution state and decode arguments frame and source to be |
1216 // evaluated. | 1210 // evaluated. |
1217 DCHECK(args.length() == 4); | 1211 DCHECK(args.length() == 4); |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 } | 1820 } |
1827 | 1821 |
1828 RUNTIME_FUNCTION(Runtime_GetWasmFunctionOffsetTable) { | 1822 RUNTIME_FUNCTION(Runtime_GetWasmFunctionOffsetTable) { |
1829 DCHECK(args.length() == 1); | 1823 DCHECK(args.length() == 1); |
1830 HandleScope scope(isolate); | 1824 HandleScope scope(isolate); |
1831 CONVERT_ARG_CHECKED(JSValue, script_val, 0); | 1825 CONVERT_ARG_CHECKED(JSValue, script_val, 0); |
1832 | 1826 |
1833 RUNTIME_ASSERT(script_val->value()->IsScript()); | 1827 RUNTIME_ASSERT(script_val->value()->IsScript()); |
1834 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); | 1828 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); |
1835 | 1829 |
1836 Handle<wasm::WasmDebugInfo> debug_info( | 1830 Handle<JSObject> wasm(script->wasm_object(), isolate); |
1837 wasm::GetDebugInfo(script->wasm_object()), isolate); | 1831 Handle<wasm::WasmDebugInfo> debug_info(wasm::GetDebugInfo(wasm), isolate); |
1838 Handle<FixedArray> elements = wasm::WasmDebugInfo::GetFunctionOffsetTable( | 1832 Handle<FixedArray> elements = wasm::WasmDebugInfo::GetFunctionOffsetTable( |
1839 debug_info, script->wasm_function_index()); | 1833 debug_info, script->wasm_function_index()); |
1840 return *isolate->factory()->NewJSArrayWithElements(elements); | 1834 return *isolate->factory()->NewJSArrayWithElements(elements); |
1841 } | 1835 } |
1842 | 1836 |
1843 RUNTIME_FUNCTION(Runtime_DisassembleWasmFunction) { | 1837 RUNTIME_FUNCTION(Runtime_DisassembleWasmFunction) { |
1844 DCHECK(args.length() == 1); | 1838 DCHECK(args.length() == 1); |
1845 HandleScope scope(isolate); | 1839 HandleScope scope(isolate); |
1846 CONVERT_ARG_CHECKED(JSValue, script_val, 0); | 1840 CONVERT_ARG_CHECKED(JSValue, script_val, 0); |
1847 | 1841 |
1848 RUNTIME_ASSERT(script_val->value()->IsScript()); | 1842 RUNTIME_ASSERT(script_val->value()->IsScript()); |
1849 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); | 1843 Handle<Script> script = Handle<Script>(Script::cast(script_val->value())); |
1850 | 1844 |
1851 Handle<wasm::WasmDebugInfo> debug_info( | 1845 Handle<JSObject> wasm(script->wasm_object(), isolate); |
1852 wasm::GetDebugInfo(script->wasm_object()), isolate); | 1846 Handle<wasm::WasmDebugInfo> debug_info(wasm::GetDebugInfo(wasm), isolate); |
1853 return *wasm::WasmDebugInfo::DisassembleFunction( | 1847 return *wasm::WasmDebugInfo::DisassembleFunction( |
1854 debug_info, script->wasm_function_index()); | 1848 debug_info, script->wasm_function_index()); |
1855 } | 1849 } |
1856 | 1850 |
| 1851 RUNTIME_FUNCTION(Runtime_GetWasmInterpreterBuffer) { |
| 1852 DCHECK(args.length() == 2); |
| 1853 HandleScope scope(isolate); |
| 1854 CONVERT_NUMBER_CHECKED(int32_t, func_index, Int32, args[0]); |
| 1855 CONVERT_ARG_HANDLE_CHECKED(JSObject, wasm_object, 1); |
| 1856 |
| 1857 return wasm::GetDebugInfo(wasm_object)->GetInterpreterArgBuffer(func_index); |
| 1858 } |
| 1859 |
| 1860 RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { |
| 1861 DCHECK(args.length() == 2); |
| 1862 HandleScope scope(isolate); |
| 1863 CONVERT_NUMBER_CHECKED(int32_t, func_index, Int32, args[0]); |
| 1864 CONVERT_ARG_HANDLE_CHECKED(JSObject, wasm_object, 1); |
| 1865 |
| 1866 wasm::GetDebugInfo(wasm_object)->RunInterpreter(func_index); |
| 1867 return isolate->heap()->undefined_value(); |
| 1868 } |
| 1869 |
1857 } // namespace internal | 1870 } // namespace internal |
1858 } // namespace v8 | 1871 } // namespace v8 |
OLD | NEW |