Skip to content

Commit dd04e01

Browse files
lambdageekjkotas
andauthored
[mono] Use InlineArrayAttribute for ArgumentData and StackAllocatedByRefs (#88149)
* [mono] Use InlineArrayAttribute for ArgumentData and StackAllocatedByRefs Mono supports InlineArray * Apply suggestions from code review * Expose two more uses of InlineArray in ParamsArray.cs --------- Co-authored-by: Jan Kotas <[email protected]>
1 parent be09d86 commit dd04e01

File tree

2 files changed

+1
-49
lines changed

2 files changed

+1
-49
lines changed

src/libraries/System.Private.CoreLib/src/System/ParamsArray.cs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
namespace System
1414
{
15-
#if CORECLR || NATIVEAOT
16-
1715
[InlineArray(Length)]
1816
internal struct TwoObjects
1917
{
@@ -46,33 +44,4 @@ public ThreeObjects(object? arg0, object? arg1, object? arg2)
4644
this[2] = arg2;
4745
}
4846
}
49-
50-
#else
51-
52-
internal struct TwoObjects
53-
{
54-
internal object? Arg0;
55-
private object? _arg1;
56-
57-
public TwoObjects(object? arg0, object? arg1)
58-
{
59-
Arg0 = arg0;
60-
_arg1 = arg1;
61-
}
62-
}
63-
64-
internal struct ThreeObjects
65-
{
66-
internal object? Arg0;
67-
private object? _arg1;
68-
private object? _arg2;
69-
70-
public ThreeObjects(object? arg0, object? arg1, object? arg2)
71-
{
72-
Arg0 = arg0;
73-
_arg1 = arg1;
74-
_arg2 = arg2;
75-
}
76-
}
77-
#endif
7847
}

src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBase.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -274,19 +274,11 @@ BindingFlags invokeAttr
274274

275275
internal const int MaxStackAllocArgCount = 4;
276276

277-
#if CORECLR
278277
[InlineArray(MaxStackAllocArgCount)]
279-
#endif
280278
private protected struct ArgumentData<T>
281279
{
282280
private T _arg0;
283-
#if !CORECLR
284-
#pragma warning disable CA1823, CS0169, IDE0051, IDE0044 // accessed via 'CheckArguments' ref arithmetic
285-
private T _arg1;
286-
private T _arg2;
287-
private T _arg3;
288-
#pragma warning restore CA1823, CS0169, IDE0051, IDE0044
289-
#endif
281+
290282
[UnscopedRef]
291283
public Span<T> AsSpan(int length)
292284
{
@@ -308,19 +300,10 @@ private protected ref struct StackAllocedArguments
308300
}
309301

310302
// Helper struct to avoid intermediate IntPtr[] allocation and RegisterForGCReporting in calls to the native reflection stack.
311-
#if CORECLR
312303
[InlineArray(MaxStackAllocArgCount)]
313-
#endif
314304
private protected ref struct StackAllocatedByRefs
315305
{
316306
internal ref byte _arg0;
317-
#if !CORECLR
318-
#pragma warning disable CA1823, CS0169, IDE0051 // accessed via 'CheckArguments' ref arithmetic
319-
private ref byte _arg1;
320-
private ref byte _arg2;
321-
private ref byte _arg3;
322-
#pragma warning restore CA1823, CS0169, IDE0051
323-
#endif
324307
}
325308
#endif
326309
}

0 commit comments

Comments
 (0)