Browse Source

* packed column writing/reading for token recorder, reduces size of fgl.ppu by approx. 10%

git-svn-id: trunk@17512 -
florian 14 năm trước cách đây
mục cha
commit
d19d8de8fe
3 tập tin đã thay đổi với 87 bổ sung59 xóa
  1. 1 1
      compiler/ppu.pas
  2. 53 31
      compiler/scanner.pas
  3. 33 27
      compiler/utils/ppudump.pp

+ 1 - 1
compiler/ppu.pas

@@ -43,7 +43,7 @@ type
 {$endif Test_Double_checksum}
 {$endif Test_Double_checksum}
 
 
 const
 const
-  CurrentPPUVersion = 129;
+  CurrentPPUVersion = 130;
 
 
 { buffer sizes }
 { buffer sizes }
   maxentrysize = 1024;
   maxentrysize = 1024;

+ 53 - 31
compiler/scanner.pas

@@ -2080,6 +2080,7 @@ In case not, the value returned can be arbitrary.
         t : ttoken;
         t : ttoken;
         s : tspecialgenerictoken;
         s : tspecialgenerictoken;
         len : sizeint;
         len : sizeint;
+        b : byte;
       begin
       begin
         if not assigned(recordtokenbuf) then
         if not assigned(recordtokenbuf) then
           internalerror(200511176);
           internalerror(200511176);
@@ -2108,8 +2109,17 @@ In case not, the value returned can be arbitrary.
           begin
           begin
             s:=ST_COLUMN;
             s:=ST_COLUMN;
             writetoken(t);
             writetoken(t);
-            recordtokenbuf.write(s,1);
-            recordtokenbuf.write(current_tokenpos.column,sizeof(current_tokenpos.column));
+            { can the column be written packed? }
+            if current_tokenpos.column<$80 then
+              begin
+                b:=$80 or current_tokenpos.column;
+                recordtokenbuf.write(b,1);
+              end
+            else
+              begin
+                recordtokenbuf.write(s,1);
+                recordtokenbuf.write(current_tokenpos.column,sizeof(current_tokenpos.column));
+              end;
             last_filepos.column:=current_tokenpos.column;
             last_filepos.column:=current_tokenpos.column;
           end;
           end;
         if current_tokenpos.fileindex<>last_filepos.fileindex then
         if current_tokenpos.fileindex<>last_filepos.fileindex then
@@ -2258,45 +2268,57 @@ In case not, the value returned can be arbitrary.
             _GENERICSPECIALTOKEN:
             _GENERICSPECIALTOKEN:
               begin
               begin
                 replaytokenbuf.read(specialtoken,1);
                 replaytokenbuf.read(specialtoken,1);
-                case specialtoken of
-                  ST_LOADSETTINGS:
-                    replaytokenbuf.read(current_settings,sizeof(current_settings));
-                  ST_LINE:
-                    begin
-                      replaytokenbuf.read(current_tokenpos.line,sizeof(current_tokenpos.line));
+                { packed column? }
+                if (ord(specialtoken) and $80)<>0 then
+                  begin
+                      current_tokenpos.column:=ord(specialtoken) and $7f;
 
 
                       { don't generate invalid line info if no sources are available for the current module }
                       { don't generate invalid line info if no sources are available for the current module }
                       if not(get_module(current_filepos.moduleindex).sources_avail) then
                       if not(get_module(current_filepos.moduleindex).sources_avail) then
-                        current_tokenpos.line:=0;
+                        current_tokenpos.column:=0;
 
 
                       current_filepos:=current_tokenpos;
                       current_filepos:=current_tokenpos;
-                    end;
-                  ST_COLUMN:
-                    begin
-                      replaytokenbuf.read(current_tokenpos.column,sizeof(current_tokenpos.column));
+                  end
+                else
+                  case specialtoken of
+                    ST_LOADSETTINGS:
+                      replaytokenbuf.read(current_settings,sizeof(current_settings));
+                    ST_LINE:
+                      begin
+                        replaytokenbuf.read(current_tokenpos.line,sizeof(current_tokenpos.line));
 
 
-                      { don't generate invalid line info if no sources are available for the current module }
-                      if not(get_module(current_filepos.moduleindex).sources_avail) then
-                        current_tokenpos.column:=0;
+                        { don't generate invalid line info if no sources are available for the current module }
+                        if not(get_module(current_filepos.moduleindex).sources_avail) then
+                          current_tokenpos.line:=0;
 
 
-                      current_filepos:=current_tokenpos;
-                    end;
-                  ST_FILEINDEX:
-                    begin
-                      replaytokenbuf.read(current_tokenpos.fileindex,sizeof(current_tokenpos.fileindex));
+                        current_filepos:=current_tokenpos;
+                      end;
+                    ST_COLUMN:
+                      begin
+                        replaytokenbuf.read(current_tokenpos.column,sizeof(current_tokenpos.column));
 
 
-                      { don't generate invalid line info if no sources are available for the current module }
-                      if not(get_module(current_filepos.moduleindex).sources_avail) then
-                        begin
+                        { don't generate invalid line info if no sources are available for the current module }
+                        if not(get_module(current_filepos.moduleindex).sources_avail) then
                           current_tokenpos.column:=0;
                           current_tokenpos.column:=0;
-                          current_tokenpos.line:=0;
-                        end;
 
 
-                      current_filepos:=current_tokenpos;
-                    end;
-                  else
-                    internalerror(2006103010);
-                end;
+                        current_filepos:=current_tokenpos;
+                      end;
+                    ST_FILEINDEX:
+                      begin
+                        replaytokenbuf.read(current_tokenpos.fileindex,sizeof(current_tokenpos.fileindex));
+
+                        { don't generate invalid line info if no sources are available for the current module }
+                        if not(get_module(current_filepos.moduleindex).sources_avail) then
+                          begin
+                            current_tokenpos.column:=0;
+                            current_tokenpos.line:=0;
+                          end;
+
+                        current_filepos:=current_tokenpos;
+                      end;
+                    else
+                      internalerror(2006103010);
+                  end;
                 continue;
                 continue;
               end;
               end;
           end;
           end;

+ 33 - 27
compiler/utils/ppudump.pp

@@ -1081,32 +1081,38 @@ begin
               end;
               end;
             _GENERICSPECIALTOKEN:
             _GENERICSPECIALTOKEN:
               begin
               begin
-                case tspecialgenerictoken(tokenbuf[i]) of
-                  ST_LOADSETTINGS:
-                    begin
-                      inc(i);
-                      write('Settings');
-                      inc(i,sizeof(tsettings));
-                    end;
-                  ST_LINE:
-                    begin
-                      inc(i);
-                      write('Line: ',pdword(@tokenbuf[i])^);
-                      inc(i,4);
-                    end;
-                  ST_COLUMN:
-                    begin
-                      inc(i);
-                      write('Col: ',pword(@tokenbuf[i])^);
-                      inc(i,2);
-                    end;
-                  ST_FILEINDEX:
-                    begin
-                      inc(i);
-                      write('File: ',pword(@tokenbuf[i])^);
-                      inc(i,2);
-                    end;
-                end;
+                if (tokenbuf[i] and $80)<>0 then
+                  begin
+                    write('Col: ',tokenbuf[i] and $7f);
+                    inc(i);
+                  end
+                else
+                  case tspecialgenerictoken(tokenbuf[i]) of
+                    ST_LOADSETTINGS:
+                      begin
+                        inc(i);
+                        write('Settings');
+                        inc(i,sizeof(tsettings));
+                      end;
+                    ST_LINE:
+                      begin
+                        inc(i);
+                        write('Line: ',pdword(@tokenbuf[i])^);
+                        inc(i,4);
+                      end;
+                    ST_COLUMN:
+                      begin
+                        inc(i);
+                        write('Col: ',pword(@tokenbuf[i])^);
+                        inc(i,2);
+                      end;
+                    ST_FILEINDEX:
+                      begin
+                        inc(i);
+                        write('File: ',pword(@tokenbuf[i])^);
+                        inc(i,2);
+                      end;
+                  end;
               {
               {
                 replaytokenbuf.read(specialtoken,1);
                 replaytokenbuf.read(specialtoken,1);
                 case specialtoken of
                 case specialtoken of
@@ -2143,7 +2149,7 @@ begin
              readcommondef('WideString definition',defoptions);
              readcommondef('WideString definition',defoptions);
              writeln(space,'           Length : ',getlongint);
              writeln(space,'           Length : ',getlongint);
            end;
            end;
-         
+
          ibunicodestringdef :
          ibunicodestringdef :
            begin
            begin
              readcommondef('UnicodeString definition',defoptions);
              readcommondef('UnicodeString definition',defoptions);