Browse Source

* Use linear mechanism to check whether function types were emitted

Michaël Van Canneyt 3 months ago
parent
commit
cc81e56eb2
2 changed files with 12 additions and 15 deletions
  1. 1 0
      compiler/fmodule.pas
  2. 11 15
      compiler/wasm32/nwasmutil.pas

+ 1 - 0
compiler/fmodule.pas

@@ -206,6 +206,7 @@ interface
         compilecount : integer;
         compilecount : integer;
         consume_semicolon_after_uses : Boolean;
         consume_semicolon_after_uses : Boolean;
         initfinalchecked : boolean;
         initfinalchecked : boolean;
+        functypechecked : boolean;
 
 
         { contains a list of types that are extended by helper types; the key is
         { contains a list of types that are extended by helper types; the key is
           the full name of the type and the data is a TFPObjectList of
           the full name of the type and the data is a TFPObjectList of

+ 11 - 15
compiler/wasm32/nwasmutil.pas

@@ -70,19 +70,16 @@ implementation
 
 
   class procedure twasmnodeutils.InsertObjectInfo;
   class procedure twasmnodeutils.InsertObjectInfo;
 
 
-    var
-      modules: TFPList;
-
-    function ModuleExists(m: tmodule): Boolean;
+      procedure resetfunctypechecked;
       var
       var
-        q: tmodule;
-      begin
-        result:=modules.IndexOf(Pointer(m))>=0;
-      end;
-
-    procedure AddModule(m: tmodule);
+        module : tmodule;
       begin
       begin
-        modules.Add(Pointer(m));
+         module:=tmodule(loaded_units.first);
+        while assigned(module) do
+          begin
+          module.functypechecked:=false;
+          module:=tmodule(module.next);
+          end;
       end;
       end;
 
 
       procedure WriteImportDll(list: TAsmList; proc: tprocdef);
       procedure WriteImportDll(list: TAsmList; proc: tprocdef);
@@ -99,9 +96,9 @@ implementation
           proc : tprocdef;
           proc : tprocdef;
           cur_unit : tused_unit;
           cur_unit : tused_unit;
         begin
         begin
-          if ModuleExists(u) then
+          if u.functypechecked then
             exit;
             exit;
-          AddModule(u);
+          u.functypechecked:=true;
 
 
           cur_unit:=tused_unit(u.used_units.First);
           cur_unit:=tused_unit(u.used_units.First);
           while assigned(cur_unit) do
           while assigned(cur_unit) do
@@ -142,7 +139,7 @@ implementation
     begin
     begin
       inherited;
       inherited;
 
 
-      modules:=TFPList.Create;
+      resetfunctypechecked;
 
 
       list:=current_asmdata.asmlists[al_start];
       list:=current_asmdata.asmlists[al_start];
 
 
@@ -185,7 +182,6 @@ implementation
         end;
         end;
       destroy_hlcodegen;
       destroy_hlcodegen;
 
 
-      modules.Free;
     end;
     end;
 
 
 begin
 begin