Ver código fonte

+ 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 anos atrás
pai
commit
600ed6701e
2 arquivos alterados com 21 adições e 3 exclusões
  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 }
           recordalignmin,            { local equivalents of global settings, so that records can }
           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);
           destructor destroy;override;
           procedure ppuload(ppufile:tcompilerppufile);override;
@@ -1204,6 +1205,7 @@ implementation
         recordalignmin:=shortint(ppufile.getbyte);
         if (usefieldalignment=C_alignment) then
           fieldalignment:=shortint(ppufile.getbyte);
+        ppufile.getsmallset(has_fields_with_mop);
         inherited ppuload(ppufile);
       end;
 
@@ -1221,6 +1223,10 @@ implementation
          ppufile.putbyte(byte(recordalignmin));
          if (usefieldalignment=C_alignment) then
            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);
 
          inherited ppuwrite(ppufile);
@@ -1284,6 +1290,11 @@ implementation
         sym.visibility:=vis;
         { this symbol can't be loaded to a register }
         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 }
         l:=sym.getsize;
         vardef:=sym.vardef;
@@ -1684,6 +1695,9 @@ implementation
           internalerror(2018082301);
         if mop=mop_none then
           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
           begin
             mop_list[mop]:=tfplist.create;

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

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