File tree Expand file tree Collapse file tree 4 files changed +47
-8
lines changed
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow Expand file tree Collapse file tree 4 files changed +47
-8
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,19 @@ internal static bool IsStateMachineType(string typeName)
36
36
return typeName . Length > i + 1 && typeName [ i + 1 ] == 'd' ;
37
37
}
38
38
39
+ internal static bool IsStateMachineCurrentField ( string fieldName )
40
+ {
41
+ if ( ! IsGeneratedMemberName ( fieldName ) )
42
+ return false ;
43
+
44
+ int i = fieldName . LastIndexOf ( '>' ) ;
45
+ if ( i == - 1 )
46
+ return false ;
47
+
48
+ // Current field is <>2__current
49
+ return fieldName . Length > i + 1 && fieldName [ i + 1 ] == '2' ;
50
+ }
51
+
39
52
internal static bool IsGeneratedType ( string name ) => IsStateMachineType ( name ) || IsLambdaDisplayClass ( name ) ;
40
53
41
54
internal static bool IsLambdaOrLocalFunction ( string methodName ) => IsLambdaMethod ( methodName ) || IsLocalFunction ( methodName ) ;
Original file line number Diff line number Diff line change @@ -500,10 +500,17 @@ static IEnumerable<MetadataType> GetCompilerGeneratedNestedTypes(MetadataType ty
500
500
501
501
public static bool IsHoistedLocal ( FieldDesc field )
502
502
{
503
- // Treat all fields on compiler-generated types as hoisted locals.
504
- // This avoids depending on the name mangling scheme for hoisted locals.
505
- var declaringTypeName = field . OwningType . Name ;
506
- return CompilerGeneratedNames . IsLambdaDisplayClass ( declaringTypeName ) || CompilerGeneratedNames . IsStateMachineType ( declaringTypeName ) ;
503
+ if ( CompilerGeneratedNames . IsLambdaDisplayClass ( field . OwningType . Name ) )
504
+ return true ;
505
+
506
+ if ( CompilerGeneratedNames . IsStateMachineType ( field . OwningType . Name ) )
507
+ {
508
+ // Don't track the "current" field which is used for state machine return values,
509
+ // because this can be expensive to track.
510
+ return ! CompilerGeneratedNames . IsStateMachineCurrentField ( field . Name ) ;
511
+ }
512
+
513
+ return false ;
507
514
}
508
515
509
516
// "Nested function" refers to lambdas and local functions.
Original file line number Diff line number Diff line change @@ -34,6 +34,19 @@ internal static bool IsStateMachineType (string typeName)
34
34
return typeName . Length > i + 1 && typeName [ i + 1 ] == 'd' ;
35
35
}
36
36
37
+ internal static bool IsStateMachineCurrentField ( string fieldName )
38
+ {
39
+ if ( ! IsGeneratedMemberName ( fieldName ) )
40
+ return false ;
41
+
42
+ int i = fieldName . LastIndexOf ( '>' ) ;
43
+ if ( i == - 1 )
44
+ return false ;
45
+
46
+ // Current field is <>2__current
47
+ return fieldName . Length > i + 1 && fieldName [ i + 1 ] == '2' ;
48
+ }
49
+
37
50
internal static bool IsGeneratedType ( string name ) => IsStateMachineType ( name ) || IsLambdaDisplayClass ( name ) ;
38
51
39
52
internal static bool IsLambdaOrLocalFunction ( string methodName ) => IsLambdaMethod ( methodName ) || IsLocalFunction ( methodName ) ;
Original file line number Diff line number Diff line change @@ -55,10 +55,16 @@ static IEnumerable<TypeDefinition> GetCompilerGeneratedNestedTypes (TypeDefiniti
55
55
56
56
public static bool IsHoistedLocal ( FieldDefinition field )
57
57
{
58
- // Treat all fields on compiler-generated types as hoisted locals.
59
- // This avoids depending on the name mangling scheme for hoisted locals.
60
- var declaringTypeName = field . DeclaringType . Name ;
61
- return CompilerGeneratedNames . IsLambdaDisplayClass ( declaringTypeName ) || CompilerGeneratedNames . IsStateMachineType ( declaringTypeName ) ;
58
+ if ( CompilerGeneratedNames . IsLambdaDisplayClass ( field . DeclaringType . Name ) )
59
+ return true ;
60
+
61
+ if ( CompilerGeneratedNames . IsStateMachineType ( field . DeclaringType . Name ) ) {
62
+ // Don't track the "current" field which is used for state machine return values,
63
+ // because this can be expensive to track.
64
+ return ! CompilerGeneratedNames . IsStateMachineCurrentField ( field . Name ) ;
65
+ }
66
+
67
+ return false ;
62
68
}
63
69
64
70
// "Nested function" refers to lambdas and local functions.
You can’t perform that action at this time.
0 commit comments