OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --expose-wasm |
| 6 |
| 7 load("test/mjsunit/wasm/wasm-constants.js"); |
| 8 load("test/mjsunit/wasm/wasm-module-builder.js"); |
| 9 |
| 10 (function() { |
| 11 print("F32: sNaN - 0 = qNaN"); |
| 12 var builder = new WasmModuleBuilder(); |
| 13 builder.addFunction("F32Sub0", kSig_i_i) |
| 14 .addBody([ |
| 15 kExprGetLocal, 0, |
| 16 kExprF32ReinterpretI32, |
| 17 kExprF32Const, 0x00, 0x00, 0x00, 0x00, // 0.0 |
| 18 kExprF32Sub, |
| 19 kExprI32ReinterpretF32, |
| 20 ]) |
| 21 .exportFunc(); |
| 22 var module = builder.instantiate(); |
| 23 // F32Sub0(signalling_NaN) |
| 24 assertEquals(0x7fe00000, module.exports.F32Sub0(0x7fa00000)); |
| 25 })(); |
| 26 |
| 27 (function() { |
| 28 print("F32: sNaN - X = qNaN"); |
| 29 var builder = new WasmModuleBuilder(); |
| 30 builder.addFunction("F32NaNSubX", kSig_i_i) |
| 31 .addBody([ |
| 32 kExprF32Const, 0x00, 0x00, 0xa0, 0x7f, |
| 33 kExprF32Const, 0x12, 0x34, 0x56, 0x78, |
| 34 kExprF32Sub, |
| 35 kExprI32ReinterpretF32, |
| 36 ]) |
| 37 .exportFunc(); |
| 38 var module = builder.instantiate(); |
| 39 assertEquals(0x7fe00000, module.exports.F32NaNSubX()); |
| 40 })(); |
| 41 |
| 42 (function() { |
| 43 print("F32: X - sNaN = qNaN"); |
| 44 var builder = new WasmModuleBuilder(); |
| 45 builder.addFunction("F32XSubNaN", kSig_i_i) |
| 46 .addBody([ |
| 47 kExprF32Const, 0x12, 0x34, 0x56, 0x78, |
| 48 kExprF32Const, 0x00, 0x00, 0xa0, 0x7f, |
| 49 kExprF32Sub, |
| 50 kExprI32ReinterpretF32, |
| 51 ]) |
| 52 .exportFunc(); |
| 53 var module = builder.instantiate(); |
| 54 assertEquals(0x7fe00000, module.exports.F32XSubNaN()); |
| 55 })(); |
| 56 |
| 57 (function() { |
| 58 print("F64: X + sNaN = qNaN"); |
| 59 var builder = new WasmModuleBuilder(); |
| 60 builder.addFunction("F32XAddNaN", kSig_i_i) |
| 61 .addBody([ |
| 62 kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, |
| 63 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, |
| 64 kExprF64Add, |
| 65 kExprI64ReinterpretF64, |
| 66 kExprI64Const, 32, |
| 67 kExprI64ShrU, |
| 68 kExprI32ConvertI64, |
| 69 ]) |
| 70 .exportFunc(); |
| 71 var module = builder.instantiate(); |
| 72 assertEquals(0x7ffa0000, module.exports.F32XAddNaN()); |
| 73 })(); |
| 74 |
| 75 (function() { |
| 76 print("F64: sNaN - 0 = qNaN"); |
| 77 var builder = new WasmModuleBuilder(); |
| 78 builder.addFunction("F64Sub0", kSig_i_i) |
| 79 .addBody([ |
| 80 kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00, |
| 81 kExprF64ReinterpretI64, |
| 82 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0.0 |
| 83 kExprF64Sub, |
| 84 kExprI64ReinterpretF64, |
| 85 kExprI64Const, 32, |
| 86 kExprI64ShrU, |
| 87 kExprI32ConvertI64, |
| 88 ]) |
| 89 .exportFunc(); |
| 90 var module = builder.instantiate(); |
| 91 assertEquals(0x7ffa0000, module.exports.F64Sub0()); |
| 92 })(); |
| 93 |
| 94 (function() { |
| 95 print("F64: sNaN - X = qNaN"); |
| 96 var builder = new WasmModuleBuilder(); |
| 97 builder.addFunction("F64NaNSubX", kSig_i_i) |
| 98 .addBody([ |
| 99 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, |
| 100 kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, |
| 101 kExprF64Sub, |
| 102 kExprI64ReinterpretF64, |
| 103 kExprI64Const, 32, |
| 104 kExprI64ShrU, |
| 105 kExprI32ConvertI64, |
| 106 ]) |
| 107 .exportFunc(); |
| 108 var module = builder.instantiate(); |
| 109 assertEquals(0x7ffa0000, module.exports.F64NaNSubX()); |
| 110 })(); |
| 111 |
| 112 (function() { |
| 113 print("F64: X - sNaN = qNaN"); |
| 114 var builder = new WasmModuleBuilder(); |
| 115 builder.addFunction("F64XSubNaN", kSig_i_i) |
| 116 .addBody([ |
| 117 kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, |
| 118 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, |
| 119 kExprF64Sub, |
| 120 kExprI64ReinterpretF64, |
| 121 kExprI64Const, 32, |
| 122 kExprI64ShrU, |
| 123 kExprI32ConvertI64, |
| 124 ]) |
| 125 .exportFunc(); |
| 126 var module = builder.instantiate(); |
| 127 assertEquals(0x7ffa0000, module.exports.F64XSubNaN()); |
| 128 })(); |
| 129 |
| 130 (function() { |
| 131 print("F64: sNaN * 1 = qNaN"); |
| 132 var builder = new WasmModuleBuilder(); |
| 133 builder.addFunction("F64Mul1", kSig_i_i) |
| 134 .addBody([ |
| 135 kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00, |
| 136 kExprF64ReinterpretI64, |
| 137 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, |
| 138 kExprF64Mul, |
| 139 kExprI64ReinterpretF64, |
| 140 kExprI64Const, 32, |
| 141 kExprI64ShrU, |
| 142 kExprI32ConvertI64, |
| 143 ]) |
| 144 .exportFunc(); |
| 145 var module = builder.instantiate(); |
| 146 assertEquals(0x7ffa0000, module.exports.F64Mul1()); |
| 147 })(); |
| 148 |
| 149 (function() { |
| 150 print("F64: X * sNaN = qNaN"); |
| 151 var builder = new WasmModuleBuilder(); |
| 152 builder.addFunction("F64XMulNaN", kSig_i_i) |
| 153 .addBody([ |
| 154 kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, |
| 155 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, |
| 156 kExprF64Mul, |
| 157 kExprI64ReinterpretF64, |
| 158 kExprI64Const, 32, |
| 159 kExprI64ShrU, |
| 160 kExprI32ConvertI64, |
| 161 ]) |
| 162 .exportFunc(); |
| 163 var module = builder.instantiate(); |
| 164 assertEquals(0x7ffa0000, module.exports.F64XMulNaN()); |
| 165 })(); |
| 166 |
| 167 (function() { |
| 168 print("F64: sNaN / 1 = qNaN"); |
| 169 var builder = new WasmModuleBuilder(); |
| 170 builder.addFunction("F64Div1", kSig_i_i) |
| 171 .addBody([ |
| 172 kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00, |
| 173 kExprF64ReinterpretI64, |
| 174 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, |
| 175 kExprF64Div, |
| 176 kExprI64ReinterpretF64, |
| 177 kExprI64Const, 32, |
| 178 kExprI64ShrU, |
| 179 kExprI32ConvertI64, |
| 180 ]) |
| 181 .exportFunc(); |
| 182 var module = builder.instantiate(); |
| 183 assertEquals(0x7ffa0000, module.exports.F64Div1()); |
| 184 })(); |
| 185 |
| 186 (function() { |
| 187 print("F64: X / sNaN = qNaN"); |
| 188 var builder = new WasmModuleBuilder(); |
| 189 builder.addFunction("F64XDivNaN", kSig_i_i) |
| 190 .addBody([ |
| 191 kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, |
| 192 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, |
| 193 kExprF64Div, |
| 194 kExprI64ReinterpretF64, |
| 195 kExprI64Const, 32, |
| 196 kExprI64ShrU, |
| 197 kExprI32ConvertI64, |
| 198 ]) |
| 199 .exportFunc(); |
| 200 var module = builder.instantiate(); |
| 201 assertEquals(0x7ffa0000, module.exports.F64XDivNaN()); |
| 202 })(); |
| 203 |
| 204 (function() { |
| 205 print("F64: sNaN / X = qNaN"); |
| 206 var builder = new WasmModuleBuilder(); |
| 207 builder.addFunction("F64NaNDivX", kSig_i_i) |
| 208 .addBody([ |
| 209 kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, |
| 210 kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, |
| 211 kExprF64Div, |
| 212 kExprI64ReinterpretF64, |
| 213 kExprI64Const, 32, |
| 214 kExprI64ShrU, |
| 215 kExprI32ConvertI64, |
| 216 ]) |
| 217 .exportFunc(); |
| 218 var module = builder.instantiate(); |
| 219 assertEquals(0x7ffa0000, module.exports.F64NaNDivX()); |
| 220 })(); |
OLD | NEW |