aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/webassembly
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/webassembly
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/webassembly')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/compile/index.html101
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html114
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html77
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/global/index.html107
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html106
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/instance/index.html89
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiate/index.html175
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html85
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/memory/index.html112
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html87
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html111
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/table/index.html130
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/validate/index.html75
13 files changed, 1369 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/compile/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compile/index.html
new file mode 100644
index 0000000000..6489b54a09
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compile/index.html
@@ -0,0 +1,101 @@
+---
+title: WebAssembly.compile()
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/compile
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/compile
+---
+<div>{{JSRef}} {{SeeCompatTable}}</div>
+
+<p><strong><code>WebAssembly.compile()</code></strong> 方法编译WebAssembly二进制代码到一个{{jsxref("WebAssembly.Module")}} 对象。如果在实例化之前有必要去编译一个模块,那么这个方法是有用的(否则,将会使用{{jsxref("WebAssembly.instantiate()")}} 方法)</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">Promise&lt;WebAssembly.Module&gt; WebAssembly.compile(bufferSource);</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em>bufferSource</em></dt>
+ <dd>一个包含你想编译的wasm模块二进制代码的 <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a>(类型数组) or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a>(数组缓冲区)</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>一个解析为 {{jsxref("WebAssembly.Module")}} 的<code>Promise</code> 对象。</p>
+
+<h3 id="异常">异常</h3>
+
+<ul>
+ <li>如果 <code>bufferSource</code> 不是一个 <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a>, 将抛出一个 {{jsxref("TypeError")}} 。</li>
+ <li>如果编译失败 promise 将会 reject 一个 {{jsxref("WebAssembly.CompileError")}}。</li>
+</ul>
+
+<h2 id="例子">例子</h2>
+
+<p>下面的例子 (查看GitHub上的 <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index-compile.html">index-compile.html</a> 例子, 并且也能 <a href="https://mdn.github.io/webassembly-examples/js-api-examples/index-compile.html">查看运行效果</a>) 使用 <code>compile()</code> 方法编译加载进来的 simple.wasm 二进制代码并且使用 <a href="/en-US/docs/Web/API/Worker/postMessage">postMessage()</a> 发送给一个 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API">worker</a>。</p>
+
+<pre class="brush: js">var worker = new Worker("wasm_worker.js");
+
+fetch('simple.wasm').then(response =&gt;
+  response.arrayBuffer()
+).then(bytes =&gt;
+  WebAssembly.compile(bytes)
+).then(mod =&gt;
+  worker.postMessage(mod)
+);</pre>
+
+<p>在线程中 (查看 <code><a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/wasm_worker.js">wasm_worker.js</a></code>) 我们定义了一个导入对象共模块使用,然后设置了一个事件处理函数来接收主线程发送过来的模块。当模块被接收之后,我们使用{{jsxref("WebAssembly.Instantiate()")}} 方法创建了一个实例,调用从它里面导出的一个方法,接下来展示了我们可以用 {{jsxref("WebAssembly.Module/exports", "WebAssembly.Module.exports")}} 属性来调用模块上返回的可用信息。</p>
+
+<pre class="brush: js">var importObject = {
+ imports: {
+ imported_func: function(arg) {
+ console.log(arg);
+ }
+ }
+};
+
+onmessage = function(e) {
+ console.log('module received from main thread');
+ var mod = e.data;
+
+ WebAssembly.instantiate(mod, importObject).then(function(instance) {
+ instance.exports.exported_func();
+ });
+
+ var exports = WebAssembly.Module.exports(mod);
+ console.log(exports[0]);
+};</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#webassemblycompile', 'compile()')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Initial draft definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.compile")}}</p>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html
new file mode 100644
index 0000000000..179b8589a2
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html
@@ -0,0 +1,114 @@
+---
+title: WebAssembly.CompileError()
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError
+---
+<div>{{JSRef}}</div>
+
+<p><code><strong>WebAssembly.CompileError()</strong></code>构造函数创建一个新的WebAssembly <code>CompileError</code>对象,该对象表示WebAssembly解码或验证期间的错误。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><code>new WebAssembly.CompileError(<var>message</var>, <var>fileName</var>, <var>lineNumber</var>)</code></pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>message</code> {{optional_inline}}</dt>
+ <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">有可读性的错误描述。</span></span></dd>
+ <dt><code>fileName</code> {{optional_inline}}{{non-standard_inline}}</dt>
+ <dd>包含导致异常的代码的文件名。</dd>
+ <dt><code>lineNumber</code> {{optional_inline}}{{non-standard_inline}}</dt>
+ <dd>导致异常的代码的行号。</dd>
+</dl>
+
+<h2 id="属性">属性</h2>
+
+<p><em><code>CompileError</code>构造函数没有一些它特有的属性,但是,它确实通过原型链继承了某些属性。</em></p>
+
+<dl>
+ <dt><code>WebAssembly.CompileError.prototype.constructor</code></dt>
+ <dd>创建示例原型的特定函数。</dd>
+ <dt>{{jsxref("Error.prototype.message", "WebAssembly.CompileError.prototype.message")}}</dt>
+ <dd>错误信息。 尽管ECMA-262指定{{jsxref("URIError")}}应提供自己的<code>message</code>属性,但在<a href="/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a>中,它继承了 {{jsxref("Error.prototype.message")}}。</dd>
+ <dt>{{jsxref("Error.prototype.name", "WebAssembly.CompileError.prototype.name")}}</dt>
+ <dd>错误名称。继承自 {{jsxref("Error")}}。</dd>
+ <dt>{{jsxref("Error.prototype.fileName", "WebAssembly.CompileError.prototype.fileName")}}</dt>
+ <dd>报出错误的文件名。继承自 {{jsxref("Error")}}。</dd>
+ <dt>{{jsxref("Error.prototype.lineNumber", "WebAssembly.CompileError.prototype.lineNumber")}}</dt>
+ <dd>报出错误的代码所在文件中的行数。继承自 {{jsxref("Error")}}。</dd>
+ <dt>{{jsxref("Error.prototype.columnNumber", "WebAssembly.CompileError.prototype.columnNumber")}}</dt>
+ <dd>报出错误的代码所在文件中的列数。继承自 {{jsxref("Error")}}。</dd>
+ <dt>{{jsxref("Error.prototype.stack", "WebAssembly.CompileError.prototype.stack")}}</dt>
+ <dd>堆栈跟踪。 继承自{{jsxref("Error")}}。</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<p><em><code>CompileError</code>构造函数不包含自己的方法,但是,它确实通过原型链继承了一些方法。</em></p>
+
+<dl>
+ <dt>{{jsxref("Error.prototype.toSource", "WebAssembly.CompileError.prototype.toSource()")}}</dt>
+ <dd>返回可能导致相同错误的代码。 继承自{{jsxref("Error")}}。</dd>
+ <dt>{{jsxref("Error.prototype.toString", "WebAssembly.CompileError.prototype.toString()")}}</dt>
+ <dd>返回表示代表指定的<code>Error</code>对象的字符串。从 {{jsxref("Error")}}继承。</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<p>以下代码段创建一个新的CompileError实例,并将其详细信息记录到控制台:</p>
+
+<pre class="brush: js">try {
+ throw new WebAssembly.CompileError('Hello', 'someFile', 10);
+} catch (e) {
+ console.log(e instanceof CompileError); // true
+ console.log(e.message); // "Hello"
+ console.log(e.name); // "CompileError"
+ console.log(e.fileName); // "someFile"
+ console.log(e.lineNumber); // 10
+ console.log(e.columnNumber); // 0
+ console.log(e.stack); // 返回代码运行的位置
+}</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#constructor-properties-of-the-webassembly-object', 'WebAssembly constructors')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Initial WebAssembly draft definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard', 'NativeError')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td>Definition of standard NativeError types.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.CompileError")}}</p>
+</div>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>
+
+<dl>
+</dl>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html
new file mode 100644
index 0000000000..f36e646699
--- /dev/null
+++ b/files/zh-cn/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
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>WebAssembly.compileStreaming()</code></strong> 方法用来从一个流式源中直接编译一个 {{jsxref("WebAssembly.Module")}}。当模块需要在被实例化前被编译时,这个方法会很有用。如果要从流式源实例化一个模块应采用 {{jsxref("WebAssembly.instantiateStreaming()")}} 方法。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">Promise&lt;WebAssembly.Module&gt; WebAssembly.compileStreaming(<em>source</em>);</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em>source</em></dt>
+ <dd>一个 {{domxref("Response")}} 对象或一个会履行(fulfill)它的 promise,用来表示你想编译的 .wasm 模块的流式源。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>一个会被解决(resolve)为编译后的 {{jsxref("WebAssembly.Module")}} 对象的 <code>Promise</code>。</p>
+
+<h3 id="异常">异常</h3>
+
+<ul>
+ <li>如果 <code>bufferSource</code> 不是一个 <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a>,将会抛出 {{jsxref("TypeError")}} 异常。</li>
+ <li>如果编译失败,promise 会通过拒绝(reject)来返回一个 {{jsxref("WebAssembly.CompileError")}}。</li>
+</ul>
+
+<h2 id="例子">例子</h2>
+
+<p>下面的例子(在 GitHub 上查看我们的 <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/compile-streaming.html">compile-streaming.html</a> 示例或者直接<a href="https://mdn.github.io/webassembly-examples/js-api-examples/compile-streaming.html">在线预览</a>)直接从流式源传输一个 .wasm 模块然后将其编译为一个 {{jsxref("WebAssembly.Module")}} 对象。因为 <code>compileStreaming()</code> 方法可以接受一个结果为  {{domxref("Response")}} 对象的 promise,因此你可以直接用 {{domxref("WindowOrWorkerGlobalScope.fetch()")}} 的调用结果来调用该方法。</p>
+
+<pre class="brush: js">var importObject = { imports: { imported_func: arg =&gt; console.log(arg) } };
+
+WebAssembly.compileStreaming(fetch('simple.wasm'))
+.then(module =&gt; WebAssembly.instantiate(module, importObject))
+.then(instance =&gt; instance.exports.exported_func());</pre>
+
+<p>得到的 module 实例接下来通过 {{jsxref("WebAssembly.instantiate()")}} 方法被实例化了,然后调用模块导出的函数。</p>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly Embedding', '#webassemblycompilestreaming', 'compileStreaming()')}}</td>
+ <td>{{Spec2('WebAssembly Embedding')}}</td>
+ <td>Initial draft definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.compileStreaming")}}</p>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/global/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/global/index.html
new file mode 100644
index 0000000000..3366032120
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/global/index.html
@@ -0,0 +1,107 @@
+---
+title: WebAssembly.Global
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Global
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Global
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>WebAssembly.Global</code></strong> 对象表示一个全局变量实例, 可以被JavaScript 和importable/exportable 访问 ,跨越一个或多个{{jsxref("WebAssembly.Module")}} 实例. 他允许被多个modules动态连接.</p>
+
+<h2 id="构造函数语法">构造函数语法</h2>
+
+<p><strong><a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global">WebAssembly.Global()</a></strong></p>
+
+<p>     创建一个新的<code>全局</code>对象。</p>
+
+<h2 id="Global_实例">Global 实例</h2>
+
+<p>所有的 <code>Global</code> 实例 继承自 <code>Global()</code> 构造函数 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global/prototype">prototype object</a> — 修改会影响 所有 <code>Global</code> 实例.</p>
+
+<h3 id="实例属性">实例属性</h3>
+
+<dl>
+ <dt><code>Global.prototype.constructor</code></dt>
+ <dd>返回创建对象实例的函数. 缺省为构造函数为 {{jsxref("WebAssembly.Global()")}}</dd>
+ <dt><code>Global.prototype[@@toStringTag]</code></dt>
+ <dd>属性 <a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag">@@toStringTag</a> 初始值为字符串 "WebAssembly.Global".</dd>
+ <dt><code>Global.prototype.value</code></dt>
+ <dd>全局变量包含的值 — 可以直接用于设置和获取全局变量的值.</dd>
+</dl>
+
+<h3 id="实例方法">实例方法</h3>
+
+<dl>
+ <dt><code>Global.prototype.valueOf()</code></dt>
+ <dd>旧式的方法,返回全局变量包含的值.</dd>
+</dl>
+
+<h2 id="例子">例子</h2>
+
+<h3 id="创建_Global_实例">创建 Global 实例 </h3>
+
+<p>以下例子展示了使用 <code>WebAssembly.Global()</code> 构造函数创建一个新的实例. 它定义为可修饰的 类型为<code>i32</code> , 值为 0.</p>
+
+<p>global的值发生改变, 首先设置<code>Global.value</code> 为42, 然后使用导出函数 <code>incGlobal()</code> 增加为43. 导出函数在 <code>global.wasm</code> 模块中(它将参数的值加一并返回).</p>
+
+<pre class="brush: js notranslate">const output = document.getElementById('output');
+
+function assertEq(msg, got, expected) {
+ output.innerHTML += `Testing ${msg}: `;
+ if (got !== expected)
+ output.innerHTML += `FAIL!&lt;br&gt;Got: ${got}&lt;br&gt;Expected: ${expected}&lt;br&gt;`;
+ else
+ output.innerHTML += `SUCCESS! Got: ${got}&lt;br&gt;`;
+}
+
+assertEq("WebAssembly.Global exists", typeof WebAssembly.Global, "function");
+
+const global = new WebAssembly.Global({value:'i32', mutable:true}, 0);
+
+WebAssembly.instantiateStreaming(fetch('global.wasm'), { js: { global } })
+.then(({instance}) =&gt; {
+ assertEq("getting initial value from wasm", instance.exports.getGlobal(), 0);
+ global.value = 42;
+ assertEq("getting JS-updated value from wasm", instance.exports.getGlobal(), 42);
+ instance.exports.incGlobal();
+ assertEq("getting wasm-updated value from JS", global.value, 43);
+});</pre>
+
+<div class="note">
+<p><strong>注意</strong>: 你可以在<a href="https://mdn.github.io/webassembly-examples/js-api-examples/global.html">running live on GitHub</a> 查看例子; 也可以访问<a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/global.html">source code</a>.</p>
+</div>
+
+<h2 id="规格">规格</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规格</th>
+ <th scope="col">状态</th>
+ <th scope="col">解释</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#globals', 'WebAssembly.Global()')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Initial draft definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.Global")}}</p>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+ <li><a href="https://github.com/WebAssembly/mutable-global/blob/master/proposals/mutable-global/Overview.md">Import/Export mutable globals proposal</a></li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html
new file mode 100644
index 0000000000..66f14793af
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html
@@ -0,0 +1,106 @@
+---
+title: WebAssembly
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly
+tags:
+ - API
+ - JavaScript
+ - WebAssembly
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>WebAssembly</code></strong>JavaScript 对象是所有 <a href="/en-US/docs/WebAssembly">WebAssembly</a> 相关功能的命名空间。</p>
+
+<p>和大多数全局对象不一样,<code>WebAssembly</code>不是一个构造函数(它不是一个函数对象)。它类似于 {{jsxref("Math")}} 对象或者 {{jsxref("Intl")}} 对象,Math 对象也是一个命名空间对象,用于保存数学常量和函数;Intl则是用于国际化和其他语言相关函数的命名空间对象。</p>
+
+<h2 id="描述">描述</h2>
+
+<p><code>WebAssembly</code>对象主要用于:</p>
+
+<ul>
+ <li>使用 {{jsxref("WebAssembly.instantiate()")}} 函数加载 WebAssembly 代码。</li>
+ <li>通过 {{jsxref("WebAssembly.Memory()")}}/{{jsxref("WebAssembly.Table()")}}  构造函数创建新的内存和表实例。</li>
+ <li>由 {{jsxref("WebAssembly.CompileError()")}}/{{jsxref("WebAssembly.LinkError()")}}/{{jsxref("WebAssembly.RuntimeError()")}} 构造函数来提供 WebAssembly 中的错误信息。</li>
+</ul>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{jsxref("WebAssembly.instantiate()")}}</dt>
+ <dd>用于编译和实例化 WebAssembly 代码的主 API,返回一个 <code>Module</code> 和它的第一个<code>Instance</code>实例。</dd>
+ <dt>{{jsxref("WebAssembly.instantiateStreaming()")}}</dt>
+ <dd>直接从流式底层源编译和实例化WebAssembly模块,同时返回<code>Module</code>及其第一个<code>Instance</code>实例。</dd>
+ <dt>{{jsxref("WebAssembly.compile()")}}</dt>
+ <dd>把 WebAssembly 二进制代码编译为一个 {{jsxref("WebAssembly.Module")}} ,不进行实例化。</dd>
+ <dt>{{jsxref("WebAssembly.compileStreaming()")}}</dt>
+ <dd>直接从流式底层源代码编译{{jsxref("WebAssembly.Module")}} ,将实例化作为一个单独的步骤。</dd>
+ <dt>{{jsxref("WebAssembly.validate()")}}</dt>
+ <dd>校验 WebAssembly 二进制代码的类型数组是否合法,合法则返回 true ,否则返回 false 。</dd>
+</dl>
+
+<h2 id="构造器">构造器</h2>
+
+<dl>
+ <dt>{{jsxref("WebAssembly.Global()")}}</dt>
+ <dd>创建一个新的WebAssembly <code>Global</code> 全局对象.</dd>
+ <dt>{{jsxref("WebAssembly.Module()")}}</dt>
+ <dd>创建一个新的WebAssembly <code>Module</code>模块对象。</dd>
+ <dt>{{jsxref("WebAssembly.Instance()")}}</dt>
+ <dd>创建一个新的WebAssembly <code>Instance</code>实例对象。</dd>
+ <dt>{{jsxref("WebAssembly.Memory()")}}</dt>
+ <dd>创建一个新的WebAssembly <code>Memory</code>内存对象。</dd>
+ <dt>{{jsxref("WebAssembly.Table()")}}</dt>
+ <dd>创建一个新的WebAssembly <code>Table</code>表格对象。</dd>
+ <dt>{{jsxref("WebAssembly.CompileError()")}}</dt>
+ <dd>创建一个新的WebAssembly <code>CompileError</code>编译错误对象。</dd>
+ <dt>{{jsxref("WebAssembly.LinkError()")}}</dt>
+ <dd>创建一个新的WebAssembly <code>LinkError</code>链接错误对象。</dd>
+ <dt>{{jsxref("WebAssembly.RuntimeError()")}}</dt>
+ <dd>创建一个新的WebAssembly <code>RuntimeError</code>运行时错误对象。</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<p>下面的示例(请参见GitHub上的<a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/instantiate-streaming.html">Instantiate-streaming.html</a>演示,并查看<a href="https://mdn.github.io/webassembly-examples/js-api-examples/instantiate-streaming.html">在线演示</a>)直接从流式底层源传输.wasm模块,然后对其进行编译和实例化,并通过<code>ResultObject</code>实现promise。 由于<code>instantiateStreaming()</code>函数接受对 {{domxref("Response")}} 对象的promise,因此您可以直接向其传递{{domxref("WindowOrWorkerGlobalScope.fetch()")}}调用,然后它将把返回的response传递给随后的函数。</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">var</span> importObject <span class="operator token">=</span> <span class="punctuation token">{</span> imports<span class="punctuation token">:</span> <span class="punctuation token">{</span> <span class="function function-variable token">imported_func</span><span class="punctuation token">:</span> <span class="parameter token">arg</span> <span class="operator token">=&gt;</span> console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>arg<span class="punctuation token">)</span> <span class="punctuation token">}</span> <span class="punctuation token">}</span><span class="punctuation token">;</span>
+
+WebAssembly<span class="punctuation token">.</span><span class="function token">instantiateStreaming</span><span class="punctuation token">(</span><span class="function token">fetch</span><span class="punctuation token">(</span><span class="string token">'simple.wasm'</span><span class="punctuation token">)</span><span class="punctuation token">,</span> importObject<span class="punctuation token">)</span>
+<span class="punctuation token">.</span><span class="function token">then</span><span class="punctuation token">(</span><span class="parameter token">obj</span> <span class="operator token">=&gt;</span> obj<span class="punctuation token">.</span>instance<span class="punctuation token">.</span>exports<span class="punctuation token">.</span><span class="function token">exported_func</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">)</span></code></pre>
+
+<p>返回的<code>ResultObject</code>实例的成员可以被随后访问到,可以调用实例中被导出的方法。</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#the-webassembly-object', 'WebAssembly')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>初始草案定义</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>
+</div>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/instance/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instance/index.html
new file mode 100644
index 0000000000..d9fdee81e1
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instance/index.html
@@ -0,0 +1,89 @@
+---
+title: WebAssembly.Instance
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance
+tags:
+ - API
+ - Experimental
+ - JavaScript
+ - Reference
+ - WebAssembly
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance
+---
+<div>{{JSRef}} {{SeeCompatTable}}</div>
+
+<p>  <strong><code>WebAssembly.Instance</code></strong> 对象本身是有状态的,是 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module">WebAssembly.Module</a> 的一个可执行实例。  <code>实例</code>包含所有的 <a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions">WebAssembly 导出函数</a> ,允许从JavaScript 调用 WebAssembly 代码。</p>
+
+<p><code>WebAssembly.Instance()</code> 构造函数以同步方式实例化一个{{jsxref("WebAssembly.Module")}} 对象。 然而, 通常获取实例的方法是通过异步函数{{jsxref("WebAssembly.instantiate()")}} .</p>
+
+<h2 id="构造函数">构造函数</h2>
+
+<div class="warning">
+<p><strong>重要</strong>: 由于大型模块的实例化代价极高, 开发人员应只在必须同步实例化的时候,才使用<code>Instance()</code>;绝大多数情况应该使用异步方法{{jsxref("WebAssembly.instantiate()")}} .</p>
+</div>
+
+<pre class="syntaxbox notranslate">var myInstance = new WebAssembly.Instance(<em>module</em>, <em>importObject</em>);</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em>module</em></dt>
+ <dd>要被实例化的 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module" title="The Module() constructor of the WebAssembly global object creates a new Module object instance."><code>WebAssembly.Module</code></a> 对象.</dd>
+ <dt><em>importObject</em> {{optional_inline}}</dt>
+ <dd>一个包含值的对象,导入到新创建的 <code>实例</code>, 比如函数或 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory" title="The Memory() constructor of the WebAssembly global object creates a new Memory object instance, which represents a WebAssembly memory. These can be thought of as resizeable array buffers, wrappers around WebAssembly memories."><code>WebAssembly.Memory</code></a> 对象. There must be one matching property for each declared import of <code>module</code> 否则抛出 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError">WebAssembly.LinkError</a> 异常.</dd>
+</dl>
+
+<h2 id="实例化">实例化</h2>
+
+<p>所有的 <code>Instance</code> 实例继承自<code>Instance()</code> <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/prototype">属性对象</a>— 修改它会影响所有的<code>Instance</code> 实例.</p>
+
+<h3 id="实例属性">实例属性</h3>
+
+<dl>
+ <dt>{{jsxref("WebAssembly/Instance/exports", "Instance.prototype.exports")}}</dt>
+ <dd>返回一个包含此 WebAssembly 模块实例所导出的全部成员的 JS 对象,以便 JavaScript 访问和使用这些成员,这个对象是只读的。</dd>
+ <dt></dt>
+</dl>
+
+<div class="hidden">
+<dl>
+ <dt></dt>
+ <dt>
+ <p>译者注:英文版的变动有点大,用例模块暂时不翻译,后来者有心的话可以翻译一下。</p>
+ </dt>
+</dl>
+</div>
+
+<h2 id="规格">规格</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规格</th>
+ <th scope="col">状态</th>
+ <th scope="col">描述</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#webassemblyinstance-objects', 'Instance')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Initial draft definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div class="hidden">
+<p>为了便于维护,此兼容性表格由结构化数据生成。如果您有意向此表格贡献内容,请向 <a href="https://github.com/mdn/browser-compat-data ">这个仓库</a> 提交代码并发送对应的 pull request 给我们。</p>
+</div>
+
+<div>{{Compat("javascript.builtins.WebAssembly.Instance")}}</div>
+
+<h2 id="参考">参考</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiate/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiate/index.html
new file mode 100644
index 0000000000..5567c99432
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiate/index.html
@@ -0,0 +1,175 @@
+---
+title: WebAssembly.instantiate()
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>WebAssembly.instantiate()</code></strong> 允许你编译和实例化 WebAssembly 代码。这个方法有两个重载方式:</p>
+
+<ul>
+ <li>第一种主要重载方式使用WebAssembly二进制代码的 <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a> 或{{jsxref("ArrayBuffer")}}形,一并进行编译和实例化。返回的 <code>Promise</code> 会携带已编译的 {{jsxref("WebAssembly.Module")}} 和它的第一个实例化对象 {{jsxref("WebAssembly.Instance")}}.</li>
+ <li>第二种重载使用已编译的 {{jsxref("WebAssembly.Module")}} , 返回的 <code>Promise</code> 携带一个 <code>Module</code>的实例化对象 <code>Instance</code>. 如果这个 <code>Module</code> 已经被编译了或者是从缓存中获取的( <a href="/en-US/docs/WebAssembly/Caching_modules">retrieved from cache</a>), 那么这种重载方式是非常有用的.</li>
+</ul>
+
+<div class="blockIndicator warning">
+<p><strong>重要</strong>: 此方法不是获取(fetch)和实例化wasm模块的最具效率方法。 如果可能的话,您应该改用较新的{{jsxref("WebAssembly.instantiateStreaming()")}}方法,该方法直接从原始字节码中直接获取,编译和实例化模块,因此不需要转换为{{jsxref("ArrayBuffer")}}。</p>
+</div>
+
+<h2 id="语法">语法</h2>
+
+<h3 id="主重载方式_—_使用wasm二进制代码">主重载方式 — 使用wasm二进制代码</h3>
+
+<pre class="syntaxbox">Promise&lt;ResultObject&gt; WebAssembly.instantiate(bufferSource, importObject);
+</pre>
+
+<h4 id="参数">参数</h4>
+
+<dl>
+ <dt><em>bufferSource</em></dt>
+ <dd>一个包含你想编译的wasm模块二进制代码的 <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a>(类型数组) or <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a>(数组缓冲区)</dd>
+ <dt><em>importObject</em> {{optional_inline}}</dt>
+ <dd>一个将被导入到新创建实例中的对象,它包含的值有函数、{{jsxref("WebAssembly.Memory")}} 对象等等。编译的模块中,对于每一个导入的值都要有一个与其匹配的属性与之相对应,否则将会抛出 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError">WebAssembly.LinkError</a>。</dd>
+</dl>
+
+<h4 id="返回值">返回值</h4>
+
+<p>解析为包含两个字段的 <code>ResultObject</code> 的一个 <code>Promise</code>:</p>
+
+<ul>
+ <li><code>module</code>: 一个被编译好的 {{jsxref("WebAssembly.Module")}} 对象. 这个模块可以被再次实例化,通过 <a href="/en-US/docs/Web/API/Worker/postMessage">postMessage()</a> 被分享,或者缓存到 <a href="/en-US/docs/WebAssembly/Caching_modules">IndexedDB</a>。</li>
+ <li><code>instance</code>: 一个包含所有 <a href="/en-US/docs/WebAssembly/Exported_functions">Exported WebAssembly functions</a>的{{jsxref("WebAssembly.Instance")}}对象。</li>
+</ul>
+
+<h4 id="异常">异常</h4>
+
+<ul>
+ <li>如果参数的类型或结构不正确,将会抛出异常 {{jsxref("TypeError")}} .</li>
+ <li>如果操作失败,promise 将会被 reject 掉, 根据失败的原因不同,会抛出3种异常,{{jsxref("WebAssembly.CompileError")}},{{jsxref("WebAssembly.LinkError")}}, 或{{jsxref("WebAssembly.RuntimeError")}}。</li>
+</ul>
+
+<h3 id="第二种重载_—_使用模块对象">第二种重载 — 使用模块对象</h3>
+
+<pre class="syntaxbox">Promise&lt;WebAssembly.Instance&gt; WebAssembly.instantiate(module, importObject);
+</pre>
+
+<h4 id="参数_2">参数</h4>
+
+<dl>
+ <dt><em>module</em></dt>
+ <dd>将被实例化的 {{jsxref("WebAssembly.Module")}} 对象。</dd>
+ <dt><em>importObject</em> {{optional_inline}}</dt>
+ <dd>一个将被导入到新创建实例中的对象,它包含的值有函数、{{jsxref("WebAssembly.Memory")}} 对象等等。编译的模块中,对于每一个导入的值都要有一个与其匹配的属性与之相对应,否则将会抛出{{jsxref("WebAssembly.LinkError")}} 。</dd>
+</dl>
+
+<h4 id="返回值_2">返回值</h4>
+
+<p>一个解析为 {{jsxref("WebAssembly.Instance")}} 的<code>Promise</code> 对象。</p>
+
+<h4 id="异常_2">异常</h4>
+
+<ul>
+ <li>如果参数的类型或结构不正确,将抛出异常 {{jsxref("TypeError")}} 。</li>
+ <li>如果操作失败,promise 将会被 reject 掉, 根据失败的原因不同,会抛出3种异常,{{jsxref("WebAssembly.CompileError")}},{{jsxref("WebAssembly.LinkError")}}, 或{{jsxref("WebAssembly.RuntimeError")}}。</li>
+</ul>
+
+<h2 id="例子">例子</h2>
+
+<p><strong>提示</strong>: 在大多数情况下,您可能需要使用{{jsxref("WebAssembly.instantiateStreaming()")}},因为它比<code>instantiate()</code>更具效率。</p>
+
+<h3 id="第一种重载例子">第一种重载例子</h3>
+
+<p>使用 fetch 获取一些 WebAssembly 二进制代码后,我们使用 {{jsxref("WebAssembly.instantiate()")}}  方法编译并实例化模块,在此过程中,导入了一个 Javascript 方法在 WebAssembly 模块中, 接下来我们使用<code>Instance</code> 导出的<a href="/en-US/docs/WebAssembly/Exported_functions">Exported WebAssembly </a>方法。</p>
+
+<pre class="brush: js">var importObject = {
+ imports: {
+  imported_func: function(arg) {
+  console.log(arg);
+  }
+  },
+ env: {
+  abort: () =&gt; {},
+  },
+};
+
+/* 2019-08-03:importObject必须存在env对象以及env对象的abort方法 */
+
+fetch('simple.wasm').then(response =&gt;
+  response.arrayBuffer()
+).then(bytes =&gt;
+  WebAssembly.instantiate(bytes, importObject)
+).then(result =&gt;
+  result.instance.exports
+);</pre>
+
+<div class="note">
+<p><strong>注</strong>: 查看GitHub(<a href="https://mdn.github.io/webassembly-examples/js-api-examples/">在线实例</a>)的 <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index.html">index.html</a> 中一个相似的例子,使用了我们的<code><a href="https://github.com/mdn/webassembly-examples/blob/master/wasm-utils.js#L1">fetchAndInstantiate()</a></code>库函数</p>
+</div>
+
+<h3 id="第二种重载例子">第二种重载例子</h3>
+
+<p>下面的例子(查看我们GitHub的 <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index-compile.html">index-compile.html</a> 例子,可在线演示)使用 <code>compile()</code> 方法编译了 simple.wasm 字节码,然后通过 <a href="/en-US/docs/Web/API/Worker/postMessage">postMessage()</a> 发送给一个线程 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API">worker</a>。</p>
+
+<pre class="brush: js">var worker = new Worker("wasm_worker.js");
+
+fetch('simple.wasm').then(response =&gt;
+  response.arrayBuffer()
+).then(bytes =&gt;
+  WebAssembly.compile(bytes)
+).then(mod =&gt;
+  worker.postMessage(mod)
+);</pre>
+
+<p>在线程中 (查看 <code><a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/wasm_worker.js">wasm_worker.js</a></code>) 我们定义了一个导入对象供模块使用,然后设置了一个事件处理函数来接收主线程发来的模块。当模块被接收到后,我们使用{{jsxref("WebAssembly.instantiate()")}} 方法创建一个实例并且调用它从内部导出的函数。</p>
+
+<pre class="brush: js">var importObject = {
+ imports: {
+ imported_func: function(arg) {
+ console.log(arg);
+ }
+ }
+};
+
+onmessage = function(e) {
+ console.log('module received from main thread');
+ var mod = e.data;
+
+ WebAssembly.instantiate(mod, importObject).then(function(instance) {
+ instance.exports.exported_func();
+ });
+};</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#webassemblyinstantiate', 'instantiate()')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Initial draft definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.instantiate")}}</p>
+</div>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html
new file mode 100644
index 0000000000..f6698d9862
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html
@@ -0,0 +1,85 @@
+---
+title: WebAssembly.instantiateStreaming()
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>WebAssembly.instantiateStreaming()</code></strong> 方法直接从流式底层源编译和实例化WebAssembly模块。这是加载wasm代码一种非常有效的优化方式。</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox">Promise&lt;ResultObject&gt; WebAssembly.instantiateStreaming(<em>source</em>, <em>importObject</em>);</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><em>source</em></dt>
+ <dd>一个{{domxref("Response")}}对象 或 一个可以履行(fulfill)一个(Response)的 {{jsxref("Promise")}},表示你想要传输、编译和实例化的 .wasm 模块基础源。</dd>
+ <dt><em>importObject</em> {{optional_inline}}</dt>
+ <dd>包含一些想要导入到新创建<code>Instance</code>中值的对象,例如方法 或  {{jsxref("WebAssembly.Memory")}} 对象。每个已编译模块的声明导入必须有一个匹配属性,否则抛出 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError">WebAssembly.LinkError</a> 异常。</dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>一个 <code>Promise</code> ,通过resolve返回一个包含两个属性的 <code>ResultObject</code> :</p>
+
+<ul>
+ <li><code>module</code>: {{jsxref("WebAssembly.Module")}} 对象表示编译完成的WebAssembly模块. 这个<code>Module</code>能够再次被实例化 或 通过<a href="/en-US/docs/Web/API/Worker/postMessage">postMessage()</a>共享。</li>
+ <li><code>instance</code>: {{jsxref("WebAssembly.Instance")}} 对象包含WebAssembly所有公开方法 <a href="/en-US/docs/WebAssembly/Exported_functions">Exported WebAssembly functions</a>.</li>
+</ul>
+
+<h3 id="Exceptions">Exceptions</h3>
+
+<ul>
+ <li>如果任意参数的类型或结构错误, {{jsxref("TypeError")}} 抛出.</li>
+ <li>如果操作失败, Promise通过reject根据失败原因返回 {{jsxref("WebAssembly.CompileError")}},{{jsxref("WebAssembly.LinkError")}} 或 {{jsxref("WebAssembly.RuntimeError")}}。</li>
+</ul>
+
+<h2 id="Examples">Examples</h2>
+
+<p>下面的示例 (在GitHub上查看 <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/instantiate-streaming.html">instantiate-streaming.html</a> 示例, 并且也可 <a href="https://mdn.github.io/webassembly-examples/js-api-examples/instantiate-streaming.html">view it live</a> ) 直接从基础源传输一个 .wasm 模块,然后进行编译和实例化, Promise 履行后返回一个 <code>ResultObject</code>. 因为 <code>instantiateStreaming()</code> 方法允许履行后返回{{domxref("Response")}}对象的Promise,你可以直接传递一个 {{domxref("WindowOrWorkerGlobalScope.fetch()")}} 请求,它会在履行后将response传递给方法.</p>
+
+<pre class="brush: js">var importObject = { imports: { imported_func: arg =&gt; console.log(arg) } };
+
+WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)
+.then(obj =&gt; obj.instance.exports.exported_func());</pre>
+
+<p>然后访问<code>ResultObject</code>的实例成员,并调用包含的公开函数。</p>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly Embedding', '#webassemblyinstantiatestreaming', 'instantiateStreaming()')}}</td>
+ <td>{{Spec2('WebAssembly Embedding')}}</td>
+ <td>Initial draft definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.instantiateStreaming")}}</p>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+ <li><a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></li>
+ <li><a href="/zh-CN/docs/Web/API/Fetch_API/Using_Fetch">使用Fetch</a></li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/memory/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/memory/index.html
new file mode 100644
index 0000000000..1d559210a4
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/memory/index.html
@@ -0,0 +1,112 @@
+---
+title: WebAssembly.Memory()
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory
+---
+<div>{{JSRef}}</div>
+
+<p><code><strong>WebAssembly.Memory()</strong></code> 构造函数创建一个新的 <code>Memory</code> 对象。该对象的 {{jsxref("WebAssembly/Memory/buffer","buffer")}} 属性是一个可调整大小的 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a> ,其内存储的是 WebAssembly <code>实例</code> 所访问内存的原始字节码。</p>
+
+<p>从 JavaScript 或 WebAssembly 中所创建的内存,可以由 JavaScript 或 WebAssembly 来访问及更改。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">var myMemory = new WebAssembly.Memory(memoryDescriptor);</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em>memoryDescriptor</em></dt>
+ <dd>一个可包含以下成员的对象:
+ <dl>
+ <dt><em>initial</em></dt>
+ <dd>WebAssembly 内存的初始大小,以 WebAssembly 页面为单位。</dd>
+ <dt><em>maximum {{optional_inline}}</em></dt>
+ <dd>以 WebAssembly 页面为单位,可允许 WebAssembly 内存的 <code>最大值</code>。当存在此属性时,此参数用于提示引擎预先保留内存。但是,引擎可能会忽略或限制此预留请求。通常情况下大多数 WebAssembly 模块不需要设置 <code>最大值</code>。</dd>
+ </dl>
+ </dd>
+</dl>
+
+<div class="note">
+<p><strong>注意</strong>: A WebAssembly 页面的大小为一个常量 65,536 字节,即64KB。</p>
+</div>
+
+<h3 id="异常">异常</h3>
+
+<ul>
+ <li>如果 <code>memoryDescriptor</code> 的类型不是对象,则抛出 {{jsxref("TypeError")}} 异常。</li>
+ <li>如果指定了 <code>maximum</code> 并且小于 <code>initial</code>,则抛出 {{jsxref("RangeError")}} 异常。</li>
+</ul>
+
+<h2 id="Memory_实例"><code>Memory</code> 实例</h2>
+
+<p>所有 <code>Memory</code> 实例都继承自 <code>Memory()</code> 构造函数的 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/prototype">原型对象</a> — 这个原型可被修改并影响到所有的 <code>Memory</code> 实例。</p>
+
+<h3 id="实例属性">实例属性</h3>
+
+<dl>
+ <dt><code>Memory.prototype.constructor</code></dt>
+ <dd>返回创建此对象实例的函数。默认情况下,它是 {{jsxref("WebAssembly.Memory()")}} 构造函数。</dd>
+ <dt>{{jsxref("WebAssembly/Memory/buffer","Memory.prototype.buffer")}}</dt>
+ <dd>一个访问器,用于返回内存中包含的缓冲区。</dd>
+</dl>
+
+<h3 id="实例方法">实例方法</h3>
+
+<dl>
+ <dt>{{jsxref("WebAssembly/Memory/grow","Memory.prototype.grow()")}}</dt>
+ <dd>通过指定 WebAssembly 页面数量来增加内存实例的大小。(每个页面大小为64KB)</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<p>有两种方法可以获得 <code>WebAssembly.Memory</code> 对象。第一种方法是由 JavaScript 来创建。以下示例创建了一个新的 WebAssembly 内存实例,初始大小为 10页(640KB),最大值设置为 100页(6.4MB)。</p>
+
+<pre class="brush: js">var memory = new WebAssembly.Memory({initial:10, maximum:100});</pre>
+
+<p>获取 <code>WebAssembly.Memory</code> 对象的第二种方法是从 WebAssembly 模块中导出。以下示例 (详见GitHub页面 <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/memory.html">memory.html</a> ,也可以 <a href="https://mdn.github.io/webassembly-examples/js-api-examples/memory.html">用浏览器运行查看</a>) 使用 {{jsxref("WebAssembly.instantiateStreaming()")}} 方法实例化已加载的 memory.wasm 字节代码,同时导入上面一行中创建的内存。用它来存储一些值,然后导出一个函数并用它来对一些值进行求和操作。</p>
+
+<pre class="brush: js">WebAssembly.instantiateStreaming(fetch('memory.wasm'), { js: { mem: memory } })
+.then(obj =&gt; {
+  var i32 = new Uint32Array(memory.buffer);
+  for (var i = 0; i &lt; 10; i++) {
+    i32[i] = i;
+  }
+  var sum = obj.instance.exports.accumulate(0, 10);
+  console.log(sum);
+});</pre>
+
+<h2 id="标准规范">标准规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#webassemblymemory-objects', 'Memory')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>初步定义草案</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.Memory")}}</p>
+</div>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html
new file mode 100644
index 0000000000..c328e5f3ba
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html
@@ -0,0 +1,87 @@
+---
+title: WebAssembly.Module
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Module
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Module
+---
+<div>{{JSRef}}</div>
+
+<div><strong><code>WebAssembly.Module</code></strong> 对象包含已经由浏览器编译的无状态 WebAssembly 代码,可以高效地<a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage">与 Workers 共享</a>、<a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Caching_modules">缓存在 IndexedDB 中</a>,和多次实例化。</div>
+
+<div> </div>
+
+<div><code>WebAssembly.Module()</code> 构造函数可以用来同步编译给定的 WebAssembly 二进制代码。不过,获取 <code>Module</code> 对象的主要方法是通过异步编译函数,如 {{jsxref("WebAssembly.compile()")}},或者是<a href="/en-US/docs/WebAssembly/Caching_modules">通过 IndexedDB 读取 Module 对象</a>.</div>
+
+<div> </div>
+
+<h2 id="构造函数语法">构造函数语法</h2>
+
+<div class="warning">
+<p><strong>重要提示:</strong>由于大型模块的编译可能很消耗资源,开发人员只有在绝对需要同步编译时,才使用 <code>Module()</code> 构造函数;其他情况下,应该使用异步 {{jsxref("WebAssembly.compile()")}} 方法。</p>
+</div>
+
+<pre class="syntaxbox">var myModule = new WebAssembly.Module(bufferSource);</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em>bufferSource</em></dt>
+ <dd>一个 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays">类型化数组</a> 或 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a>,包含要编译的 .wasm 模块的二进制代码。</dd>
+</dl>
+
+<h2 id="Module_构造函数的方法属性"><code>Module</code> 构造函数的方法属性</h2>
+
+<dl>
+ <dt>{{jsxref("Global_Objects/WebAssembly/Module/customSections", "WebAssembly.Module.customSections()")}}</dt>
+ <dd>给定 <code>Module</code> 对象和字符串,通过该字符串,返回 Module 对象中所有自定义部分的内容的副本。</dd>
+ <dt>{{jsxref("Global_Objects/WebAssembly/Module/exports", "WebAssembly.Module.exports()")}}</dt>
+ <dd>给定 <code>Module</code> 对象,返回一个数组,内容是所有已声明的接口的描述。</dd>
+ <dt>{{jsxref("Global_Objects/WebAssembly/Module/imports", "WebAssembly.Module.imports()")}}</dt>
+ <dd>给定 <code>Module</code> 对象,返回一个数组,内容是所有已声明的引用的描述。</dd>
+</dl>
+
+<h2 id="Module_实例"><code>Module</code> 实例</h2>
+
+<p>所有 <code>Module</code> 实例继承自 <code>Module()</code> 构造函数的<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype">原型对象</a> —— 修改它会影响所有 <code>Module</code> 实例。</p>
+
+<h3 id="实例属性">实例属性</h3>
+
+<p>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype', 'Properties')}}</p>
+
+<h3 id="实例方法">实例方法</h3>
+
+<p>Module 实例没有自己的默认方法。</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">注释</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#webassemblymodule-objects', 'WebAssembly.Module()')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>定义初稿</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div>
+<div class="hidden">此页面上的兼容性表格由结构化数据生成。 如果您想为数据做出贡献,请查看 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并向我们发送合并请求。</div>
+
+<p>{{Compat("javascript.builtins.WebAssembly.Module")}}</p>
+</div>
+
+<h2 id="另请查阅">另请查阅</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> 概览页面</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly 概念</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">使用 WebAssembly JavaScript API</a></li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html
new file mode 100644
index 0000000000..3962917a9e
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html
@@ -0,0 +1,111 @@
+---
+title: WebAssembly.RuntimeError()
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError
+---
+<div>{{JSRef}}</div>
+
+<p><code><strong>WebAssembly.RuntimeError()</strong></code>构造函数创建一个新的WebAssembly RuntimeError对象---一个每当WebAssembly陷入指定陷阱时将抛出的类型。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">new WebAssembly.RuntimeError(<var>message</var>, <var>fileName</var>, <var>lineNumber</var>)</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>message</code> {{optional_inline}}</dt>
+ <dd>有可读性的错误信息。</dd>
+ <dt><code>fileName</code> {{optional_inline}}{{non-standard_inline}}</dt>
+ <dd>包含导致异常的代码的文件名。</dd>
+ <dt><code>lineNumber</code> {{optional_inline}}{{non-standard_inline}}</dt>
+ <dd>导致异常的代码的行号。</dd>
+</dl>
+
+<h2 id="属性">属性</h2>
+
+<p><em><code>RuntimeError</code>构造函数不包含其自身特有的属性,但是,它确实通过原型链继承了某些属性。</em></p>
+
+<dl>
+ <dt><code>WebAssembly.RuntimeError.prototype.constructor</code></dt>
+ <dd>创建示例原型的特定函数。</dd>
+ <dt>{{jsxref("Error.prototype.message", "WebAssembly.RuntimeError.prototype.message")}}</dt>
+ <dd>错误信息。 尽管ECMA-262指定{{jsxref("URIError")}}应提供自己的<code>message</code>属性,但在<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a>中,它继承了{{jsxref("Error.prototype.message")}}。</dd>
+ <dt>{{jsxref("Error.prototype.name", "WebAssembly.RuntimeError.prototype.name")}}</dt>
+ <dd>错误名称。继承自 {{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.fileName", "WebAssembly.RuntimeError.prototype.fileName")}}</dt>
+ <dd>报出错误的文件路径。继承自 {{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.lineNumber", "WebAssembly.RuntimeError.prototype.lineNumber")}}</dt>
+ <dd>报出错误的代码所在文件中的行数。继承自{{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.columnNumber", "WebAssembly.RuntimeError.prototype.columnNumber")}}</dt>
+ <dd>报出错误的代码所在文件中的列数。继承自 {{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.stack", "WebAssembly.RuntimeError.prototype.stack")}}</dt>
+ <dd>堆栈跟踪。 继承自 {{jsxref("Error")}}.</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<p><em><code>RuntimeError</code>构造函数不包含自己的方法,但是,它确实通过原型链继承了一些方法。</em></p>
+
+<dl>
+ <dt>{{jsxref("Error.prototype.toSource", "WebAssembly.RuntimeError.prototype.toSource()")}}</dt>
+ <dd>返回可能导致相同错误的代码。 继承自{{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.toString", "WebAssembly.RuntimeError.prototype.toString()")}}</dt>
+ <dd>返回表示代表指定的<code>Error</code>对象的字符串。从{{jsxref("Error")}}.</dd>
+</dl>
+
+<h2 id="样例">样例</h2>
+
+<p>以下代码段创建了一个新的RuntimeError实例,并将其详细信息记录到控制台:</p>
+
+<pre class="brush: js">try {
+ throw new WebAssembly.RuntimeError('Hello', 'someFile', 10);
+} catch (e) {
+ console.log(e instanceof RuntimeError); // true
+ console.log(e.message); // "Hello"
+ console.log(e.name); // "RuntimeError"
+ console.log(e.fileName); // "someFile"
+ console.log(e.lineNumber); // 10
+ console.log(e.columnNumber); // 0
+ console.log(e.stack); // 返回代码运行的位置
+}</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#constructor-properties-of-the-webassembly-object', 'WebAssembly constructors')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Initial WebAssembly draft definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard', 'NativeError')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td>Definition of standard NativeError types.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.RuntimeError")}}</p>
+</div>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/table/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/table/index.html
new file mode 100644
index 0000000000..a3fbc0a4dc
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/table/index.html
@@ -0,0 +1,130 @@
+---
+title: WebAssembly.Table()
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Table
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Table
+---
+<div>{{JSRef}}</div>
+
+<p><code><strong>WebAssembly.Table()</strong></code> 构造函数根据给定的大小和元素类型创建一个Table对象。 </p>
+
+<p>这是一个包装了WebAssemble Table 的Javascript包装对象,具有类数组结构,存储了多个函数引用。在Javascript或者WebAssemble中创建Table 对象可以同时被Javascript或WebAssemble 访问和更改。</p>
+
+<div class="note">
+<p><strong>Note</strong>: Tables 对象目前只能存储函数引用,不过在将来可能会被扩展。</p>
+</div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox notranslate">var myTable = new WebAssembly.Table(tableDescriptor);</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em>tableDescriptor</em></dt>
+ <dd>该对象具有以下属性:
+ <dl>
+ <dt><em>element</em></dt>
+ <dd>一个表明储存在该Table中对象的类型。 目前只能是: <code>"anyfunc"</code> (函数)。</dd>
+ <dt><em>initial</em></dt>
+ <dd>该WebAssembly Table初始大小。</dd>
+ <dt><em>maximum {{optional_inline}}</em></dt>
+ <dd>该WebAssembly Table允许扩展到的最大大小。</dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="异常">异常</h3>
+
+<ul>
+ <li>如果 <code>tableDescriptor</code> 不是对象类型, 将会抛出 {{jsxref("TypeError")}} 异常。</li>
+ <li>如果申明了 <code>maximum</code> 属性并且比 <code>initial小</code>, 将会抛出{{jsxref("RangeError")}} 异常。</li>
+</ul>
+
+<h2 id="Table_Instance"><code>Table</code> Instance</h2>
+
+<p>所有<code>Table</code>实例都继承自<code>Table()</code>构造函数的<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/prototype">原型对象</a>-可以对其进行修改以影响所有<code>Table</code>实例。</p>
+
+<h3 id="Instance_属性">Instance 属性</h3>
+
+<dl>
+ <dt><code>Table.prototype.constructor</code></dt>
+ <dd><font><font>返回创建该对象实例的函数。</font><font>默认情况下,这是</font></font>{{jsxref("WebAssembly.Table()")}} 的<font><font>构造函数。</font></font></dd>
+ <dt>{{jsxref("WebAssembly/Table/length","Table.prototype.length")}}</dt>
+ <dd>返回Table的长度,即元素数。</dd>
+</dl>
+
+<h3 id="Instance_methods">Instance methods</h3>
+
+<dl>
+ <dt>{{jsxref("WebAssembly/Table/get","Table.prototype.get()")}}</dt>
+ <dd>Accessor function — gets the element stored at a given index.</dd>
+ <dt>{{jsxref("WebAssembly/Table/grow","Table.prototype.grow()")}}</dt>
+ <dd>Increases the size of the Table instance by a specified number of elements.</dd>
+ <dt>{{jsxref("WebAssembly/Table/set","Table.prototype.set()")}}</dt>
+ <dd>Sets an element stored at a given index to a given value.</dd>
+</dl>
+
+<h2 id="例子">例子</h2>
+
+<p>The following example (see table2.html <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/table2.html">source code</a> and <a href="https://mdn.github.io/webassembly-examples/js-api-examples/table2.html">live version</a>) creates a new WebAssembly Table instance with an initial size of 2 elements. We then print out the table length and contents of the two indexes (retrieved via {{jsxref("WebAssembly/Table/get", "Table.prototype.get()")}} to show that the length is two and both elements are {{jsxref("null")}}.</p>
+
+<pre class="brush: js notranslate">var tbl = new WebAssembly.Table({initial:2, element:"anyfunc"});
+console.log(tbl.length); // "2"
+console.log(tbl.get(0)); // "null"
+console.log(tbl.get(1)); // "null"</pre>
+
+<p>We then create an import object that contains the table:</p>
+
+<pre class="brush: js notranslate">var importObj = {
+ js: {
+ tbl:tbl
+ }
+};</pre>
+
+<p>Finally, we load and instantiate a wasm module (table2.wasm) using the {{jsxref("WebAssembly.instantiateStreaming()")}} method.  The table2.wasm module contains two functions (one that returns 42 and another that returns 83) and stores both into elements 0 and 1 of the imported table (see <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/table2.wat">text representation</a>).  So after instantiation, the table still has length 2, but the elements now contain callable <a href="/en-US/docs/WebAssembly/Exported_functions">Exported WebAssembly Functions</a> which we can call from JS.</p>
+
+<pre class="brush: js notranslate">WebAssembly.instantiateStreaming(fetch('table2.wasm'), importObject)
+.then(function(obj) {
+  console.log(tbl.length);
+  console.log(tbl.get(0)());
+  console.log(tbl.get(1)());
+});</pre>
+
+<p>Note how you've got to include a second function invocation operator at the end of the accessor to actually invoke the referenced function and log the value stored inside it (e.g. <code>get(0)()</code> rather than <code>get(0)</code>) .</p>
+
+<p>This example shows that we're creating and accessing the table from JavaScript, but the same table is visible and callable inside the wasm instance too.</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#webassemblytable-objects', 'Table')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Initial draft definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.Table")}}</p>
+</div>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/validate/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/validate/index.html
new file mode 100644
index 0000000000..7d44cc216b
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/validate/index.html
@@ -0,0 +1,75 @@
+---
+title: WebAssembly.validate()
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/validate
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/validate
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>WebAssembly.validate()</code></strong> 方法用于验证包含 WebAssembly 二进制码的一个 <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a> 是否合法,返回 <code>true</code> 如果这些字节能构成一个合法的 wasm 模块,否则返回 <code>false</code>。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">WebAssembly.validate(bufferSource);</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>bufferSource</code></dt>
+ <dd>一个包含 WebAssembly 二进制码的 <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a> 或 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a>。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>一个布尔值,用来表示给定的 <code>bufferSource</code> 是合法 wasm 代码(<code>true</code>)或者不是(<code>false</code>)。</p>
+
+<h3 id="异常">异常</h3>
+
+<p>如果给定的 <code>bufferSource</code> 不是 <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typed array</a> 或 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a> 类型,将会抛出 {{jsxref("TypeError")}} 异常。</p>
+
+<h2 id="例子">例子</h2>
+
+<p>下面的例子(查看 validate.html <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/validate.html">源代码</a>,或者<a href="https://mdn.github.io/webassembly-examples/js-api-examples/validate.html">在线预览</a>)通过 <code>fetch</code> 获取了一个 .wasm 模块并将其转换为一个 typed array。接下来用 <code>validate()</code> 方法来验证这个模块是否合法。</p>
+
+<pre class="brush: js">fetch('simple.wasm').then(response =&gt;
+  response.arrayBuffer()
+).then(function(bytes) {
+  var valid = WebAssembly.validate(bytes);
+  console.log("The given bytes are "
+ + (valid ? "" : "not ") + "a valid wasm module");
+});
+</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#webassemblyvalidate', 'validate()')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Initial draft definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.validate")}}</p>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>