Changeset 207781 in webkit


Ignore:
Timestamp:
Oct 24, 2016 2:44:34 PM (7 years ago)
Author:
keith_miller@apple.com
Message:

Wasm should support floating point operations.
https://bugs.webkit.org/show_bug.cgi?id=163770

Reviewed by Michael Saboff.

JSTests:

Add appropriate b3op names for floating point wasm bytecodes, where they exist.
Also, fix some WASM => Wasm in WasmOps.h generator script that I missed
the first time I made the change.

  • wasm/generate-wasmops-header.js:

(const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.template.typename.Int.inline.bool.isValidOpType): Deleted.
(const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.enum.BinaryOpType): Deleted.
(const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.enum.UnaryOpType): Deleted.
(const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.enum.LoadOpType): Deleted.
(const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.enum.StoreOpType): Deleted.
(const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.undef.CREATE_ENUM_VALUE.inline.bool.isControlOp): Deleted.

  • wasm/wasm.json:

Source/JavaScriptCore:

Since we now have a Double => Float Trunc in B3, we can now support calls in Wasm
that take floating point arguments. This patch also enables most of the Wasm
floating point operations, as the associated B3 opcode has been linked via wasm.json.
If there is no direct mapping to a B3 opcode the Wasm is not yet implemented. This
patch also fixes a bug in calls where the arguments would be reversed.

  • testWasm.cpp:

(cast):
(invoke):
(boxf):
(boxd):
(runWasmTests):

  • wasm/WasmB3IRGenerator.cpp:

(JSC::Wasm::createJSWrapper):

  • wasm/WasmCallingConvention.h:

(JSC::Wasm::CallingConvention::loadArguments):
(JSC::Wasm::CallingConvention::setupCall):

  • wasm/WasmFunctionParser.h:

(JSC::Wasm::FunctionParser<Context>::parseExpression):
(JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression):

  • wasm/WasmOps.h:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r207697 r207781  
     12016-10-24  Keith Miller  <keith_miller@apple.com>
     2
     3        Wasm should support floating point operations.
     4        https://bugs.webkit.org/show_bug.cgi?id=163770
     5
     6        Reviewed by Michael Saboff.
     7
     8        Add appropriate b3op names for floating point wasm bytecodes, where they exist.
     9        Also, fix some WASM => Wasm in WasmOps.h generator script that I missed
     10        the first time I made the change.
     11
     12        * wasm/generate-wasmops-header.js:
     13        (const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.template.typename.Int.inline.bool.isValidOpType): Deleted.
     14        (const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.enum.BinaryOpType): Deleted.
     15        (const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.enum.UnaryOpType): Deleted.
     16        (const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.enum.LoadOpType): Deleted.
     17        (const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.enum.StoreOpType): Deleted.
     18        (const.template.pragma.once.ENABLE.WEBASSEMBLY.include.cstdint.namespace.JSC.namespace.WASM.undef.CREATE_ENUM_VALUE.inline.bool.isControlOp): Deleted.
     19        * wasm/wasm.json:
     20
    1212016-10-21  Saam Barati  <sbarati@apple.com>
    222
  • trunk/JSTests/wasm/generate-wasmops-header.js

    r207671 r207781  
    1 // Use the JSON description of WebAssembly to generate the JavaScriptCore's WASMOps.h.
     1// Use the JSON description of WebAssembly to generate the JavaScriptCore's WasmOps.h.
    22
    33const jsonFile = 'wasm.json';
     
    9191#include <cstdint>
    9292
    93 namespace JSC { namespace WASM {
     93namespace JSC { namespace Wasm {
    9494
    9595${defines}
     
    148148}
    149149
    150 } } // namespace JSC::WASM
     150} } // namespace JSC::Wasm
    151151
    152152#endif // ENABLE(WEBASSEMBLY)
  • trunk/JSTests/wasm/wasm.json

    r207572 r207781  
    151151        "i64.popcnt":          { "category": "arithmetic", "value": 116, "return": ["i64"],      "parameter": ["i64"],                  "immediate": []                         },
    152152        "i64.eqz":             { "category": "comparison", "value": 186, "return": ["bool"],     "parameter": ["i64"],                  "immediate": []                         },
    153         "f32.add":             { "category": "arithmetic", "value": 117, "return": ["f32"],      "parameter": ["f32", "f32"],           "immediate": []                         },
    154         "f32.sub":             { "category": "arithmetic", "value": 118, "return": ["f32"],      "parameter": ["f32", "f32"],           "immediate": []                         },
    155         "f32.mul":             { "category": "arithmetic", "value": 119, "return": ["f32"],      "parameter": ["f32", "f32"],           "immediate": []                         },
    156         "f32.div":             { "category": "arithmetic", "value": 120, "return": ["f32"],      "parameter": ["f32", "f32"],           "immediate": []                         },
     153        "f32.add":             { "category": "arithmetic", "value": 117, "return": ["f32"],      "parameter": ["f32", "f32"],           "immediate": [], "b3op": "Add"          },
     154        "f32.sub":             { "category": "arithmetic", "value": 118, "return": ["f32"],      "parameter": ["f32", "f32"],           "immediate": [], "b3op": "Sub"          },
     155        "f32.mul":             { "category": "arithmetic", "value": 119, "return": ["f32"],      "parameter": ["f32", "f32"],           "immediate": [], "b3op": "Mul"          },
     156        "f32.div":             { "category": "arithmetic", "value": 120, "return": ["f32"],      "parameter": ["f32", "f32"],           "immediate": [], "b3op": "Div"          },
    157157        "f32.min":             { "category": "arithmetic", "value": 121, "return": ["f32"],      "parameter": ["f32", "f32"],           "immediate": []                         },
    158158        "f32.max":             { "category": "arithmetic", "value": 122, "return": ["f32"],      "parameter": ["f32", "f32"],           "immediate": []                         },
    159         "f32.abs":             { "category": "arithmetic", "value": 123, "return": ["f32"],      "parameter": ["f32"],                  "immediate": []                         },
     159        "f32.abs":             { "category": "arithmetic", "value": 123, "return": ["f32"],      "parameter": ["f32"],                  "immediate": [], "b3op": "Abs"          },
    160160        "f32.neg":             { "category": "arithmetic", "value": 124, "return": ["f32"],      "parameter": ["f32"],                  "immediate": []                         },
    161161        "f32.copysign":        { "category": "arithmetic", "value": 125, "return": ["f32"],      "parameter": ["f32"],                  "immediate": []                         },
    162         "f32.ceil":            { "category": "arithmetic", "value": 126, "return": ["f32"],      "parameter": ["f32"],                  "immediate": []                         },
    163         "f32.floor":           { "category": "arithmetic", "value": 127, "return": ["f32"],      "parameter": ["f32"],                  "immediate": []                         },
     162        "f32.ceil":            { "category": "arithmetic", "value": 126, "return": ["f32"],      "parameter": ["f32"],                  "immediate": [], "b3op": "Ceil"         },
     163        "f32.floor":           { "category": "arithmetic", "value": 127, "return": ["f32"],      "parameter": ["f32"],                  "immediate": [], "b3op": "Floor"        },
    164164        "f32.trunc":           { "category": "arithmetic", "value": 128, "return": ["f32"],      "parameter": ["f32"],                  "immediate": []                         },
    165165        "f32.nearest":         { "category": "arithmetic", "value": 129, "return": ["f32"],      "parameter": ["f32"],                  "immediate": []                         },
    166166        "f32.sqrt":            { "category": "arithmetic", "value": 130, "return": ["f32"],      "parameter": ["f32"],                  "immediate": []                         },
    167         "f32.eq":              { "category": "comparison", "value": 131, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": []                         },
    168         "f32.ne":              { "category": "comparison", "value": 132, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": []                         },
    169         "f32.lt":              { "category": "comparison", "value": 133, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": []                         },
    170         "f32.le":              { "category": "comparison", "value": 134, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": []                         },
    171         "f32.gt":              { "category": "comparison", "value": 135, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": []                         },
    172         "f32.ge":              { "category": "comparison", "value": 136, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": []                        },
    173         "f64.add":             { "category": "arithmetic", "value": 137, "return": ["f64"],      "parameter": ["f64", "f64"],           "immediate": []                         },
    174         "f64.sub":             { "category": "arithmetic", "value": 138, "return": ["f64"],      "parameter": ["f64", "f64"],           "immediate": []                         },
    175         "f64.mul":             { "category": "arithmetic", "value": 139, "return": ["f64"],      "parameter": ["f64", "f64"],           "immediate": []                         },
    176         "f64.div":             { "category": "arithmetic", "value": 140, "return": ["f64"],      "parameter": ["f64", "f64"],           "immediate": []                         },
     167        "f32.eq":              { "category": "comparison", "value": 131, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": [], "b3op": "Equal"        },
     168        "f32.ne":              { "category": "comparison", "value": 132, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": [], "b3op": "NotEqual"     },
     169        "f32.lt":              { "category": "comparison", "value": 133, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": [], "b3op": "LessThan"     },
     170        "f32.le":              { "category": "comparison", "value": 134, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": [], "b3op": "LessEqual"    },
     171        "f32.gt":              { "category": "comparison", "value": 135, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": [], "b3op": "GreaterThan"  },
     172        "f32.ge":              { "category": "comparison", "value": 136, "return": ["bool"],     "parameter": ["f32", "f32"],           "immediate": [], "b3op": "GreaterEqual" },
     173        "f64.add":             { "category": "arithmetic", "value": 137, "return": ["f64"],      "parameter": ["f64", "f64"],           "immediate": [], "b3op": "Add"          },
     174        "f64.sub":             { "category": "arithmetic", "value": 138, "return": ["f64"],      "parameter": ["f64", "f64"],           "immediate": [], "b3op": "Sub"          },
     175        "f64.mul":             { "category": "arithmetic", "value": 139, "return": ["f64"],      "parameter": ["f64", "f64"],           "immediate": [], "b3op": "Mul"          },
     176        "f64.div":             { "category": "arithmetic", "value": 140, "return": ["f64"],      "parameter": ["f64", "f64"],           "immediate": [], "b3op": "Div"          },
    177177        "f64.min":             { "category": "arithmetic", "value": 141, "return": ["f64"],      "parameter": ["f64", "f64"],           "immediate": []                         },
    178178        "f64.max":             { "category": "arithmetic", "value": 142, "return": ["f64"],      "parameter": ["f64", "f64"],           "immediate": []                         },
    179         "f64.abs":             { "category": "arithmetic", "value": 143, "return": ["f64"],      "parameter": ["f64"],                  "immediate": []                         },
     179        "f64.abs":             { "category": "arithmetic", "value": 143, "return": ["f64"],      "parameter": ["f64"],                  "immediate": [], "b3op": "Abs"          },
    180180        "f64.neg":             { "category": "arithmetic", "value": 144, "return": ["f64"],      "parameter": ["f64"],                  "immediate": []                         },
    181181        "f64.copysign":        { "category": "arithmetic", "value": 145, "return": ["f64"],      "parameter": ["f64"],                  "immediate": []                         },
    182         "f64.ceil":            { "category": "arithmetic", "value": 146, "return": ["f64"],      "parameter": ["f64"],                  "immediate": []                         },
    183         "f64.floor":           { "category": "arithmetic", "value": 147, "return": ["f64"],      "parameter": ["f64"],                  "immediate": []                         },
     182        "f64.ceil":            { "category": "arithmetic", "value": 146, "return": ["f64"],      "parameter": ["f64"],                  "immediate": [], "b3op": "Ceil"         },
     183        "f64.floor":           { "category": "arithmetic", "value": 147, "return": ["f64"],      "parameter": ["f64"],                  "immediate": [], "b3op": "Floor"        },
    184184        "f64.trunc":           { "category": "arithmetic", "value": 148, "return": ["f64"],      "parameter": ["f64"],                  "immediate": []                         },
    185185        "f64.nearest":         { "category": "arithmetic", "value": 149, "return": ["f64"],      "parameter": ["f64"],                  "immediate": []                         },
    186186        "f64.sqrt":            { "category": "arithmetic", "value": 150, "return": ["f64"],      "parameter": ["f64"],                  "immediate": []                         },
    187         "f64.eq":              { "category": "comparison", "value": 151, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": []                         },
    188         "f64.ne":              { "category": "comparison", "value": 152, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": []                         },
    189         "f64.lt":              { "category": "comparison", "value": 153, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": []                         },
    190         "f64.le":              { "category": "comparison", "value": 154, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": []                         },
    191         "f64.gt":              { "category": "comparison", "value": 155, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": []                         },
    192         "f64.ge":              { "category": "comparison", "value": 156, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": []                        },
     187        "f64.eq":              { "category": "comparison", "value": 151, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": [], "b3op": "Equal"        },
     188        "f64.ne":              { "category": "comparison", "value": 152, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": [], "b3op": "NotEqual"     },
     189        "f64.lt":              { "category": "comparison", "value": 153, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": [], "b3op": "LessThan"     },
     190        "f64.le":              { "category": "comparison", "value": 154, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": [], "b3op": "LessEqual"    },
     191        "f64.gt":              { "category": "comparison", "value": 155, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": [], "b3op": "GreaterThan"  },
     192        "f64.ge":              { "category": "comparison", "value": 156, "return": ["bool"],     "parameter": ["f64", "f64"],           "immediate": [], "b3op": "GreaterEqual" },
    193193        "i32.trunc_s/f32":     { "category": "conversion", "value": 157, "return": ["i32"],      "parameter": ["f32"],                  "immediate": []                         },
    194194        "i32.trunc_s/f64":     { "category": "conversion", "value": 158, "return": ["i32"],      "parameter": ["f64"],                  "immediate": []                         },
  • trunk/Source/JavaScriptCore/ChangeLog

    r207765 r207781  
     12016-10-24  Keith Miller  <keith_miller@apple.com>
     2
     3        Wasm should support floating point operations.
     4        https://bugs.webkit.org/show_bug.cgi?id=163770
     5
     6        Reviewed by Michael Saboff.
     7
     8        Since we now have a Double => Float Trunc in B3, we can now support calls in Wasm
     9        that take floating point arguments. This patch also enables most of the Wasm
     10        floating point operations, as the associated B3 opcode has been linked via wasm.json.
     11        If there is no direct mapping to a B3 opcode the Wasm is not yet implemented. This
     12        patch also fixes a bug in calls where the arguments would be reversed.
     13
     14        * testWasm.cpp:
     15        (cast):
     16        (invoke):
     17        (boxf):
     18        (boxd):
     19        (runWasmTests):
     20        * wasm/WasmB3IRGenerator.cpp:
     21        (JSC::Wasm::createJSWrapper):
     22        * wasm/WasmCallingConvention.h:
     23        (JSC::Wasm::CallingConvention::loadArguments):
     24        (JSC::Wasm::CallingConvention::setupCall):
     25        * wasm/WasmFunctionParser.h:
     26        (JSC::Wasm::FunctionParser<Context>::parseExpression):
     27        (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression):
     28        * wasm/WasmOps.h:
     29
    1302016-10-24  Mark Lam  <mark.lam@apple.com>
    231
  • trunk/Source/JavaScriptCore/testWasm.cpp

    r207693 r207781  
    2626#include "config.h"
    2727
     28#include "B3Common.h"
    2829#include "B3Compilation.h"
    2930#include "InitializeThreading.h"
     
    9697        CRASH(); \
    9798    } while (false)
     99
     100#define CHECK(x) CHECK_EQ(x, true)
    98101
    99102#define FOR_EACH_UNSIGNED_LEB_TEST(macro) \
     
    209212
    210213template<typename T>
     214T cast(EncodedJSValue value)
     215{
     216    return static_cast<T>(value);
     217}
     218
     219template<>
     220double cast(EncodedJSValue value)
     221{
     222    return bitwise_cast<double>(value);
     223}
     224
     225template<>
     226float cast(EncodedJSValue value)
     227{
     228    return bitwise_cast<float>(static_cast<int>(value));
     229}
     230
     231template<typename T>
    211232T invoke(MacroAssemblerCodePtr ptr, std::initializer_list<JSValue> args)
    212233{
     
    225246    protoCallFrame.init(nullptr, nullptr, firstArgument, argCount, remainingArguments);
    226247
    227     // This won't work for floating point values but we don't have those yet.
    228     return static_cast<T>(vmEntryToWasm(ptr.executableAddress(), vm, &protoCallFrame));
     248    return cast<T>(vmEntryToWasm(ptr.executableAddress(), vm, &protoCallFrame));
    229249}
    230250
     
    240260}
    241261
     262inline JSValue boxf(float value)
     263{
     264    return box(bitwise_cast<uint32_t>(value));
     265}
     266
     267inline JSValue boxd(double value)
     268{
     269    return box(bitwise_cast<uint64_t>(value));
     270}
     271
    242272// For now we inline the test files.
    243273static void runWasmTests()
    244274{
     275
     276    {
     277        // Generated from:
     278        //    (module
     279        //     (func $f32-sub (export "f32-sub") (param f32) (param f32) (result f32) (return (f32.sub (get_local 0) (get_local 1))))
     280        //     (func (export "indirect-f32-sub") (param f32) (param f32) (result f32) (return (call $f32-sub (get_local 0) (get_local 1))))
     281        //     )
     282        Vector<uint8_t> vector = {
     283            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
     284            0x02, 0x03, 0x03, 0x01, 0x03, 0x03, 0x83, 0x80, 0x80, 0x80, 0x00, 0x02, 0x00, 0x00, 0x07, 0x9e,
     285            0x80, 0x80, 0x80, 0x00, 0x02, 0x07, 0x66, 0x33, 0x32, 0x2d, 0x73, 0x75, 0x62, 0x00, 0x00, 0x10,
     286            0x69, 0x6e, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x2d, 0x66, 0x33, 0x32, 0x2d, 0x73, 0x75, 0x62,
     287            0x00, 0x01, 0x0a, 0x9c, 0x80, 0x80, 0x80, 0x00, 0x02, 0x88, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14,
     288            0x00, 0x14, 0x01, 0x76, 0x09, 0x0f, 0x89, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01,
     289            0x16, 0x00, 0x09, 0x0f
     290        };
     291
     292        Plan plan(*vm, vector);
     293        if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
     294            dataLogLn("Module failed to compile correctly.");
     295            CRASH();
     296        }
     297
     298        // Test this doesn't crash.
     299        CHECK(isIdentical(invoke<float>(*plan.result[1]->jsEntryPoint, { boxf(0.0), boxf(1.5) }), -1.5f));
     300        CHECK(isIdentical(invoke<float>(*plan.result[1]->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 87.6234f));
     301        CHECK(isIdentical(invoke<float>(*plan.result[0]->jsEntryPoint, { boxf(0.0), boxf(1.5) }), -1.5f));
     302        CHECK(isIdentical(invoke<float>(*plan.result[0]->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 87.6234f));
     303    }
     304
     305    {
     306        // Generated from:
     307        //    (module
     308        //     (func $f32-add (export "f32-add") (param f32) (param f32) (result f32) (return (f32.add (get_local 0) (get_local 1))))
     309        //     (func (export "indirect-f32-add") (param f32) (param f32) (result f32) (return (call $f32-add (get_local 0) (get_local 1))))
     310        //     )
     311        Vector<uint8_t> vector = {
     312            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
     313            0x02, 0x03, 0x03, 0x01, 0x03, 0x03, 0x83, 0x80, 0x80, 0x80, 0x00, 0x02, 0x00, 0x00, 0x07, 0x9e,
     314            0x80, 0x80, 0x80, 0x00, 0x02, 0x07, 0x66, 0x33, 0x32, 0x2d, 0x61, 0x64, 0x64, 0x00, 0x00, 0x10,
     315            0x69, 0x6e, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x2d, 0x66, 0x33, 0x32, 0x2d, 0x61, 0x64, 0x64,
     316            0x00, 0x01, 0x0a, 0x9c, 0x80, 0x80, 0x80, 0x00, 0x02, 0x88, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14,
     317            0x00, 0x14, 0x01, 0x75, 0x09, 0x0f, 0x89, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x00, 0x14, 0x01,
     318            0x16, 0x00, 0x09, 0x0f
     319        };
     320
     321        Plan plan(*vm, vector);
     322        if (plan.result.size() != 2 || !plan.result[0] || !plan.result[1]) {
     323            dataLogLn("Module failed to compile correctly.");
     324            CRASH();
     325        }
     326
     327        // Test this doesn't crash.
     328        CHECK(isIdentical(invoke<float>(*plan.result[1]->jsEntryPoint, { boxf(0.0), boxf(1.5) }), 1.5f));
     329        CHECK(isIdentical(invoke<float>(*plan.result[1]->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 112.6234f));
     330        CHECK(isIdentical(invoke<float>(*plan.result[0]->jsEntryPoint, { boxf(0.0), boxf(1.5) }), 1.5f));
     331        CHECK(isIdentical(invoke<float>(*plan.result[0]->jsEntryPoint, { boxf(100.1234), boxf(12.5) }), 112.6234f));
     332    }
     333
    245334    {
    246335        // Generated from:
  • trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp

    r207693 r207781  
    698698
    699699    // Return the result, if needed.
    700     if (signature->returnType != Void)
     700    switch (signature->returnType) {
     701    case Void:
     702        block->appendNewControlValue(proc, B3::Return, Origin());
     703        break;
     704    case F32:
     705    case F64:
     706        result = block->appendNew<Value>(proc, BitwiseCast, Origin(), result);
     707        FALLTHROUGH;
     708    case I32:
     709    case I64:
    701710        block->appendNewControlValue(proc, B3::Return, Origin(), result);
    702     else
    703         block->appendNewControlValue(proc, B3::Return, Origin());
     711        break;
     712    }
    704713
    705714    return std::make_unique<Compilation>(vm, proc);
  • trunk/Source/JavaScriptCore/wasm/WasmCallingConvention.h

    r207693 r207781  
    9999            if (rep.isReg()) {
    100100                argument = block->appendNew<B3::ArgumentRegValue>(proc, origin, rep.reg());
    101                 if (type == B3::Int32)
     101                if (type == B3::Int32 || type == B3::Float)
    102102                    argument = block->appendNew<B3::Value>(proc, B3::Trunc, origin, argument);
    103                 // FIXME: How do I get a float from a FPR? We don't support floating points yet so it's not a big deal... yet.
    104                 // see: https://bugs.webkit.org/show_bug.cgi?id=163770
    105103            } else {
    106104                ASSERT(rep.isStackArgument());
     
    135133        patchpointFunctor(patchpoint);
    136134
    137         if (returnType == B3::Void)
     135        switch (returnType) {
     136        case B3::Void:
    138137            return nullptr;
    139 
    140         patchpoint->resultConstraint = B3::ValueRep::reg(GPRInfo::returnValueGPR);
     138        case B3::Float:
     139        case B3::Double:
     140            patchpoint->resultConstraint = B3::ValueRep::reg(FPRInfo::returnValueFPR);
     141            break;
     142        case B3::Int32:
     143        case B3::Int64:
     144            patchpoint->resultConstraint = B3::ValueRep::reg(GPRInfo::returnValueGPR);
     145            break;
     146        }
    141147        return patchpoint;
    142148    }
  • trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h

    r207693 r207781  
    191191    }
    192192
     193    case OpType::F32Const:
    193194    case OpType::I32Const: {
    194195        uint32_t constant;
     
    199200    }
    200201
     202    case OpType::F64Const:
    201203    case OpType::I64Const: {
    202204        uint64_t constant;
     
    237239        const FunctionInformation& info = m_functions[functionIndex];
    238240
     241        if (info.signature->arguments.size() > m_expressionStack.size())
     242            return false;
     243
     244        size_t firstArgumentIndex = m_expressionStack.size() - info.signature->arguments.size();
    239245        Vector<ExpressionType> args;
    240         for (unsigned i = 0; i < info.signature->arguments.size(); ++i)
    241             args.append(m_expressionStack.takeLast());
     246        args.reserveInitialCapacity(info.signature->arguments.size());
     247        for (unsigned i = firstArgumentIndex; i < m_expressionStack.size(); ++i)
     248            args.append(m_expressionStack[i]);
     249        m_expressionStack.shrink(firstArgumentIndex);
    242250
    243251        ExpressionType result = Context::emptyExpression;
     
    319327    case OpType::Nop:
    320328    case OpType::Drop:
    321     case OpType::F32Const:
    322     case OpType::F64Const:
    323329    case OpType::TeeLocal:
    324330    case OpType::GetGlobal:
     
    375381    // one immediate cases
    376382    case OpType::Return:
     383    case OpType::F32Const:
    377384    case OpType::I32Const:
     385    case OpType::F64Const:
     386    case OpType::I64Const:
    378387    case OpType::SetLocal:
    379388    case OpType::GetLocal: {
  • trunk/Source/JavaScriptCore/wasm/WasmOps.h

    r207693 r207781  
    6969    macro(I64Ctz, 0x73, Oops) \
    7070    macro(I64Popcnt, 0x74, Oops) \
    71     macro(F32Abs, 0x7b, Oops) \
     71    macro(F32Abs, 0x7b, Abs) \
    7272    macro(F32Neg, 0x7c, Oops) \
    7373    macro(F32Copysign, 0x7d, Oops) \
    74     macro(F32Ceil, 0x7e, Oops) \
    75     macro(F32Floor, 0x7f, Oops) \
     74    macro(F32Ceil, 0x7e, Ceil) \
     75    macro(F32Floor, 0x7f, Floor) \
    7676    macro(F32Trunc, 0x80, Oops) \
    7777    macro(F32Nearest, 0x81, Oops) \
    7878    macro(F32Sqrt, 0x82, Oops) \
    79     macro(F64Abs, 0x8f, Oops) \
     79    macro(F64Abs, 0x8f, Abs) \
    8080    macro(F64Neg, 0x90, Oops) \
    8181    macro(F64Copysign, 0x91, Oops) \
    82     macro(F64Ceil, 0x92, Oops) \
    83     macro(F64Floor, 0x93, Oops) \
     82    macro(F64Ceil, 0x92, Ceil) \
     83    macro(F64Floor, 0x93, Floor) \
    8484    macro(F64Trunc, 0x94, Oops) \
    8585    macro(F64Nearest, 0x95, Oops) \
     
    137137    macro(I64GtU, 0x70, Above) \
    138138    macro(I64GeU, 0x71, AboveEqual) \
    139     macro(F32Add, 0x75, Oops) \
    140     macro(F32Sub, 0x76, Oops) \
    141     macro(F32Mul, 0x77, Oops) \
    142     macro(F32Div, 0x78, Oops) \
     139    macro(F32Add, 0x75, Add) \
     140    macro(F32Sub, 0x76, Sub) \
     141    macro(F32Mul, 0x77, Mul) \
     142    macro(F32Div, 0x78, Div) \
    143143    macro(F32Min, 0x79, Oops) \
    144144    macro(F32Max, 0x7a, Oops) \
    145     macro(F32Eq, 0x83, Oops) \
    146     macro(F32Ne, 0x84, Oops) \
    147     macro(F32Lt, 0x85, Oops) \
    148     macro(F32Le, 0x86, Oops) \
    149     macro(F32Gt, 0x87, Oops) \
    150     macro(F32Ge, 0x88, Oops) \
    151     macro(F64Add, 0x89, Oops) \
    152     macro(F64Sub, 0x8a, Oops) \
    153     macro(F64Mul, 0x8b, Oops) \
    154     macro(F64Div, 0x8c, Oops) \
     145    macro(F32Eq, 0x83, Equal) \
     146    macro(F32Ne, 0x84, NotEqual) \
     147    macro(F32Lt, 0x85, LessThan) \
     148    macro(F32Le, 0x86, LessEqual) \
     149    macro(F32Gt, 0x87, GreaterThan) \
     150    macro(F32Ge, 0x88, GreaterEqual) \
     151    macro(F64Add, 0x89, Add) \
     152    macro(F64Sub, 0x8a, Sub) \
     153    macro(F64Mul, 0x8b, Mul) \
     154    macro(F64Div, 0x8c, Div) \
    155155    macro(F64Min, 0x8d, Oops) \
    156156    macro(F64Max, 0x8e, Oops) \
    157     macro(F64Eq, 0x97, Oops) \
    158     macro(F64Ne, 0x98, Oops) \
    159     macro(F64Lt, 0x99, Oops) \
    160     macro(F64Le, 0x9a, Oops) \
    161     macro(F64Gt, 0x9b, Oops) \
    162     macro(F64Ge, 0x9c, Oops)
     157    macro(F64Eq, 0x97, Equal) \
     158    macro(F64Ne, 0x98, NotEqual) \
     159    macro(F64Lt, 0x99, LessThan) \
     160    macro(F64Le, 0x9a, LessEqual) \
     161    macro(F64Gt, 0x9b, GreaterThan) \
     162    macro(F64Ge, 0x9c, GreaterEqual)
    163163
    164164#define FOR_EACH_WASM_MEMORY_LOAD_OP(macro) \
Note: See TracChangeset for help on using the changeset viewer.