@@ -61,22 +61,26 @@ static Program()
61
61
{
62
62
IL . Emit . Ldftn ( new MethodRef ( typeof ( Program ) , nameof ( CalcStaticCalli ) ) ) ;
63
63
IL . Pop ( out IntPtr calcStaticCalli ) ;
64
+ s_calcStaticCalli = calcStaticCalli ;
65
+
64
66
IL . Emit . Ldftn ( new MethodRef ( typeof ( Program ) , nameof ( CalcStaticCalliOther ) ) ) ;
65
67
IL . Pop ( out IntPtr calcStaticCalliOther ) ;
68
+ s_calcStaticCalliOther = calcStaticCalliOther ;
69
+
66
70
IL . Emit . Ldftn ( new MethodRef ( typeof ( Program ) , nameof ( CalcStaticCalliRetbuf ) ) ) ;
67
71
IL . Pop ( out IntPtr calcStaticCalliRetbuf ) ;
72
+ s_calcStaticCalliRetbuf = calcStaticCalliRetbuf ;
73
+
68
74
IL . Emit . Ldftn ( new MethodRef ( typeof ( Program ) , nameof ( CalcStaticCalliRetbufOther ) ) ) ;
69
75
IL . Pop ( out IntPtr calcStaticCalliRetbufOther ) ;
76
+ s_calcStaticCalliRetbufOther = calcStaticCalliRetbufOther ;
77
+
70
78
IL . Emit . Ldftn ( new MethodRef ( typeof ( Program ) , nameof ( EmptyCalliOther ) ) ) ;
71
79
IL . Pop ( out IntPtr emptyCalliOther ) ;
80
+ s_emptyCalliOther = emptyCalliOther ;
81
+
72
82
IL . Emit . Ldftn ( new MethodRef ( typeof ( S16 ) , nameof ( S16 . InstanceMethod ) ) ) ;
73
83
IL . Pop ( out IntPtr instanceMethodOnValueType ) ;
74
-
75
- s_calcStaticCalli = calcStaticCalli ;
76
- s_calcStaticCalliOther = calcStaticCalliOther ;
77
- s_calcStaticCalliRetbuf = calcStaticCalliRetbuf ;
78
- s_calcStaticCalliRetbufOther = calcStaticCalliRetbufOther ;
79
- s_emptyCalliOther = emptyCalliOther ;
80
84
s_instanceMethodOnValueType = instanceMethodOnValueType ;
81
85
}
82
86
@@ -183,6 +187,10 @@ void TestCalc<T>(Func<int, int, T> f, T expected, string name)
183
187
Test ( ( ) => GenAbstractGString ( ga1 ) , "System.String" , "Abstract generic without generic on method 1" ) ;
184
188
Test ( ( ) => GenAbstractGInt ( ga2 ) , "System.Int32" , "Abstract generic without generic on method 2" ) ;
185
189
190
+ int [ ] a = new int [ 1_000_000 ] ;
191
+ a [ 99 ] = 1 ;
192
+ Test ( ( ) => InstantiatingStub1 ( 0 , 0 , "string" , a ) , a . Length + 1 , "Instantiating stub direct" ) ;
193
+
186
194
if ( result )
187
195
Console . WriteLine ( "All tailcall-via-help succeeded" ) ;
188
196
else
@@ -686,6 +694,42 @@ private static string GenAbstractGInt(GenAbstract<int> ga)
686
694
IL . Emit . Callvirt ( new MethodRef ( typeof ( GenAbstract < int > ) , nameof ( GenAbstract < int > . G ) ) ) ;
687
695
return IL . Return < string > ( ) ;
688
696
}
697
+
698
+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
699
+ private static int InstantiatingStub1 < T > ( int a , int r , T c , Span < int > d )
700
+ {
701
+ IL . Push ( c ) ;
702
+ IL . Push ( c ) ;
703
+ IL . Push ( c ) ;
704
+ IL . Push ( c ) ;
705
+ IL . Push ( c ) ;
706
+ IL . Push ( c ) ;
707
+ IL . Push ( c ) ;
708
+ IL . Push ( c ) ;
709
+ IL . Push ( a ) ;
710
+ IL . Push ( r ) ;
711
+ IL . Emit . Ldarg ( nameof ( d ) ) ;
712
+ IL . Push ( r + d [ 99 ] ) ;
713
+ IL . Emit . Tail ( ) ;
714
+ IL . Emit . Call ( new MethodRef ( typeof ( Program ) , nameof ( InstantiatingStub1Other ) ) . MakeGenericMethod ( typeof ( T ) ) ) ;
715
+ return IL . Return < int > ( ) ;
716
+ }
717
+
718
+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
719
+ private static int InstantiatingStub1Other < T > ( T c0 , T c1 , T c2 , T c3 , T c4 , T c5 , T c6 , T c7 , int a , int r , Span < int > d , int result )
720
+ {
721
+ if ( a == d . Length ) return result ;
722
+ else
723
+ {
724
+ IL . Push ( a + 1 ) ;
725
+ IL . Push ( result ) ;
726
+ IL . Push ( c0 ) ;
727
+ IL . Emit . Ldarg ( nameof ( d ) ) ;
728
+ IL . Emit . Tail ( ) ;
729
+ IL . Emit . Call ( new MethodRef ( typeof ( Program ) , nameof ( InstantiatingStub1 ) ) . MakeGenericMethod ( typeof ( T ) ) ) ;
730
+ return IL . Return < int > ( ) ;
731
+ }
732
+ }
689
733
}
690
734
691
735
class Instance
0 commit comments