| 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 // Note that this test file contains tests that explicitly check modules are |
| 8 // valid asm.js and then break them with invalid instantiation arguments. If |
| 9 // this script is run more than once (e.g. --stress-opt) then modules remain |
| 10 // broken in the second run and assertions would fail. We prevent re-runs. |
| 11 // Flags: --nostress-opt |
| 12 |
| 7 function assertValidAsm(func) { | 13 function assertValidAsm(func) { |
| 8 assertTrue(%IsAsmWasmCode(func)); | 14 assertTrue(%IsAsmWasmCode(func)); |
| 9 } | 15 } |
| 10 | 16 |
| 11 (function TestConst() { | 17 (function TestConst() { |
| 12 function Module(s) { | 18 function Module(s) { |
| 13 "use asm"; | 19 "use asm"; |
| 14 var fround = s.Math.fround; | 20 var fround = s.Math.fround; |
| 15 // Global constants. These are treated just like numeric literals. | 21 // Global constants. These are treated just like numeric literals. |
| 16 const fConst = fround(-3.0); | 22 const fConst = fround(-3.0); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 return 43; | 328 return 43; |
| 323 } | 329 } |
| 324 return 0; | 330 return 0; |
| 325 } | 331 } |
| 326 return { foo: foo }; | 332 return { foo: foo }; |
| 327 } | 333 } |
| 328 var m = Module(); | 334 var m = Module(); |
| 329 assertTrue(%IsNotAsmWasmCode(Module)); | 335 assertTrue(%IsNotAsmWasmCode(Module)); |
| 330 assertEquals(43, m.foo(3)); | 336 assertEquals(43, m.foo(3)); |
| 331 })(); | 337 })(); |
| OLD | NEW |