Forráskód Böngészése

compiler: wait for crc: clean up waitingforunit, processqueue: stop endless loop

mattias 1 hete
szülő
commit
9e54493696
4 módosított fájl, 43 hozzáadás és 36 törlés
  1. 24 19
      compiler/ctask.pas
  2. 5 5
      compiler/fppu.pas
  3. 1 1
      compiler/pgenutil.pas
  4. 13 11
      compiler/pmodules.pas

+ 24 - 19
compiler/ctask.pas

@@ -334,8 +334,22 @@ begin
   While t<>nil do
     begin
 
+    process:=cancontinue(t,firstwaiting);
+    {$IFDEF Debug_WaitCRC}
+    if firstwaiting<>nil then
+      writeln('ttask_handler.processqueue "',t.module.realmodulename^,'" state=',t.module.state,' waitingfor="',firstwaiting.realmodulename^,'",',firstwaiting.state)
+    else
+      writeln('ttask_handler.processqueue "',t.module.realmodulename^,'" state=',t.module.state,' waitingfor=nil');
+    {$ENDIF}
     if process then
       begin
+      if continue(t) then
+        begin
+        {$IFDEF DEBUG_CTASK}Writeln(t.module.ToString,' is finished, removing from task list');{$ENDIF}
+        hash.Remove(t.module);
+        list.Remove(t);
+        end;
+
       // first search for any module that is ready to be written as ppu
       t2:=list.firsttask;
       while (t2<>nil)
@@ -345,29 +359,15 @@ begin
       if t2<>nil then
         begin
         t:=t2;
-        {$IFDEF Debug_Mattias}
+        {$IFDEF Debug_WaitCRC}
         writeln('ttask_handler.processqueue FOUND CRC READY ',t.module.realmodulename^,' state=',t.module.state);
         {$ENDIF}
-        end;
-      end;
-
-    process:=cancontinue(t,firstwaiting);
-    {$IFDEF Debug_Mattias}
-    if firstwaiting<>nil then
-      writeln('ttask_handler.processqueue "',t.module.realmodulename^,'" state=',t.module.state,' waitingfor="',firstwaiting.realmodulename^,'",',firstwaiting.state)
-    else
-      writeln('ttask_handler.processqueue "',t.module.realmodulename^,'" state=',t.module.state,' waitingfor=nil');
-    {$ENDIF}
-    if process then
-      begin
-      if continue(t) then
+        end
+      else
         begin
-        {$IFDEF DEBUG_CTASK}Writeln(t.module.ToString,' is finished, removing from task list');{$ENDIF}
-        hash.Remove(t.module);
-        list.Remove(t);
+        // maybe the strategy can be improved.
+        t:=list.firsttask;
         end;
-      // maybe the strategy can be improved.
-      t:=list.firsttask;
       end
     else if assigned(firstwaiting) and cancontinue(firstwaiting,true, dummy) then
       begin
@@ -381,7 +381,12 @@ begin
       t:=t.nexttask;
       end;
     if t=nil then
+      begin
       t:=list.firsttask;
+      if t<>nil then
+        // no progress possible
+        InternalError(2025090301);
+      end;
     end;
 end;
 

+ 5 - 5
compiler/fppu.pas

@@ -893,7 +893,7 @@ var
         u: tmodule;
       begin
         { write a reference for each used unit }
-        {$IFDEF Debug_Mattias}
+        {$IFDEF Debug_WaitCRC}
         writeln('tppumodule.writeusedunit START ',realmodulename^,' intf=',intf);
         {$ENDIF}
         hp:=tused_unit(used_units.first);
@@ -906,7 +906,7 @@ var
                { the checksum should not affect the crc of this unit ! (PFV) }
                oldcrc:=ppufile.do_crc;
                ppufile.do_crc:=false;
-               {$IFDEF Debug_Mattias}
+               {$IFDEF Debug_WaitCRC}
                writeln('tppumodule.writeusedunit ',u.realmodulename^,' crc=',hexstr(u.crc,8),' interface_crc=',hexstr(u.interface_crc,8),' indirect_crc=',hexstr(u.indirect_crc,8));
                {$ENDIF}
                hp.checksum:=u.crc;
@@ -1640,7 +1640,7 @@ var
 
     procedure tppumodule.writeppu;
       begin
-        {$IFDEF Debug_Mattias}
+        {$IFDEF Debug_WaitCRC}
         writeln('tppumodule.writeppu ',realmodulename^);
         {$ENDIF}
          Message1(unit_u_ppu_write,realmodulename^);
@@ -1844,7 +1844,7 @@ var
          crc:=ppufile.crc;
          interface_crc:=ppufile.interface_crc;
          indirect_crc:=ppufile.indirect_crc;
-         {$IFDEF Debug_Mattias}
+         {$IFDEF Debug_WaitCRC}
          writeln('tppumodule.writeppu ',realmodulename^,' crc=',hexstr(crc,8));
          {$ENDIF}
 
@@ -1934,7 +1934,7 @@ var
          crc:=ppufile.crc;
          interface_crc:=ppufile.interface_crc;
          indirect_crc:=ppufile.indirect_crc;
-         {$IFDEF Debug_Mattias}
+         {$IFDEF Debug_WaitCRC}
          writeln('tppumodule.getppucrc ',realmodulename^,' crc=',hexstr(crc,8));
          {$ENDIF}
 

+ 1 - 1
compiler/pgenutil.pas

@@ -288,7 +288,7 @@ uses
         if (hmodule.state = ms_load) and hmodule.interface_compiled then
           Exit;
 
-        if not (hmodule.state in [ms_compiled_waitcrc,ms_compiled,ms_processed]) then
+        if not (hmodule.state in [ms_compiling_waitfinish,ms_compiled_waitcrc,ms_compiled,ms_processed]) then
           begin
 {$ifdef DEBUG_UNITWAITING}
             Writeln('Unit ', current_module.modulename^,

+ 13 - 11
compiler/pmodules.pas

@@ -1205,11 +1205,12 @@ type
         for i:=0 to curr.waitingunits.count-1 do
           for j:=curr.waitingforunit.count-1 downto 0 do
             if curr.waitingunits[i]=curr.waitingforunit[j] then
-              curr.waitingforunit.delete(j);
+              curr.waitingforunit.Delete(j);
 
     {$ifdef DEBUG_UNITWAITING}
-        Writeln('Units waiting for ', curr.modulename^, ': ',
-          curr.waitingforunit.Count);
+        Writeln('Unit ', curr.modulename^, ' is waiting for units: ');
+        for i:=curr.waitingforunit.count-1 downto 0 do
+          writeln('  ',i,'/',curr.waitingforunit.count,' ',tmodule(curr.waitingforunit[i]).realmodulename^);
     {$endif}
         result:=curr.waitingforunit.count=0;
 
@@ -1291,7 +1292,7 @@ type
           add_synthetic_interface_classes_for_st(curr.globalsymtable,true,false);
 
         { Our interface is compiled, generate interface CRC and switch to implementation }
-        {$IFDEF Debug_Mattias}
+        {$IFDEF Debug_WaitCRC}
         writeln('parse_unit_interface_declarations ',curr.realmodulename^);
         {$ENDIF}
         if not(cs_compilesystem in current_settings.moduleswitches) and
@@ -1750,6 +1751,13 @@ type
              create_objectfile(module);
            end;
 
+        // remove all waits for this unit
+        for i:=0 to module.waitingunits.count-1 do
+          begin
+            waitingmodule:=tmodule(module.waitingunits[i]);
+            waitingmodule.remove_from_waitingforunits(module);
+          end;
+
         // compute CRC
         if ErrorCount=0 then
           begin
@@ -1759,7 +1767,7 @@ type
               Compute the final CRC of this module, for the case of a
               circular dependency, and wait.
             }
-            {$IFDEF Debug_Mattias}
+            {$IFDEF Debug_WaitCRC}
             writeln('finish_compile_unit ',module.realmodulename^,' waiting for used unit CRCs...');
             {$ENDIF}
             tppumodule(module).getppucrc;
@@ -1866,12 +1874,6 @@ type
         module_is_done(module);
         module.end_of_parsing;
 
-        for i:=0 to module.waitingunits.count-1 do
-          begin
-            waitingmodule:=tmodule(module.waitingunits[i]);
-            waitingmodule.remove_from_waitingforunits(module);
-          end;
-
 {$ifdef DEBUG_NODE_XML}
         XMLFinalizeNodeFile('unit');
 {$endif DEBUG_NODE_XML}