From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- files/zh-tw/webassembly/index.html | 118 +++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 files/zh-tw/webassembly/index.html (limited to 'files/zh-tw/webassembly/index.html') diff --git a/files/zh-tw/webassembly/index.html b/files/zh-tw/webassembly/index.html new file mode 100644 index 0000000000..9ccadd6fb5 --- /dev/null +++ b/files/zh-tw/webassembly/index.html @@ -0,0 +1,118 @@ +--- +title: WebAssembly +slug: WebAssembly +tags: + - WebAssembly + - wasm +translation_of: WebAssembly +--- +
{{WebAssemblySidebar}}
+ +

WebAssembly 是一種新的低階程式語言,可在今日的網頁瀏覽器中被執行 —— 它是低階的類組合語言,具有嚴謹的二進位格式,能以接近原生應用程式的效能執行,並提供如 C/C++ 等語言一個構建目標,使它們能在 Web 上被執行。他也被設計為可與 JavaScript 共存,允許兩者一同工作。

+ +

簡而言之

+ +

WebAssembly 對於網路平台而言具有極大的意義 —— 它提供了一種方式,使得那些以各種語言編寫的程式都能以接近原生的速度於 Web 環境中執行,在這條件下,先前無法以此種方式運作的用戶端軟體皆能在 Web 中被執行。

+ +

WebAssembly 被設計來與  JavaScript 協同工作 —— 藉由 WebAssembly 的  JavaScript API,你可以把 WebAssembly 模組載入至一個  JavaScript 應用程式,並在兩者間共享功能。這允許你在同一應用程式內彈性地發揮  WebAssembly 的高效能威力同時兼顧  JavaScript 的表達力與高靈活性,即便你可能不知道如何編寫 WebAssembly 程式碼。

+ +

而且更棒的是, 這是通過 W3C WebAssembly Community Group 開發的一項網路標準,並也得到來自各大主要瀏覽器廠商的積極參與。

+ +
+
+

指南

+ +
+
WebAssembly 概念
+
藉由閱讀 WebAssembly 後的高階概念開始 —— 也就是說,它為何是如此有用,是如何相容網路平台(及其他),和如何使用它。
+
將 C/C++ 模組編譯為 WebAssembly
+
當你使用 C/C++ 編寫程式後,你可以使用諸如 Emscripten 等工具將其編譯為 .wasm 文件。讓我們看看它是如何實作的。
+
從現有的 C 模組編譯為 WebAssembly
+
WebAssembly 核心的使用案例是期望能讓開發者在 Web 環境中使用現存 C 的生態環境。
+
載入並運行 WebAssembly 程式碼
+
本文介紹如何透過把 Fetch 或 XHR API 與  WebAssembly JavaScript API 結合起來、編譯及實例化 .wasm 文件。
+
快取編譯後的 WebAssembly 模組
+
就加速應用程式速度而言,在用戶端快取較大的 WebAssembly 模組是有效的。本文解釋如何使用 IndexedDB 來實作這一點。
+
使用 WebAssembly 的 JavaScript API
+
當你載入一個 .wasm 模組後,你就用到它。在本文中將向你展示如何透過 WebAssembly 的 JavaScript API 來使用  WebAssembly。
+
導出 WebAssembly 函數
+
被導出的 WebAssembly 函數是用 JavaScript 來表示 WebAssembly 函數的封裝,並允許從 JavaScript 調用 WebAssembly 原始碼。本文將描述他們。
+
了解 WebAssembly 的文件格式
+
本文介紹了 .wasm 的文件格式。這是在進行偵錯時由瀏覽器開發工具中展現出 .wasm 模組的一種低階文件格式。
+
把 WebAssembly 文件格式轉為 wasm
+
本文提供一個如何把以 WebAssembly 編寫的模組轉換為二進位的 .wasm 文件格式的指南。
+
+
+ +
+

API 參考

+ +
+
{{jsxref("Global_objects/WebAssembly", "WebAssembly")}}
+
This object acts as the namespace for all WebAssembly related functionality.
+
{{jsxref("Global_objects/WebAssembly/Module", "WebAssembly.Module()")}}
+
A WebAssembly.Module object contains stateless WebAssembly code that has already been compiled by the browser and can be efficiently shared with Workers, cached in IndexedDB, and instantiated multiple times.
+
{{jsxref("Global_objects/WebAssembly/Instance", "WebAssembly.Instance()")}}
+
A WebAssembly.Instance object is a stateful, executable instance of a ModuleInstance objects contain all the Exported WebAssembly functions that allow calling into WebAssembly code from JavaScript.
+
{{jsxref("Global_objects/WebAssembly/instantiateStreaming", "WebAssembly.instantiateStreaming()")}}
+
The WebAssembly.instantiateStreaming() function is the primary API for compiling and instantiating WebAssembly code, returning both a Module and its first Instance.
+
{{jsxref("Global_objects/WebAssembly/Memory", "WebAssembly.Memory()")}}
+
A WebAssembly.Memory object is a resizable {{jsxref("Global_objects/ArrayBuffer", "ArrayBuffer")}} that holds the raw bytes of memory accessed by an Instance.
+
{{jsxref("Global_objects/WebAssembly/Table", "WebAssembly.Table()")}}
+
A WebAssembly.Table object is a resizable typed array of opaque values, like function references, that are accessed by an Instance.
+
{{jsxref("WebAssembly.CompileError()")}}
+
Creates a new WebAssembly CompileError object.
+
{{jsxref("WebAssembly.LinkError()")}}
+
Creates a new WebAssembly LinkError object.
+
{{jsxref("WebAssembly.RuntimeError()")}}
+
Creates a new WebAssembly RuntimeError object.
+
+
+
+ +

範本

+ + + +

規範

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('WebAssembly JS')}}{{Spec2('WebAssembly JS')}}Initial draft definition of the JavaScript API.
+ +

瀏覽器相容性

+ +
+ + +

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

+
+ +

參見

+ + + +

 

-- cgit v1.2.3-54-g00ecf