Title: [209850] trunk
Revision
209850
Author
[email protected]
Date
2016-12-14 19:30:44 -0800 (Wed, 14 Dec 2016)

Log Message

WebAssembly: Add various low hanging fruit that will allow us to run the LLVM torture tests in Wasm
https://bugs.webkit.org/show_bug.cgi?id=165883

Reviewed by Keith Miller.

JSTests:

* wasm/Builder.js:
(export.default.Builder.prototype._registerSectionBuilders.switch.case.string_appeared_here.this.section):
* wasm/Builder_WebAssemblyBinary.js:
(const.emitters.Export):
* wasm/js-api/table.js:
(assertBadBinary):
(assertBadTable):
(assert.truthy):
* wasm/js-api/test_memory.js:
(binaryShouldNotParse):
(test):
(test.testMemImportError):
(assert.truthy):
(assert): Deleted.

Source/_javascript_Core:

This patch implements some low hanging fruit:
- Exporting Table
- Exporting Memory
- Load16 with zero extension to both 32 and 64 bit values.
- Fixes Unreachable to emit code that will prevent B3 from having a validation error.

* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::addUnreachable):
(JSC::Wasm::sizeOfLoadOp):
(JSC::Wasm::B3IRGenerator::emitLoadOp):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser<Context>::parseExpression):
* wasm/WasmModuleParser.cpp:
(JSC::Wasm::ModuleParser::parseExport):
* wasm/WasmValidate.cpp:
(JSC::Wasm::Validate::addUnreachable):
* wasm/js/WebAssemblyInstanceConstructor.cpp:
(JSC::constructJSWebAssemblyInstance):
* wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::finishCreation):
(JSC::WebAssemblyModuleRecord::link):

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (209849 => 209850)


--- trunk/JSTests/ChangeLog	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/JSTests/ChangeLog	2016-12-15 03:30:44 UTC (rev 209850)
@@ -1,3 +1,25 @@
+2016-12-14  Saam Barati  <[email protected]>
+
+        WebAssembly: Add various low hanging fruit that will allow us to run the LLVM torture tests in Wasm
+        https://bugs.webkit.org/show_bug.cgi?id=165883
+
+        Reviewed by Keith Miller.
+
+        * wasm/Builder.js:
+        (export.default.Builder.prototype._registerSectionBuilders.switch.case.string_appeared_here.this.section):
+        * wasm/Builder_WebAssemblyBinary.js:
+        (const.emitters.Export):
+        * wasm/js-api/table.js:
+        (assertBadBinary):
+        (assertBadTable):
+        (assert.truthy):
+        * wasm/js-api/test_memory.js:
+        (binaryShouldNotParse):
+        (test):
+        (test.testMemImportError):
+        (assert.truthy):
+        (assert): Deleted.
+
 2016-12-14  Filip Pizlo  <[email protected]>
 
         DirectTailCall implementation needs to tell the shuffler what to put into the ArgumentCount explicitly

Modified: trunk/JSTests/wasm/Builder.js (209849 => 209850)


--- trunk/JSTests/wasm/Builder.js	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/JSTests/wasm/Builder.js	2016-12-15 03:30:44 UTC (rev 209850)
@@ -191,6 +191,22 @@
     }
 };
 
+const _exportMemoryContinuation = (builder, section, nextBuilder) => {
+    return (field, index) => {
+        assert.isNumber(index, `Memory exports only support number indices`);
+        section.data.push({field, kind: "Memory", index});
+        return nextBuilder;
+    }
+};
+
+const _exportTableContinuation = (builder, section, nextBuilder) => {
+    return (field, index) => {
+        assert.isNumber(index, `Table exports only support number indices`);
+        section.data.push({field, kind: "Table", index});
+        return nextBuilder;
+    }
+};
+
 const _importGlobalContinuation = (builder, section, nextBuilder) => {
     return () => {
         const globalBuilder = {
@@ -516,11 +532,11 @@
                     const s = this._addSection(section);
                     const exportBuilder = {
                         End: () => this,
-                        Table: () => { throw new Error(`Unimplemented: export table`); },
-                        Memory: () => { throw new Error(`Unimplemented: export memory`); },
                     };
                     exportBuilder.Global = _exportGlobalContinuation(this, s, exportBuilder);
                     exportBuilder.Function = _exportFunctionContinuation(this, s, exportBuilder);
+                    exportBuilder.Memory = _exportMemoryContinuation(this, s, exportBuilder);
+                    exportBuilder.Table = _exportTableContinuation(this, s, exportBuilder);
                     return exportBuilder;
                 };
                 break;

Modified: trunk/JSTests/wasm/Builder_WebAssemblyBinary.js (209849 => 209850)


--- trunk/JSTests/wasm/Builder_WebAssemblyBinary.js	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/JSTests/wasm/Builder_WebAssemblyBinary.js	2016-12-15 03:30:44 UTC (rev 209850)
@@ -167,14 +167,13 @@
             put(bin, "string", entry.field);
             put(bin, "uint8", WASM.externalKindValue[entry.kind]);
             switch (entry.kind) {
-            default: throw new Error(`Implementation problem: unexpected kind ${entry.kind}`);
             case "Global":
             case "Function":
+            case "Memory":
+            case "Table":
                 put(bin, "varuint32", entry.index);
                 break;
-            case "Table": throw new Error(`Not yet implemented`);
-            case "Memory": throw new Error(`Not yet implemented`);
-
+            default: throw new Error(`Implementation problem: unexpected kind ${entry.kind}`);
             }
         }
     },

Modified: trunk/JSTests/wasm/js-api/table.js (209849 => 209850)


--- trunk/JSTests/wasm/js-api/table.js	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/JSTests/wasm/js-api/table.js	2016-12-15 03:30:44 UTC (rev 209850)
@@ -1,19 +1,13 @@
 import Builder from '../Builder.js';
 import * as assert from '../assert.js';
 
-const badTableString = "couldn't parse section Table";
-const badImportString = "couldn't parse section Import";
+const badTableString = "couldn't parse section Table: Indirect function table and other tables (evaluating 'new WebAssembly.Module(bin)')";
+const badImportString = "couldn't parse section Import: Import declarations (evaluating 'new WebAssembly.Module(bin)')";
+const badExportString = "couldn't parse section Export: Exports (evaluating 'new WebAssembly.Module(bin)')";
+
 function assertBadBinary(builder, str) {
     const bin = builder.WebAssembly().get();
-    let threw = false;
-    try {
-        new WebAssembly.Module(bin);
-    } catch(e) {
-        threw = true;
-        assert.truthy(e.toString().indexOf(str) !== -1);
-        assert.truthy(e instanceof WebAssembly.CompileError);
-    }
-    assert.truthy(threw);
+    assert.throws(() => new WebAssembly.Module(bin), WebAssembly.CompileError, str);
 }
 
 {
@@ -57,7 +51,7 @@
                 .CallIndirect(0, 0)
             .End()
         .End();
-    assertBadBinary(builder, "call_indirect is only valid when a table is defined or imported");
+    assertBadBinary(builder, "call_indirect is only valid when a table is defined or imported (evaluating 'new WebAssembly.Module(bin)')");
 }
 
 {
@@ -76,9 +70,38 @@
                 .CallIndirect(0, 1)
             .End()
         .End();
-    assertBadBinary(builder, "call_indirect 'reserved' varuint1 must be 0x0");
+    assertBadBinary(builder, "call_indirect 'reserved' varuint1 must be 0x0 (evaluating 'new WebAssembly.Module(bin)')");
 }
 
+{
+    // Can't export an undefined table
+    const builder = new Builder()
+        .Type().End()
+        .Function().End()
+        .Export()
+            .Table("foo", 0)
+        .End()
+        .Code()
+        .End();
+    assertBadBinary(builder, badExportString);
+}
+
+{
+    // Can't export a table at index 1.
+    const builder = new Builder()
+        .Type().End()
+        .Function().End()
+        .Table()
+            .Table({initial: 20, maximum: 30, element: "anyfunc"})
+        .End()
+        .Export()
+            .Table("foo", 1)
+        .End()
+        .Code()
+        .End();
+    assertBadBinary(builder, badExportString);
+}
+
 function assertBadTable(tableDescription) {
     const builder = new Builder()
         .Type().End()
@@ -228,3 +251,43 @@
     assertBadTable([]);
     assertBadTable(new WebAssembly.Memory({initial:1}));
 }
+
+{
+    const builder = new Builder()
+        .Type().End()
+        .Import()
+            .Table("imp", "table", {initial: 25, element: "anyfunc"})
+        .End()
+        .Function().End()
+        .Export()
+            .Table("table", 0)
+            .Table("table2", 0)
+        .End()
+        .Code().End();
+
+    const module = new WebAssembly.Module(builder.WebAssembly().get());
+    const table = new WebAssembly.Table({element: "anyfunc", initial: 25});
+    const instance = new WebAssembly.Instance(module, {imp: {table}});
+    assert.truthy(table === instance.exports.table);
+    assert.truthy(table === instance.exports.table2);
+}
+
+{
+    const builder = new Builder()
+        .Type().End()
+        .Function().End()
+        .Table()
+            .Table({initial: 20, maximum: 30, element: "anyfunc"})
+        .End()
+        .Export()
+            .Table("table", 0)
+            .Table("table2", 0)
+        .End()
+        .Code().End();
+
+    const module = new WebAssembly.Module(builder.WebAssembly().get());
+    const instance = new WebAssembly.Instance(module);
+    assert.eq(instance.exports.table, instance.exports.table2);
+    assert.eq(instance.exports.table.length, 20);
+    assert.truthy(instance.exports.table instanceof WebAssembly.Table);
+}

Modified: trunk/JSTests/wasm/js-api/test_memory.js (209849 => 209850)


--- trunk/JSTests/wasm/js-api/test_memory.js	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/JSTests/wasm/js-api/test_memory.js	2016-12-15 03:30:44 UTC (rev 209850)
@@ -1,12 +1,7 @@
 // FIXME: use the assert library: https://bugs.webkit.org/show_bug.cgi?id=165684
 import Builder from '../Builder.js';
+import * as assert from '../assert.js';
 
-function assert(b) {
-    if (!b) {
-        throw new Error("Bad assertion");
-    }
-}
-
 const pageSize = 64 * 1024;
 const maxPageCount = (2**32) / pageSize;
 
@@ -18,7 +13,7 @@
     } catch(e) {
         threw = true;
     }
-    assert(threw);
+    assert.truthy(threw);
 }
 
 {
@@ -102,29 +97,37 @@
 }
 
 {
-    let threw = false;
-    try {
-        new WebAssembly.Memory(20);
-    } catch(e) {
-        assert(e instanceof TypeError);
-        assert(e.message === "WebAssembly.Memory expects its first argument to be an object");
-        threw = true;
-    }
-    assert(threw);
+    // Can't export an undefined memory.
+    const builder = (new Builder())
+        .Type().End()
+        .Function().End()
+        .Export()
+            .Memory("memory", 0)
+        .End()
+        .Code()
+        .End();
+    binaryShouldNotParse(builder);
 }
 
 {
-    let threw = false;
-    try {
-        new WebAssembly.Memory({}, {});
-    } catch(e) {
-        assert(e instanceof TypeError);
-        assert(e.message === "WebAssembly.Memory expects exactly one argument");
-        threw = true;
-    }
-    assert(threw);
+    // Can't export a non-zero memory index.
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory("imp", "memory", {initial: 20}).End()
+        .Function().End()
+        .Export()
+            .Memory("memory", 1)
+        .End()
+        .Code()
+        .End();
+    binaryShouldNotParse(builder);
 }
 
+{
+    assert.throws(() => new WebAssembly.Memory(20), TypeError, "WebAssembly.Memory expects its first argument to be an object"); 
+    assert.throws(() => new WebAssembly.Memory({}, {}), TypeError,  "WebAssembly.Memory expects exactly one argument");
+}
+
 function test(f) {
     noInline(f);
     for (let i = 0; i < 2; i++) {
@@ -164,10 +167,10 @@
         let value = i + 1;
         let address = i * 4;
         let result = foo(value, address);
-        assert(result === value);
+        assert.truthy(result === value);
         let arrayBuffer = memory.buffer;
         let buffer = new Uint32Array(arrayBuffer);
-        assert(buffer[i] === value);
+        assert.truthy(buffer[i] === value);
     }
 });
 
@@ -204,10 +207,10 @@
         let address = i;
         let result = foo(value, address);
         let expectedValue = (value & ((2**8) - 1)); 
-        assert(result === expectedValue);
+        assert.truthy(result === expectedValue);
         let arrayBuffer = memory.buffer;
         let buffer = new Uint8Array(arrayBuffer);
-        assert(buffer[i] === expectedValue);
+        assert.truthy(buffer[i] === expectedValue);
     }
 });
 
@@ -241,14 +244,14 @@
     const bytes = memoryDescription.initial * pageSize;
     for (let i = 0; i < (bytes/4); i++) {
         let value = i + 1 + .0128213781289;
-        assert(value !== Math.fround(value));
+        assert.truthy(value !== Math.fround(value));
         let address = i * 4;
         let result = foo(value, address);
         let expectedValue = Math.fround(result);
-        assert(result === expectedValue);
+        assert.truthy(result === expectedValue);
         let arrayBuffer = memory.buffer;
         let buffer = new Float32Array(arrayBuffer);
-        assert(buffer[i] === expectedValue);
+        assert.truthy(buffer[i] === expectedValue);
     }
 });
 
@@ -285,10 +288,10 @@
         let address = i * 8;
         let result = foo(value, address);
         let expectedValue = result;
-        assert(result === expectedValue);
+        assert.truthy(result === expectedValue);
         let arrayBuffer = memory.buffer;
         let buffer = new Float64Array(arrayBuffer);
-        assert(buffer[i] === expectedValue);
+        assert.truthy(buffer[i] === expectedValue);
     }
 });
 
@@ -320,13 +323,13 @@
         try {
             new WebAssembly.Instance(module, instanceObj);
         } catch(e) {
-            assert(e instanceof TypeError);
+            assert.truthy(e instanceof TypeError);
             threw = true;
             if (expectedError) {
-                assert(e.message === expectedError);
+                assert.truthy(e.message === expectedError);
             }
         }
-        assert(threw);
+        assert.truthy(threw);
     }
 
     testMemImportError(20);
@@ -363,17 +366,7 @@
     const module = new WebAssembly.Module(bin);
 
     function testMemImportError(instanceObj, expectedError) {
-        let threw = false;
-        try {
-            new WebAssembly.Instance(module, instanceObj);
-        } catch(e) {
-            assert(e instanceof TypeError);
-            threw = true;
-            if (expectedError) {
-                assert(e.message === expectedError);
-            }
-        }
-        assert(threw);
+        assert.throws(() => new WebAssembly.Instance(module, instanceObj), TypeError, expectedError);
     }
 
     testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }, "Memory import provided an 'initial' that is too small");
@@ -383,3 +376,41 @@
     new WebAssembly.Instance(module, {imp: {memory: new WebAssembly.Memory({initial:20})}});
     new WebAssembly.Instance(module, {imp: {memory: new WebAssembly.Memory({initial:20, maximum:20})}});
 });
+
+{
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory("imp", "memory", {initial: 20}).End()
+        .Function().End()
+        .Export()
+            .Memory("memory", 0)
+            .Memory("memory2", 0)
+        .End()
+        .Code()
+        .End();
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory({initial: 20});
+    const instance = new WebAssembly.Instance(module, {imp: {memory}});
+    assert.truthy(memory === instance.exports.memory);
+    assert.truthy(memory === instance.exports.memory2);
+}
+
+{
+    const builder = (new Builder())
+        .Type().End()
+        .Function().End()
+        .Memory().InitialMaxPages(20, 25).End()
+        .Export()
+            .Memory("memory", 0)
+            .Memory("memory2", 0)
+        .End()
+        .Code()
+        .End();
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const instance = new WebAssembly.Instance(module);
+    assert.eq(instance.exports.memory, instance.exports.memory2);
+    assert.eq(instance.exports.memory.buffer.byteLength, 20 * pageSize);
+    assert.truthy(instance.exports.memory instanceof WebAssembly.Memory);
+}

Modified: trunk/Source/_javascript_Core/ChangeLog (209849 => 209850)


--- trunk/Source/_javascript_Core/ChangeLog	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-12-15 03:30:44 UTC (rev 209850)
@@ -1,3 +1,32 @@
+2016-12-14  Saam Barati  <[email protected]>
+
+        WebAssembly: Add various low hanging fruit that will allow us to run the LLVM torture tests in Wasm
+        https://bugs.webkit.org/show_bug.cgi?id=165883
+
+        Reviewed by Keith Miller.
+
+        This patch implements some low hanging fruit:
+        - Exporting Table
+        - Exporting Memory
+        - Load16 with zero extension to both 32 and 64 bit values.
+        - Fixes Unreachable to emit code that will prevent B3 from having a validation error.
+
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::B3IRGenerator::addUnreachable):
+        (JSC::Wasm::sizeOfLoadOp):
+        (JSC::Wasm::B3IRGenerator::emitLoadOp):
+        * wasm/WasmFunctionParser.h:
+        (JSC::Wasm::FunctionParser<Context>::parseExpression):
+        * wasm/WasmModuleParser.cpp:
+        (JSC::Wasm::ModuleParser::parseExport):
+        * wasm/WasmValidate.cpp:
+        (JSC::Wasm::Validate::addUnreachable):
+        * wasm/js/WebAssemblyInstanceConstructor.cpp:
+        (JSC::constructJSWebAssemblyInstance):
+        * wasm/js/WebAssemblyModuleRecord.cpp:
+        (JSC::WebAssemblyModuleRecord::finishCreation):
+        (JSC::WebAssemblyModuleRecord::link):
+
 2016-12-14  Yusuke Suzuki  <[email protected]>
 
         Update ModuleLoader code by using the latest builtin primitives

Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (209849 => 209850)


--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2016-12-15 03:30:44 UTC (rev 209850)
@@ -178,6 +178,7 @@
     // Calls
     bool WARN_UNUSED_RETURN addCall(uint32_t calleeIndex, const Signature*, Vector<ExpressionType>& args, ExpressionType& result);
     bool WARN_UNUSED_RETURN addCallIndirect(const Signature*, Vector<ExpressionType>& args, ExpressionType& result);
+    void addUnreachable();
 
     void dump(const Vector<ControlEntry>& controlStack, const ExpressionList& expressionStack);
 
@@ -326,6 +327,15 @@
     return true;
 }
 
+void B3IRGenerator::addUnreachable()
+{
+    B3::PatchpointValue* unreachable = m_currentBlock->appendNew<B3::PatchpointValue>(m_proc, B3::Void, Origin());
+    unreachable->setGenerator([=] (CCallHelpers& jit, const B3::StackmapGenerationParams&) {
+        jit.breakpoint();
+    });
+    unreachable->effects.terminal = true;
+}
+
 bool B3IRGenerator::setLocal(uint32_t index, ExpressionType value)
 {
     ASSERT(m_locals[index]);
@@ -367,6 +377,8 @@
         return 1;
     case LoadOpType::I32Load16S:
     case LoadOpType::I64Load16S:
+    case LoadOpType::I32Load16U:
+    case LoadOpType::I64Load16U:
         return 2;
     case LoadOpType::I32Load:
     case LoadOpType::I64Load32S:
@@ -376,9 +388,6 @@
     case LoadOpType::I64Load:
     case LoadOpType::F64Load:
         return 8;
-    case LoadOpType::I32Load16U:
-    case LoadOpType::I64Load16U:
-        break;
     }
     RELEASE_ASSERT_NOT_REACHED();
 }
@@ -438,11 +447,21 @@
         return m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Double, origin, pointer);
     }
 
-    // B3 doesn't support Load16Z yet.
-    case LoadOpType::I32Load16U:
-    case LoadOpType::I64Load16U:
-        break;
+    // FIXME: B3 doesn't support Load16Z yet. We should lower to that value when
+    // it's added. https://bugs.webkit.org/show_bug.cgi?id=165884
+    case LoadOpType::I32Load16U: {
+        Value* value = m_currentBlock->appendNew<MemoryValue>(m_proc, Load16S, origin, pointer, offset);
+        return m_currentBlock->appendNew<Value>(m_proc, BitAnd, Origin(), value,
+                m_currentBlock->appendNew<Const32Value>(m_proc, Origin(), 0x0000ffff));
     }
+    case LoadOpType::I64Load16U: {
+        Value* value = m_currentBlock->appendNew<MemoryValue>(m_proc, Load16S, origin, pointer, offset);
+        Value* partialResult = m_currentBlock->appendNew<Value>(m_proc, BitAnd, Origin(), value,
+                m_currentBlock->appendNew<Const32Value>(m_proc, Origin(), 0x0000ffff));
+
+        return m_currentBlock->appendNew<Value>(m_proc, ZExt32, Origin(), partialResult);
+    }
+    }
     RELEASE_ASSERT_NOT_REACHED();
 }
 

Modified: trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h (209849 => 209850)


--- trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h	2016-12-15 03:30:44 UTC (rev 209850)
@@ -566,6 +566,7 @@
     }
 
     case OpType::Unreachable: {
+        m_context.addUnreachable();
         m_unreachableBlocks = 1;
         return true;
     }

Modified: trunk/Source/_javascript_Core/wasm/WasmModuleParser.cpp (209849 => 209850)


--- trunk/Source/_javascript_Core/wasm/WasmModuleParser.cpp	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/Source/_javascript_Core/wasm/WasmModuleParser.cpp	2016-12-15 03:30:44 UTC (rev 209850)
@@ -511,11 +511,17 @@
             break;
         }
         case External::Table: {
-            // FIXME https://bugs.webkit.org/show_bug.cgi?id=165782
+            if (!m_hasTable)
+                return false;
+            if (exp.kindIndex != 0)
+                return false;
             break;
         }
         case External::Memory: {
-            // FIXME: https://bugs.webkit.org/show_bug.cgi?id=165671
+            if (!m_module->memory)
+                return false;
+            if (exp.kindIndex != 0)
+                return false;
             break;
         }
         case External::Global: {

Modified: trunk/Source/_javascript_Core/wasm/WasmValidate.cpp (209849 => 209850)


--- trunk/Source/_javascript_Core/wasm/WasmValidate.cpp	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/Source/_javascript_Core/wasm/WasmValidate.cpp	2016-12-15 03:30:44 UTC (rev 209850)
@@ -114,6 +114,8 @@
     bool WARN_UNUSED_RETURN endBlock(ControlEntry&, ExpressionList& expressionStack);
     bool WARN_UNUSED_RETURN addEndToUnreachable(ControlEntry&);
 
+    void addUnreachable() { }
+
     // Calls
     bool WARN_UNUSED_RETURN addCall(unsigned calleeIndex, const Signature*, const Vector<ExpressionType>& args, ExpressionType& result);
     bool WARN_UNUSED_RETURN addCallIndirect(const Signature*, const Vector<ExpressionType>& args, ExpressionType& result);

Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyInstanceConstructor.cpp (209849 => 209850)


--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyInstanceConstructor.cpp	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyInstanceConstructor.cpp	2016-12-15 03:30:44 UTC (rev 209850)
@@ -245,7 +245,7 @@
         if (!!moduleInformation.tableInformation && !hasTableImport) {
             RELEASE_ASSERT(!moduleInformation.tableInformation.isImport());
             // We create a Table when it's a Table definition.
-            JSWebAssemblyTable* table = JSWebAssemblyTable::create(exec, vm, exec->lexicalGlobalObject()->WebAssemblyMemoryStructure(),
+            JSWebAssemblyTable* table = JSWebAssemblyTable::create(exec, vm, exec->lexicalGlobalObject()->WebAssemblyTableStructure(),
                 moduleInformation.tableInformation.initial(), moduleInformation.tableInformation.maximum());
             // We should always be able to allocate a JSWebAssemblyTable we've defined.
             // If it's defined to be too large, we should have thrown a validation error.

Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleRecord.cpp (209849 => 209850)


--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleRecord.cpp	2016-12-15 02:31:37 UTC (rev 209849)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleRecord.cpp	2016-12-15 03:30:44 UTC (rev 209850)
@@ -70,27 +70,8 @@
 {
     Base::finishCreation(exec, vm);
     ASSERT(inherits(info()));
-    for (const auto& exp : moduleInformation.exports) {
-        switch (exp.kind) {
-        case Wasm::External::Function: {
-            addExportEntry(ExportEntry::createLocal(exp.field, exp.field));
-            break;
-        }
-        case Wasm::External::Table: {
-            // FIXME https://bugs.webkit.org/show_bug.cgi?id=165782
-            break;
-        }
-        case Wasm::External::Memory: {
-            // FIXME: https://bugs.webkit.org/show_bug.cgi?id=165671
-            break;
-        }
-        case Wasm::External::Global: {
-            // In the MVP, only immutable global variables can be exported.
-            addExportEntry(ExportEntry::createLocal(exp.field, exp.field));
-            break;
-        }
-        }
-    }
+    for (const auto& exp : moduleInformation.exports)
+        addExportEntry(ExportEntry::createLocal(exp.field, exp.field));
 }
 
 void WebAssemblyModuleRecord::visitChildren(JSCell* cell, SlotVisitor& visitor)
@@ -146,14 +127,21 @@
             break;
         }
         case Wasm::External::Table: {
-            // FIXME https://bugs.webkit.org/show_bug.cgi?id=165782
+            // This should be guaranteed by module verification.
+            RELEASE_ASSERT(instance->table()); 
+            ASSERT(exp.kindIndex == 0);
+
+            exportedValue = instance->table();
             break;
         }
         case Wasm::External::Memory: {
-            // FIXME: https://bugs.webkit.org/show_bug.cgi?id=165671
+            // This should be guaranteed by module verification.
+            RELEASE_ASSERT(instance->memory()); 
+            ASSERT(exp.kindIndex == 0);
+
+            exportedValue = instance->memory();
             break;
         }
-
         case Wasm::External::Global: {
             // Assert: the global is immutable by MVP validation constraint.
             const Wasm::Global& global = moduleInformation.globals[exp.kindIndex];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to