Properly set up memory if memoryBase is specified even if there are no static segments, fixes #414

This commit is contained in:
dcode 2019-01-11 21:54:59 +01:00
parent 201bd5f2b1
commit 2aa5c437c7

View File

@ -392,12 +392,11 @@ export class Compiler extends DiagnosticEmitter {
);
}
// determine initial page size
var numPages = this.memorySegments.length
? i64_low(i64_shr_u(i64_align(memoryOffset, 0x10000), i64_new(16, 0)))
: 0;
// set up memory
module.setMemory(
numPages,
this.options.memoryBase /* is specified */ || this.memorySegments.length
? i64_low(i64_shr_u(i64_align(memoryOffset, 0x10000), i64_new(16, 0)))
: 0,
Module.UNLIMITED_MEMORY,
this.memorySegments,
options.target,