-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fast field access #97784
Fast field access #97784
Conversation
Tagging subscribers to this area: @dotnet/area-system-reflection Issue Detailsnull
|
GCPROTECT_BEGIN(refField); | ||
|
||
if (refField->GetField()->IsThreadStatic()) { | ||
ret = Thread::GetStaticFieldAddress(pFieldDesc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These addresses may be in GC allocated memory in some cases. They can move and need to be reported to the GC.
|
||
// IsFastPathSupported needs to checked before calling this method. | ||
_ASSERTE(!pFieldDesc->IsEnCNew()); | ||
_ASSERTE(!refField->GetField()->IsThreadStatic()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addresses of regular static fields in collectitble assemblies are allocated on the GC heap and can move.
This needs to have similar set of cases as the JIT:
runtime/src/coreclr/vm/jitinterface.cpp
Lines 1563 to 1571 in 1e8f741
if (pFieldMT->Collectible()) | |
{ | |
// Static fields are not pinned in collectible types. We will always access | |
// them using a helper since the address cannot be embedded into the code. | |
fieldAccessor = CORINFO_FIELD_STATIC_SHARED_STATIC_HELPER; | |
pResult->helper = getSharedStaticsHelper(pField, pFieldMT); | |
} | |
else if (pField->IsThreadStatic()) |
src/libraries/System.Runtime/tests/System.Reflection.Tests/FieldInfoTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Reflection.Tests/FieldInfoTests.cs
Outdated
Show resolved
Hide resolved
} | ||
else | ||
{ | ||
_addressOrOffset = RuntimeFieldHandle.GetInstanceFieldOffset(_fieldInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK fields added in EnC don't have a valid offset that's inside of the object.
Closing due to corrupt branch; will reopen new PR; see #98199 |
[verifying tests]
Click for benchmarks