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 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 // Success. | 25 // Success. |
26 return; | 26 return; |
27 } | 27 } |
28 throw new MjsUnitAssertionError("Did not throw exception"); | 28 throw new MjsUnitAssertionError("Did not throw exception"); |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 function makeDivRem(opcode) { | 32 function makeDivRem(opcode) { |
33 var kBodySize = 5; | 33 var kBodySize = 5; |
34 var kNameMainOffset = 6 + 11 + kBodySize + 1; | 34 var kNameMainOffset = kHeaderSize + 6 + 11 + kBodySize + 1; |
35 | 35 |
36 var data = bytes( | 36 var data = bytesWithHeader( |
37 // signatures | 37 // signatures |
38 kDeclSignatures, 1, | 38 kDeclSignatures, 1, |
39 2, kAstI32, kAstI32, kAstI32, // (int,int) -> int | 39 2, kAstI32, kAstI32, kAstI32, // (int,int) -> int |
40 // -- main function | 40 // -- main function |
41 kDeclFunctions, 1, | 41 kDeclFunctions, 1, |
42 kDeclFunctionName | kDeclFunctionExport, | 42 kDeclFunctionName | kDeclFunctionExport, |
43 0, 0, | 43 0, 0, |
44 kNameMainOffset, 0, 0, 0, // name offset | 44 kNameMainOffset, 0, 0, 0, // name offset |
45 kBodySize, 0, | 45 kBodySize, 0, |
46 // main body | 46 // main body |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |