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

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

Issue 2493823003: [wasm] Allocate a single script per wasm module (Closed)
Patch Set: Fix signed/unsigned issues Created 4 years, 1 month 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/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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 if (it.is_wasm()) { 545 if (it.is_wasm()) {
546 // Create the details array (no dynamic information for wasm). 546 // Create the details array (no dynamic information for wasm).
547 Handle<FixedArray> details = 547 Handle<FixedArray> details =
548 isolate->factory()->NewFixedArray(kFrameDetailsFirstDynamicIndex); 548 isolate->factory()->NewFixedArray(kFrameDetailsFirstDynamicIndex);
549 549
550 // Add the frame id. 550 // Add the frame id.
551 details->set(kFrameDetailsFrameIdIndex, *frame_id); 551 details->set(kFrameDetailsFrameIdIndex, *frame_id);
552 552
553 // Add the function name. 553 // Add the function name.
554 Handle<Object> wasm_instance(it.wasm_frame()->wasm_instance(), isolate); 554 Handle<Object> wasm_instance(it.wasm_frame()->wasm_instance(), isolate);
555 Handle<wasm::WasmCompiledModule> compiled_module(
556 wasm::GetCompiledModule(*wasm_instance), isolate);
555 int func_index = it.wasm_frame()->function_index(); 557 int func_index = it.wasm_frame()->function_index();
556 Handle<String> func_name = 558 Handle<String> func_name =
557 wasm::GetWasmFunctionName(isolate, wasm_instance, func_index); 559 wasm::GetWasmFunctionName(isolate, compiled_module, func_index);
558 details->set(kFrameDetailsFunctionIndex, *func_name); 560 details->set(kFrameDetailsFunctionIndex, *func_name);
559 561
560 // Add the script wrapper 562 // Add the script wrapper
561 Handle<Object> script_wrapper = 563 Handle<Object> script_wrapper =
562 Script::GetWrapper(frame_inspector.GetScript()); 564 Script::GetWrapper(frame_inspector.GetScript());
563 details->set(kFrameDetailsScriptIndex, *script_wrapper); 565 details->set(kFrameDetailsScriptIndex, *script_wrapper);
564 566
565 // Add the arguments count. 567 // Add the arguments count.
566 details->set(kFrameDetailsArgumentCountIndex, Smi::kZero); 568 details->set(kFrameDetailsArgumentCountIndex, Smi::kZero);
567 569
568 // Add the locals count 570 // Add the locals count
569 details->set(kFrameDetailsLocalCountIndex, Smi::kZero); 571 details->set(kFrameDetailsLocalCountIndex, Smi::kZero);
570 572
571 // Add the source position. 573 // Add the source position.
574 // For wasm, it is function-local, so translate it to a module-relative
575 // position, such that together with the script it uniquely identifies the
576 // position.
577 Handle<Object> positionValue;
572 if (position != kNoSourcePosition) { 578 if (position != kNoSourcePosition) {
573 details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position)); 579 int translated_position = position;
580 if (!wasm::WasmIsAsmJs(*wasm_instance, isolate)) {
581 Handle<wasm::WasmCompiledModule> compiled_module(
582 wasm::GetCompiledModule(JSObject::cast(*wasm_instance)), isolate);
583 translated_position +=
584 wasm::GetFunctionCodeOffset(compiled_module, func_index);
585 }
586 details->set(kFrameDetailsSourcePositionIndex,
587 Smi::FromInt(translated_position));
574 } 588 }
575 589
576 // Add the constructor information. 590 // Add the constructor information.
577 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(false)); 591 details->set(kFrameDetailsConstructCallIndex, heap->ToBoolean(false));
578 592
579 // Add the at return information. 593 // Add the at return information.
580 details->set(kFrameDetailsAtReturnIndex, heap->ToBoolean(false)); 594 details->set(kFrameDetailsAtReturnIndex, heap->ToBoolean(false));
581 595
582 // Add flags to indicate information on whether this frame is 596 // Add flags to indicate information on whether this frame is
583 // bit 0: invoked in the debugger context. 597 // bit 0: invoked in the debugger context.
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 SealHandleScope shs(isolate); 1904 SealHandleScope shs(isolate);
1891 return Smi::FromInt(isolate->debug()->is_active()); 1905 return Smi::FromInt(isolate->debug()->is_active());
1892 } 1906 }
1893 1907
1894 1908
1895 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { 1909 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
1896 UNIMPLEMENTED(); 1910 UNIMPLEMENTED();
1897 return NULL; 1911 return NULL;
1898 } 1912 }
1899 1913
1900 // TODO(5530): Remove once uses in debug.js are gone.
1901 RUNTIME_FUNCTION(Runtime_GetWasmFunctionOffsetTable) {
1902 DCHECK(args.length() == 1);
1903 HandleScope scope(isolate);
1904 CONVERT_ARG_CHECKED(JSValue, script_val, 0);
1905
1906 CHECK(script_val->value()->IsScript());
1907 Handle<Script> script = Handle<Script>(Script::cast(script_val->value()));
1908
1909 Handle<wasm::WasmDebugInfo> debug_info =
1910 wasm::GetDebugInfo(handle(script->wasm_instance(), isolate));
1911 Handle<FixedArray> elements = wasm::WasmDebugInfo::GetFunctionOffsetTable(
1912 debug_info, script->wasm_function_index());
1913 return *isolate->factory()->NewJSArrayWithElements(elements);
1914 }
1915
1916 // TODO(5530): Remove once uses in debug.js are gone.
1917 RUNTIME_FUNCTION(Runtime_DisassembleWasmFunction) {
1918 DCHECK(args.length() == 1);
1919 HandleScope scope(isolate);
1920 CONVERT_ARG_CHECKED(JSValue, script_val, 0);
1921
1922 CHECK(script_val->value()->IsScript());
1923 Handle<Script> script = Handle<Script>(Script::cast(script_val->value()));
1924
1925 Handle<wasm::WasmDebugInfo> debug_info =
1926 wasm::GetDebugInfo(handle(script->wasm_instance(), isolate));
1927 return *wasm::WasmDebugInfo::DisassembleFunction(
1928 debug_info, script->wasm_function_index());
1929 }
1930
1931 } // namespace internal 1914 } // namespace internal
1932 } // namespace v8 1915 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698