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 | 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 | 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 | 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. | 10 // broken in the second run and assertions would fail. We prevent re-runs. |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 b = b | 0; | 469 b = b | 0; |
470 // Disallowed because conditional yields int, even when both sides | 470 // Disallowed because conditional yields int, even when both sides |
471 // are signed. | 471 // are signed. |
472 return 1 ? a | 0 : b | 0; | 472 return 1 ? a | 0 : b | 0; |
473 } | 473 } |
474 return foo; | 474 return foo; |
475 } | 475 } |
476 Module(); | 476 Module(); |
477 assertFalse(% IsAsmWasmCode(Module)); | 477 assertFalse(% IsAsmWasmCode(Module)); |
478 })(); | 478 })(); |
| 479 |
| 480 (function TestAsmIsRegular() { |
| 481 function Module() { |
| 482 'use asm'; |
| 483 var g = 123; |
| 484 function foo() { |
| 485 return g | 0; |
| 486 } |
| 487 return {x: foo}; |
| 488 } |
| 489 var o = Module(); |
| 490 assertValidAsm(Module); |
| 491 assertFalse(o instanceof WebAssembly.Instance); |
| 492 assertTrue(o instanceof Object); |
| 493 assertTrue(o.__proto__ === Object.prototype); |
| 494 o.x = 5; |
| 495 assertTrue(typeof o.x === 'number'); |
| 496 assertTrue(o.__single_function__ === undefined); |
| 497 assertTrue(o.__foreign_init__ === undefined); |
| 498 })(); |
OLD | NEW |