Recent

Author Topic: Compiler Generated Temporary Interface References  (Read 3979 times)

Coxy

  • New Member
  • *
  • Posts: 32
Re: Compiler Generated Temporary Interface References
« Reply #15 on: January 28, 2021, 10:55:26 am »
As I said before, I'm just trying to improve the compiler for developers.

Code: Pascal  [Select][+][-]
  1. Some compilers deallocate temps quickly, which is something that dates back to old (16-bit) compilers, to keep pressure of the limited stack. (and keep in mind that with old static (short)string types that was more deeply felt. A recursive procedure with two by-value shortstring parameters and some local variables could run out of 16-bits worth of stack space rather quickly)
  2.  
  3. Some let them linger longer because it is more efficient to do it all at once, usually at the end of the method. ABI rules also play a role.

Removed  [It seems the compiler is reducing determinism for developers at the cost of efficiency.]

NEW *** It seems the compiler is increasing efficiency at the cost of reducing determinism for developers. ***

As a side note, Delphi doesn't seem to exhibit this behaviour, if I compile in {$mode delphi} what should I expect in terms of compatibility of execution?
« Last Edit: January 28, 2021, 10:59:07 am by Coxy »

PascalDragon

  • Hero Member
  • *****
  • Posts: 3310
  • Compiler Developer
Re: Compiler Generated Temporary Interface References
« Reply #16 on: January 28, 2021, 01:35:24 pm »
As a side note, Delphi doesn't seem to exhibit this behaviour, if I compile in {$mode delphi} what should I expect in terms of compatibility of execution?

We only provide compatibility for documented behaviour. The point of release of temporary variables is not documented in the Delphi documentation thus we don't provide compatibility here.

Coxy

  • New Member
  • *
  • Posts: 32
Re: Compiler Generated Temporary Interface References
« Reply #17 on: January 28, 2021, 03:11:49 pm »
I've created a bug report for this

id: 0038415

I'll post back the outcome.

Coxy

  • New Member
  • *
  • Posts: 32
Re: Compiler Generated Temporary Interface References
« Reply #18 on: January 28, 2021, 06:59:56 pm »
Apparently this has been raised as an issue before, earliest one being id: 9472 back in 2007, now having Resolution of "won't fix"!

My bug report, id: 38415, has therefore been flagged as "resolved".

I have suggested compiler emitting a warning of temporary interface reference use so application developers can be aware of them and, if needed, explicitly create temporary variables themselves negating compilers need for them.

nanobit

  • Full Member
  • ***
  • Posts: 112
Re: Compiler Generated Temporary Interface References
« Reply #19 on: January 28, 2021, 07:36:13 pm »
Very recently the LCL was hit by such temp-ref issue:
https://bugs.freepascal.org/view.php?id=36151

Sequence in TCustomFormEditor.deleteComponent():
1) (AForm as INonFormDesigner).LookupRoot := nil; // new temp ref
2) call to PropertyEditorHook.PersistentDeleted; contains
some very hidden Application.ProcessMessages which destroys objects
3) release of temp ref at method-end (crash in destructor)
« Last Edit: January 28, 2021, 07:43:20 pm by nanobit »

Coxy

  • New Member
  • *
  • Posts: 32
Re: Compiler Generated Temporary Interface References
« Reply #20 on: January 28, 2021, 09:46:46 pm »
Quote
Very recently the LCL was hit by such temp-ref issue:
https://bugs.freepascal.org/view.php?id=36151

Well hopefully as more application problems relating to this issue arise the devs will consider modifying compiler functionality.

Documented behaviour does not necessarily equate to usability.

 

TinyPortal © 2005-2018