From 2aa5c437c730cc9407285a83e4b802f17626d2e2 Mon Sep 17 00:00:00 2001 From: dcode Date: Fri, 11 Jan 2019 21:54:59 +0100 Subject: [PATCH] Properly set up memory if memoryBase is specified even if there are no static segments, fixes #414 --- src/compiler.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/compiler.ts b/src/compiler.ts index c381c9d6..3e020df2 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -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,