| Index: src/runtime/runtime-debug.cc
|
| diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
|
| index 5411ea7c68df1ac023d883e11aaa3a3864e2ae8a..2dddd875a8c55bd1c28ec2e62b4fbf50c27aec66 100644
|
| --- a/src/runtime/runtime-debug.cc
|
| +++ b/src/runtime/runtime-debug.cc
|
| @@ -457,14 +457,10 @@ RUNTIME_FUNCTION(Runtime_GetFrameCount) {
|
|
|
| for (StackTraceFrameIterator it(isolate, id); !it.done(); it.Advance()) {
|
| List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
|
| - if (it.is_wasm()) {
|
| - n++;
|
| - } else {
|
| - it.javascript_frame()->Summarize(&frames);
|
| - for (int i = frames.length() - 1; i >= 0; i--) {
|
| - // Omit functions from native and extension scripts.
|
| - if (frames[i].function()->shared()->IsSubjectToDebugging()) n++;
|
| - }
|
| + it.frame()->Summarize(&frames);
|
| + for (int i = frames.length() - 1; i >= 0; i--) {
|
| + // Omit functions from native and extension scripts.
|
| + if (frames[i].is_subject_to_debugging()) n++;
|
| }
|
| }
|
| return Smi::FromInt(n);
|
| @@ -519,11 +515,11 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
|
|
|
| StackTraceFrameIterator it(isolate, id);
|
| // Inlined frame index in optimized frame, starting from outer function.
|
| - int inlined_jsframe_index =
|
| + int inlined_frame_index =
|
| DebugFrameHelper::FindIndexedNonNativeFrame(&it, index);
|
| - if (inlined_jsframe_index == -1) return heap->undefined_value();
|
| + if (inlined_frame_index == -1) return heap->undefined_value();
|
|
|
| - FrameInspector frame_inspector(it.frame(), inlined_jsframe_index, isolate);
|
| + FrameInspector frame_inspector(it.frame(), inlined_frame_index, isolate);
|
|
|
| // Traverse the saved contexts chain to find the active context for the
|
| // selected frame.
|
| @@ -546,11 +542,8 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
|
| details->set(kFrameDetailsFrameIdIndex, *frame_id);
|
|
|
| // Add the function name.
|
| - Handle<Object> wasm_obj(it.wasm_frame()->wasm_obj(), isolate);
|
| - int func_index = it.wasm_frame()->function_index();
|
| - Handle<String> func_name =
|
| - wasm::GetWasmFunctionName(isolate, wasm_obj, func_index);
|
| - details->set(kFrameDetailsFunctionIndex, *func_name);
|
| + details->set(kFrameDetailsFunctionIndex,
|
| + *frame_inspector.GetFunctionName());
|
|
|
| // Add the script wrapper
|
| Handle<Object> script_wrapper =
|
| @@ -668,7 +661,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
|
| // the provided parameters whereas the function frame always have the number
|
| // of arguments matching the functions parameters. The rest of the
|
| // information (except for what is collected above) is the same.
|
| - if ((inlined_jsframe_index == 0) &&
|
| + if ((inlined_frame_index == 0) &&
|
| it.javascript_frame()->has_adapted_arguments()) {
|
| it.AdvanceToArgumentsFrame();
|
| frame_inspector.SetArgumentsFrame(it.frame());
|
| @@ -721,12 +714,13 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
|
| // bit 1: optimized frame.
|
| // bit 2: inlined in optimized frame
|
| int flags = 0;
|
| - if (*save->context() == *isolate->debug()->debug_context()) {
|
| + if (!save->context().is_null() &&
|
| + *save->context() == *isolate->debug()->debug_context()) {
|
| flags |= 1 << 0;
|
| }
|
| if (is_optimized) {
|
| flags |= 1 << 1;
|
| - flags |= inlined_jsframe_index << 2;
|
| + flags |= inlined_frame_index << 2;
|
| }
|
| details->set(kFrameDetailsFlagsIndex, Smi::FromInt(flags));
|
|
|
| @@ -812,14 +806,14 @@ RUNTIME_FUNCTION(Runtime_GetScopeDetails) {
|
| RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id));
|
|
|
| CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
|
| - CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
|
| + CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]);
|
| CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]);
|
|
|
| // Get the frame where the debugging is performed.
|
| StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id);
|
| JavaScriptFrameIterator frame_it(isolate, id);
|
| JavaScriptFrame* frame = frame_it.frame();
|
| - FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
|
| + FrameInspector frame_inspector(frame, inlined_frame_index, isolate);
|
|
|
| // Find the requested scope.
|
| int n = 0;
|
| @@ -850,7 +844,7 @@ RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) {
|
| RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id));
|
|
|
| CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
|
| - CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
|
| + CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]);
|
|
|
| ScopeIterator::Option option = ScopeIterator::DEFAULT;
|
| if (args.length() == 4) {
|
| @@ -862,7 +856,7 @@ RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) {
|
| StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id);
|
| StackTraceFrameIterator frame_it(isolate, id);
|
| StandardFrame* frame = frame_it.frame();
|
| - FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
|
| + FrameInspector frame_inspector(frame, inlined_frame_index, isolate);
|
|
|
| List<Handle<JSObject> > result(4);
|
| ScopeIterator it(isolate, &frame_inspector, option);
|
| @@ -960,13 +954,13 @@ RUNTIME_FUNCTION(Runtime_SetScopeVariableValue) {
|
| RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id));
|
|
|
| CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
|
| - CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
|
| + CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]);
|
|
|
| // Get the frame where the debugging is performed.
|
| StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id);
|
| JavaScriptFrameIterator frame_it(isolate, id);
|
| JavaScriptFrame* frame = frame_it.frame();
|
| - FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
|
| + FrameInspector frame_inspector(frame, inlined_frame_index, isolate);
|
|
|
| ScopeIterator it(isolate, &frame_inspector);
|
| res = SetScopeVariableValue(&it, index, variable_name, new_value);
|
| @@ -1196,7 +1190,7 @@ RUNTIME_FUNCTION(Runtime_DebugEvaluate) {
|
| RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id));
|
|
|
| CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
|
| - CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
|
| + CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]);
|
| CONVERT_ARG_HANDLE_CHECKED(String, source, 3);
|
| CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4);
|
| CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 5);
|
| @@ -1204,7 +1198,7 @@ RUNTIME_FUNCTION(Runtime_DebugEvaluate) {
|
| StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id);
|
|
|
| RETURN_RESULT_OR_FAILURE(
|
| - isolate, DebugEvaluate::Local(isolate, id, inlined_jsframe_index, source,
|
| + isolate, DebugEvaluate::Local(isolate, id, inlined_frame_index, source,
|
| disable_break, context_extension));
|
| }
|
|
|
| @@ -1833,8 +1827,8 @@ RUNTIME_FUNCTION(Runtime_GetWasmFunctionOffsetTable) {
|
| RUNTIME_ASSERT(script_val->value()->IsScript());
|
| Handle<Script> script = Handle<Script>(Script::cast(script_val->value()));
|
|
|
| - Handle<wasm::WasmDebugInfo> debug_info(
|
| - wasm::GetDebugInfo(script->wasm_object()), isolate);
|
| + Handle<JSObject> wasm(script->wasm_object(), isolate);
|
| + Handle<wasm::WasmDebugInfo> debug_info(wasm::GetDebugInfo(wasm), isolate);
|
| Handle<FixedArray> elements = wasm::WasmDebugInfo::GetFunctionOffsetTable(
|
| debug_info, script->wasm_function_index());
|
| return *isolate->factory()->NewJSArrayWithElements(elements);
|
| @@ -1848,11 +1842,30 @@ RUNTIME_FUNCTION(Runtime_DisassembleWasmFunction) {
|
| RUNTIME_ASSERT(script_val->value()->IsScript());
|
| Handle<Script> script = Handle<Script>(Script::cast(script_val->value()));
|
|
|
| - Handle<wasm::WasmDebugInfo> debug_info(
|
| - wasm::GetDebugInfo(script->wasm_object()), isolate);
|
| + Handle<JSObject> wasm(script->wasm_object(), isolate);
|
| + Handle<wasm::WasmDebugInfo> debug_info(wasm::GetDebugInfo(wasm), isolate);
|
| return *wasm::WasmDebugInfo::DisassembleFunction(
|
| debug_info, script->wasm_function_index());
|
| }
|
|
|
| +RUNTIME_FUNCTION(Runtime_GetWasmInterpreterBuffer) {
|
| + DCHECK(args.length() == 2);
|
| + HandleScope scope(isolate);
|
| + CONVERT_NUMBER_CHECKED(int32_t, func_index, Int32, args[0]);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSObject, wasm_object, 1);
|
| +
|
| + return wasm::GetDebugInfo(wasm_object)->GetInterpreterArgBuffer(func_index);
|
| +}
|
| +
|
| +RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
|
| + DCHECK(args.length() == 2);
|
| + HandleScope scope(isolate);
|
| + CONVERT_NUMBER_CHECKED(int32_t, func_index, Int32, args[0]);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSObject, wasm_object, 1);
|
| +
|
| + wasm::GetDebugInfo(wasm_object)->RunInterpreter(func_index);
|
| + return isolate->heap()->undefined_value();
|
| +}
|
| +
|
| } // namespace internal
|
| } // namespace v8
|
|
|