Ian Rogers wrote: > Andrew Haley wrote: >> Andrew John Hughes wrote: >> >>> Daniel's copyright assignment is finally through, so >>> I'm committing this patch which optimises the use of >>> ThreadLocals by replacing the use of the generic java.util.WeakHashMap >>> with a ThreadLocal-specific implementation. >>> >> >> It's slightly weird to be doing this in pure Java: all POSIX- >> compatible systems have thread-local variables, and the glibc >> implementation is very fast. Still, I'm sure this patch is an >> improvement. > > I agree with what you say for static compilation. I think there's room > for improvement in the pthread interfaces for getting thread locals > especially if you want to have JIT compiled code that accesses them.
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? Andrew.