Commit 7a0898c7 authored by Ben L. Titzer's avatar Ben L. Titzer Committed by Commit Bot

[wasm][test] Integrate improvements to wasm-module-builder.js from spec repo.

R=ahaas@chromium.org

Bug: 
Change-Id: Ic2331617624ce724ba33e07a1a42ebe2549f8054
Reviewed-on: https://chromium-review.googlesource.com/586547Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46903}
parent 9e02f326
......@@ -107,8 +107,8 @@ class WasmFunctionBuilder {
addBody(body) {
for (let b of body) {
if (typeof b != 'number')
throw new Error('invalid body (entries have to be numbers): ' + body);
if (typeof b !== 'number' || (b & (~0xFF)) !== 0 )
throw new Error('invalid body (entries must be 8 bit numbers): ' + body);
}
this.body = body.slice();
// Automatically add the end for the function block to the body.
......@@ -378,9 +378,10 @@ class WasmModuleBuilder {
if (debug) print("emitting memory @ " + binary.length);
binary.emit_section(kMemorySectionCode, section => {
section.emit_u8(1); // one memory entry
section.emit_u32v(kResizableMaximumFlag);
const has_max = wasm.memory.max !== undefined;
section.emit_u32v(has_max ? kResizableMaximumFlag : 0);
section.emit_u32v(wasm.memory.min);
section.emit_u32v(wasm.memory.max);
if (has_max) section.emit_u32v(wasm.memory.max);
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment