<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[207825] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/207825">207825</a></dd>
<dt>Author</dt> <dd>jfbastien@apple.com</dd>
<dt>Date</dt> <dd>2016-10-25 10:23:53 -0700 (Tue, 25 Oct 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>WebAssembly JS API: implement Module
This implementation allows us to:
- Syncrhonously create a WebAssembly.Module with a typed array.
- Creates a compilation plan.
- Parse the Module and creates corresponding code.
- Throw WebAssembly.CompileError with mildly helpful [*] error messages on
failure.
Consult the API documentation for expected behavior: https://github.com/WebAssembly/design/blob/master/JS.md#webassemblymodule-constructor
For now the implementation discards the generated code.
The next steps will be:
- Expose a Module's exports.
- Implement WebAssembly.Instance, which allows instantiating and running a
compiled Module.
- Beef up the testing infrastructure under JSTests/wasm so that more complex
modules can be created and tested (instead of writing the bits by hand).
This patch also:
- Adds assert.instanceof in assert.js.
- Refactors Wasm::Parser and friends to accept const uint8_t* as well as a
Vector, to avoid copying when invoked synchronously.
- Remove useless Structure from some of the wasm constructors: they're already
on the JSGlobalObject, visited properly and all.
- Fix off-by-one error in parsing: Parser::parseUInt32 failed if the integer
was exactly at end of file.
[*] On error messages while parsing: I filed https://bugs.webkit.org/show_bug.cgi?id=163919
WebAssembly JS API: implement Module
https://bugs.webkit.org/show_bug.cgi?id=163903
Reviewed by Keith Miller.
JSTests:
* wasm/assert.js: use underscore in name, and remove when exporting to avoid clasing with builtin names
(const._notUndef):
(const._isUndef):
(const._eq):
(const._ge):
(const._throws):
* wasm/js-api/test_basic_api.js: test the WebAssembly.Module API
(const.c.in.constructorProperties.switch):
Source/JavaScriptCore:
* runtime/ExceptionHelpers.cpp:
(JSC::defaultSourceAppender): make this public so that WebAssembly can use it: it generates those fancy (evaluating '...') messages at the end
* runtime/ExceptionHelpers.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init): remove the useless Structure from the WebAssembly objects (it's already in this file, no need to hold two references and visit them twice)
* testWasm.cpp:
(runWasmTests): update API
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile): use updated API
* wasm/WasmB3IRGenerator.h:
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser<Context>::FunctionParser): use updated API
(JSC::Wasm::FunctionParser<Context>::parseExpression): use updated API
* wasm/WasmModuleParser.cpp:
(JSC::Wasm::ModuleParser::parse): generate error messages
* wasm/WasmModuleParser.h:
(JSC::Wasm::ModuleParser::ModuleParser):
(JSC::Wasm::ModuleParser::failed):
(JSC::Wasm::ModuleParser::errorMessage):
(JSC::Wasm::ModuleParser::functionInformation):
(JSC::Wasm::ModuleParser::memory):
* wasm/WasmParser.h: use update non-public API
(JSC::Wasm::Parser::parseVarUInt32):
(JSC::Wasm::Parser::parseVarUInt64):
(JSC::Wasm::Parser::source):
(JSC::Wasm::Parser::length):
(JSC::Wasm::Parser::Parser):
(JSC::Wasm::Parser::consumeCharacter):
(JSC::Wasm::Parser::consumeString):
(JSC::Wasm::Parser::parseUInt32):
(JSC::Wasm::Parser::parseUInt7):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::Plan):
(JSC::Wasm::Plan::~Plan):
* wasm/WasmPlan.h:
(JSC::Wasm::Plan::failed):
(JSC::Wasm::Plan::errorMessage):
(JSC::Wasm::Plan::resultSize):
(JSC::Wasm::Plan::result):
(JSC::Wasm::Plan::memory):
* wasm/js/JSWebAssemblyCompileError.cpp:
(JSC::createWebAssemblyCompileError): makes it easier to throw a WebAssembly.CompileError from Module
* wasm/js/JSWebAssemblyCompileError.h:
* wasm/js/WebAssemblyCompileErrorConstructor.cpp:
(JSC::WebAssemblyCompileErrorConstructor::create):
(JSC::WebAssemblyCompileErrorConstructor::finishCreation):
* wasm/js/WebAssemblyCompileErrorConstructor.h:
* wasm/js/WebAssemblyInstanceConstructor.cpp:
(JSC::WebAssemblyInstanceConstructor::create):
(JSC::WebAssemblyInstanceConstructor::finishCreation):
(JSC::WebAssemblyInstanceConstructor::visitChildren):
* wasm/js/WebAssemblyInstanceConstructor.h:
* wasm/js/WebAssemblyMemoryConstructor.cpp:
(JSC::WebAssemblyMemoryConstructor::create):
(JSC::WebAssemblyMemoryConstructor::finishCreation):
(JSC::WebAssemblyMemoryConstructor::visitChildren):
* wasm/js/WebAssemblyMemoryConstructor.h:
* wasm/js/WebAssemblyModuleConstructor.cpp:
(JSC::constructJSWebAssemblyModule):
(JSC::WebAssemblyModuleConstructor::create):
(JSC::WebAssemblyModuleConstructor::finishCreation):
(JSC::WebAssemblyModuleConstructor::visitChildren):
* wasm/js/WebAssemblyModuleConstructor.h:
* wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
(JSC::WebAssemblyRuntimeErrorConstructor::create):
(JSC::WebAssemblyRuntimeErrorConstructor::finishCreation):
* wasm/js/WebAssemblyRuntimeErrorConstructor.h:
* wasm/js/WebAssemblyTableConstructor.cpp:
(JSC::WebAssemblyTableConstructor::create):
(JSC::WebAssemblyTableConstructor::finishCreation):
(JSC::WebAssemblyTableConstructor::visitChildren):
* wasm/js/WebAssemblyTableConstructor.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkJSTestswasmassertjs">trunk/JSTests/wasm/assert.js</a></li>
<li><a href="#trunkJSTestswasmjsapitest_basic_apijs">trunk/JSTests/wasm/js-api/test_basic_api.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeExceptionHelperscpp">trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeExceptionHelpersh">trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretestWasmcpp">trunk/Source/JavaScriptCore/testWasm.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmB3IRGeneratorcpp">trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmB3IRGeneratorh">trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmFunctionParserh">trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmModuleParsercpp">trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmModuleParserh">trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmParserh">trunk/Source/JavaScriptCore/wasm/WasmParser.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmPlancpp">trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmPlanh">trunk/Source/JavaScriptCore/wasm/WasmPlan.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorcpp">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorh">trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyCompileErrorConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyCompileErrorConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyModuleConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyModuleConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyRuntimeErrorConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyRuntimeErrorConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyTableConstructorcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyTableConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/JSTests/ChangeLog        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2016-10-25 JF Bastien <jfbastien@apple.com>
+
+ WebAssembly JS API: implement Module
+
+ This implementation allows us to:
+ - Syncrhonously create a WebAssembly.Module with a typed array.
+ - Creates a compilation plan.
+ - Parse the Module and creates corresponding code.
+ - Throw WebAssembly.CompileError with mildly helpful [*] error messages on
+ failure.
+
+ Consult the API documentation for expected behavior: https://github.com/WebAssembly/design/blob/master/JS.md#webassemblymodule-constructor
+
+ For now the implementation discards the generated code.
+
+ The next steps will be:
+ - Expose a Module's exports.
+ - Implement WebAssembly.Instance, which allows instantiating and running a
+ compiled Module.
+ - Beef up the testing infrastructure under JSTests/wasm so that more complex
+ modules can be created and tested (instead of writing the bits by hand).
+
+ This patch also:
+ - Adds assert.instanceof in assert.js.
+ - Refactors Wasm::Parser and friends to accept const uint8_t* as well as a
+ Vector, to avoid copying when invoked synchronously.
+ - Remove useless Structure from some of the wasm constructors: they're already
+ on the JSGlobalObject, visited properly and all.
+ - Fix off-by-one error in parsing: Parser::parseUInt32 failed if the integer
+ was exactly at end of file.
+
+ [*] On error messages while parsing: I filed https://bugs.webkit.org/show_bug.cgi?id=163919
+
+ WebAssembly JS API: implement Module
+ https://bugs.webkit.org/show_bug.cgi?id=163903
+
+ Reviewed by Keith Miller.
+
+ * wasm/assert.js: use underscore in name, and remove when exporting to avoid clasing with builtin names
+ (const._notUndef):
+ (const._isUndef):
+ (const._eq):
+ (const._ge):
+ (const._throws):
+ * wasm/js-api/test_basic_api.js: test the WebAssembly.Module API
+ (const.c.in.constructorProperties.switch):
+
</ins><span class="cx"> 2016-10-25 Keith Miller <keith_miller@apple.com>
</span><span class="cx">
</span><span class="cx"> Add trivial Wasm conversion opcodes
</span></span></pre></div>
<a id="trunkJSTestswasmassertjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/assert.js (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/assert.js        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/JSTests/wasm/assert.js        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -23,29 +23,29 @@
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-export const notUndef = (v) => {
</del><ins>+const _notUndef = (v) => {
</ins><span class="cx"> if (typeof v === "undefined")
</span><span class="cx"> throw new Error("Shouldn't be undefined");
</span><span class="cx"> };
</span><span class="cx">
</span><del>-export const isUndef = (v) => {
</del><ins>+const _isUndef = (v) => {
</ins><span class="cx"> if (typeof v !== "undefined")
</span><span class="cx"> throw new Error("Should be undefined");
</span><span class="cx"> };
</span><span class="cx">
</span><del>-export const eq = (lhs, rhs) => {
</del><ins>+const _eq = (lhs, rhs) => {
</ins><span class="cx"> if (lhs !== rhs)
</span><span class="cx"> throw new Error(`Not the same: "${lhs}" and "${rhs}"`);
</span><span class="cx"> };
</span><span class="cx">
</span><del>-export const ge = (lhs, rhs) => {
- notUndef(lhs);
- notUndef(rhs);
</del><ins>+const _ge = (lhs, rhs) => {
+ _notUndef(lhs);
+ _notUndef(rhs);
</ins><span class="cx"> if (!(lhs >= rhs))
</span><span class="cx"> throw new Error(`Expected: "${lhs}" < "${rhs}"`);
</span><span class="cx"> };
</span><span class="cx">
</span><del>-export const throws = (func, type, message, ...args) => {
</del><ins>+const _throws = (func, type, message, ...args) => {
</ins><span class="cx"> try {
</span><span class="cx"> func(...args);
</span><span class="cx"> } catch (e) {
</span><span class="lines">@@ -55,3 +55,15 @@
</span><span class="cx"> }
</span><span class="cx"> throw new Error(`Expected to throw a ${type.name} with message "${message}"`);
</span><span class="cx"> };
</span><ins>+
+const _instanceof = (obj, type) => obj instanceof type;
+
+// Use underscore names to avoid clashing with builtin names.
+export {
+ _notUndef as notUndef,
+ _isUndef as isUndef,
+ _eq as eq,
+ _ge as ge,
+ _throws as throws,
+ _instanceof as instanceof,
+};
</ins></span></pre></div>
<a id="trunkJSTestswasmjsapitest_basic_apijs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/js-api/test_basic_api.js (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/js-api/test_basic_api.js        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/JSTests/wasm/js-api/test_basic_api.js        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -1,6 +1,9 @@
</span><span class="cx"> import * as assert from '../assert.js';
</span><span class="cx"> import * as utilities from '../utilities.js';
</span><span class="cx">
</span><ins>+const version = 0xC;
+const emptyModule = Uint8Array.of(0x0, 0x61, 0x73, 0x6d, version, 0x00, 0x00, 0x00);
+
</ins><span class="cx"> const checkOwnPropertyDescriptor = (obj, prop, expect) => {
</span><span class="cx"> const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
</span><span class="cx"> assert.eq(typeof descriptor.value, expect.typeofvalue);
</span><span class="lines">@@ -14,12 +17,12 @@
</span><span class="cx"> "compile": { length: 1 },
</span><span class="cx"> };
</span><span class="cx"> const constructorProperties = {
</span><del>- "Module": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1, isError: false },
- "Instance": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1, isError: false },
- "Memory": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1, isError: false },
- "Table": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1, isError: false },
- "CompileError": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1, isError: true },
- "RuntimeError": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1, isError: true },
</del><ins>+ "Module": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1 },
+ "Instance": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1 },
+ "Memory": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1 },
+ "Table": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1 },
+ "CompileError": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1 },
+ "RuntimeError": { typeofvalue: "function", writable: true, configurable: true, enumerable: false, length: 1 },
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -44,7 +47,30 @@
</span><span class="cx"> checkOwnPropertyDescriptor(WebAssembly, c, constructorProperties[c]);
</span><span class="cx"> checkOwnPropertyDescriptor(WebAssembly[c], "prototype", { typeofvalue: "object", writable: false, configurable: false, enumerable: false });
</span><span class="cx"> assert.throws(() => WebAssembly[c](), TypeError, `calling WebAssembly.${c} constructor without new is invalid`);
</span><del>- if (constructorProperties[c].isError) {
</del><ins>+ switch (c) {
+ case "Module":
+ for (const invalid of [undefined, "", 1, {}, []])
+ assert.throws(() => new WebAssembly[c](invalid), TypeError, `first argument to WebAssembly.Module must be an ArrayBufferView or an ArrayBuffer (evaluating 'new WebAssembly[c](invalid)')`);
+ for (const buffer of [new ArrayBuffer(), new DataView(new ArrayBuffer()), new Int8Array(), new Uint8Array(), new Uint8ClampedArray(), new Int16Array(), new Uint16Array(), new Int32Array(), new Uint32Array(), new Float32Array(), new Float64Array()])
+ // FIXME the following should be WebAssembly.CompileError. https://bugs.webkit.org/show_bug.cgi?id=163768
+ assert.throws(() => new WebAssembly[c](buffer), Error, `Module is 0 bytes, expected at least 8 bytes (evaluating 'new WebAssembly[c](buffer)')`);
+ assert.instanceof(new WebAssembly[c](emptyModule), WebAssembly.Module);
+ // FIXME test neutered TypedArray and TypedArrayView. https://bugs.webkit.org/show_bug.cgi?id=163899
+ break;
+ case "Instance":
+ // FIXME Implement and test these APIs further. For now they just throw. https://bugs.webkit.org/show_bug.cgi?id=159775
+ assert.throws(() => new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
+ break;
+ case "Memory":
+ // FIXME Implement and test these APIs further. For now they just throw. https://bugs.webkit.org/show_bug.cgi?id=159775
+ assert.throws(() => new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
+ break;
+ case "Table":
+ // FIXME Implement and test these APIs further. For now they just throw. https://bugs.webkit.org/show_bug.cgi?id=159775
+ assert.throws(() => new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
+ break;
+ case "CompileError":
+ case "RuntimeError": {
</ins><span class="cx"> const e = new WebAssembly[c];
</span><span class="cx"> assert.eq(e instanceof WebAssembly[c], true);
</span><span class="cx"> assert.eq(e instanceof Error, true);
</span><span class="lines">@@ -54,16 +80,12 @@
</span><span class="cx"> const sillyString = "uh-oh!";
</span><span class="cx"> const e2 = new WebAssembly[c](sillyString);
</span><span class="cx"> assert.eq(e2.message, sillyString);
</span><ins>+ } break;
+ default: throw new Error(`Implementation error: unexpected constructor property "${c}"`);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // FIXME Implement and test these APIs further. For now they just throw. https://bugs.webkit.org/show_bug.cgi?id=159775
</span><del>-
</del><span class="cx"> for (const f in functionProperties) {
</span><span class="cx"> assert.throws(() => WebAssembly[f](), Error, `WebAssembly doesn't yet implement the ${f} function property`);
</span><span class="cx"> }
</span><del>-
-for (const c in constructorProperties) {
- if (!constructorProperties[c].isError)
- assert.throws(() => new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
-}
</del></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -1,3 +1,114 @@
</span><ins>+2016-10-25 JF Bastien <jfbastien@apple.com>
+
+ WebAssembly JS API: implement Module
+
+ This implementation allows us to:
+ - Syncrhonously create a WebAssembly.Module with a typed array.
+ - Creates a compilation plan.
+ - Parse the Module and creates corresponding code.
+ - Throw WebAssembly.CompileError with mildly helpful [*] error messages on
+ failure.
+
+ Consult the API documentation for expected behavior: https://github.com/WebAssembly/design/blob/master/JS.md#webassemblymodule-constructor
+
+ For now the implementation discards the generated code.
+
+ The next steps will be:
+ - Expose a Module's exports.
+ - Implement WebAssembly.Instance, which allows instantiating and running a
+ compiled Module.
+ - Beef up the testing infrastructure under JSTests/wasm so that more complex
+ modules can be created and tested (instead of writing the bits by hand).
+
+ This patch also:
+ - Adds assert.instanceof in assert.js.
+ - Refactors Wasm::Parser and friends to accept const uint8_t* as well as a
+ Vector, to avoid copying when invoked synchronously.
+ - Remove useless Structure from some of the wasm constructors: they're already
+ on the JSGlobalObject, visited properly and all.
+ - Fix off-by-one error in parsing: Parser::parseUInt32 failed if the integer
+ was exactly at end of file.
+
+ [*] On error messages while parsing: I filed https://bugs.webkit.org/show_bug.cgi?id=163919
+
+ WebAssembly JS API: implement Module
+ https://bugs.webkit.org/show_bug.cgi?id=163903
+
+ Reviewed by Keith Miller.
+
+ * runtime/ExceptionHelpers.cpp:
+ (JSC::defaultSourceAppender): make this public so that WebAssembly can use it: it generates those fancy (evaluating '...') messages at the end
+ * runtime/ExceptionHelpers.h:
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::init): remove the useless Structure from the WebAssembly objects (it's already in this file, no need to hold two references and visit them twice)
+ * testWasm.cpp:
+ (runWasmTests): update API
+ * wasm/WasmB3IRGenerator.cpp:
+ (JSC::Wasm::parseAndCompile): use updated API
+ * wasm/WasmB3IRGenerator.h:
+ * wasm/WasmFunctionParser.h:
+ (JSC::Wasm::FunctionParser<Context>::FunctionParser): use updated API
+ (JSC::Wasm::FunctionParser<Context>::parseExpression): use updated API
+ * wasm/WasmModuleParser.cpp:
+ (JSC::Wasm::ModuleParser::parse): generate error messages
+ * wasm/WasmModuleParser.h:
+ (JSC::Wasm::ModuleParser::ModuleParser):
+ (JSC::Wasm::ModuleParser::failed):
+ (JSC::Wasm::ModuleParser::errorMessage):
+ (JSC::Wasm::ModuleParser::functionInformation):
+ (JSC::Wasm::ModuleParser::memory):
+ * wasm/WasmParser.h: use update non-public API
+ (JSC::Wasm::Parser::parseVarUInt32):
+ (JSC::Wasm::Parser::parseVarUInt64):
+ (JSC::Wasm::Parser::source):
+ (JSC::Wasm::Parser::length):
+ (JSC::Wasm::Parser::Parser):
+ (JSC::Wasm::Parser::consumeCharacter):
+ (JSC::Wasm::Parser::consumeString):
+ (JSC::Wasm::Parser::parseUInt32):
+ (JSC::Wasm::Parser::parseUInt7):
+ * wasm/WasmPlan.cpp:
+ (JSC::Wasm::Plan::Plan):
+ (JSC::Wasm::Plan::~Plan):
+ * wasm/WasmPlan.h:
+ (JSC::Wasm::Plan::failed):
+ (JSC::Wasm::Plan::errorMessage):
+ (JSC::Wasm::Plan::resultSize):
+ (JSC::Wasm::Plan::result):
+ (JSC::Wasm::Plan::memory):
+ * wasm/js/JSWebAssemblyCompileError.cpp:
+ (JSC::createWebAssemblyCompileError): makes it easier to throw a WebAssembly.CompileError from Module
+ * wasm/js/JSWebAssemblyCompileError.h:
+ * wasm/js/WebAssemblyCompileErrorConstructor.cpp:
+ (JSC::WebAssemblyCompileErrorConstructor::create):
+ (JSC::WebAssemblyCompileErrorConstructor::finishCreation):
+ * wasm/js/WebAssemblyCompileErrorConstructor.h:
+ * wasm/js/WebAssemblyInstanceConstructor.cpp:
+ (JSC::WebAssemblyInstanceConstructor::create):
+ (JSC::WebAssemblyInstanceConstructor::finishCreation):
+ (JSC::WebAssemblyInstanceConstructor::visitChildren):
+ * wasm/js/WebAssemblyInstanceConstructor.h:
+ * wasm/js/WebAssemblyMemoryConstructor.cpp:
+ (JSC::WebAssemblyMemoryConstructor::create):
+ (JSC::WebAssemblyMemoryConstructor::finishCreation):
+ (JSC::WebAssemblyMemoryConstructor::visitChildren):
+ * wasm/js/WebAssemblyMemoryConstructor.h:
+ * wasm/js/WebAssemblyModuleConstructor.cpp:
+ (JSC::constructJSWebAssemblyModule):
+ (JSC::WebAssemblyModuleConstructor::create):
+ (JSC::WebAssemblyModuleConstructor::finishCreation):
+ (JSC::WebAssemblyModuleConstructor::visitChildren):
+ * wasm/js/WebAssemblyModuleConstructor.h:
+ * wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
+ (JSC::WebAssemblyRuntimeErrorConstructor::create):
+ (JSC::WebAssemblyRuntimeErrorConstructor::finishCreation):
+ * wasm/js/WebAssemblyRuntimeErrorConstructor.h:
+ * wasm/js/WebAssemblyTableConstructor.cpp:
+ (JSC::WebAssemblyTableConstructor::create):
+ (JSC::WebAssemblyTableConstructor::finishCreation):
+ (JSC::WebAssemblyTableConstructor::visitChildren):
+ * wasm/js/WebAssemblyTableConstructor.h:
+
</ins><span class="cx"> 2016-10-25 Keith Miller <keith_miller@apple.com>
</span><span class="cx">
</span><span class="cx"> Add trivial Wasm conversion opcodes
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeExceptionHelperscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx"> return makeString(originalMessage, " (near '...", sourceText, "...')");
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static String defaultSourceAppender(const String& originalMessage, const String& sourceText, RuntimeType, ErrorInstance::SourceTextWhereErrorOccurred occurrence)
</del><ins>+String defaultSourceAppender(const String& originalMessage, const String& sourceText, RuntimeType, ErrorInstance::SourceTextWhereErrorOccurred occurrence)
</ins><span class="cx"> {
</span><span class="cx"> if (occurrence == ErrorInstance::FoundApproximateSource)
</span><span class="cx"> return defaultApproximateSourceError(originalMessage, sourceText);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeExceptionHelpersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -37,6 +37,8 @@
</span><span class="cx">
</span><span class="cx"> typedef JSObject* (*ErrorFactory)(ExecState*, const String&, ErrorInstance::SourceAppender);
</span><span class="cx">
</span><ins>+String defaultSourceAppender(const String&, const String&, RuntimeType, ErrorInstance::SourceTextWhereErrorOccurred);
+
</ins><span class="cx"> JSObject* createTerminatedExecutionException(VM*);
</span><span class="cx"> JS_EXPORT_PRIVATE bool isTerminatedExecutionException(Exception*);
</span><span class="cx"> JS_EXPORT_PRIVATE JSObject* createError(ExecState*, JSValue, const String&, ErrorInstance::SourceAppender);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -832,7 +832,7 @@
</span><span class="cx"> auto* base = m_ ## prototypeBase ## Prototype.get(); \
</span><span class="cx"> auto* prototype = Prototype::create(vm, this, Prototype::createStructure(vm, this, base)); \
</span><span class="cx"> auto* structure = JSObj::createStructure(vm, this, prototype); \
</span><del>- auto* constructor = Constructor::create(vm, Constructor::createStructure(vm, this, this->functionPrototype()), prototype, structure); \
</del><ins>+ auto* constructor = Constructor::create(vm, Constructor::createStructure(vm, this, this->functionPrototype()), prototype); \
</ins><span class="cx"> prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, constructor, DontEnum); \
</span><span class="cx"> m_ ## lowerName ## Prototype.set(vm, this, prototype); \
</span><span class="cx"> m_ ## properName ## Structure.set(vm, this, structure); \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestWasmcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/testWasm.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/testWasm.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/testWasm.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -290,16 +290,16 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK(isIdentical(invoke<float>(*plan.result[1]->jsEntryPoint, { boxf(0.0), boxf(1.5) }), -1.5f));
- CHECK(isIdentical(invoke<float>(*plan.result[1]->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 87.6234f));
- CHECK(isIdentical(invoke<float>(*plan.result[0]->jsEntryPoint, { boxf(0.0), boxf(1.5) }), -1.5f));
- CHECK(isIdentical(invoke<float>(*plan.result[0]->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 87.6234f));
</del><ins>+ CHECK(isIdentical(invoke<float>(*plan.result(1)->jsEntryPoint, { boxf(0.0), boxf(1.5) }), -1.5f));
+ CHECK(isIdentical(invoke<float>(*plan.result(1)->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 87.6234f));
+ CHECK(isIdentical(invoke<float>(*plan.result(0)->jsEntryPoint, { boxf(0.0), boxf(1.5) }), -1.5f));
+ CHECK(isIdentical(invoke<float>(*plan.result(0)->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 87.6234f));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -319,16 +319,16 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK(isIdentical(invoke<float>(*plan.result[1]->jsEntryPoint, { boxf(0.0), boxf(1.5) }), 1.5f));
- CHECK(isIdentical(invoke<float>(*plan.result[1]->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 112.6234f));
- CHECK(isIdentical(invoke<float>(*plan.result[0]->jsEntryPoint, { boxf(0.0), boxf(1.5) }), 1.5f));
- CHECK(isIdentical(invoke<float>(*plan.result[0]->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 112.6234f));
</del><ins>+ CHECK(isIdentical(invoke<float>(*plan.result(1)->jsEntryPoint, { boxf(0.0), boxf(1.5) }), 1.5f));
+ CHECK(isIdentical(invoke<float>(*plan.result(1)->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 112.6234f));
+ CHECK(isIdentical(invoke<float>(*plan.result(0)->jsEntryPoint, { boxf(0.0), boxf(1.5) }), 1.5f));
+ CHECK(isIdentical(invoke<float>(*plan.result(0)->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 112.6234f));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -353,17 +353,17 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[1]->jsEntryPoint, { box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[1]->jsEntryPoint, { box(100) }), 1200);
- CHECK_EQ(invoke<int>(*plan.result[1]->jsEntryPoint, { box(1) }), 12);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(2), box(3), box(4), box(5), box(6), box(7), box(8), box(9), box(10), box(11), box(12) }), 78);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(2), box(3), box(4), box(5), box(6), box(7), box(8), box(9), box(10), box(11), box(100) }), 166);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(1)->jsEntryPoint, { box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(1)->jsEntryPoint, { box(100) }), 1200);
+ CHECK_EQ(invoke<int>(*plan.result(1)->jsEntryPoint, { box(1) }), 12);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(2), box(3), box(4), box(5), box(6), box(7), box(8), box(9), box(10), box(11), box(12) }), 78);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(2), box(3), box(4), box(5), box(6), box(7), box(8), box(9), box(10), box(11), box(100) }), 166);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -387,16 +387,16 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2) }), 2);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(4) }), 24);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2) }), 2);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(4) }), 24);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -416,18 +416,18 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
</del><ins>+ if (plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[1]->jsEntryPoint, { box(0), box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[1]->jsEntryPoint, { box(100), box(0) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[1]->jsEntryPoint, { box(1), box(15) }), 16);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100) }), 200);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1) }), 2);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(1)->jsEntryPoint, { box(0), box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(1)->jsEntryPoint, { box(100), box(0) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(1)->jsEntryPoint, { box(1), box(15) }), 16);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100) }), 200);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1) }), 2);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -447,18 +447,18 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[1]->jsEntryPoint, { box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[1]->jsEntryPoint, { box(100) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[1]->jsEntryPoint, { box(1) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1) }), 1);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(1)->jsEntryPoint, { box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(1)->jsEntryPoint, { box(100) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(1)->jsEntryPoint, { box(1) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1) }), 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -480,15 +480,15 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(10) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(2) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(100) }), 1);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(10) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(2) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(100) }), 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -510,15 +510,15 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(10) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(2) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(100) }), 1);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(10) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(2) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(100) }), 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -550,17 +550,17 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><del>- ASSERT(plan.memory->size());
</del><ins>+ ASSERT(plan.memory()->size());
</ins><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><span class="cx"> unsigned length = 5;
</span><span class="cx"> unsigned offset = sizeof(uint32_t);
</span><del>- uint32_t* memory = static_cast<uint32_t*>(plan.memory->memory());
- invoke<void>(*plan.result[0]->jsEntryPoint, { box(100), box(offset), box(length) });
</del><ins>+ uint32_t* memory = static_cast<uint32_t*>(plan.memory()->memory());
+ invoke<void>(*plan.result(0)->jsEntryPoint, { box(100), box(offset), box(length) });
</ins><span class="cx"> offset /= sizeof(uint32_t);
</span><span class="cx"> CHECK_EQ(memory[offset - 1], 0u);
</span><span class="cx"> CHECK_EQ(memory[offset + length], 0u);
</span><span class="lines">@@ -569,7 +569,7 @@
</span><span class="cx">
</span><span class="cx"> length = 10;
</span><span class="cx"> offset = 5 * sizeof(uint32_t);
</span><del>- invoke<void>(*plan.result[0]->jsEntryPoint, { box(5), box(offset), box(length) });
</del><ins>+ invoke<void>(*plan.result(0)->jsEntryPoint, { box(5), box(offset), box(length) });
</ins><span class="cx"> offset /= sizeof(uint32_t);
</span><span class="cx"> CHECK_EQ(memory[offset - 1], 100u);
</span><span class="cx"> CHECK_EQ(memory[offset + length], 0u);
</span><span class="lines">@@ -605,17 +605,17 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><del>- ASSERT(plan.memory->size());
</del><ins>+ ASSERT(plan.memory()->size());
</ins><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><span class="cx"> unsigned length = 5;
</span><span class="cx"> unsigned offset = 1;
</span><del>- uint8_t* memory = static_cast<uint8_t*>(plan.memory->memory());
- invoke<void>(*plan.result[0]->jsEntryPoint, { box(100), box(offset), box(length) });
</del><ins>+ uint8_t* memory = static_cast<uint8_t*>(plan.memory()->memory());
+ invoke<void>(*plan.result(0)->jsEntryPoint, { box(100), box(offset), box(length) });
</ins><span class="cx"> CHECK_EQ(memory[offset - 1], 0u);
</span><span class="cx"> CHECK_EQ(memory[offset + length], 0u);
</span><span class="cx"> for (unsigned i = 0; i < length; ++i)
</span><span class="lines">@@ -623,7 +623,7 @@
</span><span class="cx">
</span><span class="cx"> length = 10;
</span><span class="cx"> offset = 5;
</span><del>- invoke<void>(*plan.result[0]->jsEntryPoint, { box(5), box(offset), box(length) });
</del><ins>+ invoke<void>(*plan.result(0)->jsEntryPoint, { box(5), box(offset), box(length) });
</ins><span class="cx"> CHECK_EQ(memory[offset - 1], 100u);
</span><span class="cx"> CHECK_EQ(memory[offset + length], 0u);
</span><span class="cx"> for (unsigned i = 0; i < length; ++i)
</span><span class="lines">@@ -649,16 +649,16 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><del>- ASSERT(plan.memory->size());
</del><ins>+ ASSERT(plan.memory()->size());
</ins><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(10) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(2) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(100) }), 1);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(10) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(2) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(100) }), 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -680,15 +680,15 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1) }), 1);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1) }), 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -710,16 +710,16 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(10) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(2) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(100) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(-12), box(plan.memory->size() - sizeof(uint64_t)) }), -12);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(10) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(2) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(100) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(-12), box(plan.memory()->size() - sizeof(uint64_t)) }), -12);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -741,15 +741,15 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(10) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(2) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(100) }), 1);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(10) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(2) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(100) }), 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -781,17 +781,17 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><del>- ASSERT(plan.memory->size());
</del><ins>+ ASSERT(plan.memory()->size());
</ins><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><span class="cx"> unsigned length = 5;
</span><span class="cx"> unsigned offset = sizeof(uint32_t);
</span><del>- uint32_t* memory = static_cast<uint32_t*>(plan.memory->memory());
- invoke<void>(*plan.result[0]->jsEntryPoint, { box(100), box(offset), box(length) });
</del><ins>+ uint32_t* memory = static_cast<uint32_t*>(plan.memory()->memory());
+ invoke<void>(*plan.result(0)->jsEntryPoint, { box(100), box(offset), box(length) });
</ins><span class="cx"> offset /= sizeof(uint32_t);
</span><span class="cx"> CHECK_EQ(memory[offset - 1], 0u);
</span><span class="cx"> CHECK_EQ(memory[offset + length], 0u);
</span><span class="lines">@@ -800,7 +800,7 @@
</span><span class="cx">
</span><span class="cx"> length = 10;
</span><span class="cx"> offset = 5 * sizeof(uint32_t);
</span><del>- invoke<void>(*plan.result[0]->jsEntryPoint, { box(5), box(offset), box(length) });
</del><ins>+ invoke<void>(*plan.result(0)->jsEntryPoint, { box(5), box(offset), box(length) });
</ins><span class="cx"> offset /= sizeof(uint32_t);
</span><span class="cx"> CHECK_EQ(memory[offset - 1], 100u);
</span><span class="cx"> CHECK_EQ(memory[offset + length], 0u);
</span><span class="lines">@@ -836,17 +836,17 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><del>- ASSERT(plan.memory->size());
</del><ins>+ ASSERT(plan.memory()->size());
</ins><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><span class="cx"> unsigned length = 5;
</span><span class="cx"> unsigned offset = 1;
</span><del>- uint8_t* memory = static_cast<uint8_t*>(plan.memory->memory());
- invoke<void>(*plan.result[0]->jsEntryPoint, { box(100), box(offset), box(length) });
</del><ins>+ uint8_t* memory = static_cast<uint8_t*>(plan.memory()->memory());
+ invoke<void>(*plan.result(0)->jsEntryPoint, { box(100), box(offset), box(length) });
</ins><span class="cx"> CHECK_EQ(memory[offset - 1], 0u);
</span><span class="cx"> CHECK_EQ(memory[offset + length], 0u);
</span><span class="cx"> for (unsigned i = 0; i < length; ++i)
</span><span class="lines">@@ -854,7 +854,7 @@
</span><span class="cx">
</span><span class="cx"> length = 10;
</span><span class="cx"> offset = 5;
</span><del>- invoke<void>(*plan.result[0]->jsEntryPoint, { box(5), box(offset), box(length) });
</del><ins>+ invoke<void>(*plan.result(0)->jsEntryPoint, { box(5), box(offset), box(length) });
</ins><span class="cx"> CHECK_EQ(memory[offset - 1], 100u);
</span><span class="cx"> CHECK_EQ(memory[offset + length], 0u);
</span><span class="cx"> for (unsigned i = 0; i < length; ++i)
</span><span class="lines">@@ -880,16 +880,16 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><del>- ASSERT(plan.memory->size());
</del><ins>+ ASSERT(plan.memory()->size());
</ins><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(10) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(2) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(100) }), 1);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(10) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(2) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(100) }), 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -911,15 +911,15 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100) }), 100);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1) }), 1);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100) }), 100);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1) }), 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -941,20 +941,20 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(1) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(0) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(1) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(2) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(2) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(1) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(6) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(6) }), 1);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(1) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(0) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(1) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(2) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(2) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(1) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(6) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(6) }), 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -982,20 +982,20 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(1) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(1) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(2) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(2) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(1) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(6) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(6) }), 0);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(1) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(1) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(2) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(2) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(1) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(6) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(6) }), 0);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1009,13 +1009,13 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { }), 5);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { }), 5);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1030,13 +1030,13 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { }), 11);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { }), 11);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -1050,13 +1050,13 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { }), 11);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { }), 11);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -1070,13 +1070,13 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { }), 11);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { }), 11);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -1089,16 +1089,16 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(1) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(1) }), 101);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(-1), box(1)}), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(std::numeric_limits<int>::max()), box(1) }), std::numeric_limits<int>::min());
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(1) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(1) }), 101);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(-1), box(1)}), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(std::numeric_limits<int>::max()), box(1) }), std::numeric_limits<int>::min());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -1118,14 +1118,14 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(10) }), 10);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(10) }), 10);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -1154,16 +1154,16 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2)}), 3);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100) }), 5050);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2)}), 3);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100) }), 5050);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -1198,20 +1198,20 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(1) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(1) }), 2);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(2) }), 2);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(2) }), 4);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(6) }), 12);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(6) }), 600);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(100) }), 10000);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(1) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(1) }), 2);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(2) }), 2);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(2) }), 4);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(6) }), 12);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(6) }), 600);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(100) }), 10000);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> {
</span><span class="lines">@@ -1251,20 +1251,20 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> Plan plan(*vm, vector);
</span><del>- if (plan.result.size() != 1 || !plan.result[0]) {
</del><ins>+ if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
</ins><span class="cx"> dataLogLn("Module failed to compile correctly.");
</span><span class="cx"> CRASH();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Test this doesn't crash.
</span><del>- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(0), box(1) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(0) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(1) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(2) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(2) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(1), box(1) }), 0);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(2), box(6) }), 1);
- CHECK_EQ(invoke<int>(*plan.result[0]->jsEntryPoint, { box(100), box(6) }), 0);
</del><ins>+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(0), box(1) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(0) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(1) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(2) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(2) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(1), box(1) }), 0);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(2), box(6) }), 1);
+ CHECK_EQ(invoke<int>(*plan.result(0)->jsEntryPoint, { box(100), box(6) }), 0);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmB3IRGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -718,13 +718,13 @@
</span><span class="cx"> return std::make_unique<Compilation>(vm, proc);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-std::unique_ptr<FunctionCompilation> parseAndCompile(VM& vm, Vector<uint8_t>& source, Memory* memory, FunctionInformation info, const Vector<FunctionInformation>& functions, unsigned optLevel)
</del><ins>+std::unique_ptr<FunctionCompilation> parseAndCompile(VM& vm, const uint8_t* functionStart, size_t functionLength, Memory* memory, const Signature* signature, const Vector<FunctionInformation>& functions, unsigned optLevel)
</ins><span class="cx"> {
</span><span class="cx"> auto result = std::make_unique<FunctionCompilation>();
</span><span class="cx">
</span><span class="cx"> Procedure procedure;
</span><span class="cx"> B3IRGenerator context(memory, procedure, result->unlinkedCalls);
</span><del>- FunctionParser<B3IRGenerator> parser(context, source, info, functions);
</del><ins>+ FunctionParser<B3IRGenerator> parser(context, functionStart, functionLength, signature, functions);
</ins><span class="cx"> if (!parser.parse())
</span><span class="cx"> RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">
</span><span class="lines">@@ -736,7 +736,7 @@
</span><span class="cx"> dataLog("Post SSA: ", procedure);
</span><span class="cx">
</span><span class="cx"> result->code = std::make_unique<Compilation>(vm, procedure, optLevel);
</span><del>- result->jsEntryPoint = createJSWrapper(vm, info.signature, result->code->code(), memory);
</del><ins>+ result->jsEntryPoint = createJSWrapper(vm, signature, result->code->code(), memory);
</ins><span class="cx"> return result;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmB3IRGeneratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx">
</span><span class="cx"> class Memory;
</span><span class="cx">
</span><del>-std::unique_ptr<FunctionCompilation> parseAndCompile(VM&, Vector<uint8_t>&, Memory*, FunctionInformation, const Vector<FunctionInformation>&, unsigned optLevel = 1);
</del><ins>+std::unique_ptr<FunctionCompilation> parseAndCompile(VM&, const uint8_t*, size_t, Memory*, const Signature*, const Vector<FunctionInformation>&, unsigned optLevel = 1);
</ins><span class="cx">
</span><span class="cx"> } } // namespace JSC::Wasm
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmFunctionParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> typedef typename Context::ExpressionType ExpressionType;
</span><span class="cx"> typedef typename Context::ControlType ControlType;
</span><span class="cx">
</span><del>- FunctionParser(Context&, const Vector<uint8_t>& sourceBuffer, const FunctionInformation&, const Vector<FunctionInformation>& functions);
</del><ins>+ FunctionParser(Context&, const uint8_t* functionStart, size_t functionLength, const Signature*, const Vector<FunctionInformation>& functions);
</ins><span class="cx">
</span><span class="cx"> bool WARN_UNUSED_RETURN parse();
</span><span class="cx">
</span><span class="lines">@@ -59,21 +59,21 @@
</span><span class="cx"> Context& m_context;
</span><span class="cx"> Vector<ExpressionType, 1> m_expressionStack;
</span><span class="cx"> Vector<ControlType> m_controlStack;
</span><del>- const Signature& m_signature;
</del><ins>+ const Signature* m_signature;
</ins><span class="cx"> const Vector<FunctionInformation>& m_functions;
</span><span class="cx"> unsigned m_unreachableBlocks { 0 };
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> template<typename Context>
</span><del>-FunctionParser<Context>::FunctionParser(Context& context, const Vector<uint8_t>& sourceBuffer, const FunctionInformation& info, const Vector<FunctionInformation>& functions)
- : Parser(sourceBuffer, info.start, info.end)
</del><ins>+FunctionParser<Context>::FunctionParser(Context& context, const uint8_t* functionStart, size_t functionLength, const Signature* signature, const Vector<FunctionInformation>& functions)
+ : Parser(functionStart, functionLength)
</ins><span class="cx"> , m_context(context)
</span><del>- , m_signature(*info.signature)
</del><ins>+ , m_signature(signature)
</ins><span class="cx"> , m_functions(functions)
</span><span class="cx"> {
</span><span class="cx"> if (verbose)
</span><del>- dataLogLn("Parsing function starting at: ", info.start, " ending at: ", info.end);
- m_context.addArguments(m_signature.arguments);
</del><ins>+ dataLogLn("Parsing function starting at: ", (uintptr_t)functionStart, " of length: ", functionLength);
+ m_context.addArguments(m_signature->arguments);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template<typename Context>
</span><span class="lines">@@ -309,7 +309,7 @@
</span><span class="cx">
</span><span class="cx"> case OpType::Return: {
</span><span class="cx"> Vector<ExpressionType, 1> returnValues;
</span><del>- if (m_signature.returnType != Void)
</del><ins>+ if (m_signature->returnType != Void)
</ins><span class="cx"> returnValues.append(m_expressionStack.takeLast());
</span><span class="cx">
</span><span class="cx"> m_unreachableBlocks = 1;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmModuleParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -41,20 +41,29 @@
</span><span class="cx">
</span><span class="cx"> bool ModuleParser::parse()
</span><span class="cx"> {
</span><del>- if (m_sourceLength < 8)
</del><ins>+ const size_t minSize = 8;
+ if (length() < minSize) {
+ m_errorMessage = "Module is " + String::number(length()) + " bytes, expected at least " + String::number(minSize) + " bytes";
</ins><span class="cx"> return false;
</span><del>- if (!consumeCharacter(0))
</del><ins>+ }
+ if (!consumeCharacter(0) || !consumeString("asm")) {
+ m_errorMessage = "Modules doesn't start with '\\0asm'";
</ins><span class="cx"> return false;
</span><del>- if (!consumeString("asm"))
- return false;
</del><ins>+ }
</ins><span class="cx">
</span><span class="cx"> // Skip the version number for now since we don't do anything with it.
</span><span class="cx"> uint32_t versionNumber;
</span><del>- if (!parseUInt32(versionNumber))
</del><ins>+ if (!parseUInt32(versionNumber)) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "couldn't parse version number";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><del>- if (versionNumber != magicNumber)
</del><ins>+ if (versionNumber != magicNumber) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "unexpected version number";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> if (verbose)
</span><span class="lines">@@ -61,13 +70,16 @@
</span><span class="cx"> dataLogLn("Passed processing header.");
</span><span class="cx">
</span><span class="cx"> Sections::Section previousSection = Sections::Unknown;
</span><del>- while (m_offset < m_sourceLength) {
</del><ins>+ while (m_offset < length()) {
</ins><span class="cx"> if (verbose)
</span><span class="cx"> dataLogLn("Starting to parse next section at offset: ", m_offset);
</span><span class="cx">
</span><span class="cx"> uint8_t sectionByte;
</span><del>- if (!parseUInt7(sectionByte))
</del><ins>+ if (!parseUInt7(sectionByte)) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "couldn't get section byte";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> if (verbose)
</span><span class="cx"> dataLogLn("Section byte: ", sectionByte);
</span><span class="lines">@@ -78,12 +90,18 @@
</span><span class="cx"> section = static_cast<Sections::Section>(sectionByte);
</span><span class="cx"> } else {
</span><span class="cx"> uint32_t sectionNameLength;
</span><del>- if (!parseVarUInt32(sectionNameLength))
</del><ins>+ if (!parseVarUInt32(sectionNameLength)) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "couldn't get section name length";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> // Make sure we can read up to the section's size.
</span><del>- if (m_offset + sectionNameLength + WTF::LEBDecoder::max32BitLEBByteLength >= m_sourceLength)
</del><ins>+ if (m_offset + sectionNameLength + WTF::LEBDecoder::max32BitLEBByteLength >= length()) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "section length is bigger than actual size";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> // We don't support any custom sections yet.
</span><span class="cx">
</span><span class="lines">@@ -90,12 +108,18 @@
</span><span class="cx"> m_offset += sectionNameLength;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (!Sections::validateOrder(previousSection, section))
</del><ins>+ if (!Sections::validateOrder(previousSection, section)) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "invalid section order";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> uint32_t sectionLength;
</span><del>- if (!parseVarUInt32(sectionLength))
</del><ins>+ if (!parseVarUInt32(sectionLength)) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "couldn't get section length";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> unsigned end = m_offset + sectionLength;
</span><span class="cx">
</span><span class="lines">@@ -104,8 +128,11 @@
</span><span class="cx"> case Sections::Memory: {
</span><span class="cx"> if (verbose)
</span><span class="cx"> dataLogLn("Parsing Memory.");
</span><del>- if (!parseMemory())
</del><ins>+ if (!parseMemory()) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "couldn't parse memory";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -112,8 +139,11 @@
</span><span class="cx"> case Sections::FunctionTypes: {
</span><span class="cx"> if (verbose)
</span><span class="cx"> dataLogLn("Parsing types.");
</span><del>- if (!parseFunctionTypes())
</del><ins>+ if (!parseFunctionTypes()) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "couldn't parse types";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -120,8 +150,11 @@
</span><span class="cx"> case Sections::Signatures: {
</span><span class="cx"> if (verbose)
</span><span class="cx"> dataLogLn("Parsing function signatures.");
</span><del>- if (!parseFunctionSignatures())
</del><ins>+ if (!parseFunctionSignatures()) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "couldn't parse function signatures";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -128,8 +161,11 @@
</span><span class="cx"> case Sections::Definitions: {
</span><span class="cx"> if (verbose)
</span><span class="cx"> dataLogLn("Parsing function definitions.");
</span><del>- if (!parseFunctionDefinitions())
</del><ins>+ if (!parseFunctionDefinitions()) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "couldn't parse function definitions";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -146,13 +182,17 @@
</span><span class="cx"> if (verbose)
</span><span class="cx"> dataLogLn("Finished parsing section.");
</span><span class="cx">
</span><del>- if (end != m_offset)
</del><ins>+ if (end != m_offset) {
+ // FIXME improve error message https://bugs.webkit.org/show_bug.cgi?id=163919
+ m_errorMessage = "parsing ended before the end of the section";
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> previousSection = section;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // TODO
</span><ins>+ m_failed = false;
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmModuleParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmModuleParser.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,15 +39,33 @@
</span><span class="cx">
</span><span class="cx"> static const unsigned magicNumber = 0xc;
</span><span class="cx">
</span><ins>+ ModuleParser(const uint8_t* sourceBuffer, size_t sourceLength)
+ : Parser(sourceBuffer, sourceLength)
+ {
+ }
</ins><span class="cx"> ModuleParser(const Vector<uint8_t>& sourceBuffer)
</span><del>- : Parser(sourceBuffer, 0, sourceBuffer.size())
</del><ins>+ : Parser(sourceBuffer.data(), sourceBuffer.size())
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool WARN_UNUSED_RETURN parse();
</span><ins>+ bool WARN_UNUSED_RETURN failed() const { return m_failed; }
+ const String& errorMessage() const
+ {
+ RELEASE_ASSERT(failed());
+ return m_errorMessage;
+ }
</ins><span class="cx">
</span><del>- const Vector<FunctionInformation>& functionInformation() const { return m_functions; }
- std::unique_ptr<Memory>& memory() { return m_memory; }
</del><ins>+ const Vector<FunctionInformation>& functionInformation() const
+ {
+ RELEASE_ASSERT(!failed());
+ return m_functions;
+ }
+ std::unique_ptr<Memory>& memory()
+ {
+ RELEASE_ASSERT(!failed());
+ return m_memory;
+ }
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> bool WARN_UNUSED_RETURN parseMemory();
</span><span class="lines">@@ -59,6 +77,8 @@
</span><span class="cx"> Vector<FunctionInformation> m_functions;
</span><span class="cx"> Vector<Signature> m_signatures;
</span><span class="cx"> std::unique_ptr<Memory> m_memory;
</span><ins>+ bool m_failed { true };
+ String m_errorMessage;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } } // namespace JSC::Wasm
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmParser.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmParser.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmParser.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">
</span><span class="cx"> class Parser {
</span><span class="cx"> protected:
</span><del>- Parser(const Vector<uint8_t>&, size_t start, size_t end);
</del><ins>+ Parser(const uint8_t*, size_t);
</ins><span class="cx">
</span><span class="cx"> bool WARN_UNUSED_RETURN consumeCharacter(char);
</span><span class="cx"> bool WARN_UNUSED_RETURN consumeString(const char*);
</span><span class="lines">@@ -46,31 +46,32 @@
</span><span class="cx"> bool WARN_UNUSED_RETURN parseVarUInt1(uint8_t& result);
</span><span class="cx"> bool WARN_UNUSED_RETURN parseUInt7(uint8_t& result);
</span><span class="cx"> bool WARN_UNUSED_RETURN parseUInt32(uint32_t& result);
</span><del>- bool WARN_UNUSED_RETURN parseVarUInt32(uint32_t& result) { return WTF::LEBDecoder::decodeUInt32(m_source.data(), m_sourceLength, m_offset, result); }
- bool WARN_UNUSED_RETURN parseVarUInt64(uint64_t& result) { return WTF::LEBDecoder::decodeUInt64(m_source.data(), m_sourceLength, m_offset, result); }
</del><ins>+ bool WARN_UNUSED_RETURN parseVarUInt32(uint32_t& result) { return WTF::LEBDecoder::decodeUInt32(m_source, m_sourceLength, m_offset, result); }
+ bool WARN_UNUSED_RETURN parseVarUInt64(uint64_t& result) { return WTF::LEBDecoder::decodeUInt64(m_source, m_sourceLength, m_offset, result); }
</ins><span class="cx">
</span><del>-
</del><span class="cx"> bool WARN_UNUSED_RETURN parseValueType(Type& result);
</span><span class="cx">
</span><del>- const Vector<uint8_t>& m_source;
</del><ins>+ const uint8_t* source() const { return m_source; }
+ size_t length() const { return m_sourceLength; }
+
+ size_t m_offset = 0;
+
+private:
+ const uint8_t* m_source;
</ins><span class="cx"> size_t m_sourceLength;
</span><del>- size_t m_offset;
</del><span class="cx"> };
</span><span class="cx">
</span><del>-ALWAYS_INLINE Parser::Parser(const Vector<uint8_t>& sourceBuffer, size_t start, size_t end)
</del><ins>+ALWAYS_INLINE Parser::Parser(const uint8_t* sourceBuffer, size_t sourceLength)
</ins><span class="cx"> : m_source(sourceBuffer)
</span><del>- , m_sourceLength(end)
- , m_offset(start)
</del><ins>+ , m_sourceLength(sourceLength)
</ins><span class="cx"> {
</span><del>- ASSERT(end <= sourceBuffer.size());
- ASSERT(start < end);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ALWAYS_INLINE bool Parser::consumeCharacter(char c)
</span><span class="cx"> {
</span><del>- if (m_offset >= m_sourceLength)
</del><ins>+ if (m_offset >= length())
</ins><span class="cx"> return false;
</span><del>- if (c == m_source[m_offset]) {
</del><ins>+ if (c == source()[m_offset]) {
</ins><span class="cx"> m_offset++;
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -80,9 +81,9 @@
</span><span class="cx"> ALWAYS_INLINE bool Parser::consumeString(const char* str)
</span><span class="cx"> {
</span><span class="cx"> unsigned start = m_offset;
</span><del>- if (m_offset >= m_sourceLength)
</del><ins>+ if (m_offset >= length())
</ins><span class="cx"> return false;
</span><del>- for (unsigned i = 0; str[i]; i++) {
</del><ins>+ for (size_t i = 0; str[i]; i++) {
</ins><span class="cx"> if (!consumeCharacter(str[i])) {
</span><span class="cx"> m_offset = start;
</span><span class="cx"> return false;
</span><span class="lines">@@ -93,9 +94,9 @@
</span><span class="cx">
</span><span class="cx"> ALWAYS_INLINE bool Parser::parseUInt32(uint32_t& result)
</span><span class="cx"> {
</span><del>- if (m_sourceLength < 4 || m_offset >= m_sourceLength - 4)
</del><ins>+ if (length() < 4 || m_offset > length() - 4)
</ins><span class="cx"> return false;
</span><del>- result = *reinterpret_cast<const uint32_t*>(m_source.data() + m_offset);
</del><ins>+ result = *reinterpret_cast<const uint32_t*>(source() + m_offset);
</ins><span class="cx"> m_offset += 4;
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -102,9 +103,9 @@
</span><span class="cx">
</span><span class="cx"> ALWAYS_INLINE bool Parser::parseUInt7(uint8_t& result)
</span><span class="cx"> {
</span><del>- if (m_offset >= m_sourceLength)
</del><ins>+ if (m_offset >= length())
</ins><span class="cx"> return false;
</span><del>- result = m_source[m_offset++];
</del><ins>+ result = source()[m_offset++];
</ins><span class="cx"> return result < 0x80;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmPlancpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmPlan.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -37,14 +37,20 @@
</span><span class="cx"> namespace JSC { namespace Wasm {
</span><span class="cx">
</span><span class="cx"> static const bool verbose = false;
</span><del>-
</del><ins>+
</ins><span class="cx"> Plan::Plan(VM& vm, Vector<uint8_t> source)
</span><ins>+ : Plan(vm, source.data(), source.size())
</ins><span class="cx"> {
</span><ins>+}
+
+Plan::Plan(VM& vm, const uint8_t* source, size_t sourceLength)
+{
</ins><span class="cx"> if (verbose)
</span><span class="cx"> dataLogLn("Starting plan.");
</span><del>- ModuleParser moduleParser(source);
</del><ins>+ ModuleParser moduleParser(source, sourceLength);
</ins><span class="cx"> if (!moduleParser.parse()) {
</span><del>- dataLogLn("Parsing module failed.");
</del><ins>+ dataLogLn("Parsing module failed: ", moduleParser.errorMessage());
+ m_errorMessage = moduleParser.errorMessage();
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -54,19 +60,25 @@
</span><span class="cx"> for (const FunctionInformation& info : moduleParser.functionInformation()) {
</span><span class="cx"> if (verbose)
</span><span class="cx"> dataLogLn("Processing funcion starting at: ", info.start, " and ending at: ", info.end);
</span><del>- result.append(parseAndCompile(vm, source, moduleParser.memory().get(), info, moduleParser.functionInformation()));
</del><ins>+ const uint8_t* functionStart = source + info.start;
+ size_t functionLength = info.end - info.start;
+ ASSERT(functionLength <= sourceLength);
+ m_result.append(parseAndCompile(vm, functionStart, functionLength, moduleParser.memory().get(), info.signature, moduleParser.functionInformation()));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Patch the call sites for each function.
</span><del>- for (std::unique_ptr<FunctionCompilation>& functionPtr : result) {
</del><ins>+ for (std::unique_ptr<FunctionCompilation>& functionPtr : m_result) {
</ins><span class="cx"> FunctionCompilation* function = functionPtr.get();
</span><span class="cx"> for (auto& call : function->unlinkedCalls)
</span><del>- MacroAssembler::repatchCall(call.callLocation, CodeLocationLabel(result[call.functionIndex]->code->code()));
</del><ins>+ MacroAssembler::repatchCall(call.callLocation, CodeLocationLabel(m_result[call.functionIndex]->code->code()));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- memory = WTFMove(moduleParser.memory());
</del><ins>+ m_memory = WTFMove(moduleParser.memory());
+ m_failed = false;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+Plan::~Plan() { }
+
</ins><span class="cx"> } } // namespace JSC::Wasm
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(WEBASSEMBLY)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmPlanh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmPlan.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmPlan.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/WasmPlan.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -36,13 +36,39 @@
</span><span class="cx"> namespace JSC { namespace Wasm {
</span><span class="cx"> class Memory;
</span><span class="cx">
</span><del>-// TODO: This should create a Wasm Module not a list of functions.
</del><span class="cx"> class Plan {
</span><span class="cx"> public:
</span><del>- JS_EXPORT_PRIVATE Plan(VM&, Vector<uint8_t> source);
</del><ins>+ JS_EXPORT_PRIVATE Plan(VM&, Vector<uint8_t>);
+ JS_EXPORT_PRIVATE Plan(VM&, const uint8_t*, size_t);
+ JS_EXPORT_PRIVATE ~Plan();
</ins><span class="cx">
</span><del>- Vector<std::unique_ptr<FunctionCompilation>> result;
- std::unique_ptr<Memory> memory;
</del><ins>+ bool WARN_UNUSED_RETURN failed() const { return m_failed; }
+ const String& errorMessage() const
+ {
+ RELEASE_ASSERT(failed());
+ return m_errorMessage;
+ }
+ size_t resultSize() const
+ {
+ RELEASE_ASSERT(!failed());
+ return m_result.size();
+ }
+ const FunctionCompilation* result(size_t n) const
+ {
+ RELEASE_ASSERT(!failed());
+ return m_result.at(n).get();
+ }
+ const Memory* memory() const
+ {
+ RELEASE_ASSERT(!failed());
+ return m_memory.get();
+ }
+
+private:
+ Vector<std::unique_ptr<FunctionCompilation>> m_result;
+ std::unique_ptr<Memory> m_memory;
+ bool m_failed { true };
+ String m_errorMessage;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } } // namespace JSC::Wasm
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -47,6 +47,14 @@
</span><span class="cx">
</span><span class="cx"> const ClassInfo JSWebAssemblyCompileError::s_info = { "WebAssembly.CompileError", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyCompileError) };
</span><span class="cx">
</span><ins>+
+JSObject* createWebAssemblyCompileError(ExecState* exec, const String& message)
+{
+ ASSERT(!message.isEmpty());
+ JSGlobalObject* globalObject = exec->lexicalGlobalObject();
+ return ErrorInstance::create(exec, globalObject->vm(), globalObject->WebAssemblyCompileErrorStructure(), message, defaultSourceAppender, TypeNothing, true);
+}
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(WEBASSEMBLY)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsJSWebAssemblyCompileErrorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -47,6 +47,8 @@
</span><span class="cx"> JSWebAssemblyCompileError(VM&, Structure*);
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+JSObject* createWebAssemblyCompileError(ExecState*, const String&);
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(WEBASSEMBLY)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyCompileErrorConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> {
</span><span class="cx"> auto& vm = state->vm();
</span><span class="cx"> auto scope = DECLARE_THROW_SCOPE(vm);
</span><del>- JSValue message = state->argumentCount() ? state->argument(0) : jsUndefined();
</del><ins>+ JSValue message = state->argument(0);
</ins><span class="cx"> auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->callee())->globalObject()->WebAssemblyCompileErrorStructure());
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> return JSValue::encode(JSWebAssemblyCompileError::create(state, structure, message, false));
</span><span class="lines">@@ -61,10 +61,10 @@
</span><span class="cx"> return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, "WebAssembly.CompileError"));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-WebAssemblyCompileErrorConstructor* WebAssemblyCompileErrorConstructor::create(VM& vm, Structure* structure, WebAssemblyCompileErrorPrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyCompileErrorConstructor* WebAssemblyCompileErrorConstructor::create(VM& vm, Structure* structure, WebAssemblyCompileErrorPrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx"> auto* constructor = new (NotNull, allocateCell<WebAssemblyCompileErrorConstructor>(vm.heap)) WebAssemblyCompileErrorConstructor(vm, structure);
</span><del>- constructor->finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+ constructor->finishCreation(vm, thisPrototype);
</ins><span class="cx"> return constructor;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx"> return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebAssemblyCompileErrorConstructor::finishCreation(VM& vm, WebAssemblyCompileErrorPrototype* prototype, Structure*)
</del><ins>+void WebAssemblyCompileErrorConstructor::finishCreation(VM& vm, WebAssemblyCompileErrorPrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx"> Base::finishCreation(vm, ASCIILiteral("CompileError"));
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, ReadOnly | DontEnum | DontDelete);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyCompileErrorConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,13 +39,13 @@
</span><span class="cx"> typedef InternalFunction Base;
</span><span class="cx"> static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx">
</span><del>- static WebAssemblyCompileErrorConstructor* create(VM&, Structure*, WebAssemblyCompileErrorPrototype*, Structure*);
</del><ins>+ static WebAssemblyCompileErrorConstructor* create(VM&, Structure*, WebAssemblyCompileErrorPrototype*);
</ins><span class="cx"> static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
</span><span class="cx">
</span><span class="cx"> DECLARE_INFO;
</span><span class="cx">
</span><span class="cx"> protected:
</span><del>- void finishCreation(VM&, WebAssemblyCompileErrorPrototype*, Structure*);
</del><ins>+ void finishCreation(VM&, WebAssemblyCompileErrorPrototype*);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> WebAssemblyCompileErrorConstructor(VM&, Structure*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -57,10 +57,10 @@
</span><span class="cx"> return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, "WebAssembly.Instance"));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-WebAssemblyInstanceConstructor* WebAssemblyInstanceConstructor::create(VM& vm, Structure* structure, WebAssemblyInstancePrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyInstanceConstructor* WebAssemblyInstanceConstructor::create(VM& vm, Structure* structure, WebAssemblyInstancePrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx"> auto* constructor = new (NotNull, allocateCell<WebAssemblyInstanceConstructor>(vm.heap)) WebAssemblyInstanceConstructor(vm, structure);
</span><del>- constructor->finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+ constructor->finishCreation(vm, thisPrototype);
</ins><span class="cx"> return constructor;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -69,12 +69,11 @@
</span><span class="cx"> return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebAssemblyInstanceConstructor::finishCreation(VM& vm, WebAssemblyInstancePrototype* prototype, Structure* structure)
</del><ins>+void WebAssemblyInstanceConstructor::finishCreation(VM& vm, WebAssemblyInstancePrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx"> Base::finishCreation(vm, ASCIILiteral("Instance"));
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
</span><del>- m_InstanceStructure.set(vm, this, structure);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebAssemblyInstanceConstructor::WebAssemblyInstanceConstructor(VM& vm, Structure* structure)
</span><span class="lines">@@ -99,7 +98,6 @@
</span><span class="cx"> auto* thisObject = jsCast<WebAssemblyInstanceConstructor*>(cell);
</span><span class="cx"> ASSERT_GC_OBJECT_INHERITS(thisObject, info());
</span><span class="cx"> Base::visitChildren(thisObject, visitor);
</span><del>- visitor.append(&thisObject->m_InstanceStructure);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,15 +39,13 @@
</span><span class="cx"> typedef InternalFunction Base;
</span><span class="cx"> static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx">
</span><del>- static WebAssemblyInstanceConstructor* create(VM&, Structure*, WebAssemblyInstancePrototype*, Structure*);
</del><ins>+ static WebAssemblyInstanceConstructor* create(VM&, Structure*, WebAssemblyInstancePrototype*);
</ins><span class="cx"> static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
</span><span class="cx">
</span><span class="cx"> DECLARE_INFO;
</span><span class="cx">
</span><del>- Structure* InstanceStructure() const { return m_InstanceStructure.get(); }
-
</del><span class="cx"> protected:
</span><del>- void finishCreation(VM&, WebAssemblyInstancePrototype*, Structure*);
</del><ins>+ void finishCreation(VM&, WebAssemblyInstancePrototype*);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> WebAssemblyInstanceConstructor(VM&, Structure*);
</span><span class="lines">@@ -54,8 +52,6 @@
</span><span class="cx"> static ConstructType getConstructData(JSCell*, ConstructData&);
</span><span class="cx"> static CallType getCallData(JSCell*, CallData&);
</span><span class="cx"> static void visitChildren(JSCell*, SlotVisitor&);
</span><del>-
- WriteBarrier<Structure> m_InstanceStructure;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -57,10 +57,10 @@
</span><span class="cx"> return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, "WebAssembly.Memory"));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-WebAssemblyMemoryConstructor* WebAssemblyMemoryConstructor::create(VM& vm, Structure* structure, WebAssemblyMemoryPrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyMemoryConstructor* WebAssemblyMemoryConstructor::create(VM& vm, Structure* structure, WebAssemblyMemoryPrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx"> auto* constructor = new (NotNull, allocateCell<WebAssemblyMemoryConstructor>(vm.heap)) WebAssemblyMemoryConstructor(vm, structure);
</span><del>- constructor->finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+ constructor->finishCreation(vm, thisPrototype);
</ins><span class="cx"> return constructor;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -69,12 +69,11 @@
</span><span class="cx"> return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebAssemblyMemoryConstructor::finishCreation(VM& vm, WebAssemblyMemoryPrototype* prototype, Structure* structure)
</del><ins>+void WebAssemblyMemoryConstructor::finishCreation(VM& vm, WebAssemblyMemoryPrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx"> Base::finishCreation(vm, ASCIILiteral("Memory"));
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
</span><del>- m_MemoryStructure.set(vm, this, structure);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebAssemblyMemoryConstructor::WebAssemblyMemoryConstructor(VM& vm, Structure* structure)
</span><span class="lines">@@ -99,7 +98,6 @@
</span><span class="cx"> auto* thisObject = jsCast<WebAssemblyMemoryConstructor*>(cell);
</span><span class="cx"> ASSERT_GC_OBJECT_INHERITS(thisObject, info());
</span><span class="cx"> Base::visitChildren(thisObject, visitor);
</span><del>- visitor.append(&thisObject->m_MemoryStructure);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyMemoryConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,15 +39,13 @@
</span><span class="cx"> typedef InternalFunction Base;
</span><span class="cx"> static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx">
</span><del>- static WebAssemblyMemoryConstructor* create(VM&, Structure*, WebAssemblyMemoryPrototype*, Structure*);
</del><ins>+ static WebAssemblyMemoryConstructor* create(VM&, Structure*, WebAssemblyMemoryPrototype*);
</ins><span class="cx"> static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
</span><span class="cx">
</span><span class="cx"> DECLARE_INFO;
</span><span class="cx">
</span><del>- Structure* MemoryStructure() const { return m_MemoryStructure.get(); }
-
</del><span class="cx"> protected:
</span><del>- void finishCreation(VM&, WebAssemblyMemoryPrototype*, Structure*);
</del><ins>+ void finishCreation(VM&, WebAssemblyMemoryPrototype*);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> WebAssemblyMemoryConstructor(VM&, Structure*);
</span><span class="lines">@@ -54,8 +52,6 @@
</span><span class="cx"> static ConstructType getConstructData(JSCell*, ConstructData&);
</span><span class="cx"> static CallType getCallData(JSCell*, CallData&);
</span><span class="cx"> static void visitChildren(JSCell*, SlotVisitor&);
</span><del>-
- WriteBarrier<Structure> m_MemoryStructure;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyModuleConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -28,8 +28,14 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx">
</span><ins>+#include "ExceptionHelpers.h"
</ins><span class="cx"> #include "FunctionPrototype.h"
</span><ins>+#include "JSArrayBuffer.h"
</ins><span class="cx"> #include "JSCInlines.h"
</span><ins>+#include "JSTypedArrays.h"
+#include "JSWebAssemblyCompileError.h"
+#include "JSWebAssemblyModule.h"
+#include "WasmPlan.h"
</ins><span class="cx"> #include "WebAssemblyModulePrototype.h"
</span><span class="cx">
</span><span class="cx"> #include "WebAssemblyModuleConstructor.lut.h"
</span><span class="lines">@@ -45,9 +51,30 @@
</span><span class="cx">
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyModule(ExecState* state)
</span><span class="cx"> {
</span><del>- VM& vm = state->vm();
</del><ins>+ auto& vm = state->vm();
</ins><span class="cx"> auto scope = DECLARE_THROW_SCOPE(vm);
</span><del>- return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the Module constructor property"))));
</del><ins>+ JSValue val = state->argument(0);
+ JSArrayBuffer* arrayBuffer = val.getObject() ? jsDynamicCast<JSArrayBuffer*>(val.getObject()) : nullptr;
+ JSArrayBufferView* arrayBufferView = val.getObject() ? jsDynamicCast<JSArrayBufferView*>(val.getObject()) : nullptr;
+ if (!(arrayBuffer || arrayBufferView))
+ return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral("first argument to WebAssembly.Module must be an ArrayBufferView or an ArrayBuffer"), defaultSourceAppender, runtimeTypeForValue(val))));
+
+ if (arrayBufferView ? arrayBufferView->isNeutered() : arrayBuffer->impl()->isNeutered())
+ return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral("underlying TypedArray has been detatched from the ArrayBuffer"), defaultSourceAppender, runtimeTypeForValue(val))));
+
+ size_t byteOffset = arrayBufferView ? arrayBufferView->byteOffset() : 0;
+ size_t byteSize = arrayBufferView ? arrayBufferView->length() : arrayBuffer->impl()->byteLength();
+ const auto* base = arrayBufferView ? static_cast<uint8_t*>(arrayBufferView->vector()) : static_cast<uint8_t*>(arrayBuffer->impl()->data());
+
+ Wasm::Plan plan(vm, base + byteOffset, byteSize);
+ if (plan.failed())
+ return JSValue::encode(throwException(state, scope, createWebAssemblyCompileError(state, plan.errorMessage())));
+
+ // FIXME take content from Plan.
+
+ auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->callee())->globalObject()->WebAssemblyModuleStructure());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ return JSValue::encode(JSWebAssemblyModule::create(vm, structure));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL callJSWebAssemblyModule(ExecState* state)
</span><span class="lines">@@ -57,10 +84,10 @@
</span><span class="cx"> return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, "WebAssembly.Module"));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-WebAssemblyModuleConstructor* WebAssemblyModuleConstructor::create(VM& vm, Structure* structure, WebAssemblyModulePrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyModuleConstructor* WebAssemblyModuleConstructor::create(VM& vm, Structure* structure, WebAssemblyModulePrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx"> auto* constructor = new (NotNull, allocateCell<WebAssemblyModuleConstructor>(vm.heap)) WebAssemblyModuleConstructor(vm, structure);
</span><del>- constructor->finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+ constructor->finishCreation(vm, thisPrototype);
</ins><span class="cx"> return constructor;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -69,12 +96,11 @@
</span><span class="cx"> return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebAssemblyModuleConstructor::finishCreation(VM& vm, WebAssemblyModulePrototype* prototype, Structure* structure)
</del><ins>+void WebAssemblyModuleConstructor::finishCreation(VM& vm, WebAssemblyModulePrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx"> Base::finishCreation(vm, ASCIILiteral("Module"));
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
</span><del>- m_ModuleStructure.set(vm, this, structure);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebAssemblyModuleConstructor::WebAssemblyModuleConstructor(VM& vm, Structure* structure)
</span><span class="lines">@@ -99,7 +125,6 @@
</span><span class="cx"> auto* thisObject = jsCast<WebAssemblyModuleConstructor*>(cell);
</span><span class="cx"> ASSERT_GC_OBJECT_INHERITS(thisObject, info());
</span><span class="cx"> Base::visitChildren(thisObject, visitor);
</span><del>- visitor.append(&thisObject->m_ModuleStructure);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyModuleConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,15 +39,13 @@
</span><span class="cx"> typedef InternalFunction Base;
</span><span class="cx"> static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx">
</span><del>- static WebAssemblyModuleConstructor* create(VM&, Structure*, WebAssemblyModulePrototype*, Structure*);
</del><ins>+ static WebAssemblyModuleConstructor* create(VM&, Structure*, WebAssemblyModulePrototype*);
</ins><span class="cx"> static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
</span><span class="cx">
</span><span class="cx"> DECLARE_INFO;
</span><span class="cx">
</span><del>- Structure* ModuleStructure() const { return m_ModuleStructure.get(); }
-
</del><span class="cx"> protected:
</span><del>- void finishCreation(VM&, WebAssemblyModulePrototype*, Structure*);
</del><ins>+ void finishCreation(VM&, WebAssemblyModulePrototype*);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> WebAssemblyModuleConstructor(VM&, Structure*);
</span><span class="lines">@@ -54,8 +52,6 @@
</span><span class="cx"> static ConstructType getConstructData(JSCell*, ConstructData&);
</span><span class="cx"> static CallType getCallData(JSCell*, CallData&);
</span><span class="cx"> static void visitChildren(JSCell*, SlotVisitor&);
</span><del>-
- WriteBarrier<Structure> m_ModuleStructure;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyRuntimeErrorConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -61,10 +61,10 @@
</span><span class="cx"> return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, "WebAssembly.RuntimeError"));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-WebAssemblyRuntimeErrorConstructor* WebAssemblyRuntimeErrorConstructor::create(VM& vm, Structure* structure, WebAssemblyRuntimeErrorPrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyRuntimeErrorConstructor* WebAssemblyRuntimeErrorConstructor::create(VM& vm, Structure* structure, WebAssemblyRuntimeErrorPrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx"> auto* constructor = new (NotNull, allocateCell<WebAssemblyRuntimeErrorConstructor>(vm.heap)) WebAssemblyRuntimeErrorConstructor(vm, structure);
</span><del>- constructor->finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+ constructor->finishCreation(vm, thisPrototype);
</ins><span class="cx"> return constructor;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx"> return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebAssemblyRuntimeErrorConstructor::finishCreation(VM& vm, WebAssemblyRuntimeErrorPrototype* prototype, Structure*)
</del><ins>+void WebAssemblyRuntimeErrorConstructor::finishCreation(VM& vm, WebAssemblyRuntimeErrorPrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx"> Base::finishCreation(vm, ASCIILiteral("RuntimeError"));
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, ReadOnly | DontEnum | DontDelete);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyRuntimeErrorConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,13 +39,13 @@
</span><span class="cx"> typedef InternalFunction Base;
</span><span class="cx"> static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx">
</span><del>- static WebAssemblyRuntimeErrorConstructor* create(VM&, Structure*, WebAssemblyRuntimeErrorPrototype*, Structure*);
</del><ins>+ static WebAssemblyRuntimeErrorConstructor* create(VM&, Structure*, WebAssemblyRuntimeErrorPrototype*);
</ins><span class="cx"> static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
</span><span class="cx">
</span><span class="cx"> DECLARE_INFO;
</span><span class="cx">
</span><span class="cx"> protected:
</span><del>- void finishCreation(VM&, WebAssemblyRuntimeErrorPrototype*, Structure*);
</del><ins>+ void finishCreation(VM&, WebAssemblyRuntimeErrorPrototype*);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> WebAssemblyRuntimeErrorConstructor(VM&, Structure*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyTableConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -57,10 +57,10 @@
</span><span class="cx"> return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(state, scope, "WebAssembly.Table"));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-WebAssemblyTableConstructor* WebAssemblyTableConstructor::create(VM& vm, Structure* structure, WebAssemblyTablePrototype* thisPrototype, Structure* thisStructure)
</del><ins>+WebAssemblyTableConstructor* WebAssemblyTableConstructor::create(VM& vm, Structure* structure, WebAssemblyTablePrototype* thisPrototype)
</ins><span class="cx"> {
</span><span class="cx"> auto* constructor = new (NotNull, allocateCell<WebAssemblyTableConstructor>(vm.heap)) WebAssemblyTableConstructor(vm, structure);
</span><del>- constructor->finishCreation(vm, thisPrototype, thisStructure);
</del><ins>+ constructor->finishCreation(vm, thisPrototype);
</ins><span class="cx"> return constructor;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -69,12 +69,11 @@
</span><span class="cx"> return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebAssemblyTableConstructor::finishCreation(VM& vm, WebAssemblyTablePrototype* prototype, Structure* structure)
</del><ins>+void WebAssemblyTableConstructor::finishCreation(VM& vm, WebAssemblyTablePrototype* prototype)
</ins><span class="cx"> {
</span><span class="cx"> Base::finishCreation(vm, ASCIILiteral("Table"));
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
</span><del>- m_TableStructure.set(vm, this, structure);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebAssemblyTableConstructor::WebAssemblyTableConstructor(VM& vm, Structure* structure)
</span><span class="lines">@@ -99,7 +98,6 @@
</span><span class="cx"> auto* thisObject = jsCast<WebAssemblyTableConstructor*>(cell);
</span><span class="cx"> ASSERT_GC_OBJECT_INHERITS(thisObject, info());
</span><span class="cx"> Base::visitChildren(thisObject, visitor);
</span><del>- visitor.append(&thisObject->m_TableStructure);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyTableConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h (207824 => 207825)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h        2016-10-25 17:12:20 UTC (rev 207824)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h        2016-10-25 17:23:53 UTC (rev 207825)
</span><span class="lines">@@ -39,15 +39,13 @@
</span><span class="cx"> typedef InternalFunction Base;
</span><span class="cx"> static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
</span><span class="cx">
</span><del>- static WebAssemblyTableConstructor* create(VM&, Structure*, WebAssemblyTablePrototype*, Structure*);
</del><ins>+ static WebAssemblyTableConstructor* create(VM&, Structure*, WebAssemblyTablePrototype*);
</ins><span class="cx"> static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
</span><span class="cx">
</span><span class="cx"> DECLARE_INFO;
</span><span class="cx">
</span><del>- Structure* TableStructure() const { return m_TableStructure.get(); }
-
</del><span class="cx"> protected:
</span><del>- void finishCreation(VM&, WebAssemblyTablePrototype*, Structure*);
</del><ins>+ void finishCreation(VM&, WebAssemblyTablePrototype*);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> WebAssemblyTableConstructor(VM&, Structure*);
</span><span class="lines">@@ -54,8 +52,6 @@
</span><span class="cx"> static ConstructType getConstructData(JSCell*, ConstructData&);
</span><span class="cx"> static CallType getCallData(JSCell*, CallData&);
</span><span class="cx"> static void visitChildren(JSCell*, SlotVisitor&);
</span><del>-
- WriteBarrier<Structure> m_TableStructure;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre>
</div>
</div>
</body>
</html>