瀏覽代碼

+ WebAssembly internal linker: take into account the min heap size (specified
with the $M directive), when determining FMinMemoryPages

Nikolay Nikolov 1 年之前
父節點
當前提交
bf78823e60
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      compiler/ogwasm.pas

+ 5 - 1
compiler/ogwasm.pas

@@ -5499,13 +5499,17 @@ implementation
       end;
 
     procedure TWasmExeOutput.SetStackPointer;
+      const
+        PageSize = 65536;
       var
         BssSec: TExeSection;
         StackStart, InitialStackPtrAddr: QWord;
       begin
         BssSec:=FindExeSection('.bss');
         InitialStackPtrAddr := (BssSec.MemPos+BssSec.Size+stacksize+15) and (not 15);
-        FMinMemoryPages := (InitialStackPtrAddr+65535) shr 16;
+        FMinMemoryPages := Max(
+          QWord(Align(QWord(InitialStackPtrAddr),QWord(PageSize)) div PageSize),
+          QWord(Align(QWord(heapsize),QWord(PageSize)) div PageSize));
         FStackPointerSym.LinkingData.GlobalInitializer.init_i32:=Int32(InitialStackPtrAddr);
       end;