Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: test/mjsunit/wasm/compiled-module-serialization.js

Issue 2460773003: [wasm] make WebAssembly.Instance require a WebAssembly.Memory (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-js.cc ('k') | test/mjsunit/wasm/instantiate-module-basic.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 })();
OLDNEW
« no previous file with comments | « src/wasm/wasm-js.cc ('k') | test/mjsunit/wasm/instantiate-module-basic.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698