WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
patch
0001-wasm.json.patch (text/plain), 46.37 KB, created by
JF Bastien
on 2016-10-03 13:57:02 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
JF Bastien
Created:
2016-10-03 13:57:02 PDT
Size:
46.37 KB
patch
obsolete
>From e8b962ba9e5b15fd8e055c68a5a3511a721f1802 Mon Sep 17 00:00:00 2001 >From: JF Bastien <jfbastien@apple.com> >Date: Mon, 3 Oct 2016 11:07:18 -0700 >Subject: [PATCH] wasm.json > >--- > JSTests/ChangeLog | 12 ++ > JSTests/stress/wasm/generate-wasmops-header.js | 116 +++++++++++++ > JSTests/stress/wasm/wasm.json | 215 ++++++++++++++++++++++++ > Source/JavaScriptCore/ChangeLog | 13 ++ > Source/JavaScriptCore/wasm/WASMFunctionParser.h | 23 ++- > Source/JavaScriptCore/wasm/WASMOps.h | 107 +++++++++--- > 6 files changed, 456 insertions(+), 30 deletions(-) > create mode 100644 JSTests/stress/wasm/generate-wasmops-header.js > create mode 100644 JSTests/stress/wasm/wasm.json > >diff --git a/JSTests/ChangeLog b/JSTests/ChangeLog >index 99697e1..3febeac 100644 >--- a/JSTests/ChangeLog >+++ b/JSTests/ChangeLog >@@ -1,3 +1,15 @@ >+2016-10-03 JF Bastien <jfbastien@apple.com> >+ >+ Auto-generate WASMOps.h, share with testing JSON file >+ https://bugs.webkit.org/show_bug.cgi?id=162870 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * stress/wasm/to-c++.js: Added. Generates WASMOps.h, siilar to the current one but with more data. >+ (const.opcode_iterator): >+ (opcode_macroizer): >+ * stress/wasm/wasm.json: Added. Data from 0xC binary format version. >+ > 2016-10-01 Yusuke Suzuki <utatane.tea@gmail.com> > > [ES6] Align attributes of Generator related properties to spec >diff --git a/JSTests/stress/wasm/generate-wasmops-header.js b/JSTests/stress/wasm/generate-wasmops-header.js >new file mode 100644 >index 0000000..2399f56 >--- /dev/null >+++ b/JSTests/stress/wasm/generate-wasmops-header.js >@@ -0,0 +1,116 @@ >+// Use the JSON description of WebAssembly to generate the JavaScriptCore's WASMOps.h. >+ >+const jsonFile = 'wasm.json'; >+const wasm = JSON.parse(read(jsonFile)); >+const opcodes = wasm.opcode; >+ >+// Iterate through opcodes which match filter. >+const opcodeIterator = (filter) => { >+ return function*() { >+ for (let op in opcodes) >+ if (filter(opcodes[op])) >+ yield {name: op, opcode: opcodes[op]}; >+ }; >+}; >+ >+// WebAssembly opcode name to C++ name suitable for JSC. >+const toCpp = name => { >+ const camelCase = name.replace(/([^a-z0-9].)/g, c => c[1].toUpperCase()); >+ const CamelCase = camelCase.charAt(0).toUpperCase() + camelCase.slice(1); >+ return CamelCase; >+}; >+ >+const cppMacro = (wasmOpcode, value, b3Opcode) => " \\\n macro(" + toCpp(wasmOpcode) + ", 0x" + parseInt(value).toString(16) + ", " + b3Opcode + ")"; >+ >+function* opcodeMacroizer(filter) { >+ for (let op of opcodeIterator(filter)()) >+ yield cppMacro(op.name, op.opcode.value, op.opcode.b3op || "Oops"); >+} >+ >+const defines = [ >+ "#define FOR_EACH_WASM_SPECIAL_OP(macro)", >+ ...opcodeMacroizer(op => op.category === "special"), >+ "\n\n#define FOR_EACH_WASM_CONTROL_FLOW_OP(macro)", >+ ...opcodeMacroizer(op => op.category === "control"), >+ "\n\n#define FOR_EACH_WASM_UNARY_OP(macro)", >+ ...opcodeMacroizer(op => op.category === "arithmetic" && op.parameter.length === 1), >+ "\n\n#define FOR_EACH_WASM_BINARY_OP(macro)", >+ ...opcodeMacroizer(op => (op.category === "arithmetic" || op.category === "comparison") && op.parameter.length === 2), >+ "\n\n"].join(""); >+ >+const template = `/* >+ * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. \`\`AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+// This file is auto-generated using ${jsonFile}. >+ >+#pragma once >+ >+#if ENABLE(WEBASSEMBLY) >+ >+namespace JSC { namespace WASM { >+ >+${defines} >+ >+#define FOR_EACH_WASM_OP(macro) \\ >+ FOR_EACH_WASM_SPECIAL_OP(macro) \\ >+ FOR_EACH_WASM_CONTROL_FLOW_OP(macro) \\ >+ FOR_EACH_WASM_UNARY_OP(macro) \\ >+ FOR_EACH_WASM_BINARY_OP(macro) >+ >+#define CREATE_ENUM_VALUE(name, id, b3op) name = id, >+ >+enum OpType : uint8_t { >+ FOR_EACH_WASM_OP(CREATE_ENUM_VALUE) >+}; >+ >+enum class BinaryOpType : uint8_t { >+ FOR_EACH_WASM_BINARY_OP(CREATE_ENUM_VALUE) >+}; >+ >+enum class UnaryOpType : uint8_t { >+ FOR_EACH_WASM_UNARY_OP(CREATE_ENUM_VALUE) >+}; >+ >+#undef CREATE_ENUM_VALUE >+ >+inline bool isControlOp(OpType op) >+{ >+ switch (op) { >+#define CREATE_CASE(name, id, b3op) case OpType::name: >+ FOR_EACH_WASM_CONTROL_FLOW_OP(CREATE_CASE) >+ return true; >+#undef CREATE_CASE >+ default: >+ break; >+ } >+ return false; >+} >+ >+} } // namespace JSC::WASM >+ >+#endif // ENABLE(WEBASSEMBLY) >+`; >+ >+print(template); >diff --git a/JSTests/stress/wasm/wasm.json b/JSTests/stress/wasm/wasm.json >new file mode 100644 >index 0000000..ee1f2fb >--- /dev/null >+++ b/JSTests/stress/wasm/wasm.json >@@ -0,0 +1,215 @@ >+{ >+ "preamble": { >+ "magic number": { "type": "uint32", "value": 1836278016, "description": "NULL character followed by 'asm'" }, >+ "version": { "type": "uint32", "value": 12, "description": "Version number, will be reset to 1 for MVP" } >+ }, >+ "value_type" : { >+ "i32": { "type": "uint8", "value": 1 }, >+ "i64": { "type": "uint8", "value": 2 }, >+ "f32": { "type": "uint8", "value": 3 }, >+ "f64": { "type": "uint8", "value": 4 } >+ }, >+ "inline_signature_type" : { >+ "void": { "type": "uint8", "value": 0 }, >+ "i32": { "type": "uint8", "value": 1 }, >+ "i64": { "type": "uint8", "value": 2 }, >+ "f32": { "type": "uint8", "value": 3 }, >+ "f64": { "type": "uint8", "value": 4 } >+ }, >+ "external_kind": { >+ "Function": { "type": "uint8", "value": 0 }, >+ "Table": { "type": "uint8", "value": 1 }, >+ "Memory": { "type": "uint8", "value": 2 }, >+ "Global": { "type": "uint8", "value": 3 } >+ }, >+ "section" : { >+ "Type": { "type": "varuint7", "value": 1, "description": "Function signature declarations" }, >+ "Import": { "type": "varuint7", "value": 2, "description": "Import declarations" }, >+ "Function": { "type": "varuint7", "value": 3, "description": "Function declarations" }, >+ "Table": { "type": "varuint7", "value": 4, "description": "Indirect function table and other tables" }, >+ "Memory": { "type": "varuint7", "value": 5, "description": "Memory attributes" }, >+ "Global": { "type": "varuint7", "value": 6, "description": "Global declarations" }, >+ "Export": { "type": "varuint7", "value": 7, "description": "Exports" }, >+ "Start": { "type": "varuint7", "value": 8, "description": "Start function declaration" }, >+ "Element": { "type": "varuint7", "value": 9, "description": "Elements section" }, >+ "Code": { "type": "varuint7", "value": 10, "description": "Function bodies (code)" }, >+ "Data": { "type": "varuint7", "value": 11, "description": "Data segments" } >+ }, >+ "opcode": { >+ "unreachable": { "category": "control", "value": 0, "return": [], "parameter": [], "immediate": [], "description": "trap immediately" }, >+ "block": { "category": "control", "value": 1, "return": ["any*"], "parameter": [], "immediate": [{"name": "sig", "type": "inline_signature_type"}], "description": "begin a sequence of expressions, yielding 0 or 1 values" }, >+ "loop": { "category": "control", "value": 2, "return": ["any*"], "parameter": [], "immediate": [{"name": "sig", "type": "inline_signature_type"}], "description": "begin a block which can also form control flow loops" }, >+ "if": { "category": "control", "value": 3, "return": ["any*"], "parameter": ["bool"], "immediate": [{"name": "sig", "type": "inline_signature_type"}], "description": "begin if expression" }, >+ "else": { "category": "control", "value": 4, "return": ["any*"], "parameter": [], "immediate": [], "description": "begin else expression of if" }, >+ "select": { "category": "control", "value": 5, "return": ["any"], "parameter": ["any", "any", "bool"], "immediate": [], "description": "select one of two values based on condition" }, >+ "br": { "category": "control", "value": 6, "return": [], "parameter": [], "immediate": [{"name": "relative_depth", "type": "varuint32"}], "description": "break that targets an outer nested block" }, >+ "br_if": { "category": "control", "value": 7, "return": [], "parameter": [], "immediate": [{"name": "relative_depth", "type": "varuint32"}], "description": "conditional break that targets an outer nested block" }, >+ "br_table": { "category": "control", "value": 8, "return": [], "parameter": [], "immediate": [{"name": "target_count", "type": "varuint32", "description": "number of entries in the target_table"}, >+ {"name": "target_table", "type": "varuint32*", "description": "target entries that indicate an outer block or loop to which to break"}, >+ {"name": "default_target", "type": "varuint32", "description": "an outer block or loop to which to break in the default case"}], >+ "description": "branch table control flow construct" }, >+ "return": { "category": "control", "value": 9, "return": [], "parameter": [], "immediate": [], "description": "return zero or one value from this function" }, >+ "drop": { "category": "control", "value": 11, "return": [], "parameter": ["any"], "immediate": [], "description": "ignore value" }, >+ "nop": { "category": "control", "value": 10, "return": [], "parameter": [], "immediate": [], "description": "no operation" }, >+ "end": { "category": "control", "value": 15, "return": [], "parameter": [], "immediate": [], "description": "end a block, loop, or if" }, >+ "i32.const": { "category": "special", "value": 16, "return": ["i32"], "parameter": [], "immediate": [{"name": "value", "type": "varint32"}], "description": "a constant value interpreted as i32" }, >+ "i64.const": { "category": "special", "value": 17, "return": ["i64"], "parameter": [], "immediate": [{"name": "value", "type": "varint64"}], "description": "a constant value interpreted as i64" }, >+ "f64.const": { "category": "special", "value": 18, "return": ["f32"], "parameter": [], "immediate": [{"name": "value", "type": "uint64"}], "description": "a constant value interpreted as f64" }, >+ "f32.const": { "category": "special", "value": 19, "return": ["f64"], "parameter": [], "immediate": [{"name": "value", "type": "uint32"}], "description": "a constant value interpreted as f32" }, >+ "get_local": { "category": "special", "value": 20, "return": ["any"], "parameter": [], "immediate": [{"name": "local_index", "type": "varuint32"}], "description": "read a local variable or parameter" }, >+ "set_local": { "category": "special", "value": 21, "return": ["any"], "parameter": [], "immediate": [{"name": "local_index", "type": "varuint32"}], "description": "write a local variable or parameter" }, >+ "tee_local": { "category": "special", "value": 25, "return": ["any"], "parameter": ["any"], "immediate": [{"name": "local_index", "type": "varuint32"}], "description": "write a local variable or parameter and return the same value" }, >+ "get_global": { "category": "special", "value": 187, "return": ["any"], "parameter": [], "immediate": [{"name": "global_index", "type": "varuint32"}], "description": "read a global variable" }, >+ "set_global": { "category": "special", "value": 188, "return": ["any"], "parameter": [], "immediate": [{"name": "global_index", "type": "varuint32"}], "description": "write a global variable" }, >+ "call": { "category": "call", "value": 22, "return": ["any"], "parameter": ["any*"], "immediate": [{"name": "function_index", "type": "varuint32"}], "description": "call a function by its index" }, >+ "call_indirect": { "category": "call", "value": 23, "return": ["any"], "parameter": ["any*"], "immediate": [{"name": "type_index", "type": "varuint32"}], "description": "call a function indirect with an expected signature" }, >+ "i32.load8_s": { "category": "memory", "value": 32, "return": ["i32"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i32.load8_u": { "category": "memory", "value": 33, "return": ["i32"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i32.load16_s": { "category": "memory", "value": 34, "return": ["i32"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i32.load16_u": { "category": "memory", "value": 35, "return": ["i32"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i64.load8_s": { "category": "memory", "value": 36, "return": ["i64"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i64.load8_u": { "category": "memory", "value": 37, "return": ["i64"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i64.load16_s": { "category": "memory", "value": 38, "return": ["i64"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i64.load16_u": { "category": "memory", "value": 39, "return": ["i64"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i64.load32_s": { "category": "memory", "value": 40, "return": ["i64"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i64.load32_u": { "category": "memory", "value": 41, "return": ["i64"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i32.load": { "category": "memory", "value": 42, "return": ["i32"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i64.load": { "category": "memory", "value": 43, "return": ["i64"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "f32.load": { "category": "memory", "value": 44, "return": ["f32"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "f64.load": { "category": "memory", "value": 45, "return": ["f64"], "parameter": ["addr"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "load from memory" }, >+ "i32.store8": { "category": "memory", "value": 46, "return": [], "parameter": ["addr", "i32"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "store to memory" }, >+ "i32.store16": { "category": "memory", "value": 47, "return": [], "parameter": ["addr", "i32"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "store to memory" }, >+ "i64.store8": { "category": "memory", "value": 48, "return": [], "parameter": ["addr", "i64"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "store to memory" }, >+ "i64.store16": { "category": "memory", "value": 49, "return": [], "parameter": ["addr", "i64"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "store to memory" }, >+ "i64.store32": { "category": "memory", "value": 50, "return": [], "parameter": ["addr", "i64"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "store to memory" }, >+ "i32.store": { "category": "memory", "value": 51, "return": [], "parameter": ["addr", "i32"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "store to memory" }, >+ "i64.store": { "category": "memory", "value": 52, "return": [], "parameter": ["addr", "i64"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "store to memory" }, >+ "f32.store": { "category": "memory", "value": 53, "return": [], "parameter": ["addr", "f32"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "store to memory" }, >+ "f64.store": { "category": "memory", "value": 54, "return": [], "parameter": ["addr", "f64"], "immediate": [{"name": "flags", "type": "varuint32"}, {"name": "offset", "type": "varuint32"}], "description": "store to memory" }, >+ "current_memory": { "category": "operation", "value": 59, "return": ["size"], "parameter": [], "immediate": [], "description": "query the size of memory" }, >+ "grow_memory": { "category": "operation", "value": 57, "return": ["size"], "parameter": ["size"], "immediate": [], "description": "grow the size of memory" }, >+ "i32.add": { "category": "arithmetic", "value": 64, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "Add" }, >+ "i32.sub": { "category": "arithmetic", "value": 65, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "Sub" }, >+ "i32.mul": { "category": "arithmetic", "value": 66, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "Mul" }, >+ "i32.div_s": { "category": "arithmetic", "value": 67, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "Div" }, >+ "i32.div_u": { "category": "arithmetic", "value": 68, "return": ["i32"], "parameter": ["i32", "i32"] }, >+ "i32.rem_s": { "category": "arithmetic", "value": 69, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "Mod" }, >+ "i32.rem_u": { "category": "arithmetic", "value": 70, "return": ["i32"], "parameter": ["i32", "i32"] }, >+ "i32.and": { "category": "arithmetic", "value": 71, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "BitAnd" }, >+ "i32.or": { "category": "arithmetic", "value": 72, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "BitOr" }, >+ "i32.xor": { "category": "arithmetic", "value": 73, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "BitXor" }, >+ "i32.shl": { "category": "arithmetic", "value": 74, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "Shl" }, >+ "i32.shr_u": { "category": "arithmetic", "value": 75, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "SShr" }, >+ "i32.shr_s": { "category": "arithmetic", "value": 76, "return": ["i32"], "parameter": ["i32", "i32"], "b3op": "ZShr" }, >+ "i32.rotr": { "category": "arithmetic", "value": 182, "return": ["i32"], "parameter": ["i32", "i32"] }, >+ "i32.rotl": { "category": "arithmetic", "value": 183, "return": ["i32"], "parameter": ["i32", "i32"] }, >+ "i32.eq": { "category": "comparison", "value": 77, "return": ["bool"], "parameter": ["i32", "i32"], "b3op": "Equal" }, >+ "i32.ne": { "category": "comparison", "value": 78, "return": ["bool"], "parameter": ["i32", "i32"], "b3op": "NotEqual" }, >+ "i32.lt_s": { "category": "comparison", "value": 79, "return": ["bool"], "parameter": ["i32", "i32"], "b3op": "LessThan" }, >+ "i32.le_s": { "category": "comparison", "value": 80, "return": ["bool"], "parameter": ["i32", "i32"], "b3op": "LessEqual" }, >+ "i32.lt_u": { "category": "comparison", "value": 81, "return": ["bool"], "parameter": ["i32", "i32"], "b3op": "Below" }, >+ "i32.le_u": { "category": "comparison", "value": 82, "return": ["bool"], "parameter": ["i32", "i32"], "b3op": "BelowEqual" }, >+ "i32.gt_s": { "category": "comparison", "value": 83, "return": ["bool"], "parameter": ["i32", "i32"], "b3op": "GreaterThan" }, >+ "i32.ge_s": { "category": "comparison", "value": 84, "return": ["bool"], "parameter": ["i32", "i32"], "b3op": "GreaterEqual" }, >+ "i32.gt_u": { "category": "comparison", "value": 85, "return": ["bool"], "parameter": ["i32", "i32"], "b3op": "Above" }, >+ "i32.ge_u": { "category": "comparison", "value": 86, "return": ["bool"], "parameter": ["i32", "i32"], "b3op": "AboveEqual" }, >+ "i32.clz": { "category": "arithmetic", "value": 87, "return": ["i32"], "parameter": ["i32"], "b3op": "Clz" }, >+ "i32.ctz": { "category": "arithmetic", "value": 88, "return": ["i32"], "parameter": ["i32"] }, >+ "i32.popcnt": { "category": "arithmetic", "value": 89, "return": ["i32"], "parameter": ["i32"] }, >+ "i32.eqz": { "category": "comparison", "value": 90, "return": ["bool"], "parameter": ["i32"] }, >+ "i64.add": { "category": "arithmetic", "value": 91, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "Add" }, >+ "i64.sub": { "category": "arithmetic", "value": 92, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "Sub" }, >+ "i64.mul": { "category": "arithmetic", "value": 93, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "Mul" }, >+ "i64.div_s": { "category": "arithmetic", "value": 94, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "Div" }, >+ "i64.div_u": { "category": "arithmetic", "value": 95, "return": ["i64"], "parameter": ["i64", "i64"] }, >+ "i64.rem_s": { "category": "arithmetic", "value": 96, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "Mod" }, >+ "i64.rem_u": { "category": "arithmetic", "value": 97, "return": ["i64"], "parameter": ["i64", "i64"] }, >+ "i64.and": { "category": "arithmetic", "value": 98, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "BitAnd" }, >+ "i64.or": { "category": "arithmetic", "value": 99, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "BitOr" }, >+ "i64.xor": { "category": "arithmetic", "value": 100, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "BitXor" }, >+ "i64.shl": { "category": "arithmetic", "value": 101, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "Shl" }, >+ "i64.shr_u": { "category": "arithmetic", "value": 102, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "SShr" }, >+ "i64.shr_s": { "category": "arithmetic", "value": 103, "return": ["i64"], "parameter": ["i64", "i64"], "b3op": "ZShr" }, >+ "i64.rotr": { "category": "arithmetic", "value": 184, "return": ["i64"], "parameter": ["i64", "i64"] }, >+ "i64.rotl": { "category": "arithmetic", "value": 185, "return": ["i64"], "parameter": ["i64", "i64"] }, >+ "i64.eq": { "category": "comparison", "value": 104, "return": ["bool"], "parameter": ["i64", "i64"], "b3op": "Equal" }, >+ "i64.ne": { "category": "comparison", "value": 105, "return": ["bool"], "parameter": ["i64", "i64"], "b3op": "NotEqual" }, >+ "i64.lt_s": { "category": "comparison", "value": 106, "return": ["bool"], "parameter": ["i64", "i64"], "b3op": "LessThan" }, >+ "i64.le_s": { "category": "comparison", "value": 107, "return": ["bool"], "parameter": ["i64", "i64"], "b3op": "LessEqual" }, >+ "i64.lt_u": { "category": "comparison", "value": 108, "return": ["bool"], "parameter": ["i64", "i64"], "b3op": "Below" }, >+ "i64.le_u": { "category": "comparison", "value": 109, "return": ["bool"], "parameter": ["i64", "i64"], "b3op": "BelowEqual" }, >+ "i64.gt_s": { "category": "comparison", "value": 110, "return": ["bool"], "parameter": ["i64", "i64"], "b3op": "GreaterThan" }, >+ "i64.ge_s": { "category": "comparison", "value": 111, "return": ["bool"], "parameter": ["i64", "i64"], "b3op": "GreaterEqual" }, >+ "i64.gt_u": { "category": "comparison", "value": 112, "return": ["bool"], "parameter": ["i64", "i64"], "b3op": "Above" }, >+ "i64.ge_u": { "category": "comparison", "value": 113, "return": ["bool"], "parameter": ["i64", "i64"], "b3op": "AboveEqual" }, >+ "i64.clz": { "category": "arithmetic", "value": 114, "return": ["i64"], "parameter": ["i64"], "b3op": "Clz" }, >+ "i64.ctz": { "category": "arithmetic", "value": 115, "return": ["i64"], "parameter": ["i64"] }, >+ "i64.popcnt": { "category": "arithmetic", "value": 116, "return": ["i64"], "parameter": ["i64"] }, >+ "i64.eqz": { "category": "comparison", "value": 186, "return": ["bool"], "parameter": ["i64"] }, >+ "f32.add": { "category": "arithmetic", "value": 117, "return": ["f32"], "parameter": ["f32", "f32"] }, >+ "f32.sub": { "category": "arithmetic", "value": 118, "return": ["f32"], "parameter": ["f32", "f32"] }, >+ "f32.mul": { "category": "arithmetic", "value": 119, "return": ["f32"], "parameter": ["f32", "f32"] }, >+ "f32.div": { "category": "arithmetic", "value": 120, "return": ["f32"], "parameter": ["f32", "f32"] }, >+ "f32.min": { "category": "arithmetic", "value": 121, "return": ["f32"], "parameter": ["f32", "f32"] }, >+ "f32.max": { "category": "arithmetic", "value": 122, "return": ["f32"], "parameter": ["f32", "f32"] }, >+ "f32.abs": { "category": "arithmetic", "value": 123, "return": ["f32"], "parameter": ["f32"] }, >+ "f32.neg": { "category": "arithmetic", "value": 124, "return": ["f32"], "parameter": ["f32"] }, >+ "f32.copysign": { "category": "arithmetic", "value": 125, "return": ["f32"], "parameter": ["f32"] }, >+ "f32.ceil": { "category": "arithmetic", "value": 126, "return": ["f32"], "parameter": ["f32"] }, >+ "f32.floor": { "category": "arithmetic", "value": 127, "return": ["f32"], "parameter": ["f32"] }, >+ "f32.trunc": { "category": "arithmetic", "value": 128, "return": ["f32"], "parameter": ["f32"] }, >+ "f32.nearest": { "category": "arithmetic", "value": 129, "return": ["f32"], "parameter": ["f32"] }, >+ "f32.sqrt": { "category": "arithmetic", "value": 130, "return": ["f32"], "parameter": ["f32"] }, >+ "f32.eq": { "category": "comparison", "value": 131, "return": ["bool"], "parameter": ["f32", "f32"] }, >+ "f32.ne": { "category": "comparison", "value": 132, "return": ["bool"], "parameter": ["f32", "f32"] }, >+ "f32.lt": { "category": "comparison", "value": 133, "return": ["bool"], "parameter": ["f32", "f32"] }, >+ "f32.le": { "category": "comparison", "value": 134, "return": ["bool"], "parameter": ["f32", "f32"] }, >+ "f32.gt": { "category": "comparison", "value": 135, "return": ["bool"], "parameter": ["f32", "f32"] }, >+ "f32.ge": { "category": "comparison", "value": 136, "return": ["bool"], "parameter": ["f32", "f32"] }, >+ "f64.add": { "category": "arithmetic", "value": 137, "return": ["f64"], "parameter": ["f64", "f64"] }, >+ "f64.sub": { "category": "arithmetic", "value": 138, "return": ["f64"], "parameter": ["f64", "f64"] }, >+ "f64.mul": { "category": "arithmetic", "value": 139, "return": ["f64"], "parameter": ["f64", "f64"] }, >+ "f64.div": { "category": "arithmetic", "value": 140, "return": ["f64"], "parameter": ["f64", "f64"] }, >+ "f64.min": { "category": "arithmetic", "value": 141, "return": ["f64"], "parameter": ["f64", "f64"] }, >+ "f64.max": { "category": "arithmetic", "value": 142, "return": ["f64"], "parameter": ["f64", "f64"] }, >+ "f64.abs": { "category": "arithmetic", "value": 143, "return": ["f64"], "parameter": ["f64"] }, >+ "f64.neg": { "category": "arithmetic", "value": 144, "return": ["f64"], "parameter": ["f64"] }, >+ "f64.copysign": { "category": "arithmetic", "value": 145, "return": ["f64"], "parameter": ["f64"] }, >+ "f64.ceil": { "category": "arithmetic", "value": 146, "return": ["f64"], "parameter": ["f64"] }, >+ "f64.floor": { "category": "arithmetic", "value": 147, "return": ["f64"], "parameter": ["f64"] }, >+ "f64.trunc": { "category": "arithmetic", "value": 148, "return": ["f64"], "parameter": ["f64"] }, >+ "f64.nearest": { "category": "arithmetic", "value": 149, "return": ["f64"], "parameter": ["f64"] }, >+ "f64.sqrt": { "category": "arithmetic", "value": 150, "return": ["f64"], "parameter": ["f64"] }, >+ "f64.eq": { "category": "comparison", "value": 151, "return": ["bool"], "parameter": ["f64", "f64"] }, >+ "f64.ne": { "category": "comparison", "value": 152, "return": ["bool"], "parameter": ["f64", "f64"] }, >+ "f64.lt": { "category": "comparison", "value": 153, "return": ["bool"], "parameter": ["f64", "f64"] }, >+ "f64.le": { "category": "comparison", "value": 154, "return": ["bool"], "parameter": ["f64", "f64"] }, >+ "f64.gt": { "category": "comparison", "value": 155, "return": ["bool"], "parameter": ["f64", "f64"] }, >+ "f64.ge": { "category": "comparison", "value": 156, "return": ["bool"], "parameter": ["f64", "f64"] }, >+ "i32.trunc_s/f32": { "category": "conversion", "value": 157, "return": ["i32"], "parameter": ["f32"] }, >+ "i32.trunc_s/f64": { "category": "conversion", "value": 158, "return": ["i32"], "parameter": ["f64"] }, >+ "i32.trunc_u/f32": { "category": "conversion", "value": 159, "return": ["i32"], "parameter": ["f32"] }, >+ "i32.trunc_u/f64": { "category": "conversion", "value": 160, "return": ["i32"], "parameter": ["f64"] }, >+ "i32.wrap/i64": { "category": "conversion", "value": 161, "return": ["i32"], "parameter": ["i64"] }, >+ "i64.trunc_s/f32": { "category": "conversion", "value": 162, "return": ["i64"], "parameter": ["f32"] }, >+ "i64.trunc_s/f64": { "category": "conversion", "value": 163, "return": ["i64"], "parameter": ["f64"] }, >+ "i64.trunc_u/f32": { "category": "conversion", "value": 164, "return": ["i64"], "parameter": ["f32"] }, >+ "i64.trunc_u/f64": { "category": "conversion", "value": 165, "return": ["i64"], "parameter": ["f64"] }, >+ "i64.extend_s/i32": { "category": "conversion", "value": 166, "return": ["i64"], "parameter": ["i32"] }, >+ "i64.extend_u/i32": { "category": "conversion", "value": 167, "return": ["i64"], "parameter": ["i32"] }, >+ "f32.convert_s/i32": { "category": "conversion", "value": 168, "return": ["f32"], "parameter": ["i32"] }, >+ "f32.convert_u/i32": { "category": "conversion", "value": 169, "return": ["f32"], "parameter": ["i32"] }, >+ "f32.convert_s/i64": { "category": "conversion", "value": 170, "return": ["f32"], "parameter": ["i64"] }, >+ "f32.convert_u/i64": { "category": "conversion", "value": 171, "return": ["f32"], "parameter": ["i64"] }, >+ "f32.demote/f64": { "category": "conversion", "value": 172, "return": ["f32"], "parameter": ["f64"] }, >+ "f32.reinterpret/i32": { "category": "conversion", "value": 173, "return": ["f32"], "parameter": ["i32"] }, >+ "f64.convert_s/i32": { "category": "conversion", "value": 174, "return": ["f64"], "parameter": ["i32"] }, >+ "f64.convert_u/i32": { "category": "conversion", "value": 175, "return": ["f64"], "parameter": ["i32"] }, >+ "f64.convert_s/i64": { "category": "conversion", "value": 176, "return": ["f64"], "parameter": ["i64"] }, >+ "f64.convert_u/i64": { "category": "conversion", "value": 177, "return": ["f64"], "parameter": ["i64"] }, >+ "f64.promote/f32": { "category": "conversion", "value": 178, "return": ["f64"], "parameter": ["f32"] }, >+ "f64.reinterpret/i64": { "category": "conversion", "value": 179, "return": ["f64"], "parameter": ["i64"] }, >+ "i32.reinterpret/f32": { "category": "conversion", "value": 180, "return": ["i32"], "parameter": ["f32"] }, >+ "i64.reinterpret/f64": { "category": "conversion", "value": 181, "return": ["i64"], "parameter": ["f64"] } >+ } >+} >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 24320ba..6f47cb0 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,16 @@ >+2016-10-03 JF Bastien <jfbastien@apple.com> >+ >+ Auto-generate WASMOps.h, share with testing JSON file >+ https://bugs.webkit.org/show_bug.cgi?id=162870 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a few new opcodes, but keep this mostly as-is for now. I want >+ to generate smarter code but will do so in a later update to >+ reduce disruption. >+ >+ * wasm/WASMOps.h: auto-generated from ./JSTests/stress/wasm/to-c++.js >+ > 2016-10-01 Yusuke Suzuki <utatane.tea@gmail.com> > > [ES6] Align attributes of Generator related properties to spec >diff --git a/Source/JavaScriptCore/wasm/WASMFunctionParser.h b/Source/JavaScriptCore/wasm/WASMFunctionParser.h >index ab82be9..11b8a8e 100644 >--- a/Source/JavaScriptCore/wasm/WASMFunctionParser.h >+++ b/Source/JavaScriptCore/wasm/WASMFunctionParser.h >@@ -214,14 +214,14 @@ bool FunctionParser<Context>::parseExpression(OpType op) > return m_context.addElse(m_controlStack.last()); > } > >- case OpType::Branch: >- case OpType::BranchIf: { >+ case OpType::Br: >+ case OpType::BrIf: { > uint32_t target; > if (!parseVarUInt32(target) || target >= m_controlStack.size()) > return false; > > ExpressionType condition = Context::emptyExpression; >- if (op == OpType::BranchIf) >+ if (op == OpType::BrIf) > condition = m_expressionStack.takeLast(); > else > m_unreachableBlocks = 1; >@@ -245,6 +245,19 @@ bool FunctionParser<Context>::parseExpression(OpType op) > return m_context.endBlock(data, m_expressionStack); > } > >+ case OpType::Unreachable: >+ case OpType::Select: >+ case OpType::BrTable: >+ case OpType::Nop: >+ case OpType::Drop: >+ case OpType::I64Const: >+ case OpType::F32Const: >+ case OpType::F64Const: >+ case OpType::TeeLocal: >+ case OpType::GetGlobal: >+ case OpType::SetGlobal: >+ // FIXME: Not yet implemented. >+ return false; > } > > // Unknown opcode. >@@ -284,8 +297,8 @@ bool FunctionParser<Context>::parseUnreachableExpression(OpType op) > } > > // two immediate cases >- case OpType::Branch: >- case OpType::BranchIf: { >+ case OpType::Br: >+ case OpType::BrIf: { > uint32_t unused; > if (!parseVarUInt32(unused)) > return false; >diff --git a/Source/JavaScriptCore/wasm/WASMOps.h b/Source/JavaScriptCore/wasm/WASMOps.h >index 30aece5..05ac95d 100644 >--- a/Source/JavaScriptCore/wasm/WASMOps.h >+++ b/Source/JavaScriptCore/wasm/WASMOps.h >@@ -23,6 +23,8 @@ > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ > >+// This file is auto-generated using wasm.json. >+ > #pragma once > > #if ENABLE(WEBASSEMBLY) >@@ -30,46 +32,71 @@ > namespace JSC { namespace WASM { > > #define FOR_EACH_WASM_SPECIAL_OP(macro) \ >- macro(I32Const, 0x10, NA) \ >- macro(GetLocal, 0x14, NA) \ >- macro(SetLocal, 0x15, NA) >+ macro(I32Const, 0x10, Oops) \ >+ macro(I64Const, 0x11, Oops) \ >+ macro(F64Const, 0x12, Oops) \ >+ macro(F32Const, 0x13, Oops) \ >+ macro(GetLocal, 0x14, Oops) \ >+ macro(SetLocal, 0x15, Oops) \ >+ macro(TeeLocal, 0x19, Oops) \ >+ macro(GetGlobal, 0xbb, Oops) \ >+ macro(SetGlobal, 0xbc, Oops) > > #define FOR_EACH_WASM_CONTROL_FLOW_OP(macro) \ >- macro(Block, 0x01, NA) \ >- macro(Loop, 0x02, NA) \ >- macro(If, 0x03, NA) \ >- macro(Else, 0x04, NA) \ >- macro(Branch, 0x06, NA) \ >- macro(BranchIf, 0x07, NA) \ >- macro(Return, 0x09, NA) \ >- macro(End, 0x0f, NA) >+ macro(Unreachable, 0x0, Oops) \ >+ macro(Block, 0x1, Oops) \ >+ macro(Loop, 0x2, Oops) \ >+ macro(If, 0x3, Oops) \ >+ macro(Else, 0x4, Oops) \ >+ macro(Select, 0x5, Oops) \ >+ macro(Br, 0x6, Oops) \ >+ macro(BrIf, 0x7, Oops) \ >+ macro(BrTable, 0x8, Oops) \ >+ macro(Return, 0x9, Oops) \ >+ macro(Drop, 0xb, Oops) \ >+ macro(Nop, 0xa, Oops) \ >+ macro(End, 0xf, Oops) > > #define FOR_EACH_WASM_UNARY_OP(macro) \ > macro(I32Clz, 0x57, Clz) \ >- /* macro(I32Ctz, 0x58) */ \ >- /* macro(I32PopCnt, 0x59) */ \ >- /* macro(I32Eqz, 0x5a) */ \ >+ macro(I32Ctz, 0x58, Oops) \ >+ macro(I32Popcnt, 0x59, Oops) \ > macro(I64Clz, 0x72, Clz) \ >- /* macro(I64Ctz, 0x73) */ \ >- /* macro(I64PopCnt, 0x74) */ \ >- /* macro(I64Eqz, 0xba) */ >+ macro(I64Ctz, 0x73, Oops) \ >+ macro(I64Popcnt, 0x74, Oops) \ >+ macro(F32Abs, 0x7b, Oops) \ >+ macro(F32Neg, 0x7c, Oops) \ >+ macro(F32Copysign, 0x7d, Oops) \ >+ macro(F32Ceil, 0x7e, Oops) \ >+ macro(F32Floor, 0x7f, Oops) \ >+ macro(F32Trunc, 0x80, Oops) \ >+ macro(F32Nearest, 0x81, Oops) \ >+ macro(F32Sqrt, 0x82, Oops) \ >+ macro(F64Abs, 0x8f, Oops) \ >+ macro(F64Neg, 0x90, Oops) \ >+ macro(F64Copysign, 0x91, Oops) \ >+ macro(F64Ceil, 0x92, Oops) \ >+ macro(F64Floor, 0x93, Oops) \ >+ macro(F64Trunc, 0x94, Oops) \ >+ macro(F64Nearest, 0x95, Oops) \ >+ macro(F64Sqrt, 0x96, Oops) > > #define FOR_EACH_WASM_BINARY_OP(macro) \ > macro(I32Add, 0x40, Add) \ > macro(I32Sub, 0x41, Sub) \ > macro(I32Mul, 0x42, Mul) \ > macro(I32DivS, 0x43, Div) \ >- /* macro(I32DivU, 0x44) */ \ >+ macro(I32DivU, 0x44, Oops) \ > macro(I32RemS, 0x45, Mod) \ >- /* macro(I32RemU, 0x46, Mod) */ \ >+ macro(I32RemU, 0x46, Oops) \ > macro(I32And, 0x47, BitAnd) \ > macro(I32Or, 0x48, BitOr) \ > macro(I32Xor, 0x49, BitXor) \ > macro(I32Shl, 0x4a, Shl) \ > macro(I32ShrU, 0x4b, SShr) \ > macro(I32ShrS, 0x4c, ZShr) \ >- /* macro(I32RotR, 0xb6) */ \ >- /* macro(I32RotL, 0xb7) */ \ >+ macro(I32Rotr, 0xb6, Oops) \ >+ macro(I32Rotl, 0xb7, Oops) \ > macro(I32Eq, 0x4d, Equal) \ > macro(I32Ne, 0x4e, NotEqual) \ > macro(I32LtS, 0x4f, LessThan) \ >@@ -84,23 +111,52 @@ namespace JSC { namespace WASM { > macro(I64Sub, 0x5c, Sub) \ > macro(I64Mul, 0x5d, Mul) \ > macro(I64DivS, 0x5e, Div) \ >- /* macro(I64DivU, 0x5f) */ \ >+ macro(I64DivU, 0x5f, Oops) \ > macro(I64RemS, 0x60, Mod) \ >- /* macro(I64RemU, 0x61) */ \ >+ macro(I64RemU, 0x61, Oops) \ > macro(I64And, 0x62, BitAnd) \ > macro(I64Or, 0x63, BitOr) \ > macro(I64Xor, 0x64, BitXor) \ > macro(I64Shl, 0x65, Shl) \ > macro(I64ShrU, 0x66, SShr) \ > macro(I64ShrS, 0x67, ZShr) \ >- /* macro(I64RotR, 0xb8) */ \ >- /* macro(I64RotL, 0xb9) */ \ >+ macro(I64Rotr, 0xb8, Oops) \ >+ macro(I64Rotl, 0xb9, Oops) \ > macro(I64Eq, 0x68, Equal) \ > macro(I64Ne, 0x69, NotEqual) \ > macro(I64LtS, 0x6a, LessThan) \ > macro(I64LeS, 0x6b, LessEqual) \ > macro(I64LtU, 0x6c, Below) \ > macro(I64LeU, 0x6d, BelowEqual) \ >+ macro(I64GtS, 0x6e, GreaterThan) \ >+ macro(I64GeS, 0x6f, GreaterEqual) \ >+ macro(I64GtU, 0x70, Above) \ >+ macro(I64GeU, 0x71, AboveEqual) \ >+ macro(F32Add, 0x75, Oops) \ >+ macro(F32Sub, 0x76, Oops) \ >+ macro(F32Mul, 0x77, Oops) \ >+ macro(F32Div, 0x78, Oops) \ >+ macro(F32Min, 0x79, Oops) \ >+ macro(F32Max, 0x7a, Oops) \ >+ macro(F32Eq, 0x83, Oops) \ >+ macro(F32Ne, 0x84, Oops) \ >+ macro(F32Lt, 0x85, Oops) \ >+ macro(F32Le, 0x86, Oops) \ >+ macro(F32Gt, 0x87, Oops) \ >+ macro(F32Ge, 0x88, Oops) \ >+ macro(F64Add, 0x89, Oops) \ >+ macro(F64Sub, 0x8a, Oops) \ >+ macro(F64Mul, 0x8b, Oops) \ >+ macro(F64Div, 0x8c, Oops) \ >+ macro(F64Min, 0x8d, Oops) \ >+ macro(F64Max, 0x8e, Oops) \ >+ macro(F64Eq, 0x97, Oops) \ >+ macro(F64Ne, 0x98, Oops) \ >+ macro(F64Lt, 0x99, Oops) \ >+ macro(F64Le, 0x9a, Oops) \ >+ macro(F64Gt, 0x9b, Oops) \ >+ macro(F64Ge, 0x9c, Oops) >+ > > > #define FOR_EACH_WASM_OP(macro) \ >@@ -141,3 +197,4 @@ inline bool isControlOp(OpType op) > } } // namespace JSC::WASM > > #endif // ENABLE(WEBASSEMBLY) >+ >-- >2.9.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 162870
:
290493
|
290495
|
290500
|
290517
|
290519