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.

Andrew.

Hi Andrew,

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. For example, I use the below to compute a static thread local's offset and it is x86 specific:

#include <stdio.h>
static __thread char *hello;
int main(int argc, char **argv) {
 int offset;
 asm ("mov [EMAIL PROTECTED], %0" : "=r"(offset));
 hello = "hello";
 printf("%p %s %d",&hello, hello, offset);
}

As the patch comes from Jikes RVM it should be no surprise we addressed solving the performance problem in a metacircular manner. I imagine DaCapo jython is a lot faster on Classpath runtimes now.


Regards,
Ian

Reply via email to