Movatterモバイル変換


[0]ホーム

URL:


  1. WebAssembly
  2. Reference
  3. WebAssembly
  4. WebAssembly.compile()

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

WebAssembly.compile()

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2017年10月.

* Some parts of this feature may have varying levels of support.

WebAssembly.compile() 関数は WebAssembly バイナリーコードをWebAssembly.Module の形にコンパイルします。この関数は、モジュールをインスタンス化する前にコンパイルする必要がある場合に便利です (それ以外の場合は、WebAssembly.instantiate() 関数を使用してください)。

構文

js
WebAssembly.compile(bufferSource);

引数

bufferSource

コンパイルする .wasm モジュールのバイナリーコードを含む型付き配列またはArrayBuffer です。

返値

コンパイルされたモジュールを表すWebAssembly.Module オブジェクトに解決するPromise です。

例外

compile の使用

次の例では、読み込まれた simple.wasm バイトコードを、compile() 関数を使用してコンパイルし、ワーカーpostMessage() を用いて送信します。

js
var worker = new Worker("wasm_worker.js");fetch("simple.wasm")  .then((response) => response.arrayBuffer())  .then((bytes) => WebAssembly.compile(bytes))  .then((mod) => worker.postMessage(mod));

メモ:おそらく多くの場合はWebAssembly.compileStreaming() を使用したほうがcompile() よりも効率的なのでそちらの方がいいでしょう。

仕様書

Specification
WebAssembly JavaScript Interface
# dom-webassembly-compile

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp