| 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: --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 instantiate(sig, body) { | 10 function instantiate(sig, body) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 function assertVerifies(sig, body) { | 31 function assertVerifies(sig, body) { |
| 32 var module = instantiate(sig, body); | 32 var module = instantiate(sig, body); |
| 33 assertFalse(module === undefined); | 33 assertFalse(module === undefined); |
| 34 assertFalse(module === null); | 34 assertFalse(module === null); |
| 35 assertFalse(module === 0); | 35 assertFalse(module === 0); |
| 36 assertEquals("object", typeof module); | 36 assertEquals("object", typeof module); |
| 37 return module; | 37 return module; |
| 38 } | 38 } |
| 39 | 39 |
| 40 assertVerifies(kSig_v_v, [kExprNop]); | 40 assertVerifies(kSig_v_v, [kExprNop]); |
| 41 assertVerifies(kSig_i, [kExprI8Const, 0]); | 41 assertVerifies(kSig_i_v, [kExprI8Const, 0]); |
| 42 | 42 |
| 43 // Arguments aren't allow to start functions. | 43 // Arguments aren't allow to start functions. |
| 44 assertFails(kSig_i_i, [kExprGetLocal, 0]); | 44 assertFails(kSig_i_i, [kExprGetLocal, 0]); |
| 45 assertFails(kSig_i_ii, [kExprGetLocal, 0]); | 45 assertFails(kSig_i_ii, [kExprGetLocal, 0]); |
| 46 assertFails(kSig_i_dd, [kExprGetLocal, 0]); | 46 assertFails(kSig_i_dd, [kExprGetLocal, 0]); |
| 47 | 47 |
| 48 (function testInvalidIndex() { | 48 (function testInvalidIndex() { |
| 49 print("testInvalidIndex"); | 49 print("testInvalidIndex"); |
| 50 var builder = new WasmModuleBuilder(); | 50 var builder = new WasmModuleBuilder(); |
| 51 | 51 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 builder.addImport("foo", sig_index); | 103 builder.addImport("foo", sig_index); |
| 104 var func = builder.addFunction("", sig_index) | 104 var func = builder.addFunction("", sig_index) |
| 105 .addBody([kExprCallFunction, 0]); | 105 .addBody([kExprCallFunction, 0]); |
| 106 | 106 |
| 107 builder.addStart(func.index); | 107 builder.addStart(func.index); |
| 108 | 108 |
| 109 var module = builder.instantiate(ffi); | 109 var module = builder.instantiate(ffi); |
| 110 assertTrue(ranned); | 110 assertTrue(ranned); |
| 111 })(); | 111 })(); |
| OLD | NEW |