<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>A good question. I did already partially answer it:</p>
<p>"For reasons of safety, the compiler should probably not consider
values thread-safe across the boundary of a try...except or a
try...finally block, not because of the risk of another thread
modifying it, but because an interrupt might, caused by an
exception."</p>
<p>When it comes to just reading non-local values, this will pose no
problem, since if control is returned to the procedure, it will be
in the except block and then the code that follows... different
blocks. If the non-local value is written to prior to the
exception though, then it becomes a bit more complicated - one
can't just write back to the global storage prior to an
exception-prone call because that would be both hard to detect and
very inefficient.</p>
<p>The safe answer would be that using local storage should only
apply to non-local values that are only read, not written to.
Extending it to modifying non-local values would require deeper
research at best.<br>
</p>
<p>Gareth aka. Kit<br>
</p>
<div class="moz-cite-prefix">On 03/05/2019 20:45, Michael Van
Canneyt wrote:<br>
</div>
<blockquote type="cite"
cite="mid:alpine.DEB.2.20.1905032144110.14610@home.telenet.be">
<br>
<br>
On Fri, 3 May 2019, J. Gareth Moreton wrote:
<br>
<br>
<blockquote type="cite">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".
<br>
<br>
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.
<br>
</blockquote>
<br>
What about exceptions ?
<br>
<br>
Michael.<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br />
<table style="border-top: 1px solid #D3D4DE;">
<tr>
<td style="width: 55px; padding-top: 13px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
<td style="width: 470px; padding-top: 12px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a>
</td>
</tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>