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

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

Issue 2296993002: [wasm] mjsunit support for I32 globals and test (Closed)
Patch Set: formatting Created 4 years, 4 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/instantiate-module-basic.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 fecd164b56b00430af074f7f55da9b586484f259..f0cf9d18d3570a5a6e161074f738609ff6d208b1 100644
--- a/test/mjsunit/wasm/wasm-module-builder.js
+++ b/test/mjsunit/wasm/wasm-module-builder.js
@@ -104,6 +104,7 @@ class WasmModuleBuilder {
constructor() {
this.types = [];
this.imports = [];
+ this.globals = [];
this.functions = [];
this.exports = [];
this.table = [];
@@ -138,6 +139,11 @@ class WasmModuleBuilder {
return this.types.length - 1;
}
+ addGlobal(local_type) {
+ this.globals.push(local_type);
+ return this.globals.length - 1;
+ }
+
addFunction(name, type) {
let type_index = (typeof type) == "number" ? type : this.addType(type);
let func = new WasmFunctionBuilder(name, type_index);
@@ -192,6 +198,18 @@ class WasmModuleBuilder {
});
}
+ if (wasm.globals.length > 0) {
+ if (debug) print ("emitting globals @ " + binary.length);
+ binary.emit_section(kDeclGlobals, section => {
+ section.emit_varint(wasm.globals.length);
+ for (let global_type of wasm.globals) {
+ section.emit_varint(0); // length of global name
+ section.emit_u8(global_type);
+ section.emit_u8(false); // we do not support exported globals
+ }
+ });
+ }
+
// Add imports section
if (wasm.imports.length > 0) {
if (debug) print("emitting imports @ " + binary.length);
« no previous file with comments | « test/mjsunit/wasm/instantiate-module-basic.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698