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. |
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) |
MichalStrehovsky
Jan 5, 2018
Member
Maybe update the comment above (// Inherit IsByRefLike characteristic from fields
) since we're not inheriting it anymore, but merely checking?
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 |
MichalStrehovsky
Jan 5, 2018
Member
Non-empty stack but returns void?
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() |
MichalStrehovsky
Jan 5, 2018
Member
Non-empty stack but returns void?
Non-empty stack but returns void?
Yes, there are. It would be nice optimization to have. |
@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 |
6c12105
into
dotnet:master
Detect ByRefLike types using attribute and improve error messages for their invalid use
Fixes #11371 and #15458