あったら嬉しい WebAssembly のツール群 ―― 新言語の裾野は広い

先日、WebAssembly の開発がスタートしたの受け、その開発の目的について本ブログでも取り上げた。GitHub 上では言語仕様のみならず、開発に付随するツールに関しても今後の方針が掲載されている。本日はその点について取り上げる。

今後期待する WebAssembly のツール群

以下の文章は、GitHub 上の Tooling Support のページから引用である。

  • Editors:
    • Editors such as vim and emacs should just work.
  • Compilers and language virtual machines:
    • Compilers for languages which can target WebAssembly (C/C++, Rust, Go, C#) should be able to run in WebAssembly themselves, emit a WebAssembly module that can then be executed.
    • Virtual machines for languages such as bash, Python, Ruby should work.
    • Virtual machines which use a just-in-time compiler (JavaScript VMs, luajit, pypy) should be able to support a new just-in-time backend for WebAssembly.
  • Debuggers:
    • Basic browser integration can be done through source map support.
    • Full integration for languages like C++ require more standardization effort on debugging information format as well as permissions for interrupting programs, inspecting their state, modifying their state.
    • Debug information is better delivered on-demand instead of built-in to a WebAssembly module.
  • Sanitizers for non-memory-safe languages: asan, tsan, msan, ubsan. Efficient support of sanitizers may require improving:
    • Trapping support;
    • Shadow stack techniques (often implemented through mmap’s MAP_FIXED).
  • Opt-in security enhancements for developers’ own code: developers targeting WebAssembly may want their own code to be sandboxed further than what WebAssembly implementations require to protect users.
  • Profilers:
    • Sample-based;
    • Instrumentation-based.
  • Process dump: local variables, call stack, heap, global variables, list of threads.

コンパイラやデバッガがあるべきなのは当然のこととして、個人的にはエディタやプロファイラのことまではまだ考えが及ばなかった。

確かに、WebAssembly のテキストコードは独自のシンタックスになるはずなので、エディタでの対応が求められる。例えば、予約語を色付きの文字で表示したりするのはよくある機能だが、他にも言語仕様によっては自動補完機能でプログラマーを支援することもできるかもしれない。

また、先日の記事にも掲載したが、WebAssembly ではバイナリと相互変換可能なテキストフォーマットが提供される(a human-editable text format that is convertible to and from the binary format)。バイナリコードとテキストコードが一対一で対応付けできるのであれば、テキストで入力しつつ、バイナリの状態を確認できたりすると実際の生成物が把握できる。

バイナリコードとテキストコードの相互変換という視点でいうと、リバースエンジニアリングのツールがあると他の人のコードをみることができて大変勉強になる。その際、人間の理解を促すようなテキストコードに変換してくれると嬉しいものである。

さらに、人間の理解という視点でいうと、コードを図として可視化するツールがあると非常に嬉しい。コードは(バイナリもテキストも含めて)、規模が大きければ大きいほど、プログラマ独自のものになりやすく、他の人間が理解するのが困難になってしまう。呼び出し構造やデータ構造を一見して分かる形で表現してくれると、チーム開発の効率が飛躍的に向上するのは間違いない。

WebAssembly という仕様を中心に、今後さまざまなツールが生まれそうな予感がしている。今後の開発を注視したい。

binary easter egg

コメントを残す