[runtime] Refactor and unify tls access
authorVlad Brezae <brezaevlad@gmail.com>
Thu, 10 Nov 2016 22:24:51 +0000 (00:24 +0200)
committerVlad Brezae <brezaevlad@gmail.com>
Wed, 14 Dec 2016 15:52:49 +0000 (17:52 +0200)
commit7f76306f79a62af3b6466c43558ff2de448d815c
tree0901c5cb7a9d87ffb3b156064aa863d692bd7e04
parent0b8670e8fbbb1d03cc0b879f288f45cb25572a93
[runtime] Refactor and unify tls access

The purpose of this commit is to unify tls access across all platforms. We had tls information spread out throughout the entire code which was guarded with many defines/capabilities which made very hard to follow what was going on. Also this made switching between pthread and __thread very unstable since there were a lot of dependencies between different pieces of the tls infrastructure. Also it was not very clear what happens if one of the tls pieces failed.

Now we are moving all the tls variables to a single module that provides getters/setters and initialization API. Runtime code now knows that we can always access a tls variable (from managed code, we just do a nowrapper icall into the same global geters/setters). Even though we used to these type of calls all around before, it is worth mentioning that runtime should account for a thread to be in this type of unregistered code without m2n wrapper and no register jinfo.

On average this makes common tls intensive methods (m2n wrappers and managed allocator) 20% slower, with potential for more regression if we use tls getters/setters recklessly. As a consequence we will re-enable the most important pieces of fast tls code in the future.
63 files changed:
libgc/pthread_support.c
mono/metadata/boehm-gc.c
mono/metadata/domain.c
mono/metadata/object-internals.h
mono/metadata/runtime.c
mono/metadata/sgen-client-mono.h
mono/metadata/sgen-mono.c
mono/metadata/threads-types.h
mono/metadata/threads.c
mono/mini/Makefile.am.in
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/cpu-arm.md
mono/mini/cpu-ia64.md
mono/mini/cpu-mips.md
mono/mini/cpu-ppc.md
mono/mini/cpu-ppc64.md
mono/mini/cpu-s390x.md
mono/mini/exceptions-amd64.c
mono/mini/exceptions-arm.c
mono/mini/exceptions-arm64.c
mono/mini/exceptions-mips.c
mono/mini/exceptions-ppc.c
mono/mini/exceptions-s390x.c
mono/mini/exceptions-x86.c
mono/mini/ir-emit.h
mono/mini/jit-icalls.c
mono/mini/method-to-ir.c
mono/mini/mini-amd64.c
mono/mini/mini-amd64.h
mono/mini/mini-arm-tls.S [deleted file]
mono/mini/mini-arm-tls.h [deleted file]
mono/mini/mini-arm.c
mono/mini/mini-arm.h
mono/mini/mini-arm64.h
mono/mini/mini-exceptions.c
mono/mini/mini-gc.c
mono/mini/mini-ia64.c
mono/mini/mini-llvm.c
mono/mini/mini-mips.c
mono/mini/mini-posix.c
mono/mini/mini-ppc.c
mono/mini/mini-runtime.c
mono/mini/mini-s390x.c
mono/mini/mini-s390x.h
mono/mini/mini-trampolines.c
mono/mini/mini-windows.c
mono/mini/mini-x86.c
mono/mini/mini-x86.h
mono/mini/mini.c
mono/mini/mini.h
mono/mini/patch-info.h
mono/mini/tasklets.c
mono/mini/tramp-amd64.c
mono/mini/tramp-arm.c
mono/mini/tramp-arm64.c
mono/mini/tramp-s390x.c
mono/mini/tramp-x86.c
mono/sgen/sgen-alloc.c
mono/utils/mono-compiler.h
mono/utils/mono-threads.c
mono/utils/mono-tls.c
mono/utils/mono-tls.h