OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm | 5 // Flags: --expose-wasm |
6 | 6 |
7 function WrapInAsmModule(func) { | 7 function WrapInAsmModule(func) { |
8 function MODULE_NAME(stdlib) { | 8 function MODULE_NAME(stdlib) { |
9 "use asm"; | 9 "use asm"; |
10 var fround = stdlib.Math.fround; | 10 var fround = stdlib.Math.fround; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 b = fround(b); | 158 b = fround(b); |
159 if (fround(a) >= fround(b)) { | 159 if (fround(a) >= fround(b)) { |
160 return 1; | 160 return 1; |
161 } | 161 } |
162 return 0; | 162 return 0; |
163 } | 163 } |
164 | 164 |
165 | 165 |
166 var inputs = [ | 166 var inputs = [ |
167 0, 1, 2, 3, 4, | 167 0, 1, 2, 3, 4, |
| 168 NaN, |
| 169 Infinity, |
| 170 -Infinity, |
168 10, 20, 30, 31, 32, 33, 100, 2000, | 171 10, 20, 30, 31, 32, 33, 100, 2000, |
169 30000, 400000, 5000000, | 172 30000, 400000, 5000000, |
170 100000000, 2000000000, | 173 100000000, 2000000000, |
171 2147483646, | 174 2147483646, |
172 2147483647, | 175 2147483647, |
173 2147483648, | 176 2147483648, |
174 2147483649, | 177 2147483649, |
175 0x273a798e, 0x187937a3, 0xece3af83, 0x5495a16b, 0x0b668ecc, 0x11223344, | 178 0x273a798e, 0x187937a3, 0xece3af83, 0x5495a16b, 0x0b668ecc, 0x11223344, |
176 0x0000009e, 0x00000043, 0x0000af73, 0x0000116b, 0x00658ecc, 0x002b3b4c, | 179 0x0000af73, 0x0000116b, 0x00658ecc, 0x002b3b4c, |
177 0x88776655, 0x70000000, 0x07200000, 0x7fffffff, 0x56123761, 0x7fffff00, | 180 0x88776655, 0x70000000, 0x07200000, 0x7fffffff, 0x56123761, 0x7fffff00, |
178 0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff, | 181 0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff, |
179 0x00003fff, 0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff, | |
180 -0, | 182 -0, |
181 -1, -2, -3, -4, | 183 -1, -2, -3, -4, |
182 -10, -20, -30, -31, -32, -33, -100, -2000, | 184 -10, -20, -30, -31, -32, -33, -100, -2000, |
183 -30000, -400000, -5000000, | 185 -30000, -400000, -5000000, |
184 -100000000, -2000000000, | 186 -100000000, -2000000000, |
185 -2147483646, | 187 -2147483646, |
186 -2147483647, | 188 -2147483647, |
187 -2147483648, | 189 -2147483648, |
188 -2147483649, | 190 -2147483649, |
189 0.1, | 191 0.1, |
190 1.1e-2, | 192 1.1e-2, |
191 1.2e-4, | 193 1.2e-4, |
192 1.3e-8, | 194 1.3e-8, |
193 1.4e-11, | 195 1.4e-11, |
194 1.5e-12, | 196 1.5e-12, |
195 1.6e-13 | 197 1.6e-13 |
196 ]; | 198 ]; |
197 | 199 |
198 var funcs = [ | 200 var funcs = [ |
199 f32_add, | 201 f32_add, |
200 f32_sub, | 202 f32_sub, |
201 f32_mul, | 203 f32_mul, |
202 f32_div, | 204 f32_div, |
203 // TODO(bradnelson) f32_ceil, | 205 f32_ceil, |
204 // TODO(bradnelson) f32_floor, | 206 f32_floor, |
205 // TODO(bradnelson) f32_sqrt, | 207 // TODO(bradnelson) f32_sqrt, |
206 // TODO(bradnelson) f32_abs, | 208 // TODO(bradnelson) f32_abs, |
207 // TODO(bradnelson) f32_min is wrong for -0 | 209 // TODO(bradnelson) f32_min is wrong for -0 |
208 // TODO(bradnelson) f32_max is wrong for -0 | 210 // TODO(bradnelson) f32_max is wrong for -0 |
209 f32_eq, | 211 f32_eq, |
210 f32_ne, | 212 f32_ne, |
211 f32_lt, | 213 f32_lt, |
212 f32_lteq, | 214 f32_lteq, |
213 f32_gt, | 215 f32_gt, |
214 f32_gteq, | 216 f32_gteq, |
215 ]; | 217 ]; |
216 | 218 |
217 (function () { | 219 (function () { |
218 for (func of funcs) { | 220 for (func of funcs) { |
219 RunThreeWayTest(WrapInAsmModule(func), function (module) { | 221 RunThreeWayTest(WrapInAsmModule(func), function (module) { |
220 for (a of inputs) { | 222 if (func.length == 1) { |
221 for (b of inputs) { | 223 for (a of inputs) { |
222 assertEquals(func(a, b), module.main(a, b)); | 224 assertEquals(func(a), module.main(a)); |
223 assertEquals(func(a / 10, b), module.main(a / 10, b)); | 225 assertEquals(func(a / 11), module.main(a / 11)); |
224 assertEquals(func(a, b / 440.9), module.main(a, b / 440.9)); | 226 assertEquals(func(a / 430.9), module.main(a / 430.9)); |
225 assertEquals(func(a / -33.1, b), module.main(a / -33.1, b)); | 227 assertEquals(func(a / -31.1), module.main(a / -31.1)); |
| 228 } |
| 229 } else { |
| 230 for (a of inputs) { |
| 231 for (b of inputs) { |
| 232 assertEquals(func(a, b), module.main(a, b)); |
| 233 assertEquals(func(a / 11, b), module.main(a / 11, b)); |
| 234 assertEquals(func(a, b / 420.9), module.main(a, b / 420.9)); |
| 235 assertEquals(func(a / -31.1, b), module.main(a / -31.1, b)); |
| 236 } |
226 } | 237 } |
227 } | 238 } |
228 }); | 239 }); |
229 } | 240 } |
230 | 241 |
231 })(); | 242 })(); |
OLD | NEW |