Browse Source

* WebAssembly threads internal linker: generate data.drop instructions in
TWasmExeOutput.GenerateCode_InitSharedMemory. This drops the passive memory
segments, after the memory has been initialized.

Nikolay Nikolov 1 year ago
parent
commit
dfe60b53d1
1 changed files with 12 additions and 1 deletions
  1. 12 1
      compiler/ogwasm.pas

+ 12 - 1
compiler/ogwasm.pas

@@ -5655,7 +5655,18 @@ implementation
         Sec.writeUInt8($1A);
         { end }
         Sec.writeUInt8($0B);
-        { TODO: data.drop }
+        DataSecIdx:=-1;
+        for DataSecName in DataSections do
+          begin
+            ExeSec:=FindExeSection(DataSecName);
+            if Assigned(ExeSec) and (ExeSec.Size>0) then
+              begin
+                Inc(DataSecIdx);
+                { data.drop $DataSecIdx }
+                Sec.writeUInt16BE($fc09);
+                WriteUleb5(sec,DataSecIdx);
+              end;
+          end;
         { end }
         Sec.writeUInt8($0B);
       end;