Enable thread statics for collectible classes (#19944)
authorJan Vorlicek <janvorli@microsoft.com>
Thu, 4 Oct 2018 08:26:06 +0000 (10:26 +0200)
committerGitHub <noreply@github.com>
Thu, 4 Oct 2018 08:26:06 +0000 (10:26 +0200)
commit7559844bbe9e4230217a9a9cf4be8a857531c8c8
treec1ad22769c0091396307d555a5959ecdc0dfed31
parent11832401739148f1f1e9419cb51180ba5263a41b
Enable thread statics for collectible classes (#19944)

* Enable thread statics for collectible classes

This change removes checks that were preventing usage of thread statics
in collectible classes and also implements all the necessary changes.
The handles that hold arrays with thread statics are allocated from
LoaderAllocator for collectible classes instead of using the global
strong handle like in the case of non-collectible classes.
The change very much mimics what is done for regular statics.

This change also adds ability to reuse freed handles to the
LoaderAllocator handle table. Freed handle indexes are stored into a
stack and when a new handle allocation is requested, the indices from
this stack are used first.
Due to the code path from which the FreeTLM that in turn frees the
handles is called, I had to modify the critical section flags and also
refactor the handle allocation so that the actual managed array
representing the handle table is allocated out of the critical section.
When I was touching the code, I have also moved the code that was
dealing with handles that are not stored in the LoaderAllocator handle
tables out of the critical section, since there is no point in having it
inside of it.
13 files changed:
src/vm/ceeload.cpp
src/vm/generics.cpp
src/vm/jithelpers.cpp
src/vm/loaderallocator.cpp
src/vm/loaderallocator.hpp
src/vm/loaderallocator.inl
src/vm/methodtable.cpp
src/vm/methodtablebuilder.cpp
src/vm/threads.cpp
src/vm/threads.h
src/vm/threadstatics.cpp
src/vm/threadstatics.h
src/vm/typedesc.cpp