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

Unified Diff: test/mjsunit/wasm/wasm-module-builder.js

Issue 2392943006: [wasm] Implement importing of WebAssembly.Memory. (Closed)
Patch Set: Address review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/wasm/import-memory.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/wasm-module-builder.js
diff --git a/test/mjsunit/wasm/wasm-module-builder.js b/test/mjsunit/wasm/wasm-module-builder.js
index c99ab0a64d43ed149b2ee3c0a0005a627629aa19..c432756207eb5d482ec22bbeb5b59dea98c931f8 100644
--- a/test/mjsunit/wasm/wasm-module-builder.js
+++ b/test/mjsunit/wasm/wasm-module-builder.js
@@ -194,11 +194,20 @@ class WasmModuleBuilder {
return this.num_imported_globals++;
}
+ addImportedMemory(module, name, initial = 0, maximum) {
+ let o = {module: module, name: name, kind: kExternalMemory, initial: initial, maximum: maximum};
+ this.imports.push(o);
+ }
+
addDataSegment(addr, data, init) {
this.segments.push({addr: addr, data: data, init: init});
return this.segments.length - 1;
}
+ exportMemoryAs(name) {
+ this.exports.push({name: name, kind: kExternalMemory, index: 0});
+ }
+
appendToTable(array) {
this.table.push(...array);
return this;
@@ -244,6 +253,11 @@ class WasmModuleBuilder {
} else if (imp.kind == kExternalGlobal) {
section.emit_u32v(imp.type);
section.emit_u8(imp.mutable);
+ } else if (imp.kind == kExternalMemory) {
+ var has_max = (typeof imp.maximum) != "undefined";
+ section.emit_u8(has_max ? 1 : 0); // flags
+ section.emit_u32v(imp.initial); // initial
+ if (has_max) section.emit_u32v(imp.maximum); // maximum
} else {
throw new Error("unknown/unsupported import kind " + imp.kind);
}
« no previous file with comments | « test/mjsunit/wasm/import-memory.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698