Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-08

(patch) Rework of string literals codegeneration

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sergei Gorelkin

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

Reply by email