Browse Source

* WebAssembly threads internal linker: starting working on TWasmExeOutput.SetThreadVarGlobalsInitValues

Nikolay Nikolov 1 year ago
parent
commit
334ef633a8
1 changed files with 20 additions and 0 deletions
  1. 20 0
      compiler/ogwasm.pas

+ 20 - 0
compiler/ogwasm.pas

@@ -279,6 +279,7 @@ interface
         procedure PrepareTags;
         procedure PrepareTags;
         function AddOrGetIndirectFunctionTableIndex(FuncIdx: Integer): integer;
         function AddOrGetIndirectFunctionTableIndex(FuncIdx: Integer): integer;
         procedure SetStackPointer;
         procedure SetStackPointer;
+        procedure SetThreadVarGlobalsInitValues;
         procedure GenerateCode_InitTls;
         procedure GenerateCode_InitTls;
         procedure WriteExeSectionToDynArray(exesec: TExeSection; dynarr: tdynamicarray);
         procedure WriteExeSectionToDynArray(exesec: TExeSection; dynarr: tdynamicarray);
       protected
       protected
@@ -4878,6 +4879,7 @@ implementation
           WriteName(FWasmCustomSections[cust_sec],WasmCustomSectionName[cust_sec]);
           WriteName(FWasmCustomSections[cust_sec],WasmCustomSectionName[cust_sec]);
 
 
         SetStackPointer;
         SetStackPointer;
+        SetThreadVarGlobalsInitValues;
         GenerateCode_InitTls;
         GenerateCode_InitTls;
 
 
         FFuncTypes.WriteTo(FWasmSections[wsiType]);
         FFuncTypes.WriteTo(FWasmSections[wsiType]);
@@ -5425,6 +5427,24 @@ implementation
         FStackPointerSym.LinkingData.GlobalInitializer.init_i32:=Int32(InitialStackPtrAddr);
         FStackPointerSym.LinkingData.GlobalInitializer.init_i32:=Int32(InitialStackPtrAddr);
       end;
       end;
 
 
+    procedure TWasmExeOutput.SetThreadVarGlobalsInitValues;
+      var
+        exesec: TExeSection;
+        i: Integer;
+        objsec: TWasmObjSection;
+        objsym: TWasmObjSymbol;
+      begin
+        exesec:=FindExeSection('.wasm_globals');
+        if not assigned(exesec) then
+          internalerror(2024010112);
+        for i:=0 to exesec.ObjSectionList.Count-1 do
+          begin
+            objsec:=TWasmObjSection(exesec.ObjSectionList[i]);
+            objsym:=objsec.MainFuncSymbol;
+            { TODO: implement }
+          end;
+      end;
+
     procedure TWasmExeOutput.GenerateCode_InitTls;
     procedure TWasmExeOutput.GenerateCode_InitTls;
       var
       var
         a: Byte=0;
         a: Byte=0;