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

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

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. Created 4 years, 2 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 | « test/mjsunit/wasm/compiled-module-management.js ('k') | test/mjsunit/wasm/debug-disassembly.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.addMemory(1,1, true);
13 var kSig_v_i = makeSig([kAstI32], []); 13 var kSig_v_i = makeSig([kAstI32], []);
14 var signature = builder.addType(kSig_v_i); 14 var signature = builder.addType(kSig_v_i);
15 builder.addImport("some_value", kSig_i); 15 builder.addImport("some_value", kSig_i);
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 kExprI32Const, 1,
21 kExprGetLocal, 0, 20 kExprGetLocal, 0,
22 kExprI32LoadMem, 0, 0, 21 kExprI32LoadMem, 0, 0,
23 kExprCallIndirect, kArity1, signature, 22 kExprI32Const, 1,
23 kExprCallIndirect, signature,
24 kExprGetLocal,0, 24 kExprGetLocal,0,
25 kExprI32LoadMem,0, 0, 25 kExprI32LoadMem,0, 0,
26 kExprCallImport, kArity0, 0, 26 kExprCallFunction, 0,
27 kExprI32Add 27 kExprI32Add
28 ]).exportFunc(); 28 ]).exportFunc();
29 29
30 // writer(mem[i]); 30 // writer(mem[i]);
31 // return mem[i] + some_value(); 31 // return mem[i] + some_value();
32 builder.addFunction("_wrap_writer", signature) 32 builder.addFunction("_wrap_writer", signature)
33 .addBody([ 33 .addBody([
34 kExprGetLocal, 0, 34 kExprGetLocal, 0,
35 kExprCallImport, kArity1, 1]); 35 kExprCallFunction, 1]);
36 builder.appendToTable([0, 1]); 36 builder.appendToTable([2, 3]);
37 37
38 38
39 var module = new WebAssembly.Module(builder.toBuffer()); 39 var module = new WebAssembly.Module(builder.toBuffer());
40 var buff = %SerializeWasmModule(module); 40 var buff = %SerializeWasmModule(module);
41 module = null; 41 module = null;
42 gc(); 42 gc();
43 module = %DeserializeWasmModule(buff); 43 module = %DeserializeWasmModule(buff);
44 44
45 var mem_1 = new ArrayBuffer(4); 45 var mem_1 = new ArrayBuffer(4);
46 var view_1 = new Int32Array(mem_1); 46 var view_1 = new Int32Array(mem_1);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 var serialized = %SerializeWasmModule(compiled_module); 91 var serialized = %SerializeWasmModule(compiled_module);
92 var clone = %DeserializeWasmModule(serialized); 92 var clone = %DeserializeWasmModule(serialized);
93 93
94 assertNotNull(clone); 94 assertNotNull(clone);
95 assertFalse(clone == undefined); 95 assertFalse(clone == undefined);
96 assertFalse(clone == compiled_module); 96 assertFalse(clone == compiled_module);
97 assertEquals(clone.constructor, compiled_module.constructor); 97 assertEquals(clone.constructor, compiled_module.constructor);
98 var instance3 = new WebAssembly.Instance(clone); 98 var instance3 = new WebAssembly.Instance(clone);
99 assertFalse(instance3 == undefined); 99 assertFalse(instance3 == undefined);
100 })(); 100 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/compiled-module-management.js ('k') | test/mjsunit/wasm/debug-disassembly.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698