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 --allow-natives-syntax --expose-gc | 5 // Flags: --expose-wasm --allow-natives-syntax --expose-gc |
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 SerializeAndDeserializeModule() { | 10 (function SerializeAndDeserializeModule() { |
(...skipping 24 matching lines...) Expand all Loading... |
35 kExprCallFunction, 1]); | 35 kExprCallFunction, 1]); |
36 builder.appendToTable([2, 3]); | 36 builder.appendToTable([2, 3]); |
37 | 37 |
38 var wire_bytes = builder.toBuffer(); | 38 var wire_bytes = builder.toBuffer(); |
39 var module = new WebAssembly.Module(wire_bytes); | 39 var module = new WebAssembly.Module(wire_bytes); |
40 var buff = %SerializeWasmModule(module); | 40 var buff = %SerializeWasmModule(module); |
41 module = null; | 41 module = null; |
42 gc(); | 42 gc(); |
43 module = %DeserializeWasmModule(buff, wire_bytes); | 43 module = %DeserializeWasmModule(buff, wire_bytes); |
44 | 44 |
45 var mem_1 = new ArrayBuffer(4); | 45 var mem_1 = new WebAssembly.Memory({initial: 1}); |
46 var view_1 = new Int32Array(mem_1); | 46 var view_1 = new Int32Array(mem_1.buffer); |
47 | 47 |
48 view_1[0] = 42; | 48 view_1[0] = 42; |
49 | 49 |
50 var outval_1; | 50 var outval_1; |
51 var i1 = new WebAssembly.Instance(module, {some_value: () => 1, | 51 var i1 = new WebAssembly.Instance(module, {some_value: () => 1, |
52 writer: (x)=>outval_1 = x }, mem_1); | 52 writer: (x)=>outval_1 = x }, mem_1); |
53 | 53 |
54 assertEquals(43, i1.exports.main(0)); | 54 assertEquals(43, i1.exports.main(0)); |
55 | 55 |
56 assertEquals(42, outval_1); | 56 assertEquals(42, outval_1); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 var serialized = %SerializeWasmModule(compiled_module); | 93 var serialized = %SerializeWasmModule(compiled_module); |
94 var clone = %DeserializeWasmModule(serialized, wire_bytes); | 94 var clone = %DeserializeWasmModule(serialized, wire_bytes); |
95 | 95 |
96 assertNotNull(clone); | 96 assertNotNull(clone); |
97 assertFalse(clone == undefined); | 97 assertFalse(clone == undefined); |
98 assertFalse(clone == compiled_module); | 98 assertFalse(clone == compiled_module); |
99 assertEquals(clone.constructor, compiled_module.constructor); | 99 assertEquals(clone.constructor, compiled_module.constructor); |
100 var instance3 = new WebAssembly.Instance(clone); | 100 var instance3 = new WebAssembly.Instance(clone); |
101 assertFalse(instance3 == undefined); | 101 assertFalse(instance3 == undefined); |
102 })(); | 102 })(); |
OLD | NEW |