Changeset 209866 in webkit


Ignore:
Timestamp:
Dec 15, 2016 11:17:00 AM (7 years ago)
Author:
keith_miller@apple.com
Message:

Fix 64-bit shift family Wasm opcodes
https://bugs.webkit.org/show_bug.cgi?id=165902

Reviewed by Geoffrey Garen.

JSTests:

Add tests for shift family of instructions. Since
we can't generate i64 values to pass to wasm we only compile
the code for those functions. Attempting to generate any i64
code using these instructions would have been enough to cause
the B3 Validation error anyway.

  • wasm/assert.js:
  • wasm/function-tests/rotl.js: Added.
  • wasm/function-tests/rotr.js: Added.
  • wasm/function-tests/shl.js: Added.
  • wasm/function-tests/shr-s.js: Added.
  • wasm/function-tests/shr-u.js: Added.
  • wasm/wasm.json:

Source/JavaScriptCore:

The Int64 versions of the shift family B3 opcodes take an Int32
for the shift value. Wasm, however, takes an i64, so we need to
Trunc the shift value. Also, this fixes a bug where shr_u mapped
to signed shift and shr_s mapped to the unsigned shift.

  • wasm/wasm.json:
Location:
trunk
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r209863 r209866  
     12016-12-15  Keith Miller  <keith_miller@apple.com>
     2
     3        Fix 64-bit shift family Wasm opcodes
     4        https://bugs.webkit.org/show_bug.cgi?id=165902
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Add tests for shift family of instructions. Since
     9        we can't generate i64 values to pass to wasm we only compile
     10        the code for those functions. Attempting to generate any i64
     11        code using these instructions would have been enough to cause
     12        the B3 Validation error anyway.
     13
     14        * wasm/assert.js:
     15        * wasm/function-tests/rotl.js: Added.
     16        * wasm/function-tests/rotr.js: Added.
     17        * wasm/function-tests/shl.js: Added.
     18        * wasm/function-tests/shr-s.js: Added.
     19        * wasm/function-tests/shr-u.js: Added.
     20        * wasm/wasm.json:
     21
    1222016-12-14  Keith Miller  <keith_miller@apple.com>
    223
  • trunk/JSTests/wasm/assert.js

    r208401 r209866  
    8080};
    8181
     82const canonicalizeI32 = (number) => {
     83    if (Math.round(number) === number && number >= 2 ** 31)
     84        number = number - 2 ** 32;
     85    return number;
     86}
     87
     88export const eqI32 = (lhs, rhs, msg) => {
     89    return eq(canonicalizeI32(lhs), canonicalizeI32(rhs), msg);
     90};
     91
    8292export const ge = (lhs, rhs, msg) => {
    8393    isNotUndef(lhs);
  • trunk/JSTests/wasm/wasm.json

    r209852 r209866  
    102102        "i32.xor":             { "category": "arithmetic", "value": 115, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "BitXor"       },
    103103        "i32.shl":             { "category": "arithmetic", "value": 116, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "Shl"          },
    104         "i32.shr_u":           { "category": "arithmetic", "value": 118, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "SShr"         },
    105         "i32.shr_s":           { "category": "arithmetic", "value": 117, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "ZShr"         },
     104        "i32.shr_u":           { "category": "arithmetic", "value": 118, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "ZShr"         },
     105        "i32.shr_s":           { "category": "arithmetic", "value": 117, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "SShr"         },
    106106        "i32.rotr":            { "category": "arithmetic", "value": 120, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "RotR"         },
    107107        "i32.rotl":            { "category": "arithmetic", "value": 119, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "RotL"         },
     
    130130        "i64.or":              { "category": "arithmetic", "value": 132, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "BitOr"        },
    131131        "i64.xor":             { "category": "arithmetic", "value": 133, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "BitXor"       },
    132         "i64.shl":             { "category": "arithmetic", "value": 134, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "Shl"          },
    133         "i64.shr_u":           { "category": "arithmetic", "value": 136, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "SShr"        },
    134         "i64.shr_s":           { "category": "arithmetic", "value": 135, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "ZShr"        },
    135         "i64.rotr":            { "category": "arithmetic", "value": 138, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "RotR"        },
    136         "i64.rotl":            { "category": "arithmetic", "value": 137, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "RotL"        },
     132        "i64.shl":             { "category": "arithmetic", "value": 134, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "Shl(@0, Trunc(@1))" },
     133        "i64.shr_u":           { "category": "arithmetic", "value": 136, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "ZShr(@0, Trunc(@1))" },
     134        "i64.shr_s":           { "category": "arithmetic", "value": 135, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "SShr(@0, Trunc(@1))" },
     135        "i64.rotr":            { "category": "arithmetic", "value": 138, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "RotR(@0, Trunc(@1))" },
     136        "i64.rotl":            { "category": "arithmetic", "value": 137, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "RotL(@0, Trunc(@1))" },
    137137        "i64.eq":              { "category": "comparison", "value":  81, "return": ["bool"],     "parameter": ["i64", "i64"],           "immediate": [], "b3op": "Equal"        },
    138138        "i64.ne":              { "category": "comparison", "value":  82, "return": ["bool"],     "parameter": ["i64", "i64"],           "immediate": [], "b3op": "NotEqual"     },
  • trunk/Source/JavaScriptCore/ChangeLog

    r209852 r209866  
     12016-12-15  Keith Miller  <keith_miller@apple.com>
     2
     3        Fix 64-bit shift family Wasm opcodes
     4        https://bugs.webkit.org/show_bug.cgi?id=165902
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        The Int64 versions of the shift family B3 opcodes take an Int32
     9        for the shift value. Wasm, however, takes an i64, so we need to
     10        Trunc the shift value. Also, this fixes a bug where shr_u mapped
     11        to signed shift and shr_s mapped to the unsigned shift.
     12
     13        * wasm/wasm.json:
     14
    1152016-12-14  Keith Miller  <keith_miller@apple.com>
    216
  • trunk/Source/JavaScriptCore/wasm/wasm.json

    r209852 r209866  
    102102        "i32.xor":             { "category": "arithmetic", "value": 115, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "BitXor"       },
    103103        "i32.shl":             { "category": "arithmetic", "value": 116, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "Shl"          },
    104         "i32.shr_u":           { "category": "arithmetic", "value": 118, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "SShr"         },
    105         "i32.shr_s":           { "category": "arithmetic", "value": 117, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "ZShr"         },
     104        "i32.shr_u":           { "category": "arithmetic", "value": 118, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "ZShr"         },
     105        "i32.shr_s":           { "category": "arithmetic", "value": 117, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "SShr"         },
    106106        "i32.rotr":            { "category": "arithmetic", "value": 120, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "RotR"         },
    107107        "i32.rotl":            { "category": "arithmetic", "value": 119, "return": ["i32"],      "parameter": ["i32", "i32"],           "immediate": [], "b3op": "RotL"         },
     
    130130        "i64.or":              { "category": "arithmetic", "value": 132, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "BitOr"        },
    131131        "i64.xor":             { "category": "arithmetic", "value": 133, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "BitXor"       },
    132         "i64.shl":             { "category": "arithmetic", "value": 134, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "Shl"          },
    133         "i64.shr_u":           { "category": "arithmetic", "value": 136, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "SShr"        },
    134         "i64.shr_s":           { "category": "arithmetic", "value": 135, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "ZShr"        },
    135         "i64.rotr":            { "category": "arithmetic", "value": 138, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "RotR"        },
    136         "i64.rotl":            { "category": "arithmetic", "value": 137, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "RotL"        },
     132        "i64.shl":             { "category": "arithmetic", "value": 134, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "Shl(@0, Trunc(@1))" },
     133        "i64.shr_u":           { "category": "arithmetic", "value": 136, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "ZShr(@0, Trunc(@1))" },
     134        "i64.shr_s":           { "category": "arithmetic", "value": 135, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "SShr(@0, Trunc(@1))" },
     135        "i64.rotr":            { "category": "arithmetic", "value": 138, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "RotR(@0, Trunc(@1))" },
     136        "i64.rotl":            { "category": "arithmetic", "value": 137, "return": ["i64"],      "parameter": ["i64", "i64"],           "immediate": [], "b3op": "RotL(@0, Trunc(@1))" },
    137137        "i64.eq":              { "category": "comparison", "value":  81, "return": ["bool"],     "parameter": ["i64", "i64"],           "immediate": [], "b3op": "Equal"        },
    138138        "i64.ne":              { "category": "comparison", "value":  82, "return": ["bool"],     "parameter": ["i64", "i64"],           "immediate": [], "b3op": "NotEqual"     },
Note: See TracChangeset for help on using the changeset viewer.