Sign in Join

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

Mailing lists / fpc-devel / 2009-04

[patch] fixes check for unused threadvars

3 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

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

Sergei Gorelkin

Hello,

Attached is a one-line fix that makes programs a couple of bytes smaller by preventing creation of empty threadvar tables when threadvars are not actually used.
The condition "Assigned(TAsmList.First)" always evaluates to True because the list contains at least one marker item.

Regards,
Sergei

Reply by email

Sergei Gorelkin
to Sergei Gorelkin
Sergei Gorelkin wrote 6 lines
Attached is a one-line fix that makes programs a couple of bytes smaller by preventing creation of empty threadvar tables when threadvars are not actually used. The condition "Assigned(TAsmList.First)" always evaluates to True because the list contains at least one marker item.

Whoops, not that easy. It appears that
Tresourcestrings.CreateResourceStringData
does not create new section in current_asmdata.asmlists[al_const] and therefore it
depends on the state in which that asmlist was left by the previously executed code. Hence, compiling a unit that does not have threadvars but has resourcestrings ends up in an IE.

Attached a corrected patch. The section prefix 'RESSTRTABLE' is my wild guess, so it may need to be changed.

Regards,
Sergei

Reply by email

Sergei Gorelkin
to Sergei Gorelkin

Sergei Gorelkin пишет:

Show quoted text 9 lines
Whoops, not that easy. It appears that Tresourcestrings.CreateResourceStringData does not create new section in current_asmdata.asmlists[al_const] and therefore it depends on the state in which that asmlist was left by the previously executed code. Hence, compiling a unit that does not have threadvars but has resourcestrings ends up in an IE.

Please don't bother applying this yet.
It looks that the harmless tweak triggeres an issue that I've spotted back in 2007: no sections are created in asmlists[al_const] at all, and everything generated there goes to the last section of the preceding asmlist, which may be .bss.
Absense of the sections also impairs the smartlinking, I guess.

This requires a proper fixing and careful testing. I'll be back with it.

Regards,
Sergei

Reply by email