Browse Source

+ keep track whether a structured type has fields with management operators (or fields that in turn have fields with management operators and so on) and store that in the PPU to speed up compilation again
* adjusted PPUdump for this

git-svn-id: trunk@39709 -

svenbarth 7 years ago
parent
commit
600ed6701e
2 changed files with 21 additions and 3 deletions
  1. 14 0
      compiler/symtable.pas
  2. 7 3
      compiler/utils/ppuutils/ppudump.pp

+ 14 - 0
compiler/symtable.pas

@@ -110,6 +110,7 @@ interface
           padalignment : shortint;   { size to a multiple of which the symtable has to be rounded up }
           padalignment : shortint;   { size to a multiple of which the symtable has to be rounded up }
           recordalignmin,            { local equivalents of global settings, so that records can }
           recordalignmin,            { local equivalents of global settings, so that records can }
           maxCrecordalign: shortint; { be created with custom settings internally }
           maxCrecordalign: shortint; { be created with custom settings internally }
+          has_fields_with_mop : tmanagementoperators; { whether any of the fields has the need for a management operator (or one of the field's fields) }
           constructor create(const n:string;usealign,recordminalign,recordmaxCalign:shortint);
           constructor create(const n:string;usealign,recordminalign,recordmaxCalign:shortint);
           destructor destroy;override;
           destructor destroy;override;
           procedure ppuload(ppufile:tcompilerppufile);override;
           procedure ppuload(ppufile:tcompilerppufile);override;
@@ -1204,6 +1205,7 @@ implementation
         recordalignmin:=shortint(ppufile.getbyte);
         recordalignmin:=shortint(ppufile.getbyte);
         if (usefieldalignment=C_alignment) then
         if (usefieldalignment=C_alignment) then
           fieldalignment:=shortint(ppufile.getbyte);
           fieldalignment:=shortint(ppufile.getbyte);
+        ppufile.getsmallset(has_fields_with_mop);
         inherited ppuload(ppufile);
         inherited ppuload(ppufile);
       end;
       end;
 
 
@@ -1221,6 +1223,10 @@ implementation
          ppufile.putbyte(byte(recordalignmin));
          ppufile.putbyte(byte(recordalignmin));
          if (usefieldalignment=C_alignment) then
          if (usefieldalignment=C_alignment) then
            ppufile.putbyte(byte(fieldalignment));
            ppufile.putbyte(byte(fieldalignment));
+         { it's not really a "symtableoption", but loading this from the record
+           def requires storing the set in the recorddef at least between
+           ppuload and deref/derefimpl }
+         ppufile.putsmallset(has_fields_with_mop);
          ppufile.writeentry(ibrecsymtableoptions);
          ppufile.writeentry(ibrecsymtableoptions);
 
 
          inherited ppuwrite(ppufile);
          inherited ppuwrite(ppufile);
@@ -1284,6 +1290,11 @@ implementation
         sym.visibility:=vis;
         sym.visibility:=vis;
         { this symbol can't be loaded to a register }
         { this symbol can't be loaded to a register }
         sym.varregable:=vr_none;
         sym.varregable:=vr_none;
+        { management operators }
+        if sym.vardef.typ in [recorddef,objectdef] then
+          has_fields_with_mop:=has_fields_with_mop + tabstractrecordsymtable(tabstractrecorddef(sym.vardef).symtable).has_fields_with_mop;
+        if sym.vardef.typ=recorddef then
+          has_fields_with_mop:=has_fields_with_mop + trecordsymtable(trecorddef(sym.vardef).symtable).managementoperators;
         { Calculate field offset }
         { Calculate field offset }
         l:=sym.getsize;
         l:=sym.getsize;
         vardef:=sym.vardef;
         vardef:=sym.vardef;
@@ -1684,6 +1695,9 @@ implementation
           internalerror(2018082301);
           internalerror(2018082301);
         if mop=mop_none then
         if mop=mop_none then
           exit;
           exit;
+        if not (mop in has_fields_with_mop) then
+          { none of the fields or one of the field's fields has the requested operator }
+          exit;
         if not assigned(mop_list[mop]) then
         if not assigned(mop_list[mop]) then
           begin
           begin
             mop_list[mop]:=tfplist.create;
             mop_list[mop]:=tfplist.create;

+ 7 - 3
compiler/utils/ppuutils/ppudump.pp

@@ -654,6 +654,8 @@ end;
                              Read Routines
                              Read Routines
 ****************************************************************************}
 ****************************************************************************}
 
 
+function readmanagementoperatoroptions(const space : string;const name : string):tmanagementoperators;forward;
+
 procedure readrecsymtableoptions;
 procedure readrecsymtableoptions;
 var
 var
   usefieldalignment : shortint;
   usefieldalignment : shortint;
@@ -669,6 +671,7 @@ begin
   writeln([space,' recordalignmin: ',shortint(ppufile.getbyte)]);
   writeln([space,' recordalignmin: ',shortint(ppufile.getbyte)]);
   if (usefieldalignment=C_alignment) then
   if (usefieldalignment=C_alignment) then
     writeln([space,' fieldalignment: ',shortint(ppufile.getbyte)]);
     writeln([space,' fieldalignment: ',shortint(ppufile.getbyte)]);
+  readmanagementoperatoroptions(space,'Fields have MOPs');
 end;
 end;
 
 
 procedure readsymtableoptions(const s: string);
 procedure readsymtableoptions(const s: string);
@@ -2330,7 +2333,7 @@ end;
 
 
 
 
 
 
-function readmanagementoperatoroptions(const space : string):tmanagementoperators;
+function readmanagementoperatoroptions(const space : string;const name : string):tmanagementoperators;
 { type is in unit symconst }
 { type is in unit symconst }
 { Management operator options
 { Management operator options
   tmanagementoperator=(
   tmanagementoperator=(
@@ -2366,7 +2369,8 @@ begin
          if first then
          if first then
            begin
            begin
              write(space);
              write(space);
-             write('Management operators: ');
+             write(name);
+             write(': ');
              first:=false;
              first:=false;
            end
            end
          else
          else
@@ -3360,7 +3364,7 @@ begin
                  objdef.Size:=getasizeint;
                  objdef.Size:=getasizeint;
                  writeln([space,'         DataSize : ',objdef.Size]);
                  writeln([space,'         DataSize : ',objdef.Size]);
                  writeln([space,'      PaddingSize : ',getword]);
                  writeln([space,'      PaddingSize : ',getword]);
-                 readmanagementoperatoroptions(space);
+                 readmanagementoperatoroptions(space,'Management operators');
                end;
                end;
              {read the record definitions and symbols}
              {read the record definitions and symbols}
              if not(df_copied_def in current_defoptions) then
              if not(df_copied_def in current_defoptions) then