Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,19 @@ public static bool HandleCall(
}
break;

//
// System.Array
//
// CreateInstance (Type, Int32)
//
case IntrinsicId.Array_CreateInstance:
{
// We could try to analyze if the type is known, but for now making sure this works for canonical arrays is enough.
TypeDesc canonArrayType = reflectionMarker.Factory.TypeSystemContext.CanonType.MakeArrayType();
reflectionMarker.Dependencies.Add(reflectionMarker.Factory.NativeLayout.TemplateTypeLayout(canonArrayType), "Array.CreateInstance was called");
goto case IntrinsicId.None;
}

//
// System.Enum
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ internal enum IntrinsicId
// the reflection body scanner.
RequiresReflectionBodyScanner_Sentinel = 1000,
/// <summary>
/// <see cref="System.Array.CreateInstance(System.Type, int)"/>
/// </summary>
Array_CreateInstance,
/// <summary>
/// <see cref="System.Type.MakeGenericType(System.Type[])"/>
/// </summary>
Type_MakeGenericType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ public static IntrinsicId GetIntrinsicIdForMethod (MethodProxy calledMethod)
"Empty" when calledMethod.IsDeclaredOnType ("System.Array")
=> IntrinsicId.Array_Empty,

// static System.Array.CreateInstance (System.Type type, int length)
"CreateInstance" when calledMethod.IsDeclaredOnType ("System.Array")
&& calledMethod.HasMetadataParametersCount (2)
&& calledMethod.HasParameterOfType ((ParameterIndex) 1, "System.Int32")
=> IntrinsicId.Array_CreateInstance,

// static System.Activator.CreateInstance (System.Type type)
// static System.Activator.CreateInstance (System.Type type, bool nonPublic)
// static System.Activator.CreateInstance (System.Type type, params object?[]? args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ public static bool HandleCall (
}
break;

case IntrinsicId.Array_CreateInstance:
case IntrinsicId.Enum_GetValues:
case IntrinsicId.Marshal_SizeOf:
case IntrinsicId.Marshal_OffsetOf:
Expand Down