[fpc-devel] (patch) Rework of string literals codegeneration

Sergei Gorelkin sergei_gorelkin at mail.ru
Sun Aug 24 23:44:31 CEST 2008


Hello,

The attached patch contains three improvements of code generation for 
string literals:

1) Replaces linear search through assembler list by the hash lookup. 
This considerably improves performance on large projects (one example is 
winunits-jedi package, in which tcgstringconstnode.pass_generate_code 
was top #1 in calltree, consuming about 12% IRefs).

2) Enables reusing memory locations for widestring constants (and in 
general, the same approach may be used for any other type of constants).

3) Saves a sizeof(pointer) bytes per constant, by removing a location 
which points to the string. This location is necessary for the typed 
consts which may be modified, but redundant for string literals because 
the language does not allow to modify string literals in any way.

The patch may break Darwin targets - I am not sure how the assembler 
reference directives generated for Darwin should be handled, and 
unfortunately I'm unable to test it. Hope it wouldn't be much trouble to 
fix if necessary.

TFPHashList wasn't suitable for the task because of its ShortString 
limitation, therefore I introduced another container named THashSet. It 
has no indexed access, but uses arbitrary data (which it may own or 
reference, depending on the flag passed to constructor) for keys.

The patch also contains a speed improvement fix to TCmdStrList.Find.

Best regards,
Sergei
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ncon_strings.zip
Type: application/x-zip-compressed
Size: 5160 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20080825/a3477cd3/attachment.bin>


More information about the fpc-devel mailing list