OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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: --expose-wasm --expose-gc --allow-natives-syntax | 5 // Flags: --expose-wasm --expose-gc --allow-natives-syntax |
6 | 6 |
7 load("test/mjsunit/wasm/wasm-constants.js"); | 7 load("test/mjsunit/wasm/wasm-constants.js"); |
8 | 8 |
9 function assertTraps(code, msg) { | 9 function assertTraps(code, msg) { |
10 var threwException = true; | 10 var threwException = true; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 kBodySize, 0, | 45 kBodySize, 0, |
46 // main body | 46 // main body |
47 opcode, // -- | 47 opcode, // -- |
48 kExprGetLocal, 0, // -- | 48 kExprGetLocal, 0, // -- |
49 kExprGetLocal, 1, // -- | 49 kExprGetLocal, 1, // -- |
50 // names | 50 // names |
51 kDeclEnd, | 51 kDeclEnd, |
52 'm', 'a', 'i', 'n', 0 // -- | 52 'm', 'a', 'i', 'n', 0 // -- |
53 ); | 53 ); |
54 | 54 |
55 var module = WASM.instantiateModule(data); | 55 var module = _WASMEXP_.instantiateModule(data); |
56 | 56 |
57 assertEquals("function", typeof module.main); | 57 assertEquals("function", typeof module.main); |
58 | 58 |
59 return module.main; | 59 return module.main; |
60 } | 60 } |
61 | 61 |
62 var divs = makeDivRem(kExprI32DivS); | 62 var divs = makeDivRem(kExprI32DivS); |
63 var divu = makeDivRem(kExprI32DivU); | 63 var divu = makeDivRem(kExprI32DivU); |
64 | 64 |
65 assertEquals( 33, divs( 333, 10)); | 65 assertEquals( 33, divs( 333, 10)); |
(...skipping 22 matching lines...) Expand all Loading... |
88 assertEquals( 3, remu(-443, 10)); | 88 assertEquals( 3, remu(-443, 10)); |
89 | 89 |
90 assertTraps(kTrapRemByZero, "rems(100, 0);"); | 90 assertTraps(kTrapRemByZero, "rems(100, 0);"); |
91 assertTraps(kTrapRemByZero, "rems(-1009, 0);"); | 91 assertTraps(kTrapRemByZero, "rems(-1009, 0);"); |
92 | 92 |
93 assertTraps(kTrapRemByZero, "remu(200, 0);"); | 93 assertTraps(kTrapRemByZero, "remu(200, 0);"); |
94 assertTraps(kTrapRemByZero, "remu(-2009, 0);"); | 94 assertTraps(kTrapRemByZero, "remu(-2009, 0);"); |
95 | 95 |
96 assertEquals(-2147483648, remu(0x80000000, -1)); | 96 assertEquals(-2147483648, remu(0x80000000, -1)); |
97 assertEquals(0, rems(0x80000000, -1)); | 97 assertEquals(0, rems(0x80000000, -1)); |
OLD | NEW |