Andy’s Blog and Tools

Syndicate content
Delphi, C++Builder and other thoughts
Updated: 34 min 39 sec ago

IDE Fix Pack 6.2

Thu, 01/25/2018 - 11:32

Delphi 10.2 Tokyo changed how the files for units that are explicitly specified in the project file (dpr/dpk) are found. The IDE Fix Pack’s directory file search cache still made assumptions that were correct in Delphi 2009-10.1 Seattle but aren’t in Tokyo. This could result in an “program or unit xxx recursively uses itself” error messages if you had a relative path in the filename that is specified in the project file.

This release also adds another option to the compiler codegen optimizations. The new -x-orc / -x-orc=n option allows you to eliminate temporary record copies for functions like “begin Result := FRedirect.GetRecord; end;”. This optimization allows the compiler to skip the try/finally block with InitializeRecord/CopyRecord/FinalizeRecord calls for the temporary record variable that is then copied to the actual result record.

  • Fixed: Directory search cache failed if project units had “..\” in it (Delphi 10.2 only)
  • Fixed: Some VirtualProtect calls specified nil as last argument what Windows 10 1709 doesn’t like if a debugger is attached.
  • Added: Option -x-orc and -x-orc=n to remove temporary record variables for function results (n=1: only if the assignment is the last statement, n=2 for all)

Download:

Name IDE Version File Size Downloads Added IDE Fix Pack 6.2 2009 (UP4) IDEFixPack2009Reg62.7z 189.91 KB 31 times 2018-01-25 IDE Fix Pack 6.2 2010 (UP5) IDEFixPack2010Reg62.7z 186.64 KB 39 times 2018-01-25 IDE Fix Pack 6.2 XE (UP1) IDEFixPackXEReg62.7z 173.99 KB 41 times 2018-01-25 IDE Fix Pack 6.2 XE2 (UP4+HF1) IDEFixPackXE2Reg62.7z 259.6 KB 47 times 2018-01-25 IDE Fix Pack 6.2 XE3 (UP2) IDEFixPackXE3Reg62.7z 213.96 KB 26 times 2018-01-25 IDE Fix Pack 6.2 XE4 (UP1) IDEFixPackXE4Reg62.7z 216.45 KB 26 times 2018-01-25 IDE Fix Pack 6.2 XE5 (UP2) IDEFixPackXE5Reg62.7z 213.86 KB 28 times 2018-01-25 IDE Fix Pack 6.2 XE6 (UP1) IDEFixPackXE6Reg62.7z 374.48 KB 27 times 2018-01-25 IDE Fix Pack 6.2 XE7 (UP1) IDEFixPackXE7Reg62.7z 391.04 KB 41 times 2018-01-25 IDE Fix Pack 6.2 XE8 (UP1) IDEFixPackXE8Reg62.7z 389.48 KB 29 times 2018-01-25 IDE Fix Pack 6.2 10 Seattle (RTM/UP1) IDEFixPackD10Reg62.7z 397.96 KB 54 times 2018-01-25 IDE Fix Pack 6.2 10.1 Berlin IDEFixPackD101Reg62.7z 396.17 KB 97 times 2018-01-25 IDE Fix Pack 6.2 10.2 (RTM/UP1/UP2) IDEFixPackD102Reg62.7z 397.04 KB 315 times 2018-01-25

Download (fastdcc for the command line compiler):

Name IDE Version File Size Downloads Added fastdcc 6.2 2009 (UP4) fastdcc2009v62.7z 83.87 KB 14 times 2018-01-25 fastdcc 6.2 2010 (UP5) fastdcc2010v62.7z 91.24 KB 13 times 2018-01-25 fastdcc 6.2 XE (UP1) fastdccXEv62.7z 92.96 KB 19 times 2018-01-25 fastdcc 6.2 XE2 (UP4+HF1) fastdccXE2v62.7z 130.93 KB 19 times 2018-01-25 fastdcc 6.2 XE3 (UP2) fastdccXE3v62.7z 139.67 KB 13 times 2018-01-25 fastdcc 6.2 XE4 (UP1) fastdccXE4v62.7z 142.06 KB 11 times 2018-01-25 fastdcc 6.2 XE5 (UP2) fastdccXE5v62.7z 141 KB 12 times 2018-01-25 fastdcc 6.2 XE6 (UP1) fastdccXE6v62.7z 187.93 KB 12 times 2018-01-25 fastdcc 6.2 XE7 (UP1) fastdccXE7v62.7z 202.69 KB 18 times 2018-01-25 fastdcc 6.2 XE8 (UP1) fastdccXE8v62.7z 202.58 KB 14 times 2018-01-25 fastdcc 6.2 10 Seattle (RTM/UP1) fastdccD10v62.7z 202.74 KB 19 times 2018-01-25 fastdcc 6.2 10.1 Berlin fastdccD101v62.7z 202.48 KB 28 times 2018-01-25 fastdcc 6.2 10.2 (RTM/UP1/UP2) fastdccD102v62.7z 202.34 KB 71 times 2018-01-25
Categories: News, Blogs, and Tips

IDE Fix Pack 6.1.2 (supports Delphi 10.2.2)

Thu, 12/14/2017 - 15:11

A small update for IDE Fix Pack that adds support for the just released Delphi 10.2.2.

  • Added: Support for Delphi 10.2 Update 2
  • Added: Fix for unnecessary temporary variable if an empty open array argument is part of a function call (Delphi 2009-10.1)

Download:

Name IDE Version File Size Downloads Added IDE Fix Pack 6.2 2009 (UP4) IDEFixPack2009Reg62.7z 189.91 KB 31 times 2018-01-25 IDE Fix Pack 6.2 2010 (UP5) IDEFixPack2010Reg62.7z 186.64 KB 39 times 2018-01-25 IDE Fix Pack 6.2 XE (UP1) IDEFixPackXEReg62.7z 173.99 KB 41 times 2018-01-25 IDE Fix Pack 6.2 XE2 (UP4+HF1) IDEFixPackXE2Reg62.7z 259.6 KB 47 times 2018-01-25 IDE Fix Pack 6.2 XE3 (UP2) IDEFixPackXE3Reg62.7z 213.96 KB 26 times 2018-01-25 IDE Fix Pack 6.2 XE4 (UP1) IDEFixPackXE4Reg62.7z 216.45 KB 26 times 2018-01-25 IDE Fix Pack 6.2 XE5 (UP2) IDEFixPackXE5Reg62.7z 213.86 KB 28 times 2018-01-25 IDE Fix Pack 6.2 XE6 (UP1) IDEFixPackXE6Reg62.7z 374.48 KB 27 times 2018-01-25 IDE Fix Pack 6.2 XE7 (UP1) IDEFixPackXE7Reg62.7z 391.04 KB 41 times 2018-01-25 IDE Fix Pack 6.2 XE8 (UP1) IDEFixPackXE8Reg62.7z 389.48 KB 29 times 2018-01-25 IDE Fix Pack 6.2 10 Seattle (RTM/UP1) IDEFixPackD10Reg62.7z 397.96 KB 54 times 2018-01-25 IDE Fix Pack 6.2 10.1 Berlin IDEFixPackD101Reg62.7z 396.17 KB 97 times 2018-01-25 IDE Fix Pack 6.2 10.2 (RTM/UP1/UP2) IDEFixPackD102Reg62.7z 397.04 KB 315 times 2018-01-25

Download (fastdcc for the command line compiler):

Name IDE Version File Size Downloads Added fastdcc 6.2 2009 (UP4) fastdcc2009v62.7z 83.87 KB 14 times 2018-01-25 fastdcc 6.2 2010 (UP5) fastdcc2010v62.7z 91.24 KB 13 times 2018-01-25 fastdcc 6.2 XE (UP1) fastdccXEv62.7z 92.96 KB 19 times 2018-01-25 fastdcc 6.2 XE2 (UP4+HF1) fastdccXE2v62.7z 130.93 KB 19 times 2018-01-25 fastdcc 6.2 XE3 (UP2) fastdccXE3v62.7z 139.67 KB 13 times 2018-01-25 fastdcc 6.2 XE4 (UP1) fastdccXE4v62.7z 142.06 KB 11 times 2018-01-25 fastdcc 6.2 XE5 (UP2) fastdccXE5v62.7z 141 KB 12 times 2018-01-25 fastdcc 6.2 XE6 (UP1) fastdccXE6v62.7z 187.93 KB 12 times 2018-01-25 fastdcc 6.2 XE7 (UP1) fastdccXE7v62.7z 202.69 KB 18 times 2018-01-25 fastdcc 6.2 XE8 (UP1) fastdccXE8v62.7z 202.58 KB 14 times 2018-01-25 fastdcc 6.2 10 Seattle (RTM/UP1) fastdccD10v62.7z 202.74 KB 19 times 2018-01-25 fastdcc 6.2 10.1 Berlin fastdccD101v62.7z 202.48 KB 28 times 2018-01-25 fastdcc 6.2 10.2 (RTM/UP1/UP2) fastdccD102v62.7z 202.34 KB 71 times 2018-01-25
Categories: News, Blogs, and Tips

Technical the same but different generated code

Tue, 10/31/2017 - 02:12

While debugging the String4D code to hunt down a bug in the CompilerSpeedPack, I saw a lot of CopyRecord/FinalizeRecord calls with a try/finally that the compiler generated.

If you have a record with managed fields (string, interface, …) and use it as a function return type the Delphi compiler will change the function into a procedure with an extra var-parameter. So you would think that the compiler treats the result-parameter like a normal var-parameter, but that isn’t the case. The compiler will generate code that guarantees that the result record isn’t changed if the called function throws an exception. For this is adds a temporary record that is used for the function result and then copies it to the target record.

type TMyRec = record Value: string; end; function InternalGetRec: TMyRec; begin Result.Value := 'Hello'; end; function GetRec: TMyRec; begin Result := InternalGetRec; end; procedure Test; var R: TMyRec; begin R := GetRec; end;

The compiler rewrites the “Test” function to:

procedure Test; var R, TempR: TMyRec; begin try GetRec(TempR); CopyRecord(TempR, R, TypeInfo(TMyRec)); finally FinalizeArray([TempR, R], TypeInfo(TMyRec)); end; end;

The same happens if you assign another function’s record result value to your own record result value. The compiler rewrites the “GetRec” function’s code to:

function GetRec: TMyRec; var TempResult: TMyRec; begin try InternalGetRec(TempResult); CopyRecord(TempResult, Result, TypeInfo(TMyRec)); finally FinalizeRecord(TempRecord, TypeInfo(TMyRec)); end; end;

Because the compiler assumes that you may want to use “Result” in the function after the call, it has to guarantee that it is unchanged if an exception is thrown. But if it is the last statement in the function and not secured by an explicit try/finally/except where “Result” is used again, an optimization could be to omit the temporary record, making the code a lot faster.

Categories: News, Blogs, and Tips

IDE Fix Pack 6.1 released

Sun, 10/29/2017 - 09:36

With the release of IDE Fix Pack 6.1, the Compiler Speed Pack not only makes the compiler compile faster but it can now also change the generated code, something that IDE Fix Pack has never done before. For this, new command line compiler options are introduced. They all start with “-x” (eXtension) followed by the Compiler Speed Pack option (-x-ff -x-fdi -x-fvs -x-fpr) and if you want to use them from the command line compiler you need to use fastdcc32/fastdcc64.
You can specify these options in the “Project/Options…” dialog under “Delphi Compiler/Compiling/Additional options to pass to the compiler”. You may need to rebuild the project to see an effect as only then the compiler will generate new code.

Windows 10 Creators Update 1703 caused issues with all Delphi programs, libraries and packages because it changed how Windows loads imported DLLs in such a way that it causes performance issues and can crash the debugger. Delphi 10.2 Tokyo Update 2 fixed this by not producing multiple dll import sections for one DLL anymore. IDE Fix Pack 6.1 implements that “feature” for all previous Delphi versions (2009-10.1 Berlin) and extends it to not only eliminate duplicate dll imports but also duplicate delay dll imports.
This patch changes the generated binary, the Win32 and Win64 compiler outputs, and it can be disabled by using the new “-x-fdi-“ option.

The next patch that changes the Win32 code generator is the “fast floating point” option that C++Builder users may know from the “bcc32.exe -ff” option. It removes all “fwait” instructions that the compiler usually emits after floating point operations. Removing “fwait” may cause FPU exceptions to be thrown at the wrong source code line.
This option is disabled by default and can be enabled by specifying the new option “-x-ff”.

When calling virtual methods through an interface the Win32 Delphi compiler has to route that call through a helper function that translates the interface reference into an object reference and calls the virtual method. For this helper the compiler uses the XCHG instruction that has an implicit CPU LOCK.
The new “-x-fvs” / “-x-fvs=1” option replaces the XCHG instruction with an alternative code and if the called virtual function doesn’t use the ECX register for the 3rd parameter, it generates a direct jump into the virtual method.
The “-x-fvs=2” option replaces the XCHG and uses ECX if available but if ECX is not available it keeps the CPU’s “return stack cache” valid by replacing the RET with a JMP instructions. For this it uses stack memory below ESP.

For some functions that meet special conditions the Win32 compiler emits stack frame code that fills the stack with zeros to clear variables with managed types. If there are too many of those the compiler uses a loop and the XCHG instruction to restore the ECX register that is used as the loop counter.
The option “-x-fpr” replaces the XCHG with an alternative code.

 

Changelog:

  • Added: Option -x-ff to enable “fast floating point” (like Borland C++’s -ff command line option)
  • Added: Option -x-fvs and -x-fvs=n to enable fast interface virtual stub (n=1: replace XCHG, n=2: keep the CPU’s return stack buffer in order)
  • Added: Option -x-fpr to remove XCHG from the function prolog code.
  • Added: DLL import table section folding and duplicate name/ordinal elimination, also for delay dll imports
  • Changed: Split “Compiler64.X86″ patch into multiple smaller patches and removed the “Compiler64.X86” patch name
  • Changed: EditorFocusFix now skips the SetActiveWindow call if the mainform (undocked) is not the active window

Download:

Name IDE Version File Size Downloads Added IDE Fix Pack 6.2 2009 (UP4) IDEFixPack2009Reg62.7z 189.91 KB 31 times 2018-01-25 IDE Fix Pack 6.2 2010 (UP5) IDEFixPack2010Reg62.7z 186.64 KB 39 times 2018-01-25 IDE Fix Pack 6.2 XE (UP1) IDEFixPackXEReg62.7z 173.99 KB 41 times 2018-01-25 IDE Fix Pack 6.2 XE2 (UP4+HF1) IDEFixPackXE2Reg62.7z 259.6 KB 47 times 2018-01-25 IDE Fix Pack 6.2 XE3 (UP2) IDEFixPackXE3Reg62.7z 213.96 KB 26 times 2018-01-25 IDE Fix Pack 6.2 XE4 (UP1) IDEFixPackXE4Reg62.7z 216.45 KB 26 times 2018-01-25 IDE Fix Pack 6.2 XE5 (UP2) IDEFixPackXE5Reg62.7z 213.86 KB 28 times 2018-01-25 IDE Fix Pack 6.2 XE6 (UP1) IDEFixPackXE6Reg62.7z 374.48 KB 27 times 2018-01-25 IDE Fix Pack 6.2 XE7 (UP1) IDEFixPackXE7Reg62.7z 391.04 KB 41 times 2018-01-25 IDE Fix Pack 6.2 XE8 (UP1) IDEFixPackXE8Reg62.7z 389.48 KB 29 times 2018-01-25 IDE Fix Pack 6.2 10 Seattle (RTM/UP1) IDEFixPackD10Reg62.7z 397.96 KB 54 times 2018-01-25 IDE Fix Pack 6.2 10.1 Berlin IDEFixPackD101Reg62.7z 396.17 KB 97 times 2018-01-25 IDE Fix Pack 6.2 10.2 (RTM/UP1/UP2) IDEFixPackD102Reg62.7z 397.04 KB 315 times 2018-01-25

Download (fastdcc):

Name IDE Version File Size Downloads Added fastdcc 6.2 2009 (UP4) fastdcc2009v62.7z 83.87 KB 14 times 2018-01-25 fastdcc 6.2 2010 (UP5) fastdcc2010v62.7z 91.24 KB 13 times 2018-01-25 fastdcc 6.2 XE (UP1) fastdccXEv62.7z 92.96 KB 19 times 2018-01-25 fastdcc 6.2 XE2 (UP4+HF1) fastdccXE2v62.7z 130.93 KB 19 times 2018-01-25 fastdcc 6.2 XE3 (UP2) fastdccXE3v62.7z 139.67 KB 13 times 2018-01-25 fastdcc 6.2 XE4 (UP1) fastdccXE4v62.7z 142.06 KB 11 times 2018-01-25 fastdcc 6.2 XE5 (UP2) fastdccXE5v62.7z 141 KB 12 times 2018-01-25 fastdcc 6.2 XE6 (UP1) fastdccXE6v62.7z 187.93 KB 12 times 2018-01-25 fastdcc 6.2 XE7 (UP1) fastdccXE7v62.7z 202.69 KB 18 times 2018-01-25 fastdcc 6.2 XE8 (UP1) fastdccXE8v62.7z 202.58 KB 14 times 2018-01-25 fastdcc 6.2 10 Seattle (RTM/UP1) fastdccD10v62.7z 202.74 KB 19 times 2018-01-25 fastdcc 6.2 10.1 Berlin fastdccD101v62.7z 202.48 KB 28 times 2018-01-25 fastdcc 6.2 10.2 (RTM/UP1/UP2) fastdccD102v62.7z 202.34 KB 71 times 2018-01-25
Categories: News, Blogs, and Tips