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

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

Issue 2636173002: [wasm] Enforce memory and table limits during instantiation. (Closed)
Patch Set: [wasm] Enforce memory and table limits during instantiation. 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 | « test/mjsunit/wasm/indirect-tables.js ('k') | test/mjsunit/wasm/module-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 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 = 17; 10 let kReturnValue = 17;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 promise.then(compiled_module => { 119 promise.then(compiled_module => {
120 let instance_1 = new WebAssembly.Instance(compiled_module); 120 let instance_1 = new WebAssembly.Instance(compiled_module);
121 let instance_2 = new WebAssembly.Instance(compiled_module); 121 let instance_2 = new WebAssembly.Instance(compiled_module);
122 assertTrue(instance_1 != instance_2); 122 assertTrue(instance_1 != instance_2);
123 }); 123 });
124 })(); 124 })();
125 125
126 (function InstancesAreIsolatedFromEachother() { 126 (function InstancesAreIsolatedFromEachother() {
127 print("InstancesAreIsolatedFromEachother..."); 127 print("InstancesAreIsolatedFromEachother...");
128 var builder = new WasmModuleBuilder(); 128 var builder = new WasmModuleBuilder();
129 builder.addImportedMemory("", "memory", 1,1); 129 builder.addImportedMemory("", "memory", 1);
130 var kSig_v_i = makeSig([kWasmI32], []); 130 var kSig_v_i = makeSig([kWasmI32], []);
131 var signature = builder.addType(kSig_v_i); 131 var signature = builder.addType(kSig_v_i);
132 builder.addImport("m", "some_value", kSig_i_v); 132 builder.addImport("m", "some_value", kSig_i_v);
133 builder.addImport("m", "writer", signature); 133 builder.addImport("m", "writer", signature);
134 134
135 builder.addFunction("main", kSig_i_i) 135 builder.addFunction("main", kSig_i_i)
136 .addBody([ 136 .addBody([
137 kExprGetLocal, 0, 137 kExprGetLocal, 0,
138 kExprI32LoadMem, 0, 0, 138 kExprI32LoadMem, 0, 0,
139 kExprI32Const, 1, 139 kExprI32Const, 1,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 i1.exports.write(1); 200 i1.exports.write(1);
201 i2.exports.write(2); 201 i2.exports.write(2);
202 assertEquals(1, i1.exports.read()); 202 assertEquals(1, i1.exports.read());
203 assertEquals(2, i2.exports.read()); 203 assertEquals(2, i2.exports.read());
204 })(); 204 })();
205 205
206 206
207 (function InstanceMemoryIsIsolated() { 207 (function InstanceMemoryIsIsolated() {
208 print("InstanceMemoryIsIsolated..."); 208 print("InstanceMemoryIsIsolated...");
209 var builder = new WasmModuleBuilder(); 209 var builder = new WasmModuleBuilder();
210 builder.addImportedMemory("", "memory", 1,1); 210 builder.addImportedMemory("", "memory", 1);
211 211
212 builder.addFunction("f", kSig_i_v) 212 builder.addFunction("f", kSig_i_v)
213 .addBody([ 213 .addBody([
214 kExprI32Const, 0, 214 kExprI32Const, 0,
215 kExprI32LoadMem, 0, 0 215 kExprI32LoadMem, 0, 0
216 ]).exportFunc(); 216 ]).exportFunc();
217 217
218 var mem_1 = new WebAssembly.Memory({initial: 1}); 218 var mem_1 = new WebAssembly.Memory({initial: 1});
219 var mem_2 = new WebAssembly.Memory({initial: 1}); 219 var mem_2 = new WebAssembly.Memory({initial: 1});
220 var view_1 = new Int32Array(mem_1.buffer); 220 var view_1 = new Int32Array(mem_1.buffer);
(...skipping 19 matching lines...) Expand all
240 240
241 241
242 assertThrows(() => new WebAssembly.Instance(module, {"":{memory:memory}}), Web Assembly.LinkError); 242 assertThrows(() => new WebAssembly.Instance(module, {"":{memory:memory}}), Web Assembly.LinkError);
243 })(); 243 })();
244 244
245 (function TestNoMemoryToExport() { 245 (function TestNoMemoryToExport() {
246 let builder = new WasmModuleBuilder(); 246 let builder = new WasmModuleBuilder();
247 builder.exportMemoryAs('memory'); 247 builder.exportMemoryAs('memory');
248 assertThrows(() => builder.instantiate(), WebAssembly.CompileError); 248 assertThrows(() => builder.instantiate(), WebAssembly.CompileError);
249 })(); 249 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/indirect-tables.js ('k') | test/mjsunit/wasm/module-memory.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698