Stream: git-wasmtime

Topic: wasmtime / issue #3130 Support TLS in cranelift_jit


view this post on Zulip Wasmtime GitHub notifications bot (Jul 29 2021 at 20:49):

bjorn3 opened issue #3130:

Feature

See issue title.

Benefit

Required by cg_clif's jit mode.

Implementation

Give every defined jit tls variable a globally unique id using a global atomic counter. Next define a single native TLS variable inside cranelift_jit. This TLS variable points to a vec of pointers indexed by the previously mentioned globally unique id. Require the elf_tls_gd tls model and forward __tls_get_addr to a function of cranelift_jit that looks up the tls variable address using the native tls variable and initializes the tls variable if necessary.

This implementation method doesn't allow importing native tls variables, supporting native tls requires support from libc and rust never exports tls variables directly anyway. thread_local! wraps it in a function call.

Alternatives

Add a bunch of special cases in cg_clif to use a different tls declaration method when in jit mode and implement this proposal in cg_clif itself. This increases complexity and reduces reusability.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2021 at 21:21):

akirilov-arm labeled issue #3130:

Feature

See issue title.

Benefit

Required by cg_clif's jit mode.

Implementation

Give every defined jit tls variable a globally unique id using a global atomic counter. Next define a single native TLS variable inside cranelift_jit. This TLS variable points to a vec of pointers indexed by the previously mentioned globally unique id. Require the elf_tls_gd tls model and forward __tls_get_addr to a function of cranelift_jit that looks up the tls variable address using the native tls variable and initializes the tls variable if necessary.

This implementation method doesn't allow importing native tls variables, supporting native tls requires support from libc and rust never exports tls variables directly anyway. thread_local! wraps it in a function call.

Alternatives

Add a bunch of special cases in cg_clif to use a different tls declaration method when in jit mode and implement this proposal in cg_clif itself. This increases complexity and reduces reusability.


Last updated: Nov 22 2024 at 16:03 UTC