RFR: 8225035: Thread stack size issue caused by large TLS size
Andrew Haley
aph at redhat.com
Wed Jun 12 14:23:49 UTC 2019
On 6/12/19 2:42 PM, Thomas Stüfe wrote:
> What is "static tls", __thread variables? As opposed to what, dynamic tls?
> Would that be Posix TLS (pthread_setspecific and friends)? Are the
> implementations different? If they are, which TLS does this patch address?
Yes, this is __thread variables. It's nothing to do with
pthread_key_create.
The crucial distinction here is position-independent code. If an
executable which uses __thread variables is compiled non-PIC a special
(and fast) code sequence is generated. This means that the __thread
variables are allocated at a simple offset from a base
pointer. Dynamic TLS is more complicated, but much more flexible.
So, there is "dynamic TLS" and "static TLS". Dynamic TLS is used by
PIC-compiled libraries.
For this code:
__thread int boof;
int *barf() {
return &boof;
}
static TLS:
barf:
.LFB0:
.cfi_startproc
movq %fs:0, %rax
addq $boof at tpoff, %rax
ret
dynamic TLS:
barf:
subq $8, %rsp
.byte 0x66
leaq boof at tlsgd(%rip), %rdi
.value 0x6666
rex64
call __tls_get_addr at PLT
addq $8, %rsp
ret
All of this stuff gets patched by the runtime linker.
--
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the hotspot-runtime-dev
mailing list