Jeroen Frijters wrote: > Andrew Haley wrote: >> It's not just static compilation: if you look at >> VMThread.currentThread() you'll probably see something like >> >> extern DWORD _Jv_ThreadKey; >> return (java::lang::Thread *) TlsGetValue(_Jv_ThreadKey); >> >> or >> >> extern pthread_key_t _Jv_ThreadKey; >> return (java::lang::Thread *) pthread_getspecific (_Jv_ThreadKey); >> >> You see my point? > > It's probably me, but taking PTHREAD_KEYS_MAX, non-conservative GC and > thread local inheritance into account makes me think that the current > approach is superior.
Why? If you're going to call pthread_getspecific() to get the current thread, you might as well call it to get the thread-local variable. That remains true regardless of GC, TL inheritance, or anything else. > Not to mention the VMs that already have Thread.currentThread() > specific optimizations. Sure, but they might as well optimize ThreadLocals while they're at it. Andrew.