Encode section lengths with unsigned LEB128

This commit is contained in:
2026-03-15 20:03:47 +00:00
parent 3a103c46d1
commit 6784cd02b4

4
asm.js
View File

@@ -1327,7 +1327,9 @@ export class Assembler {
];
const sections = template.map(([ code, generator ]) => {
const body = generator();
return body == null ? [] : [ code, body.length, body ];
if (body == null)
return [];
return [ code, this.uleb128(body.length), body ];
});
return new Uint8Array([ HEADER, sections ].flat(Infinity));