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() { |
11 var builder = new WasmModuleBuilder(); | 11 var builder = new WasmModuleBuilder(); |
12 builder.addImportedMemory("", "memory", 1,1); | 12 builder.addImportedMemory("", "memory", 1); |
13 var kSig_v_i = makeSig([kWasmI32], []); | 13 var kSig_v_i = makeSig([kWasmI32], []); |
14 var signature = builder.addType(kSig_v_i); | 14 var signature = builder.addType(kSig_v_i); |
15 builder.addImport("", "some_value", kSig_i_v); | 15 builder.addImport("", "some_value", kSig_i_v); |
16 builder.addImport("", "writer", signature); | 16 builder.addImport("", "writer", signature); |
17 | 17 |
18 builder.addFunction("main", kSig_i_i) | 18 builder.addFunction("main", kSig_i_i) |
19 .addBody([ | 19 .addBody([ |
20 kExprGetLocal, 0, | 20 kExprGetLocal, 0, |
21 kExprI32LoadMem, 0, 0, | 21 kExprI32LoadMem, 0, 0, |
22 kExprI32Const, 1, | 22 kExprI32Const, 1, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 var serialized = %SerializeWasmModule(compiled_module); | 96 var serialized = %SerializeWasmModule(compiled_module); |
97 var clone = %DeserializeWasmModule(serialized, wire_bytes); | 97 var clone = %DeserializeWasmModule(serialized, wire_bytes); |
98 | 98 |
99 assertNotNull(clone); | 99 assertNotNull(clone); |
100 assertFalse(clone == undefined); | 100 assertFalse(clone == undefined); |
101 assertFalse(clone == compiled_module); | 101 assertFalse(clone == compiled_module); |
102 assertEquals(clone.constructor, compiled_module.constructor); | 102 assertEquals(clone.constructor, compiled_module.constructor); |
103 var instance3 = new WebAssembly.Instance(clone); | 103 var instance3 = new WebAssembly.Instance(clone); |
104 assertFalse(instance3 == undefined); | 104 assertFalse(instance3 == undefined); |
105 })(); | 105 })(); |
OLD | NEW |