瀏覽代碼

* WebAssembly internal linker: allow specifying the max memory size also for
binaries that don't use threads and shared memory. Unlike the shared memory
case, in this case the max memory limit is optional.

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

+ 11 - 2
compiler/ogwasm.pas

@@ -4956,8 +4956,17 @@ implementation
         if not (ts_wasm_threads in current_settings.targetswitches) then
           begin
             WriteUleb(FWasmSections[wsiMemory],1);
-            WriteByte(FWasmSections[wsiMemory],0);
-            WriteUleb(FWasmSections[wsiMemory],FMinMemoryPages);
+            if FMaxMemoryPages>=FMinMemoryPages then
+              begin
+                WriteByte(FWasmSections[wsiMemory],1);
+                WriteUleb(FWasmSections[wsiMemory],FMinMemoryPages);
+                WriteUleb(FWasmSections[wsiMemory],FMaxMemoryPages);
+              end
+            else
+              begin
+                WriteByte(FWasmSections[wsiMemory],0);
+                WriteUleb(FWasmSections[wsiMemory],FMinMemoryPages);
+              end;
           end;
 
         if ts_wasm_threads in current_settings.targetswitches then