Quellcode durchsuchen

* automatically create omf libraries with the smallest page size possible. This
greatly reduces the size of i8086 snapshots by keeping the amount of padding
in the library files to the minimum.

git-svn-id: trunk@39195 -

nickysn vor 7 Jahren
Ursprung
Commit
3f5577077a
1 geänderte Dateien mit 16 neuen und 2 gelöschten Zeilen
  1. 16 2
      compiler/owomflib.pas

+ 16 - 2
compiler/owomflib.pas

@@ -78,6 +78,7 @@ type
     procedure WriteHeader(DictStart: DWord; DictBlocks: Word);
     procedure WriteHeader(DictStart: DWord; DictBlocks: Word);
     procedure WriteFooter;
     procedure WriteFooter;
     function TryPageSize(aPageSize: Integer): Boolean;
     function TryPageSize(aPageSize: Integer): Boolean;
+    procedure DeterminePageSize;
     procedure WriteLib;
     procedure WriteLib;
     function WriteDictionary: Word;
     function WriteDictionary: Word;
     function TryWriteDictionaryWithSize(nblocks: Word): Boolean;
     function TryWriteDictionaryWithSize(nblocks: Word): Boolean;
@@ -185,7 +186,7 @@ implementation
 
 
     constructor TOmfLibObjectWriter.createAr(const Aarfn: string);
     constructor TOmfLibObjectWriter.createAr(const Aarfn: string);
       begin
       begin
-        createAr(Aarfn,512);
+        createAr(Aarfn,-1);
       end;
       end;
 
 
     constructor TOmfLibObjectWriter.createAr(const Aarfn: string;PageSize: Integer);
     constructor TOmfLibObjectWriter.createAr(const Aarfn: string;PageSize: Integer);
@@ -319,6 +320,19 @@ implementation
         Result:=True;
         Result:=True;
       end;
       end;
 
 
+    procedure TOmfLibObjectWriter.DeterminePageSize;
+      var
+        I: Integer;
+      begin
+        if (FPageSize<>-1) and TryPageSize(FPageSize) then
+          { success }
+          exit;
+        for I:=4 to 15 do
+          if TryPageSize(1 shl I) then
+            exit;
+        internalerror(2018060703);
+      end;
+
     procedure TOmfLibObjectWriter.WriteLib;
     procedure TOmfLibObjectWriter.WriteLib;
       var
       var
         libf: TCCustomFileStream;
         libf: TCCustomFileStream;
@@ -327,7 +341,7 @@ implementation
         I: Integer;
         I: Integer;
         buf: array [0..1023] of Byte;
         buf: array [0..1023] of Byte;
       begin
       begin
-        TryPageSize(512);
+        DeterminePageSize;
         libf:=CFileStreamClass.Create(FLibName,fmCreate);
         libf:=CFileStreamClass.Create(FLibName,fmCreate);
         if CStreamError<>0 then
         if CStreamError<>0 then
           begin
           begin