| 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 | 5 // Flags: --expose-wasm |
| 6 | 6 |
| 7 load("test/mjsunit/wasm/wasm-constants.js"); | 7 load("test/mjsunit/wasm/wasm-constants.js"); |
| 8 load("test/mjsunit/wasm/wasm-module-builder.js"); | 8 load("test/mjsunit/wasm/wasm-module-builder.js"); |
| 9 | 9 |
| 10 function assertModule(module, memsize) { | 10 function assertModule(module, memsize) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 assertEquals("object", typeof module.exports); | 33 assertEquals("object", typeof module.exports); |
| 34 | 34 |
| 35 var exp = module.exports[func]; | 35 var exp = module.exports[func]; |
| 36 assertFalse(exp === undefined); | 36 assertFalse(exp === undefined); |
| 37 assertFalse(exp === null); | 37 assertFalse(exp === null); |
| 38 assertFalse(exp === 0); | 38 assertFalse(exp === 0); |
| 39 assertEquals("function", typeof exp); | 39 assertEquals("function", typeof exp); |
| 40 return exp; | 40 return exp; |
| 41 } | 41 } |
| 42 | 42 |
| 43 (function I64SubTest() { | |
| 44 | |
| 45 var builder = new WasmModuleBuilder(); | |
| 46 | |
| 47 builder.addMemory(1, 1, true); | |
| 48 builder.addFunction("sub", kSig_l_ll) | |
| 49 .addBody([ // -- | |
| 50 kExprGetLocal, 0, // -- | |
| 51 kExprGetLocal, 1, // -- | |
| 52 kExprI64Sub]) // -- | |
| 53 .exportFunc() | |
| 54 | |
| 55 var module = builder.instantiate(); | |
| 56 assertModule(module, kPageSize); | |
| 57 | |
| 58 // Check the properties of the sub function. | |
| 59 var sub = assertFunction(module, "sub"); | |
| 60 assertEquals(-55, sub(33, 88)); | |
| 61 assertEquals(-55555, sub(33333, 88888)); | |
| 62 assertEquals(-5555555, sub(3333333, 8888888)); | |
| 63 })(); | |
| 64 | |
| 65 (function SubTest() { | 43 (function SubTest() { |
| 66 | 44 |
| 67 var builder = new WasmModuleBuilder(); | 45 var builder = new WasmModuleBuilder(); |
| 68 | 46 |
| 69 builder.addMemory(1, 1, true); | 47 builder.addMemory(1, 1, true); |
| 70 builder.addFunction("sub", kSig_i_ii) | 48 builder.addFunction("sub", kSig_i_ii) |
| 71 .addBody([ | 49 .addBody([ |
| 72 kExprGetLocal, 0, // -- | 50 kExprGetLocal, 0, // -- |
| 73 kExprGetLocal, 1, // -- | 51 kExprGetLocal, 1, // -- |
| 74 kExprI32Sub, // -- | 52 kExprI32Sub, // -- |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 .exportFunc(); | 96 .exportFunc(); |
| 119 | 97 |
| 120 var module = builder.instantiate(); | 98 var module = builder.instantiate(); |
| 121 assertModule(module, kPageSize * kPages); | 99 assertModule(module, kPageSize * kPages); |
| 122 | 100 |
| 123 var flt = assertFunction(module, "flt"); | 101 var flt = assertFunction(module, "flt"); |
| 124 assertEquals(1, flt(-2, -1)); | 102 assertEquals(1, flt(-2, -1)); |
| 125 assertEquals(0, flt(7.3, 7.1)); | 103 assertEquals(0, flt(7.3, 7.1)); |
| 126 assertEquals(1, flt(7.1, 7.3)); | 104 assertEquals(1, flt(7.1, 7.3)); |
| 127 })(); | 105 })(); |
| OLD | NEW |