-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Detect ByRefLike types using attribute #15745
Conversation
… their invalid use Fixes #11371 and #15458
Hmm, I wonder if there are sufficient guarantees that by ref like types only live on the stack for the JIT to be able to eliminate GC write barriers when writing to fields of such types. |
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.
Looks good apart from the minor comments.
@@ -4085,8 +4089,10 @@ VOID MethodTableBuilder::InitializeFieldDescs(FieldDesc *pFieldDescList, | |||
// Non-value-classes cannot contain by-ref-like instance fields | |||
BuildMethodTableThrowException(IDS_CLASSLOAD_BYREFLIKE_NOTVALUECLASSFIELD); | |||
} | |||
|
|||
bmtFP->fIsByRefLikeType = true; | |||
if (!bmtFP->fIsByRefLikeType) |
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.
Maybe update the comment above (// Inherit IsByRefLike characteristic from fields
) since we're not inheriting it anymore, but merely checking?
.maxstack 1 | ||
ldc.i4.1 | ||
newarr valuetype MyByRefLikeType | ||
ret |
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.
Non-empty stack but returns void?
.method private hidebysig static void ByRefLikeGenericInstantiation() cil managed | ||
{ | ||
.maxstack 1 | ||
newobj instance void class [System.Runtime]System.Collections.Generic.List`1<valuetype MyByRefLikeType>::.ctor() |
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.
Non-empty stack but returns void?
Yes, there are. It would be nice optimization to have. Opened https://github.com/dotnet/coreclr/issues/15755 |
@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test please |
LGTM |
@dotnet-bot test Tizen armel Cross Checked Innerloop Build and Test please |
Detect ByRefLike types using attribute and improve error messages for their invalid use
Fixes #11371 and #15458