-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete support for TLS RVA statics from the Jit #62131
Delete support for TLS RVA statics from the Jit #62131
Conversation
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsThis construct is not supported on .NET Core, so the code in question is dead. Deleting it frees one handle kind (which will be helpful in my future changes), and deletes one path from Fixes #4852. Part of #58312.
|
TLS RVA statics are not supported by CoreCLR, so all the support for them in the Jit is dead code.
46a009b
to
010dec1
Compare
TLS RVA statics have been used by managed C++. Are we sure that managed C++ does not use them anymore? Note that the issue #4852 filled against these tests is from 2015. The managed C++ was not supported in 2015, but it has changed since then. |
That is something for me to investigate before this would be ready for review (or closure). The first approximation here is that none of the IL tests work if I build/run them, though mysteriously enough they fail with Edit: I can get one test to run after all, but now it fails with AV. Hmm. |
MSVC's Here's what the field and data declarations for a class-static
I think the TLS RVA statics may have only ever been used by Managed C++, which is not supported on .NET 5+. Only C++/CLI is supported on .NET 5+ since it requires a recompilation using the |
I was about to write a comment on how it actually does work 😄. I tested it is with this (properly __declspec(thread) static int TlsInt = 100;
public ref class CppCliClass
{
public:
static int GetTlsStatic()
{
return TlsInt;
}
static void SetTlsStatic(int value)
{
TlsInt = value;
}
}; And it does indeed have the semantics expected of TLS, and produces inline code on x86 (not without first failing on some DEBUG-only asserts, but those are not critical): // CppCliClass:GetTlsStatic
IN0004: 000000 push ebp
IN0005: 000001 mov ebp, esp
G_M10086_IG02:
IN0001: 000003 mov eax, dword ptr FS:[0x002C]
IN0002: 000009 mov eax, dword ptr [eax+28]
IN0003: 00000C mov eax, dword ptr [eax+4]
G_M10086_IG03:
IN0006: 00000F pop ebp
IN0007: 000010 ret If you look at the |
@SingleAccretion did you make sure to force the Can you recompile with |
@jkoritzinsky the assembly excerpt is from the Jit compiling the IL for the methods, so, it should be the "real thing". The methods according to ildasm .method public hidebysig static int32 GetTlsStatic() cil managed
{
// Code size 6 (0x6)
.maxstack 1
IL_0000: ldsfld int32 '?A0xfa31f548.TlsInt'
IL_0005: ret
} // end of method CppCliClass::GetTlsStatic
.method public hidebysig static void SetTlsStatic(int32 'value') cil managed
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: stsfld int32 '?A0xfa31f548.TlsInt'
IL_0006: ret
} // end of method CppCliClass::SetTlsStatic
Let's see... |
Can you also share the IL from ildasm for the field definition? |
Just as in your case, it is disassembled as an ordinary .field static assembly int32 '?A0xfa31f548.TlsInt' at D_0000F77C
.data D_0000F77C = bytearray (
64 00 00 00) // d... |
Looks like that will not compile: |
Based on that, I'd say that the TLS support is somehow reliant on native code or native PE features. Not sure exactly how though. |
Correct. I expect that you can only hit it in mixed mode C++ CLI images. I am not sure whether ilasm can produce images that can hit it. |
That is the conclusion I came to as well. I do note that it is Jitted code that gets run, not some kind of native stub, I have verified that by modifying the compiler (making it import the fields in question as constants). With ilasm-produced images, while they do contain the The C++/CLI-produced images cause the index to be properly initialized, and the code produced for them is functional, on x86. On all other platforms, it crashes as the helper path is not implemented, and the Jit generates (Side note: ildasm does not see the So it appears we have this somewhat functioning on x86 for some C++/CLI code, and as such the Jit code needs to be kept. Should we keep the tests though? They will not work unless we somehow fix the TLS index situation (which I imagine is not something we'd want to do). That said, there is not a lot of value in deleting them either... |
It is #42187 (comment) |
This construct is not supported on .NET Core+, so the code in question is dead. Deleting it frees one handle kind (which will be helpful in my future changes), and deletes one path from
fgMorphField
(which will also be helpful in my future changes).Fixes #4852.
Part of #58312.