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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 (function DeserializeInvalidObject() { | 59 (function DeserializeInvalidObject() { |
60 var invalid_buffer = new ArrayBuffer(10); | 60 var invalid_buffer = new ArrayBuffer(10); |
61 | 61 |
62 module = %DeserializeWasmModule(invalid_buffer, invalid_buffer); | 62 module = %DeserializeWasmModule(invalid_buffer, invalid_buffer); |
63 assertEquals(module, undefined); | 63 assertEquals(module, undefined); |
64 })(); | 64 })(); |
65 | 65 |
66 (function RelationBetweenModuleAndClone() { | 66 (function RelationBetweenModuleAndClone() { |
67 let builder = new WasmModuleBuilder(); | 67 let builder = new WasmModuleBuilder(); |
68 builder.addFunction("main", kSig_i_v) | 68 builder.addFunction("main", kSig_i_v) |
69 .addBody([kExprI8Const, 42]) | 69 .addBody([kExprI32Const, 42]) |
70 .exportFunc(); | 70 .exportFunc(); |
71 | 71 |
72 var wire_bytes = builder.toBuffer(); | 72 var wire_bytes = builder.toBuffer(); |
73 var compiled_module = new WebAssembly.Module(wire_bytes); | 73 var compiled_module = new WebAssembly.Module(wire_bytes); |
74 var serialized = %SerializeWasmModule(compiled_module); | 74 var serialized = %SerializeWasmModule(compiled_module); |
75 var clone = %DeserializeWasmModule(serialized, wire_bytes); | 75 var clone = %DeserializeWasmModule(serialized, wire_bytes); |
76 | 76 |
77 assertNotNull(clone); | 77 assertNotNull(clone); |
78 assertFalse(clone == undefined); | 78 assertFalse(clone == undefined); |
79 assertFalse(clone == compiled_module); | 79 assertFalse(clone == compiled_module); |
80 assertEquals(clone.constructor, compiled_module.constructor); | 80 assertEquals(clone.constructor, compiled_module.constructor); |
81 })(); | 81 })(); |
82 | 82 |
83 (function SerializeAfterInstantiation() { | 83 (function SerializeAfterInstantiation() { |
84 let builder = new WasmModuleBuilder(); | 84 let builder = new WasmModuleBuilder(); |
85 builder.addFunction("main", kSig_i_v) | 85 builder.addFunction("main", kSig_i_v) |
86 .addBody([kExprI8Const, 42]) | 86 .addBody([kExprI32Const, 42]) |
87 .exportFunc(); | 87 .exportFunc(); |
88 | 88 |
89 var wire_bytes = builder.toBuffer() | 89 var wire_bytes = builder.toBuffer() |
90 var compiled_module = new WebAssembly.Module(wire_bytes); | 90 var compiled_module = new WebAssembly.Module(wire_bytes); |
91 var instance1 = new WebAssembly.Instance(compiled_module); | 91 var instance1 = new WebAssembly.Instance(compiled_module); |
92 var instance2 = new WebAssembly.Instance(compiled_module); | 92 var instance2 = new WebAssembly.Instance(compiled_module); |
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 |