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

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

Issue 1763433002: [wasm] Rework encoding of local declarations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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/wasm-constants.js ('k') | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | 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 e51d4425fdaf04ab0279a0be3c9aa08fb182f4b0..dd150018917ad795eded1cef51e3d74706bbcd8d 100644
--- a/test/mjsunit/wasm/wasm-module-builder.js
+++ b/test/mjsunit/wasm/wasm-module-builder.js
@@ -190,25 +190,46 @@ WasmModuleBuilder.prototype.toArray = function(debug) {
var hasName = func.name != undefined && func.name.length > 0;
names = names || hasName;
if (hasName) flags |= kDeclFunctionName;
- if (func.locals != undefined) flags |= kDeclFunctionLocals;
exports += func.exports.length;
emit_u8(bytes, flags);
emit_u16(bytes, func.sig_index);
- if (hasName) {
- emit_string(bytes, func.name);
+ if (hasName) emit_string(bytes, func.name);
+
+ // Function body length will be patched later.
+ var length_pos = bytes.length;
+ emit_u16(bytes, 0);
+
+ var local_decls = [];
+ var l = func.locals;
+ if (l != undefined) {
+ var local_decls_count = 0;
+ if (l.i32_count > 0) {
+ local_decls.push({count: l.i32_count, type: kAstI32});
+ }
+ if (l.i64_count > 0) {
+ local_decls.push({count: l.i64_count, type: kAstI64});
+ }
+ if (l.f32_count > 0) {
+ local_decls.push({count: l.f32_count, type: kAstF32});
+ }
+ if (l.f64_count > 0) {
+ local_decls.push({count: l.f64_count, type: kAstF64});
+ }
}
- if (func.locals != undefined) {
- emit_u16(bytes, func.locals.i32_count);
- emit_u16(bytes, func.locals.i64_count);
- emit_u16(bytes, func.locals.f32_count);
- emit_u16(bytes, func.locals.f64_count);
+ emit_u8(bytes, local_decls.length);
+ for (decl of local_decls) {
+ emit_varint(bytes, decl.count);
+ emit_u8(bytes, decl.type);
}
- emit_u16(bytes, func.body.length);
+
for (var i = 0; i < func.body.length; i++) {
emit_u8(bytes, func.body[i]);
}
+ var length = bytes.length - length_pos - 2;
+ bytes[length_pos] = length & 0xff;
+ bytes[length_pos + 1] = (length >> 8) & 0xff;
index++;
}
« no previous file with comments | « test/mjsunit/wasm/wasm-constants.js ('k') | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698