1
WebAssemblyはどのようなフォーマットでコードをコンパイルしますか?Webへのコンパイル
公式サイトから:
WebAssembly or wasm is a new portable, size- and load-time-efficient format
suitable for compilation to the web.
WebAssemblyはどのようなフォーマットでコードをコンパイルしますか?Webへのコンパイル
公式サイトから:
WebAssembly or wasm is a new portable, size- and load-time-efficient format
suitable for compilation to the web.
WebAssemblyはにコンパイルされ、通常はバイナリ形式で配布されています。
int increment(int input) {
return ++input;
}
次にコンパイルされます:
00000000: 0061 736d 0100 0000 0106 0160 017f 017f .asm.......`....
00000010: 0302 0100 0404 0170 0000 0503 0100 0107 .......p........
00000020: 1602 066d 656d 6f72 7902 0009 696e 6372 ...memory...incr
00000030: 656d 656e 7400 000a 0901 0700 2000 4101 ement....... .A.
00000040: 6a0b
あなたはWebAssembly design documentsで、このバイナリエンコードの仕様を見つけることができます
は例えば、ここでは簡単なC関数です。
ただし、コンパイルした出力を表示する場合は、wasm2wast
ツールを使用して、より読みやすいテキスト形式(S式)に変換できます。同じコードがあります:
(module
(table 0 anyfunc)
(memory $0 1)
(export "memory" (memory $0))
(export "increment" (func $increment))
(func $increment (param $0 i32) (result i32)
(i32.add
(get_local $0)
(i32.const 1)
)
)
)
偉大な答え!バイナリエンコーディングのドキュメントへのリンクを追加することをお勧めします:https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md –
ありがとう@JFBastien - 私はリンクを追加しました。 WebAssemblyを自分で学習し始めました。現時点で登るにはかなりの山のように感じます! – ColinE