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

Side by Side Diff: test/mjsunit/wasm/instantiate-module-basic.js

Issue 2395133002: Revert of [wasm] Refactor import handling for 0xC. (Closed)
Patch Set: 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/instance-gc.js ('k') | test/mjsunit/wasm/start-function.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 5 // Flags: --expose-wasm
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 let kReturnValue = 117; 10 let kReturnValue = 117;
11 11
12 let buffer = (() => { 12 let buffer = (() => {
13 let builder = new WasmModuleBuilder(); 13 let builder = new WasmModuleBuilder();
14 builder.addMemory(1, 1, true); 14 builder.addMemory(1, 1, true);
15 builder.addFunction("main", kSig_i_v) 15 builder.addFunction("main", kSig_i)
16 .addBody([kExprI8Const, kReturnValue]) 16 .addBody([kExprI8Const, kReturnValue])
17 .exportFunc(); 17 .exportFunc();
18 18
19 return builder.toBuffer(); 19 return builder.toBuffer();
20 })() 20 })()
21 21
22 function CheckInstance(instance) { 22 function CheckInstance(instance) {
23 assertFalse(instance === undefined); 23 assertFalse(instance === undefined);
24 assertFalse(instance === null); 24 assertFalse(instance === null);
25 assertFalse(instance === 0); 25 assertFalse(instance === 0);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 assertTrue(instance_1 != instance_2); 112 assertTrue(instance_1 != instance_2);
113 }); 113 });
114 })(); 114 })();
115 115
116 (function InstancesAreIsolatedFromEachother() { 116 (function InstancesAreIsolatedFromEachother() {
117 print("InstancesAreIsolatedFromEachother..."); 117 print("InstancesAreIsolatedFromEachother...");
118 var builder = new WasmModuleBuilder(); 118 var builder = new WasmModuleBuilder();
119 builder.addMemory(1,1, true); 119 builder.addMemory(1,1, true);
120 var kSig_v_i = makeSig([kAstI32], []); 120 var kSig_v_i = makeSig([kAstI32], []);
121 var signature = builder.addType(kSig_v_i); 121 var signature = builder.addType(kSig_v_i);
122 builder.addImport("some_value", kSig_i_v); 122 builder.addImport("some_value", kSig_i);
123 builder.addImport("writer", signature); 123 builder.addImport("writer", signature);
124 124
125 builder.addFunction("main", kSig_i_i) 125 builder.addFunction("main", kSig_i_i)
126 .addBody([ 126 .addBody([
127 kExprGetLocal, 0, 127 kExprGetLocal, 0,
128 kExprI32LoadMem, 0, 0, 128 kExprI32LoadMem, 0, 0,
129 kExprI32Const, 1, 129 kExprI32Const, 1,
130 kExprCallIndirect, signature, 130 kExprCallIndirect, signature,
131 kExprGetLocal,0, 131 kExprGetLocal,0,
132 kExprI32LoadMem,0, 0, 132 kExprI32LoadMem,0, 0,
(...skipping 29 matching lines...) Expand all
162 assertEquals(43, i1.exports.main(0)); 162 assertEquals(43, i1.exports.main(0));
163 assertEquals(1002, i2.exports.main(0)); 163 assertEquals(1002, i2.exports.main(0));
164 164
165 assertEquals(42, outval_1); 165 assertEquals(42, outval_1);
166 assertEquals(1000, outval_2); 166 assertEquals(1000, outval_2);
167 })(); 167 })();
168 168
169 (function GlobalsArePrivateToTheInstance() { 169 (function GlobalsArePrivateToTheInstance() {
170 print("GlobalsArePrivateToTheInstance..."); 170 print("GlobalsArePrivateToTheInstance...");
171 var builder = new WasmModuleBuilder(); 171 var builder = new WasmModuleBuilder();
172 builder.addGlobal(kAstI32, true); 172 builder.addGlobal(kAstI32);
173 builder.addFunction("read", kSig_i_v) 173 builder.addFunction("read", kSig_i_v)
174 .addBody([ 174 .addBody([
175 kExprGetGlobal, 0]) 175 kExprGetGlobal, 0])
176 .exportFunc(); 176 .exportFunc();
177 177
178 builder.addFunction("write", kSig_v_i) 178 builder.addFunction("write", kSig_v_i)
179 .addBody([ 179 .addBody([
180 kExprGetLocal, 0, 180 kExprGetLocal, 0,
181 kExprSetGlobal, 0]) 181 kExprSetGlobal, 0])
182 .exportFunc(); 182 .exportFunc();
183 183
184 var module = new WebAssembly.Module(builder.toBuffer()); 184 var module = new WebAssembly.Module(builder.toBuffer());
185 var i1 = new WebAssembly.Instance(module); 185 var i1 = new WebAssembly.Instance(module);
186 var i2 = new WebAssembly.Instance(module); 186 var i2 = new WebAssembly.Instance(module);
187 i1.exports.write(1); 187 i1.exports.write(1);
188 i2.exports.write(2); 188 i2.exports.write(2);
189 assertEquals(1, i1.exports.read()); 189 assertEquals(1, i1.exports.read());
190 assertEquals(2, i2.exports.read()); 190 assertEquals(2, i2.exports.read());
191 })(); 191 })();
192 192
193 193
194 (function InstanceMemoryIsIsolated() { 194 (function InstanceMemoryIsIsolated() {
195 print("InstanceMemoryIsIsolated..."); 195 print("InstanceMemoryIsIsolated...");
196 var builder = new WasmModuleBuilder(); 196 var builder = new WasmModuleBuilder();
197 builder.addMemory(1,1, true); 197 builder.addMemory(1,1, true);
198 198
199 builder.addFunction("f", kSig_i_v) 199 builder.addFunction("f", kSig_i)
200 .addBody([ 200 .addBody([
201 kExprI32Const, 0, 201 kExprI32Const, 0,
202 kExprI32LoadMem, 0, 0 202 kExprI32LoadMem, 0, 0
203 ]).exportFunc(); 203 ]).exportFunc();
204 204
205 var mem_1 = new ArrayBuffer(65536); 205 var mem_1 = new ArrayBuffer(65536);
206 var mem_2 = new ArrayBuffer(65536); 206 var mem_2 = new ArrayBuffer(65536);
207 var view_1 = new Int32Array(mem_1); 207 var view_1 = new Int32Array(mem_1);
208 var view_2 = new Int32Array(mem_2); 208 var view_2 = new Int32Array(mem_2);
209 view_1[0] = 1; 209 view_1[0] = 1;
210 view_2[0] = 1000; 210 view_2[0] = 1000;
211 211
212 var module = new WebAssembly.Module(builder.toBuffer()); 212 var module = new WebAssembly.Module(builder.toBuffer());
213 var i1 = new WebAssembly.Instance(module, null, mem_1); 213 var i1 = new WebAssembly.Instance(module, null, mem_1);
214 var i2 = new WebAssembly.Instance(module, null, mem_2); 214 var i2 = new WebAssembly.Instance(module, null, mem_2);
215 215
216 assertEquals(1, i1.exports.f()); 216 assertEquals(1, i1.exports.f());
217 assertEquals(1000, i2.exports.f()); 217 assertEquals(1000, i2.exports.f());
218 })(); 218 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/instance-gc.js ('k') | test/mjsunit/wasm/start-function.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698