Re: pthread impl detection
Re: pthread impl detection
- Subject: Re: pthread impl detection
- From: Eric Albert <email@hidden>
- Date: Mon, 20 Dec 2004 21:39:24 -0800
On Dec 20, 2004, at 7:26 AM, Paolo Molaro wrote:
In order to speedup access to thread local variables in
the code generated by the mono JIT, I'd like to inline
the code sequence directly instead of calling pthread_getspecific ().
Of course I know this is risky, since the implementation could change,
You're treading in very dangerous territory here. As you've noticed,
the kernel fills out __pthread_getspecific. It does so by including
the best implementation for the specific hardware in use. Short of
copying out that code at app launch and using it, you're likely to end
up with a worse implementation for various systems than the current
code. And while copying out that code at app launch may seem tempting,
even that is dangerous if the location of __pthread_getspecific changes
in the future.
Dump of assembler code for function pthread_getspecific:
0x90001de0 <pthread_getspecific+0>: li r4,72
0x90001de4 <pthread_getspecific+4>: ba 0xffff82c0
<__pthread_getspecific>
Dump of assembler code for function __pthread_getspecific:
0xffff82c0 <__pthread_getspecific+0>: nop
0xffff82c4 <__pthread_getspecific+4>: .long 0x0
0xffff82c8 <__pthread_getspecific+8>: .long 0x0
0xffff82cc <__pthread_getspecific+12>: .long 0x0
[...]
I'm not sure how you got that output, but here's what I get when I
debug Safari on my PowerBook running 10.3.6:
Breakpoint 1, 0x90001de0 in pthread_getspecific ()
(gdb) x /2i $pc
0x90001de0 <pthread_getspecific>: li r4,72
0x90001de4 <pthread_getspecific+4>: ba 0xffff82c0
<__pthread_getspecific>
(gdb) si 2
0xffff82c0 in __pthread_getspecific ()
(gdb) x /6i $pc
0xffff82c0 <__pthread_getspecific>: rlwinm r5,r3,2,0,29
0xffff82c4 <__pthread_getspecific+4>: li r0,32754
0xffff82c8 <__pthread_getspecific+8>: sc
0xffff82cc <__pthread_getspecific+12>: add r5,r5,r4
0xffff82d0 <__pthread_getspecific+16>: lwzx r3,r3,r5
0xffff82d4 <__pthread_getspecific+20>: blr
-Eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden