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

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

Issue 2454503005: [wasm] Support for restricted table imports. (Closed)
Patch Set: Fix GC stress issue; tables weren't being reset correctly 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 | « test/mjsunit/wasm/indirect-tables.js ('k') | test/unittests/wasm/module-decoder-unittest.cc » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 // Used for encoding f32 and double constants to bits. 5 // Used for encoding f32 and double constants to bits.
6 let __buffer = new ArrayBuffer(8); 6 let __buffer = new ArrayBuffer(8);
7 let byte_view = new Int8Array(__buffer); 7 let byte_view = new Int8Array(__buffer);
8 let f32_view = new Float32Array(__buffer); 8 let f32_view = new Float32Array(__buffer);
9 let f64_view = new Float64Array(__buffer); 9 let f64_view = new Float64Array(__buffer);
10 10
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 return this.num_imported_globals++; 197 return this.num_imported_globals++;
198 } 198 }
199 199
200 addImportedMemory(module, name, initial = 0, maximum) { 200 addImportedMemory(module, name, initial = 0, maximum) {
201 let o = {module: module, name: name, kind: kExternalMemory, 201 let o = {module: module, name: name, kind: kExternalMemory,
202 initial: initial, maximum: maximum}; 202 initial: initial, maximum: maximum};
203 this.imports.push(o); 203 this.imports.push(o);
204 return this; 204 return this;
205 } 205 }
206 206
207 addImportedTable(module, name, initial, maximum) {
208 let o = {module: module, name: name, kind: kExternalTable, initial: initial,
209 maximum: maximum};
210 this.imports.push(o);
211 }
212
207 addExport(name, index) { 213 addExport(name, index) {
208 this.exports.push({name: name, kind: kExternalFunction, index: index}); 214 this.exports.push({name: name, kind: kExternalFunction, index: index});
209 return this; 215 return this;
210 } 216 }
211 217
212 addExportOfKind(name, kind, index) { 218 addExportOfKind(name, kind, index) {
213 this.exports.push({name: name, kind: kind, index: index}); 219 this.exports.push({name: name, kind: kind, index: index});
214 return this; 220 return this;
215 } 221 }
216 222
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 if (imp.kind == kExternalFunction) { 288 if (imp.kind == kExternalFunction) {
283 section.emit_u32v(imp.type); 289 section.emit_u32v(imp.type);
284 } else if (imp.kind == kExternalGlobal) { 290 } else if (imp.kind == kExternalGlobal) {
285 section.emit_u32v(imp.type); 291 section.emit_u32v(imp.type);
286 section.emit_u8(imp.mutable); 292 section.emit_u8(imp.mutable);
287 } else if (imp.kind == kExternalMemory) { 293 } else if (imp.kind == kExternalMemory) {
288 var has_max = (typeof imp.maximum) != "undefined"; 294 var has_max = (typeof imp.maximum) != "undefined";
289 section.emit_u8(has_max ? 1 : 0); // flags 295 section.emit_u8(has_max ? 1 : 0); // flags
290 section.emit_u32v(imp.initial); // initial 296 section.emit_u32v(imp.initial); // initial
291 if (has_max) section.emit_u32v(imp.maximum); // maximum 297 if (has_max) section.emit_u32v(imp.maximum); // maximum
298 } else if (imp.kind == kExternalTable) {
299 section.emit_u8(kWasmAnyFunctionTypeForm);
300 var has_max = (typeof imp.maximum) != "undefined";
301 section.emit_u8(has_max ? 1 : 0); // flags
302 section.emit_u32v(imp.initial); // initial
303 if (has_max) section.emit_u32v(imp.maximum); // maximum
292 } else { 304 } else {
293 throw new Error("unknown/unsupported import kind " + imp.kind); 305 throw new Error("unknown/unsupported import kind " + imp.kind);
294 } 306 }
295 } 307 }
296 }); 308 });
297 } 309 }
298 310
299 // Add functions declarations 311 // Add functions declarations
300 let has_names = false; 312 let has_names = false;
301 let names = false; 313 let names = false;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 } 545 }
534 return buffer; 546 return buffer;
535 } 547 }
536 548
537 instantiate(...args) { 549 instantiate(...args) {
538 let module = new WebAssembly.Module(this.toBuffer()); 550 let module = new WebAssembly.Module(this.toBuffer());
539 let instance = new WebAssembly.Instance(module, ...args); 551 let instance = new WebAssembly.Instance(module, ...args);
540 return instance; 552 return instance;
541 } 553 }
542 } 554 }
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/indirect-tables.js ('k') | test/unittests/wasm/module-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698