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: --validate-asm --allow-natives-syntax | 5 // Flags: --validate-asm --allow-natives-syntax |
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 function f32_gteq(a, b) { | 153 function f32_gteq(a, b) { |
154 a = fround(a); | 154 a = fround(a); |
155 b = fround(b); | 155 b = fround(b); |
156 if (fround(a) >= fround(b)) { | 156 if (fround(a) >= fround(b)) { |
157 return 1; | 157 return 1; |
158 } | 158 } |
159 return 0; | 159 return 0; |
160 } | 160 } |
161 | 161 |
| 162 function f32_neg(a) { |
| 163 a = fround(a); |
| 164 return fround(-a); |
| 165 } |
| 166 |
162 | 167 |
163 var inputs = [ | 168 var inputs = [ |
164 0, 1, 2, 3, 4, | 169 0, 1, 2, 3, 4, |
165 NaN, | 170 NaN, |
166 Infinity, | 171 Infinity, |
167 -Infinity, | 172 -Infinity, |
168 10, 20, 30, 31, 32, 33, 100, 2000, | 173 10, 20, 30, 31, 32, 33, 100, 2000, |
169 30000, 400000, 5000000, | 174 30000, 400000, 5000000, |
170 100000000, 2000000000, | 175 100000000, 2000000000, |
171 2147483646, | 176 2147483646, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // TODO(bradnelson) f32_sqrt, | 209 // TODO(bradnelson) f32_sqrt, |
205 // TODO(bradnelson) f32_abs, | 210 // TODO(bradnelson) f32_abs, |
206 // TODO(bradnelson) f32_min is wrong for -0 | 211 // TODO(bradnelson) f32_min is wrong for -0 |
207 // TODO(bradnelson) f32_max is wrong for -0 | 212 // TODO(bradnelson) f32_max is wrong for -0 |
208 f32_eq, | 213 f32_eq, |
209 f32_ne, | 214 f32_ne, |
210 f32_lt, | 215 f32_lt, |
211 f32_lteq, | 216 f32_lteq, |
212 f32_gt, | 217 f32_gt, |
213 f32_gteq, | 218 f32_gteq, |
| 219 f32_neg, |
214 ]; | 220 ]; |
215 | 221 |
216 (function () { | 222 (function () { |
217 for (func of funcs) { | 223 for (func of funcs) { |
218 RunAsmJsTest(WrapInAsmModule(func), function (module) { | 224 RunAsmJsTest(WrapInAsmModule(func), function (module) { |
219 if (func.length == 1) { | 225 if (func.length == 1) { |
220 for (a of inputs) { | 226 for (a of inputs) { |
221 assertEquals(func(a), module.main(a)); | 227 assertEquals(func(a), module.main(a)); |
222 assertEquals(func(a / 11), module.main(a / 11)); | 228 assertEquals(func(a / 11), module.main(a / 11)); |
223 assertEquals(func(a / 430.9), module.main(a / 430.9)); | 229 assertEquals(func(a / 430.9), module.main(a / 430.9)); |
224 assertEquals(func(a / -31.1), module.main(a / -31.1)); | 230 assertEquals(func(a / -31.1), module.main(a / -31.1)); |
225 } | 231 } |
226 } else { | 232 } else { |
227 for (a of inputs) { | 233 for (a of inputs) { |
228 for (b of inputs) { | 234 for (b of inputs) { |
229 assertEquals(func(a, b), module.main(a, b)); | 235 assertEquals(func(a, b), module.main(a, b)); |
230 assertEquals(func(a / 11, b), module.main(a / 11, b)); | 236 assertEquals(func(a / 11, b), module.main(a / 11, b)); |
231 assertEquals(func(a, b / 420.9), module.main(a, b / 420.9)); | 237 assertEquals(func(a, b / 420.9), module.main(a, b / 420.9)); |
232 assertEquals(func(a / -31.1, b), module.main(a / -31.1, b)); | 238 assertEquals(func(a / -31.1, b), module.main(a / -31.1, b)); |
233 } | 239 } |
234 } | 240 } |
235 } | 241 } |
236 }); | 242 }); |
237 } | 243 } |
238 | 244 |
239 })(); | 245 })(); |
OLD | NEW |