RFR: 8230877: Rename THREAD_LOCAL_DECL to thread_local

David Holmes david.holmes at oracle.com
Wed Sep 11 23:46:18 UTC 2019


Hi Kim,

On 12/09/2019 9:34 am, Kim Barrett wrote:
>> On Sep 11, 2019, at 6:58 PM, David Holmes <david.holmes at oracle.com> wrote:
>>
>> Hi Per,
>>
>> So if I read this right, the renaming will cause the C++11 thread_local to be used always on Windows (due to our use of VS 2017) but for Solaris Studio and gcc it will only be enabled if we explicitly ask for C++11 support - is that right?
>>
>> I see Windows Visual Studio and Solaris Studio clearly state the equivalence of the two mechanisms. I'm expecting gcc is the same, but I don't see that clearly stated.
> 
> Well, bleh!  Thanks for making me look into that...

:) If it wasn't for the unconditional use of thread_local in Visual 
Studio I wouldn't have dived deeper either.

> The release notes for gcc4.8 [1] (where thread_local support was added)
> describes an important performance difference between thread_local and
> __thread, and mentions a compiler option to remove that difference under
> some circumstances.  It also suggests that because of this, one may want to
> stick with __thread where it's still applicable.  (An initializer for a
> __thread variable must be a constant expression. [3])
> 
> The gcc9.2 manual [2] (latest) describes the relevant option
> (-fno-extern-tls-init). Maybe we can use that, but it puts some non-standard
> (and well hidden) restrictions on our use of thread_local, which somewhat
> defeats the point.
> 
> [1] https://gcc.gnu.org/gcc-4.8/changes.html
> [2] https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/C_002b_002b-Dialect-Options.html#index-fextern-tls-init
> [3] https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Thread-Local.html#Thread-Local
> 
> Retracting my "Looks good”.  Fooey!

But as we are not actually enabling this as we don't turn on C++11, 
surely this still "looks good" enough? But we will have to look closer 
at things before turning it on? We may need to clarify our own rules for 
using thread-locals if we find there is a performance hit and we want to 
use the magic flag.

David

> 


More information about the hotspot-dev mailing list