[fpc-devel] Possible idea... "safe" subroutines/methods

Michael Van Canneyt michael at freepascal.org
Fri May 3 21:45:00 CEST 2019



On Fri, 3 May 2019, J. Gareth Moreton wrote:

> This is something I've been thinking about for a while, and I wonder how 
> practical it is or if it's a good idea - the ability to mark specific 
> routines as thread-safe with a directive named "safe" or "threadsafe".
>
> By telling the compiler that the procedure (or maybe a whole class) is 
> thread-safe, you are telling it that you can guarantee that any objects, 
> fields or global variables that you access are guaranteed to not 
> suddenly change mid-routine (because another thread has modified it).  
> This would allow the compiler to move commonly-accessed fields into 
> local registers or the stack for faster access, especially if the fields 
> are only read and not written, since they'll be guaranteed to contain a 
> constant value.

What about exceptions ?

Michael.


More information about the fpc-devel mailing list