| 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 23 matching lines...) Expand all Loading... |
| 34 print("Testing " + asmfunc.name + " (js)..."); | 34 print("Testing " + asmfunc.name + " (js)..."); |
| 35 var js_module = eval("(" + nonasm_source + ")")(stdlib); | 35 var js_module = eval("(" + nonasm_source + ")")(stdlib); |
| 36 expect(js_module); | 36 expect(js_module); |
| 37 | 37 |
| 38 print("Testing " + asmfunc.name + " (asm.js)..."); | 38 print("Testing " + asmfunc.name + " (asm.js)..."); |
| 39 var asm_module = asmfunc(stdlib); | 39 var asm_module = asmfunc(stdlib); |
| 40 assertTrue(%IsAsmWasmCode(asmfunc)); | 40 assertTrue(%IsAsmWasmCode(asmfunc)); |
| 41 expect(asm_module); | 41 expect(asm_module); |
| 42 } | 42 } |
| 43 | 43 |
| 44 const fround = Math.fround; | 44 var fround = Math.fround; |
| 45 const Math_ceil = Math.ceil; | 45 var Math_ceil = Math.ceil; |
| 46 const Math_floor = Math.floor; | 46 var Math_floor = Math.floor; |
| 47 const Math_sqrt = Math.sqrt; | 47 var Math_sqrt = Math.sqrt; |
| 48 const Math_abs = Math.abs; | 48 var Math_abs = Math.abs; |
| 49 const Math_min = Math.min; | 49 var Math_min = Math.min; |
| 50 const Math_max = Math.max; | 50 var Math_max = Math.max; |
| 51 | 51 |
| 52 function f32_add(a, b) { | 52 function f32_add(a, b) { |
| 53 a = fround(a); | 53 a = fround(a); |
| 54 b = fround(b); | 54 b = fround(b); |
| 55 return fround(fround(a) + fround(b)); | 55 return fround(fround(a) + fround(b)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 function f32_sub(a, b) { | 58 function f32_sub(a, b) { |
| 59 a = fround(a); | 59 a = fround(a); |
| 60 b = fround(b); | 60 b = fround(b); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 assertEquals(func(a / 11, b), module.main(a / 11, b)); | 236 assertEquals(func(a / 11, b), module.main(a / 11, b)); |
| 237 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)); |
| 238 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)); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 }); | 242 }); |
| 243 } | 243 } |
| 244 | 244 |
| 245 })(); | 245 })(); |
| OLD | NEW |