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

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

Issue 2403823002: [wasm] Base address for data segments can also be the value of a global variable. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/wasm/test-wasm-module-builder.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 c432756207eb5d482ec22bbeb5b59dea98c931f8..df6007b67a73f9c55ddcf6f08af2f803f1cf0a69 100644
--- a/test/mjsunit/wasm/wasm-module-builder.js
+++ b/test/mjsunit/wasm/wasm-module-builder.js
@@ -199,8 +199,8 @@ class WasmModuleBuilder {
this.imports.push(o);
}
- addDataSegment(addr, data, init) {
- this.segments.push({addr: addr, data: data, init: init});
+ addDataSegment(addr, data, is_global = false) {
+ this.segments.push({addr: addr, data: data, is_global: is_global});
return this.segments.length - 1;
}
@@ -444,8 +444,15 @@ class WasmModuleBuilder {
section.emit_u32v(wasm.segments.length);
for (let seg of wasm.segments) {
section.emit_u8(0); // linear memory index 0
- section.emit_u8(kExprI32Const);
- section.emit_u32v(seg.addr);
+ if (seg.is_global) {
+ // initializer is a global variable
+ section.emit_u8(kExprGetGlobal);
+ section.emit_u32v(seg.addr);
+ } else {
+ // initializer is a constant
+ section.emit_u8(kExprI32Const);
+ section.emit_u32v(seg.addr);
+ }
section.emit_u8(kExprEnd);
section.emit_u32v(seg.data.length);
section.emit_bytes(seg.data);
« no previous file with comments | « test/mjsunit/wasm/test-wasm-module-builder.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698