| 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 Math_ceil = stdlib.Math.ceil; | 10 var Math_ceil = stdlib.Math.ceil; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 function f64_sin(a) { | 198 function f64_sin(a) { |
| 199 a = +a; | 199 a = +a; |
| 200 return +Math_sin(+a); | 200 return +Math_sin(+a); |
| 201 } | 201 } |
| 202 | 202 |
| 203 function f64_tan(a) { | 203 function f64_tan(a) { |
| 204 a = +a; | 204 a = +a; |
| 205 return +Math_tan(+a); | 205 return +Math_tan(+a); |
| 206 } | 206 } |
| 207 | 207 |
| 208 function f64_exp(a, b) { | 208 function f64_exp(a) { |
| 209 a = +a; |
| 210 return +Math_exp(+a); |
| 211 } |
| 212 |
| 213 function f64_log(a) { |
| 214 a = +a; |
| 215 return +Math_log(+a); |
| 216 } |
| 217 |
| 218 function f64_atan2(a, b) { |
| 209 a = +a; | 219 a = +a; |
| 210 b = +b; | 220 b = +b; |
| 211 return +Math_exp(+a, +b); | 221 return +Math_atan2(+a, +b); |
| 212 } | 222 } |
| 213 | 223 |
| 214 function f64_log(a, b) { | 224 function f64_neg(a) { |
| 215 a = +a; | 225 a = +a; |
| 216 b = +b; | 226 return +(-a); |
| 217 return +Math_log(+a, +b); | |
| 218 } | |
| 219 | |
| 220 function f64_atan2(a) { | |
| 221 a = +a; | |
| 222 return +Math_atan2(+a); | |
| 223 } | 227 } |
| 224 | 228 |
| 225 | 229 |
| 226 var inputs = [ | 230 var inputs = [ |
| 227 0, 1, 2, 3, 4, | 231 0, 1, 2, 3, 4, |
| 228 NaN, | 232 NaN, |
| 229 Infinity, | 233 Infinity, |
| 230 -Infinity, | 234 -Infinity, |
| 231 10, 20, 30, 31, 32, 33, 100, 2000, | 235 10, 20, 30, 31, 32, 33, 100, 2000, |
| 232 30000, 400000, 5000000, | 236 30000, 400000, 5000000, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 f64_eq, | 269 f64_eq, |
| 266 f64_ne, | 270 f64_ne, |
| 267 f64_lt, | 271 f64_lt, |
| 268 f64_lteq, | 272 f64_lteq, |
| 269 f64_gt, | 273 f64_gt, |
| 270 f64_gteq, | 274 f64_gteq, |
| 271 f64_ceil, | 275 f64_ceil, |
| 272 f64_floor, | 276 f64_floor, |
| 273 // TODO(bradnelson) f64_sqrt, | 277 // TODO(bradnelson) f64_sqrt, |
| 274 f64_abs, | 278 f64_abs, |
| 279 f64_neg, |
| 275 // TODO(bradnelson) f64_min is wrong for -0 | 280 // TODO(bradnelson) f64_min is wrong for -0 |
| 276 // TODO(bradnelson) f64_max is wrong for -0 | 281 // TODO(bradnelson) f64_max is wrong for -0 |
| 277 // TODO(bradnelson) f64_acos, | 282 f64_acos, |
| 278 // TODO(bradnelson) f64_asin, | 283 f64_asin, |
| 279 // TODO(bradnelson) f64_atan, | 284 f64_atan, |
| 280 // TODO(bradnelson) f64_cos, | 285 f64_cos, |
| 281 // TODO(bradnelson) f64_sin, | 286 f64_sin, |
| 282 // TODO(bradnelson) f64_tan, | 287 f64_tan, |
| 283 // TODO(bradnelson) f64_exp, | 288 f64_exp, |
| 284 // TODO(bradnelson) f64_log, | 289 f64_log, |
| 285 // TODO(bradnelson) f64_atan2, | 290 f64_atan2, |
| 286 ]; | 291 ]; |
| 287 | 292 |
| 288 (function () { | 293 (function () { |
| 289 for (func of funcs) { | 294 for (func of funcs) { |
| 290 RunAsmJsTest(WrapInAsmModule(func), function (module) { | 295 RunAsmJsTest(WrapInAsmModule(func), function (module) { |
| 291 if (func.length == 1) { | 296 if (func.length == 1) { |
| 292 for (a of inputs) { | 297 for (a of inputs) { |
| 293 assertEquals(func(a), module.main(a)); | 298 assertEquals(func(a), module.main(a)); |
| 294 assertEquals(func(a / 10), module.main(a / 10)); | 299 assertEquals(func(a / 10), module.main(a / 10)); |
| 295 assertEquals(func(a / 440.9), module.main(a / 440.9)); | 300 assertEquals(func(a / 440.9), module.main(a / 440.9)); |
| 296 assertEquals(func(a / -33.1), module.main(a / -33.1)); | 301 assertEquals(func(a / -33.1), module.main(a / -33.1)); |
| 297 } | 302 } |
| 298 } else { | 303 } else { |
| 299 for (a of inputs) { | 304 for (a of inputs) { |
| 300 for (b of inputs) { | 305 for (b of inputs) { |
| 301 assertEquals(func(a, b), module.main(a, b)); | 306 assertEquals(func(a, b), module.main(a, b)); |
| 302 assertEquals(func(a / 10, b), module.main(a / 10, b)); | 307 assertEquals(func(a / 10, b), module.main(a / 10, b)); |
| 303 assertEquals(func(a, b / 440.9), module.main(a, b / 440.9)); | 308 assertEquals(func(a, b / 440.9), module.main(a, b / 440.9)); |
| 304 assertEquals(func(a / -33.1, b), module.main(a / -33.1, b)); | 309 assertEquals(func(a / -33.1, b), module.main(a / -33.1, b)); |
| 305 } | 310 } |
| 306 } | 311 } |
| 307 } | 312 } |
| 308 }); | 313 }); |
| 309 } | 314 } |
| 310 })(); | 315 })(); |
| OLD | NEW |