In a step towards better debugging support for Wasm, we want to show the disassembly of wasm functions in DevTools. This bug tracks the progress towards that goal. Design Doc: https://docs.google.com/a/google.com/document/d/1oth6HTiaiyZy5nLaCsnjBhLVXFWI-509Dhqy3VydKC8/edit?usp=sharing
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/0c6fa1724f3ae2642f2f1628c10c362e01078803 commit 0c6fa1724f3ae2642f2f1628c10c362e01078803 Author: clemensh <clemensh@chromium.org> Date: Mon Nov 14 16:00:03 2016 [wasm] Make reported "lines" on stack frames 1-based In captured stack traces, all lines and columns must be 1-based. Even though this makes things a bit ugly, we have to comply also for wasm locations, where line and column encode function index and byte offset (both are originally 0-based). If we don't comply, the frontend might complain, as e.g. DevTools does. BUG= chromium:659715 R=yangguo@chromium.org, kozyatinskiy@chromium.org CC=titzer@chromium.org Review-Url: https://codereview.chromium.org/2493943002 Cr-Commit-Position: refs/heads/master@{#40971} [modify] https://crrev.com/0c6fa1724f3ae2642f2f1628c10c362e01078803/src/isolate.cc [modify] https://crrev.com/0c6fa1724f3ae2642f2f1628c10c362e01078803/test/cctest/wasm/test-wasm-stack.cc [modify] https://crrev.com/0c6fa1724f3ae2642f2f1628c10c362e01078803/test/cctest/wasm/test-wasm-trap-position.cc
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/32077e01fb7f98c8cd6d9f95abbedec6cdeda469 commit 32077e01fb7f98c8cd6d9f95abbedec6cdeda469 Author: clemensh <clemensh@chromium.org> Date: Tue Nov 15 17:05:13 2016 [wasm] Allocate a single script per wasm module Before, we allocated one script per function per instance, and each script referenced the wasm instance and the function index. Now we only allocate one script per compiled wasm module, so the script also only references this WasmCompiledModule, which causes changes to many interfaces. Instead of fixing the disassemble API only used via debug.js, I decided to drop it for now. Some later CL will reintroduce it via DebugInterface. BUG= v8:5530 , chromium:659715 R=yangguo@chromium.org, titzer@chromium.org CC=jgruber@chromium.org Review-Url: https://codereview.chromium.org/2493823003 Cr-Commit-Position: refs/heads/master@{#41004} [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/debug/debug.js [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/frames.cc [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/inspector/v8-debugger.cc [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/messages.cc [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/messages.h [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/objects-inl.h [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/objects.cc [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/objects.h [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/runtime/runtime-debug.cc [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/runtime/runtime.h [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/wasm/module-decoder.cc [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/wasm/module-decoder.h [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/wasm/wasm-debug.cc [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/wasm/wasm-module.cc [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/wasm/wasm-module.h [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/src/wasm/wasm-objects.h [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/test/inspector/debugger/wasm-stack-expected.txt [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/test/inspector/debugger/wasm-stack.js [delete] https://crrev.com/244a049bfcb905054fa096829662b60b4ad0bf57/test/mjsunit/wasm/debug-disassembly.js [modify] https://crrev.com/32077e01fb7f98c8cd6d9f95abbedec6cdeda469/test/mjsunit/wasm/frame-inspection.js
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/c9c6c1a393b2f662e130169ef21864b5a89e8cb3 commit c9c6c1a393b2f662e130169ef21864b5a89e8cb3 Author: clemensh <clemensh@chromium.org> Date: Tue Nov 15 17:32:54 2016 [inspector] Fix and refactor String16 This CL defines move semantics for String16, and fixes issues with the hash code not being set correctly on swap or copy. It also extends the interface by a few handy templates. All this functionality will be used for the wasm translations, where String16s are often concatenated and used as keys in hash tables. BUG= chromium:659715 R=yangguo@chromium.org, kozyatinskiy@chromium.org Review-Url: https://codereview.chromium.org/2493723003 Cr-Commit-Position: refs/heads/master@{#41007} [modify] https://crrev.com/c9c6c1a393b2f662e130169ef21864b5a89e8cb3/src/inspector/string-16.cc [modify] https://crrev.com/c9c6c1a393b2f662e130169ef21864b5a89e8cb3/src/inspector/string-16.h [modify] https://crrev.com/c9c6c1a393b2f662e130169ef21864b5a89e8cb3/src/inspector/v8-debugger-agent-impl.cc
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/764371bc3bb8040ed914c69e4631fa08e7f36e7b commit 764371bc3bb8040ed914c69e4631fa08e7f36e7b Author: clemensh <clemensh@chromium.org> Date: Wed Nov 16 16:38:39 2016 [inspector] Change ScriptBreakpoint to include scriptId The ScriptBreakpoint struct was before just holding line, column and condition. It now additionally holds the scriptId. This encapsulates information nicer, and allows for easier translation of wasm locations, since one struct now holds all information needed for the translation. BUG= chromium:659715 R=yangguo@chromium.org, kozyatinskiy@chromium.org Review-Url: https://codereview.chromium.org/2491133003 Cr-Commit-Position: refs/heads/master@{#41044} [modify] https://crrev.com/764371bc3bb8040ed914c69e4631fa08e7f36e7b/src/inspector/script-breakpoint.h [modify] https://crrev.com/764371bc3bb8040ed914c69e4631fa08e7f36e7b/src/inspector/v8-debugger-agent-impl.cc [modify] https://crrev.com/764371bc3bb8040ed914c69e4631fa08e7f36e7b/src/inspector/v8-debugger-agent-impl.h [modify] https://crrev.com/764371bc3bb8040ed914c69e4631fa08e7f36e7b/src/inspector/v8-debugger.cc [modify] https://crrev.com/764371bc3bb8040ed914c69e4631fa08e7f36e7b/src/inspector/v8-debugger.h
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e commit d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e Author: clemensh <clemensh@chromium.org> Date: Wed Nov 16 23:35:30 2016 [inspector] Introduce translation of wasm frames This allows to show wasm source (disassembled wasm code) in DevTools. See design doc for details. More tests for the disassembly will have to follow. Also, the text format (generated by V8) will be changed. BUG= chromium:659715 R=yangguo@chromium.org, kozyatinskiy@chromium.org, titzer@chromium.org, dgozman@chromium.org Review-Url: https://codereview.chromium.org/2493773003 Cr-Commit-Position: refs/heads/master@{#41055} [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/api.cc [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/debug/debug-interface.h [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/BUILD.gn [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/inspector.gypi [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/v8-debugger-agent-impl.cc [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/v8-debugger-script.cc [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/v8-debugger-script.h [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/v8-debugger.cc [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/v8-debugger.h [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/v8-inspector-impl.cc [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/v8-stack-trace-impl.cc [add] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/wasm-translation.cc [add] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/inspector/wasm-translation.h [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/wasm/wasm-module.cc [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/src/wasm/wasm-module.h [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/test/inspector/debugger/wasm-stack-expected.txt [modify] https://crrev.com/d4a42a5f89b923a1f8cf0b09bbbd3f4a83049c5e/test/inspector/debugger/wasm-stack.js
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/8c4224a5967500407850eb66da07fede8fb18df6 commit 8c4224a5967500407850eb66da07fede8fb18df6 Author: clemensh <clemensh@chromium.org> Date: Thu Nov 17 10:17:04 2016 [inspector] Add test case for wasm source The test just prints the source text of each line on the stack. Look how beautiful it reads \o/ BUG= chromium:659715 R=yangguo@chromium.org, kozyatinskiy@chromium.org CC=titzer@chromium.org Review-Url: https://codereview.chromium.org/2492123003 Cr-Commit-Position: refs/heads/master@{#41068} [add] https://crrev.com/8c4224a5967500407850eb66da07fede8fb18df6/test/inspector/debugger/wasm-source-expected.txt [add] https://crrev.com/8c4224a5967500407850eb66da07fede8fb18df6/test/inspector/debugger/wasm-source.js
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/172f501233498e4dac793f415e12a213aa0b56b4 commit 172f501233498e4dac793f415e12a213aa0b56b4 Author: clemensh <clemensh@chromium.org> Date: Tue Nov 22 11:59:27 2016 [wasm] Implement official wasm text format When disassembling functions for the inspector, we used an internal text representation before. This CL implements the official text format like it is understood by the spec interpreter. Example output: func $main (param i32) (result i32) block i32 get_local 0 i32.const 2 i32.lt_u if i32.const -2 return end get_local 0 call_indirect 0 end R=rossberg@chromium.org, titzer@chromium.org BUG= chromium:659715 Review-Url: https://codereview.chromium.org/2520943002 Cr-Commit-Position: refs/heads/master@{#41172} [modify] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/BUILD.gn [modify] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/src/compiler/wasm-compiler.cc [modify] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/src/flag-definitions.h [modify] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/src/v8.gyp [modify] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/src/wasm/ast-decoder.h [modify] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/src/wasm/wasm-module.cc [modify] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/src/wasm/wasm-module.h [add] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/src/wasm/wasm-text.cc [add] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/src/wasm/wasm-text.h [modify] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/test/inspector/debugger/wasm-source-expected.txt [modify] https://crrev.com/172f501233498e4dac793f415e12a213aa0b56b4/test/inspector/debugger/wasm-stack-expected.txt
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/8f9bb9b8d6c0b7f2dfd68f4ed2ed67c539f77589 commit 8f9bb9b8d6c0b7f2dfd68f4ed2ed67c539f77589 Author: clemensh <clemensh@chromium.org> Date: Mon Dec 05 09:42:34 2016 [wasm] Add disassembly for select instruction This was somehow missing so far. With this CL, we can disassembly all functions on AngryBots. R=titzer@chromium.org, rossberg@chromium.org BUG= chromium:659715 Review-Url: https://codereview.chromium.org/2552643002 Cr-Commit-Position: refs/heads/master@{#41476} [modify] https://crrev.com/8f9bb9b8d6c0b7f2dfd68f4ed2ed67c539f77589/src/wasm/wasm-text.cc
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/12cdb31b2fd1a51843e0b4753af15e4488a67a3e commit 12cdb31b2fd1a51843e0b4753af15e4488a67a3e Author: clemensh <clemensh@chromium.org> Date: Tue Dec 06 13:20:07 2016 [inspector] Introduce debug::WasmScript *and* report all "virtual" wasm scripts right when the wasm script is registered at the inspector. WasmScript is a subtype of Script, with the cast checking that it is actually a wasm script. This layout makes it quite easy to implement functionality that is only available for wasm scripts, and allows to later directly use the WasmCompiledModule instead of the i::Script for backing the debug::WasmScript. We might also add virtual methods to provide different implementations for GetSourcePosition, Source and others. DisassembleWasmFunction now also becomes a method of this class instead of a static function on the DebugInterface. The WasmTranslation now uses the new WasmScript type instead of the Script wrapper, and also registers all virtual wasm scripts immediately when the wasm script is made public to the inspector (when the wasm module is created). R=yangguo@chromium.org,dgozman@chromium.org,titzer@chromium.org BUG= chromium:613110 , chromium:659715 Review-Url: https://codereview.chromium.org/2531163010 Cr-Commit-Position: refs/heads/master@{#41519} [modify] https://crrev.com/12cdb31b2fd1a51843e0b4753af15e4488a67a3e/src/api.cc [modify] https://crrev.com/12cdb31b2fd1a51843e0b4753af15e4488a67a3e/src/debug/debug-interface.h [modify] https://crrev.com/12cdb31b2fd1a51843e0b4753af15e4488a67a3e/src/inspector/v8-debugger-agent-impl.cc [modify] https://crrev.com/12cdb31b2fd1a51843e0b4753af15e4488a67a3e/src/inspector/v8-debugger.cc [modify] https://crrev.com/12cdb31b2fd1a51843e0b4753af15e4488a67a3e/src/inspector/v8-stack-trace-impl.cc [modify] https://crrev.com/12cdb31b2fd1a51843e0b4753af15e4488a67a3e/src/inspector/wasm-translation.cc [modify] https://crrev.com/12cdb31b2fd1a51843e0b4753af15e4488a67a3e/src/inspector/wasm-translation.h [add] https://crrev.com/12cdb31b2fd1a51843e0b4753af15e4488a67a3e/test/inspector/debugger/wasm-scripts-expected.txt [add] https://crrev.com/12cdb31b2fd1a51843e0b4753af15e4488a67a3e/test/inspector/debugger/wasm-scripts.js [modify] https://crrev.com/12cdb31b2fd1a51843e0b4753af15e4488a67a3e/test/inspector/protocol-test.js
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/2da865d8a44082e542b87972c1a888205e9a949d commit 2da865d8a44082e542b87972c1a888205e9a949d Author: clemensh <clemensh@chromium.org> Date: Tue Dec 06 13:50:40 2016 [inspector] [wasm] Add folder structure to wasm urls It turns out that showing a five-digit number of resources blocks the UI for a few minutes, and it remains very laggy even after that. This CL adds another component to the path of wasm scripts if the module contains more than 300 functions. The additional component will be the function index rounded down to the next multiple of 100. Example URL before: wasm://wasm/wasm-0284f1c6/wasm-0284f1c6-26337 Example URL after: wasm://wasm/wasm-0284f1c6/26300/wasm-0284f1c6-26337 This avoids showing a five-digit number of entries in the resources view. R=kozyatinskiy@chromium.org, titzer@chromium.org, yangguo@chromium.org BUG= chromium:659715 Review-Url: https://codereview.chromium.org/2555433002 Cr-Commit-Position: refs/heads/master@{#41522} [modify] https://crrev.com/2da865d8a44082e542b87972c1a888205e9a949d/src/inspector/wasm-translation.cc
Comment 1 by bugdroid1@chromium.org
, Nov 14 2016