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

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

Issue 2627763002: [wasm] JS APIs & memory (Closed)
Patch Set: Created 3 years, 11 months 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/module-decoder.cc ('k') | test/mjsunit/wasm/import-memory.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() {
11 var builder = new WasmModuleBuilder(); 11 var builder = new WasmModuleBuilder();
12 builder.addMemory(1,1, true); 12 builder.addImportedMemory("", "memory", 1,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 18 matching lines...) Expand all
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 WebAssembly.Memory({initial: 1}); 45 var mem_1 = new WebAssembly.Memory({initial: 1});
46 var view_1 = new Int32Array(mem_1.buffer); 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, {"":
52 writer: (x)=>outval_1 = x }}, mem_1); 52 {some_value: () => 1,
53 writer: (x) => outval_1 = x ,
54 memory: mem_1}
55 });
53 56
54 assertEquals(43, i1.exports.main(0)); 57 assertEquals(43, i1.exports.main(0));
55 58
56 assertEquals(42, outval_1); 59 assertEquals(42, outval_1);
57 })(); 60 })();
58 61
59 (function DeserializeInvalidObject() { 62 (function DeserializeInvalidObject() {
60 var invalid_buffer = new ArrayBuffer(10); 63 var invalid_buffer = new ArrayBuffer(10);
61 64
62 module = %DeserializeWasmModule(invalid_buffer, invalid_buffer); 65 module = %DeserializeWasmModule(invalid_buffer, invalid_buffer);
(...skipping 30 matching lines...) Expand all
93 var serialized = %SerializeWasmModule(compiled_module); 96 var serialized = %SerializeWasmModule(compiled_module);
94 var clone = %DeserializeWasmModule(serialized, wire_bytes); 97 var clone = %DeserializeWasmModule(serialized, wire_bytes);
95 98
96 assertNotNull(clone); 99 assertNotNull(clone);
97 assertFalse(clone == undefined); 100 assertFalse(clone == undefined);
98 assertFalse(clone == compiled_module); 101 assertFalse(clone == compiled_module);
99 assertEquals(clone.constructor, compiled_module.constructor); 102 assertEquals(clone.constructor, compiled_module.constructor);
100 var instance3 = new WebAssembly.Instance(clone); 103 var instance3 = new WebAssembly.Instance(clone);
101 assertFalse(instance3 == undefined); 104 assertFalse(instance3 == undefined);
102 })(); 105 })();
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | test/mjsunit/wasm/import-memory.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698