From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../webassembly/compilestreaming/index.html | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html (limited to 'files/ja/web/javascript/reference/global_objects/webassembly/compilestreaming') diff --git a/files/ja/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html b/files/ja/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html new file mode 100644 index 0000000000..e3048ea38f --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html @@ -0,0 +1,77 @@ +--- +title: WebAssembly.compileStreaming() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming +--- +
{{JSRef}} {{SeeCompatTable}}
+ +

WebAssembly.compileStreaming() 関数はソースのストリームから直接 {{jsxref("WebAssembly.Module")}} にコンパイルします。この関数はモジュールをインスタンス化する前にコンパイルする必要がある場合に役立ちます (そうでない場合は、{{jsxref("WebAssembly.instantiateStreaming()")}} 関数の仕様が推奨されます)。

+ +

構文

+ +
Promise<WebAssembly.Module> WebAssembly.compileStreaming(source);
+ +

パラメータ

+ +
+
source
+
ストリーム、コンパイルする .wasm モジュールのソースコードを表す {{domxref("Response")}} オブジェクトか、それを fulfill するプロミス。 
+
+ +

戻り値

+ +

解決時にコンパイルされたモジュールを表す {{jsxref("WebAssembly.Module")}} を渡す Promise 。

+ +

例外

+ + + +

+ +

次の例 (Github上のデモ compile-streaming.html と、動作例 を参照してください) では、ソースから直接 .wasm モジュールをストリームして、 {{jsxref("WebAssembly.Module")}} オブジェクトにコンパイルしています。compileStreaming()  関数は {{domxref("Response")}} オブジェクトを渡すプロミスを受け取るので、直接 {{domxref("WindowOrWorkerGlobalScope.fetch()")}} の呼び出し結果を渡すことができます。

+ +
var importObject = { imports: { imported_func: arg => console.log(arg) } };
+
+WebAssembly.compileStreaming(fetch('simple.wasm'))
+.then(module => WebAssembly.instantiate(module, importObject))
+.then(instance => instance.exports.exported_func());
+ +

結果として受け取ったモジュールインスタンスはその後 {{jsxref("WebAssembly.instantiate()")}} を使用してインスタンス化され、エクスポートされた関数が実行されます。

+ +

仕様

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly Embedding', '#webassemblycompilestreaming', 'compileStreaming()')}}{{Spec2('WebAssembly Embedding')}}初回ドラフト定義
+ +

ブラウザ実装状況

+ +
+ + +

{{Compat("javascript.builtins.WebAssembly.compileStreaming")}}

+
+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf